From 11938520078bcb7c16c09219990ab35509fd7fe6 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sun, 9 Feb 2025 11:01:07 +0100 Subject: [PATCH] Codechange: do not use ScriptCompany::CompanyID outside of the script API --- src/goal.cpp | 2 +- src/script/api/script_event_types.hpp | 12 ++++++------ src/town_cmd.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/goal.cpp b/src/goal.cpp index f33535fb74..a866f162db 100644 --- a/src/goal.cpp +++ b/src/goal.cpp @@ -306,7 +306,7 @@ CommandCost CmdGoalQuestionAnswer(DoCommandFlag flags, uint16_t uniqueid, uint8_ } if (flags & DC_EXEC) { - Game::NewEvent(new ScriptEventGoalQuestionAnswer(uniqueid, (ScriptCompany::CompanyID)(uint8_t)_current_company, (ScriptGoal::QuestionButton)(1 << button))); + Game::NewEvent(new ScriptEventGoalQuestionAnswer(uniqueid, _current_company, (ScriptGoal::QuestionButton)(1 << button))); } return CommandCost(); diff --git a/src/script/api/script_event_types.hpp b/src/script/api/script_event_types.hpp index ca29781e30..5ec63d2087 100644 --- a/src/script/api/script_event_types.hpp +++ b/src/script/api/script_event_types.hpp @@ -1034,10 +1034,10 @@ public: * @param company The company that is replying. * @param button The button the company pressed. */ - ScriptEventGoalQuestionAnswer(uint16_t uniqueid, ScriptCompany::CompanyID company, ScriptGoal::QuestionButton button) : + ScriptEventGoalQuestionAnswer(uint16_t uniqueid, ::CompanyID company, ScriptGoal::QuestionButton button) : ScriptEvent(ET_GOAL_QUESTION_ANSWER), uniqueid(uniqueid), - company(company), + company(ScriptCompany::ToScriptCompanyID(company)), button(button) {} #endif /* DOXYGEN_API */ @@ -1085,9 +1085,9 @@ public: * @param company The company. * @param town The town. */ - ScriptEventCompanyTown(ScriptEventType event, ScriptCompany::CompanyID company, TownID town) : + ScriptEventCompanyTown(ScriptEventType event, ::CompanyID company, TownID town) : ScriptEvent(event), - company(company), + company(ScriptCompany::ToScriptCompanyID(company)), town(town) {} #endif /* DOXYGEN_API */ @@ -1128,7 +1128,7 @@ public: * @param company The company. * @param town The town. */ - ScriptEventExclusiveTransportRights(ScriptCompany::CompanyID company, TownID town) : + ScriptEventExclusiveTransportRights(::CompanyID company, TownID town) : ScriptEventCompanyTown(ET_EXCLUSIVE_TRANSPORT_RIGHTS, company, town) {} #endif /* DOXYGEN_API */ @@ -1153,7 +1153,7 @@ public: * @param company The company. * @param town The town. */ - ScriptEventRoadReconstruction(ScriptCompany::CompanyID company, TownID town) : + ScriptEventRoadReconstruction(::CompanyID company, TownID town) : ScriptEventCompanyTown(ET_ROAD_RECONSTRUCTION, company, town) {} #endif /* DOXYGEN_API */ diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 78e08475f7..a0f380b0fa 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -3390,8 +3390,8 @@ static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlag flags) AddNewsItem( TimerGameEconomy::UsingWallclockUnits() ? STR_NEWS_ROAD_REBUILDING_MINUTES : STR_NEWS_ROAD_REBUILDING_MONTHS, NewsType::General, NewsStyle::Normal, {}, NewsReferenceType::Town, t->index, NewsReferenceType::None, UINT32_MAX); - AI::BroadcastNewEvent(new ScriptEventRoadReconstruction((ScriptCompany::CompanyID)(Owner)_current_company, t->index)); - Game::NewEvent(new ScriptEventRoadReconstruction((ScriptCompany::CompanyID)(Owner)_current_company, t->index)); + AI::BroadcastNewEvent(new ScriptEventRoadReconstruction(_current_company, t->index)); + Game::NewEvent(new ScriptEventRoadReconstruction(_current_company, t->index)); } return CommandCost(); } @@ -3545,8 +3545,8 @@ static CommandCost TownActionBuyRights(Town *t, DoCommandFlag flags) SetDParam(2, t->index); SetDParamStr(3, cni->company_name); AddNewsItem(STR_MESSAGE_NEWS_FORMAT, NewsType::General, NewsStyle::Company, {}, NewsReferenceType::Town, t->index, NewsReferenceType::None, UINT32_MAX, std::move(cni)); - AI::BroadcastNewEvent(new ScriptEventExclusiveTransportRights((ScriptCompany::CompanyID)(Owner)_current_company, t->index)); - Game::NewEvent(new ScriptEventExclusiveTransportRights((ScriptCompany::CompanyID)(Owner)_current_company, t->index)); + AI::BroadcastNewEvent(new ScriptEventExclusiveTransportRights(_current_company, t->index)); + Game::NewEvent(new ScriptEventExclusiveTransportRights(_current_company, t->index)); } return CommandCost(); }