Codechange: use a contructor for NewsItem to set the values

And use std::unique_ptr to manage the memory of the allocated data
This commit is contained in:
Rubidium
2021-06-17 16:38:34 +02:00
committed by rubidium42
parent 9a7750f14e
commit 9c7a7b53a1
2 changed files with 29 additions and 26 deletions

View File

@@ -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. */