Codechange: use std::variant instead of a custom version for news references
This commit is contained in:
@@ -20,6 +20,18 @@
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
static NewsReference CreateReference(ScriptNews::NewsReferenceType ref_type, SQInteger reference)
|
||||
{
|
||||
switch (ref_type) {
|
||||
case ScriptNews::NR_NONE: return {};
|
||||
case ScriptNews::NR_TILE: return ::TileIndex(reference);
|
||||
case ScriptNews::NR_STATION: return static_cast<StationID>(reference);
|
||||
case ScriptNews::NR_INDUSTRY: return static_cast<IndustryID>(reference);
|
||||
case ScriptNews::NR_TOWN: return static_cast<TownID>(reference);
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ bool ScriptNews::Create(NewsType type, Text *text, ScriptCompany::CompanyID company, NewsReferenceType ref_type, SQInteger reference)
|
||||
{
|
||||
ScriptObjectRef counter(text);
|
||||
@@ -38,6 +50,5 @@
|
||||
|
||||
::CompanyID c = ScriptCompany::FromScriptCompanyID(company);
|
||||
|
||||
if (ref_type == NR_NONE) reference = 0;
|
||||
return ScriptObject::Command<CMD_CUSTOM_NEWS_ITEM>::Do((::NewsType)type, (::NewsReferenceType)ref_type, c, reference, encoded);
|
||||
return ScriptObject::Command<CMD_CUSTOM_NEWS_ITEM>::Do((::NewsType)type, c, CreateReference(ref_type, reference), encoded);
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@ public:
|
||||
*/
|
||||
enum NewsReferenceType {
|
||||
/* Selection of useful game elements to refer to. */
|
||||
NR_NONE = to_underlying(::NewsReferenceType::None), ///< No reference supplied.
|
||||
NR_TILE = to_underlying(::NewsReferenceType::Tile), ///< Reference location, scroll to the location when clicking on the news.
|
||||
NR_STATION = to_underlying(::NewsReferenceType::Station), ///< Reference station, scroll to the station when clicking on the news. Delete news when the station is deleted.
|
||||
NR_INDUSTRY = to_underlying(::NewsReferenceType::Industry), ///< Reference industry, scrolls to the industry when clicking on the news. Delete news when the industry is deleted.
|
||||
NR_TOWN = to_underlying(::NewsReferenceType::Town), ///< Reference town, scroll to the town when clicking on the news.
|
||||
NR_NONE, ///< No reference supplied.
|
||||
NR_TILE, ///< Reference location, scroll to the location when clicking on the news.
|
||||
NR_STATION, ///< Reference station, scroll to the station when clicking on the news. Delete news when the station is deleted.
|
||||
NR_INDUSTRY, ///< Reference industry, scrolls to the industry when clicking on the news. Delete news when the industry is deleted.
|
||||
NR_TOWN, ///< Reference town, scroll to the town when clicking on the news.
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user