summaryrefslogtreecommitdiff
path: root/src/news_type.h
diff options
context:
space:
mode:
authorRubidium <rubidium@openttd.org>2021-06-17 16:38:34 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-07-01 19:04:38 +0200
commit9c7a7b53a192deef9dadf7f31d68c9a76cfaf35c (patch)
tree0f6effcff4ff5553845ead410a67883d4d7b3548 /src/news_type.h
parent9a7750f14eccd8afb6e8bb608ec421c09a486d53 (diff)
downloadopenttd-9c7a7b53a192deef9dadf7f31d68c9a76cfaf35c.tar.xz
Codechange: use a contructor for NewsItem to set the values
And use std::unique_ptr to manage the memory of the allocated data
Diffstat (limited to 'src/news_type.h')
-rw-r--r--src/news_type.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/news_type.h b/src/news_type.h
index 8045a58fa..4dea8c46f 100644
--- a/src/news_type.h
+++ b/src/news_type.h
@@ -135,14 +135,11 @@ struct NewsItem {
uint32 ref1; ///< Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news, and for deleting the news when the object is deleted.
uint32 ref2; ///< Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news when the object is deleted.
- const NewsAllocatedData *data; ///< Custom data for the news item that have to be deallocated (deleted) when the news item has reached its end.
-
- ~NewsItem()
- {
- delete this->data;
- }
+ std::unique_ptr<const NewsAllocatedData> data; ///< Custom data for the news item that will be deallocated (deleted) when the news item has reached its end.
uint64 params[10]; ///< Parameters for string resolving.
+
+ NewsItem(StringID string_id, NewsType type, NewsFlag flags, NewsReferenceType reftype1, uint32 ref1, NewsReferenceType reftype2, uint32 ref2, const NewsAllocatedData *data);
};
/** Container for a single string to be passed as NewsAllocatedData. */