From 2d0c1ffdb704e1b57e765c45826b8fc71a52dbbd Mon Sep 17 00:00:00 2001 From: merni-ns <66267867+merni-ns@users.noreply.github.com> Date: Wed, 25 Jan 2023 23:36:19 +0530 Subject: [PATCH 01/12] Change #10255: Reduce basic thickness of linkgraph GUI lines (#10410) From 3px to 2px (multiplied by UI scale). --- src/main_gui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 683d4f9d97..05ee75d2f3 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -224,7 +224,7 @@ struct MainWindow : Window NWidgetViewport *nvp = this->GetWidget(WID_M_VIEWPORT); nvp->InitializeViewport(this, TileXY(32, 32), ScaleZoomGUI(ZOOM_LVL_VIEWPORT)); - this->viewport->overlay = new LinkGraphOverlay(this, WID_M_VIEWPORT, 0, 0, 3); + this->viewport->overlay = new LinkGraphOverlay(this, WID_M_VIEWPORT, 0, 0, 2); this->refresh.SetInterval(LINKGRAPH_DELAY); } From 042f90a9dd30bf32102a0ac07578f1faa2f49245 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Wed, 25 Jan 2023 21:41:58 +0100 Subject: [PATCH 02/12] Fix: no ScriptEvent sub class should export constructors to scripts --- cmake/scripts/SquirrelExport.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/scripts/SquirrelExport.cmake b/cmake/scripts/SquirrelExport.cmake index d0c2283550..c1305066ab 100644 --- a/cmake/scripts/SquirrelExport.cmake +++ b/cmake/scripts/SquirrelExport.cmake @@ -342,7 +342,7 @@ foreach(LINE IN LISTS SOURCE_LINES) else() string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.PreRegister(engine, \"${API_SUPER_CLS}\");") endif() - if(NOT "${SUPER_CLS}" STREQUAL "ScriptEvent") + if(NOT "${SUPER_CLS}" MATCHES "^ScriptEvent") if("${CLS_PARAM_2}" STREQUAL "v") string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.AddSQAdvancedConstructor(engine);") else() From 41fa94bc56a371e6e036fe88632dc380b686c83f Mon Sep 17 00:00:00 2001 From: Rubidium Date: Wed, 25 Jan 2023 21:40:38 +0100 Subject: [PATCH 03/12] Fix: scripts cannot call constructors of ScriptEvents, so remove from the documentation --- src/script/api/script_event_types.hpp | 70 +++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/src/script/api/script_event_types.hpp b/src/script/api/script_event_types.hpp index 3ed6c5b10a..2a004e4f87 100644 --- a/src/script/api/script_event_types.hpp +++ b/src/script/api/script_event_types.hpp @@ -33,6 +33,7 @@ public: CRASH_FLOODED, ///< Vehicle was flooded }; +#ifndef DOXYGEN_API /** * @param vehicle The vehicle that crashed. * @param crash_site Where the vehicle crashed. @@ -44,6 +45,7 @@ public: vehicle(vehicle), crash_reason(crash_reason) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -82,6 +84,7 @@ private: */ class ScriptEventSubsidyOffer : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param subsidy_id The index of this subsidy in the _subsidies array. */ @@ -89,6 +92,7 @@ public: ScriptEvent(ET_SUBSIDY_OFFER), subsidy_id(subsidy_id) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -113,6 +117,7 @@ private: */ class ScriptEventSubsidyOfferExpired : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param subsidy_id The index of this subsidy in the _subsidies array. */ @@ -120,6 +125,7 @@ public: ScriptEvent(ET_SUBSIDY_OFFER_EXPIRED), subsidy_id(subsidy_id) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -144,6 +150,7 @@ private: */ class ScriptEventSubsidyAwarded : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param subsidy_id The index of this subsidy in the _subsidies array. */ @@ -151,6 +158,7 @@ public: ScriptEvent(ET_SUBSIDY_AWARDED), subsidy_id(subsidy_id) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -175,6 +183,7 @@ private: */ class ScriptEventSubsidyExpired : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param subsidy_id The index of this subsidy in the _subsidies array. */ @@ -182,6 +191,7 @@ public: ScriptEvent(ET_SUBSIDY_EXPIRED), subsidy_id(subsidy_id) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -208,6 +218,7 @@ private: */ class ScriptEventEnginePreview : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param engine The engine offered to test. */ @@ -215,6 +226,7 @@ public: ScriptEvent(ET_ENGINE_PREVIEW), engine(engine) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -297,6 +309,7 @@ private: */ class ScriptEventCompanyNew : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param owner The new company. */ @@ -304,6 +317,7 @@ public: ScriptEvent(ET_COMPANY_NEW), owner((ScriptCompany::CompanyID)owner) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -329,6 +343,7 @@ private: */ class ScriptEventCompanyInTrouble : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param owner The company that is in trouble. */ @@ -336,6 +351,7 @@ public: ScriptEvent(ET_COMPANY_IN_TROUBLE), owner((ScriptCompany::CompanyID)owner) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -360,6 +376,7 @@ private: */ class ScriptEventCompanyAskMerger : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param owner The company that can be bought. * @param value The value/costs of buying the company. @@ -369,6 +386,7 @@ public: owner((ScriptCompany::CompanyID)owner), value(value) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -408,6 +426,7 @@ private: */ class ScriptEventCompanyMerger : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param old_owner The company bought off. * @param new_owner The company that bought owner. @@ -417,6 +436,7 @@ public: old_owner((ScriptCompany::CompanyID)old_owner), new_owner((ScriptCompany::CompanyID)new_owner) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -451,6 +471,7 @@ private: */ class ScriptEventCompanyBankrupt : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param owner The company that has gone bankrupt. */ @@ -458,6 +479,7 @@ public: ScriptEvent(ET_COMPANY_BANKRUPT), owner((ScriptCompany::CompanyID)owner) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -482,6 +504,7 @@ private: */ class ScriptEventVehicleLost : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param vehicle_id The vehicle that is lost. */ @@ -489,6 +512,7 @@ public: ScriptEvent(ET_VEHICLE_LOST), vehicle_id(vehicle_id) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -513,6 +537,7 @@ private: */ class ScriptEventVehicleWaitingInDepot : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param vehicle_id The vehicle that is waiting in a depot. */ @@ -520,6 +545,7 @@ public: ScriptEvent(ET_VEHICLE_WAITING_IN_DEPOT), vehicle_id(vehicle_id) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -544,6 +570,7 @@ private: */ class ScriptEventVehicleUnprofitable : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param vehicle_id The vehicle that was unprofitable. */ @@ -551,6 +578,7 @@ public: ScriptEvent(ET_VEHICLE_UNPROFITABLE), vehicle_id(vehicle_id) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -575,6 +603,7 @@ private: */ class ScriptEventIndustryOpen : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param industry_id The new industry. */ @@ -582,6 +611,7 @@ public: ScriptEvent(ET_INDUSTRY_OPEN), industry_id(industry_id) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -606,6 +636,7 @@ private: */ class ScriptEventIndustryClose : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param industry_id The new industry. */ @@ -613,6 +644,7 @@ public: ScriptEvent(ET_INDUSTRY_CLOSE), industry_id(industry_id) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -637,6 +669,7 @@ private: */ class ScriptEventEngineAvailable : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param engine The engine that is available. */ @@ -644,6 +677,7 @@ public: ScriptEvent(ET_ENGINE_AVAILABLE), engine(engine) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -668,6 +702,7 @@ private: */ class ScriptEventStationFirstVehicle : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param station The station visited for the first time. * @param vehicle The vehicle visiting the station. @@ -677,6 +712,7 @@ public: station(station), vehicle(vehicle) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -708,6 +744,7 @@ private: */ class ScriptEventDisasterZeppelinerCrashed : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param station The station containing the affected airport */ @@ -715,6 +752,7 @@ public: ScriptEvent(ET_DISASTER_ZEPPELINER_CRASHED), station(station) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -739,6 +777,7 @@ private: */ class ScriptEventDisasterZeppelinerCleared : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param station The station containing the affected airport */ @@ -746,6 +785,7 @@ public: ScriptEvent(ET_DISASTER_ZEPPELINER_CLEARED), station(station) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -770,6 +810,7 @@ private: */ class ScriptEventTownFounded : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param town The town that was created. */ @@ -777,6 +818,7 @@ public: ScriptEvent(ET_TOWN_FOUNDED), town(town) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -803,6 +845,7 @@ private: */ class ScriptEventAircraftDestTooFar : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param vehicle_id The aircraft whose destination is too far away. */ @@ -810,6 +853,7 @@ public: ScriptEvent(ET_AIRCRAFT_DEST_TOO_FAR), vehicle_id(vehicle_id) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -834,10 +878,12 @@ private: */ class ScriptEventAdminPort : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param json The JSON string which got sent. */ ScriptEventAdminPort(const std::string &json); +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -882,6 +928,7 @@ private: */ class ScriptEventWindowWidgetClick : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param window The windowclass that was clicked. * @param number The windownumber that was clicked. @@ -893,6 +940,7 @@ public: number(number), widget(widget) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -930,6 +978,7 @@ private: */ class ScriptEventGoalQuestionAnswer : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param uniqueid The uniqueID you have given this question. * @param company The company that is replying. @@ -941,6 +990,7 @@ public: company(company), button(button) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -976,6 +1026,7 @@ private: */ class ScriptEventCompanyTown : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param event The eventtype. * @param company The company. @@ -986,6 +1037,7 @@ public: company(company), town(town) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -1018,6 +1070,7 @@ private: */ class ScriptEventExclusiveTransportRights : public ScriptEventCompanyTown { public: +#ifndef DOXYGEN_API /** * @param company The company. * @param town The town. @@ -1025,6 +1078,7 @@ public: ScriptEventExclusiveTransportRights(ScriptCompany::CompanyID company, TownID town) : ScriptEventCompanyTown(ET_EXCLUSIVE_TRANSPORT_RIGHTS, company, town) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -1041,6 +1095,7 @@ public: */ class ScriptEventRoadReconstruction : public ScriptEventCompanyTown { public: +#ifndef DOXYGEN_API /** * @param company The company. * @param town The town. @@ -1048,6 +1103,7 @@ public: ScriptEventRoadReconstruction(ScriptCompany::CompanyID company, TownID town) : ScriptEventCompanyTown(ET_ROAD_RECONSTRUCTION, company, town) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -1063,6 +1119,7 @@ public: */ class ScriptEventVehicleAutoReplaced : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param old_id The vehicle that has been replaced. * @param new_id The vehicle that has been created in replacement. @@ -1072,6 +1129,7 @@ public: old_id(old_id), new_id(new_id) {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -1103,6 +1161,7 @@ private: */ class ScriptEventStoryPageButtonClick : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param company_id Which company triggered the event. * @param page_id Which page was the clicked button on. @@ -1113,7 +1172,8 @@ public: company_id((ScriptCompany::CompanyID)company_id), page_id(page_id), element_id(element_id) - { } + {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -1143,6 +1203,7 @@ private: */ class ScriptEventStoryPageTileSelect : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param company_id Which company triggered the event. * @param page_id Which page is the used selection button on. @@ -1155,7 +1216,8 @@ public: page_id(page_id), element_id(element_id), tile_index(tile_index) - { } + {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. @@ -1189,6 +1251,7 @@ private: */ class ScriptEventStoryPageVehicleSelect : public ScriptEvent { public: +#ifndef DOXYGEN_API /** * @param company_id Which company triggered the event. * @param page_id Which page is the used selection button on. @@ -1201,7 +1264,8 @@ public: page_id(page_id), element_id(element_id), vehicle_id(vehicle_id) - { } + {} +#endif /* DOXYGEN_API */ /** * Convert an ScriptEvent to the real instance. From 3112b387e77d098bdecc6084c73419eb34c15919 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Wed, 25 Jan 2023 23:40:22 +0100 Subject: [PATCH 04/12] Fix: warnings about obsolete settings/setting values in Doxygen configurations --- Doxyfile.in | 4 +--- src/script/api/Doxyfile_AI.in | 3 +-- src/script/api/Doxyfile_GS.in | 3 +-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Doxyfile.in b/Doxyfile.in index 8727594771..51a44526c3 100644 --- a/Doxyfile.in +++ b/Doxyfile.in @@ -41,7 +41,6 @@ INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 2 ALIASES = -TCL_SUBST = OPTIMIZE_OUTPUT_FOR_C = YES OPTIMIZE_OUTPUT_JAVA = NO OPTIMIZE_FOR_FORTRAN = NO @@ -155,7 +154,6 @@ VERBATIM_HEADERS = YES # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = NO -COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output @@ -224,7 +222,7 @@ LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO -PAPER_TYPE = a4wide +PAPER_TYPE = a4 EXTRA_PACKAGES = LATEX_HEADER = LATEX_FOOTER = diff --git a/src/script/api/Doxyfile_AI.in b/src/script/api/Doxyfile_AI.in index f0707e0d86..cde1f21350 100644 --- a/src/script/api/Doxyfile_AI.in +++ b/src/script/api/Doxyfile_AI.in @@ -121,7 +121,6 @@ VERBATIM_HEADERS = NO # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = NO -COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output @@ -151,7 +150,7 @@ LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO -PAPER_TYPE = a4wide +PAPER_TYPE = a4 EXTRA_PACKAGES = LATEX_HEADER = PDF_HYPERLINKS = NO diff --git a/src/script/api/Doxyfile_GS.in b/src/script/api/Doxyfile_GS.in index 7dae7aad66..b017bc94c5 100644 --- a/src/script/api/Doxyfile_GS.in +++ b/src/script/api/Doxyfile_GS.in @@ -121,7 +121,6 @@ VERBATIM_HEADERS = NO # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = NO -COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output @@ -151,7 +150,7 @@ LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO -PAPER_TYPE = a4wide +PAPER_TYPE = a4 EXTRA_PACKAGES = LATEX_HEADER = PDF_HYPERLINKS = NO From f9a473bef713e9970fb5422bd25e240595936c5a Mon Sep 17 00:00:00 2001 From: Rubidium Date: Wed, 25 Jan 2023 23:40:57 +0100 Subject: [PATCH 05/12] Fix: missing/duplicate documentation tags for scripts --- src/script/api/script_clientlist.hpp | 4 +- src/script/api/script_event.hpp | 1 + src/script/api/script_event_types.hpp | 72 ++++++++++++++++++++----- src/script/api/script_game.hpp | 1 + src/script/api/script_group.hpp | 4 ++ src/script/api/script_industrytype.hpp | 2 +- src/script/api/script_league.hpp | 2 + src/script/api/script_objecttype.hpp | 2 +- src/script/api/script_priorityqueue.hpp | 1 + src/script/api/script_road.hpp | 3 +- src/script/api/script_story_page.hpp | 3 ++ src/script/api/script_viewport.hpp | 3 ++ 12 files changed, 80 insertions(+), 18 deletions(-) diff --git a/src/script/api/script_clientlist.hpp b/src/script/api/script_clientlist.hpp index 39a85fd6e0..ea7859a6af 100644 --- a/src/script/api/script_clientlist.hpp +++ b/src/script/api/script_clientlist.hpp @@ -5,7 +5,7 @@ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . */ -/** @file script_clientlist.hpp List all the TODO. */ +/** @file script_clientlist.hpp List all the clients in a game or in a company. */ #ifndef SCRIPT_CLIENTLIST_HPP #define SCRIPT_CLIENTLIST_HPP @@ -32,7 +32,7 @@ public: class ScriptClientList_Company : public ScriptList { public: /** - * @param company_id The company to list clients for. + * @param company The company to list clients for. */ ScriptClientList_Company(ScriptCompany::CompanyID company); }; diff --git a/src/script/api/script_event.hpp b/src/script/api/script_event.hpp index 8e8f181701..2ff813aa81 100644 --- a/src/script/api/script_event.hpp +++ b/src/script/api/script_event.hpp @@ -61,6 +61,7 @@ public: /** * Constructor of ScriptEvent, to get the type of event. + * @param type The type of event to construct. */ ScriptEvent(ScriptEvent::ScriptEventType type) : type(type) diff --git a/src/script/api/script_event_types.hpp b/src/script/api/script_event_types.hpp index 2a004e4f87..5431fcf1ee 100644 --- a/src/script/api/script_event_types.hpp +++ b/src/script/api/script_event_types.hpp @@ -892,10 +892,19 @@ public: */ static ScriptEventAdminPort *Convert(ScriptEvent *instance) { return (ScriptEventAdminPort *)instance; } +#ifndef DOXYGEN_API /** - * Get the information that was sent to you back as Squirrel object. + * The GetObject() wrapper from Squirrel. */ SQInteger GetObject(HSQUIRRELVM vm); +#else + /** + * Get the information that was sent to you back as Squirrel object. + * @return The object. + */ + SQObject GetObject(); +#endif /* DOXYGEN_API */ + private: std::string json; ///< The JSON string. @@ -951,16 +960,19 @@ public: /** * Get the class of the window that was clicked. + * @return The clicked window class. */ ScriptWindow::WindowClass GetWindowClass() { return this->window; } /** * Get the number of the window that was clicked. + * @return The clicked identifying number of the widget within the class. */ uint32 GetWindowNumber() { return this->number; } /** * Get the number of the widget that was clicked. + * @return The number of the clicked widget. */ uint8 GetWidgetNumber() { return this->widget; } @@ -1001,16 +1013,19 @@ public: /** * Get the unique id of the question. + * @return The unique id. */ uint16 GetUniqueID() { return this->uniqueid; } /** * Get the company that pressed a button. + * @return The company. */ ScriptCompany::CompanyID GetCompany() { return this->company; } /** * Get the button that got pressed. + * @return The button. */ ScriptGoal::QuestionButton GetButton() { return this->button; } @@ -1182,13 +1197,22 @@ public: */ static ScriptEventStoryPageButtonClick *Convert(ScriptEvent *instance) { return (ScriptEventStoryPageButtonClick *)instance; } - /** Get the CompanyID of the player that selected a tile. */ + /** + * Get the CompanyID of the player that selected a tile. + * @return The ID of the company. + */ ScriptCompany::CompanyID GetCompanyID() { return this->company_id; } - /** Get the StoryPageID of the storybook page the clicked button is located on. */ + /** + * Get the StoryPageID of the storybook page the clicked button is located on. + * @return The ID of the page in the story book the click was on. + */ StoryPageID GetStoryPageID() { return this->page_id; } - /** Get the StoryPageElementID of the button element that was clicked. */ + /** + * Get the StoryPageElementID of the button element that was clicked. + * @return The ID of the element that was clicked. + */ StoryPageElementID GetElementID() { return this->element_id; } private: @@ -1226,16 +1250,28 @@ public: */ static ScriptEventStoryPageTileSelect *Convert(ScriptEvent *instance) { return (ScriptEventStoryPageTileSelect *)instance; } - /** Get the CompanyID of the player that selected a tile. */ + /** + * Get the CompanyID of the player that selected a tile. + * @return The company that selected the tile. + */ ScriptCompany::CompanyID GetCompanyID() { return this->company_id; } - /** Get the StoryPageID of the storybook page the used selection button is located on. */ + /** + * Get the StoryPageID of the storybook page the used selection button is located on. + * @return The ID of the story page selection was done from. + */ StoryPageID GetStoryPageID() { return this->page_id; } - /** Get the StoryPageElementID of the selection button used to select the tile. */ + /** + * Get the StoryPageElementID of the selection button used to select the tile. + * @return The ID of the element that was used to select the tile. + */ StoryPageElementID GetElementID() { return this->element_id; } - /** Get the TileIndex of the tile the player selected */ + /** + * Get the TileIndex of the tile the player selected. + * @return The selected tile. + */ TileIndex GetTile() { return this->tile_index; } private: @@ -1274,16 +1310,28 @@ public: */ static ScriptEventStoryPageVehicleSelect *Convert(ScriptEvent *instance) { return (ScriptEventStoryPageVehicleSelect *)instance; } - /** Get the CompanyID of the player that selected a tile. */ + /** + * Get the CompanyID of the player that selected a tile. + * @return The company's ID. + */ ScriptCompany::CompanyID GetCompanyID() { return this->company_id; } - /** Get the StoryPageID of the storybook page the used selection button is located on. */ + /** + * Get the StoryPageID of the storybook page the used selection button is located on. + * @return The ID of the storybook page the selected element is on. + */ StoryPageID GetStoryPageID() { return this->page_id; } - /** Get the StoryPageElementID of the selection button used to select the vehicle. */ + /** + * Get the StoryPageElementID of the selection button used to select the vehicle. + * @return The ID of the selected element of the story page. + */ StoryPageElementID GetElementID() { return this->element_id; } - /** Get the VehicleID of the vehicle the player selected */ + /** + * Get the VehicleID of the vehicle the player selected. + * @return The ID of the vehicle. + */ VehicleID GetVehicleID() { return this->vehicle_id; } private: diff --git a/src/script/api/script_game.hpp b/src/script/api/script_game.hpp index a9e5b7a258..b5fd62c524 100644 --- a/src/script/api/script_game.hpp +++ b/src/script/api/script_game.hpp @@ -53,6 +53,7 @@ public: /** * Get the current landscape. + * @return The type of landscape. */ static LandscapeType GetLandscape(); diff --git a/src/script/api/script_group.hpp b/src/script/api/script_group.hpp index 384fea7a28..df3ddc3303 100644 --- a/src/script/api/script_group.hpp +++ b/src/script/api/script_group.hpp @@ -232,6 +232,7 @@ public: * @param group_id The group id to set the colour of. * @param colour Colour to set. * @pre IsValidGroup(group_id). + * @return True iff the colour was set successfully. */ static bool SetPrimaryColour(GroupID group_id, ScriptCompany::Colours colour); @@ -240,6 +241,7 @@ public: * @param group_id The group id to set the colour of. * @param colour Colour to set. * @pre IsValidGroup(group_id). + * @return True iff the colour was set successfully. */ static bool SetSecondaryColour(GroupID group_id, ScriptCompany::Colours colour); @@ -247,6 +249,7 @@ public: * Get primary colour of a group. * @param group_id The group id to get the colour of. * @pre IsValidGroup(group_id). + * @return The primary colour of the group. */ static ScriptCompany::Colours GetPrimaryColour(GroupID group_id); @@ -254,6 +257,7 @@ public: * Get secondary colour for a group. * @param group_id The group id to get the colour of. * @pre IsValidGroup(group_id). + * @return The secondary colour of the group. */ static ScriptCompany::Colours GetSecondaryColour(GroupID group_id); }; diff --git a/src/script/api/script_industrytype.hpp b/src/script/api/script_industrytype.hpp index e68546cced..ff32a63c2e 100644 --- a/src/script/api/script_industrytype.hpp +++ b/src/script/api/script_industrytype.hpp @@ -184,7 +184,7 @@ public: /** * Get a specific industry-type from a grf. - * @param grf_id The ID of the NewGRF. + * @param grfid The ID of the NewGRF. * @param grf_local_id The ID of the industry, local to the NewGRF. * @pre 0x00 <= grf_local_id < NUM_INDUSTRYTYPES_PER_GRF. * @return the industry-type ID, local to the current game (this diverges from the grf_local_id). diff --git a/src/script/api/script_league.hpp b/src/script/api/script_league.hpp index d6fc2bbfea..4c16e288b8 100644 --- a/src/script/api/script_league.hpp +++ b/src/script/api/script_league.hpp @@ -68,6 +68,8 @@ public: /** * Create a new league table. * @param title League table title (can be either a raw string, or ScriptText object). + * @param header The optional header text for the table (null is allowed). + * @param footer The optional footer text for the table (null is allowed). * @return The new LeagueTableID, or LEAGUE_TABLE_INVALID if it failed. * @pre No ScriptCompanyMode may be in scope. * @pre title != nullptr && len(title) != 0. diff --git a/src/script/api/script_objecttype.hpp b/src/script/api/script_objecttype.hpp index 94da70c467..7ceebce440 100644 --- a/src/script/api/script_objecttype.hpp +++ b/src/script/api/script_objecttype.hpp @@ -55,7 +55,7 @@ public: /** * Get a specific object-type from a grf. - * @param grf_id The ID of the NewGRF. + * @param grfid The ID of the NewGRF. * @param grf_local_id The ID of the object, local to the NewGRF. * @pre 0x00 <= grf_local_id < NUM_OBJECTS_PER_GRF. * @return the object-type ID, local to the current game (this diverges from the grf_local_id). diff --git a/src/script/api/script_priorityqueue.hpp b/src/script/api/script_priorityqueue.hpp index 517f6ab0bd..07e4448b88 100644 --- a/src/script/api/script_priorityqueue.hpp +++ b/src/script/api/script_priorityqueue.hpp @@ -61,6 +61,7 @@ public: /** * Check if an items is already included in the queue. + * @param item The item to check whether it's already in this queue. * @return true if the items is already in the queue. * @note Performance is O(n), use only when absolutely required. */ diff --git a/src/script/api/script_road.hpp b/src/script/api/script_road.hpp index 769c4a7728..9631309ebc 100644 --- a/src/script/api/script_road.hpp +++ b/src/script/api/script_road.hpp @@ -160,7 +160,7 @@ public: /** * Check if a road vehicle built for a road type can run on another road type. * @param engine_road_type The road type the road vehicle is built for. - * @param track_road_type The road type you want to check. + * @param road_road_type The road type you want to check. * @pre ScriptRoad::IsRoadTypeAvailable(engine_road_type). * @pre ScriptRoad::IsRoadTypeAvailable(road_road_type). * @return Whether a road vehicle built for 'engine_road_type' can run on 'road_road_type'. @@ -386,7 +386,6 @@ public: * one-way in the other direction, it's made a 'no'-way road (it's * forbidden to enter the tile from any direction). * @param start The start tile of the road. - * @param start The start tile of the road. * @param end The end tile of the road. * @pre 'start' is not equal to 'end'. * @pre ScriptMap::IsValidTile(start). diff --git a/src/script/api/script_story_page.hpp b/src/script/api/script_story_page.hpp index c87ef7cb37..f0f235c130 100644 --- a/src/script/api/script_story_page.hpp +++ b/src/script/api/script_story_page.hpp @@ -315,6 +315,7 @@ public: /** * Create a reference value for SPET_BUTTON_PUSH element parameters. * @param colour The colour for the face of the button. + * @param flags The formatting and layout flags for the button. * @return A reference value usable with the #NewElement and #UpdateElement functions. */ static StoryPageButtonFormatting MakePushButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags); @@ -322,6 +323,7 @@ public: /** * Create a reference value for SPET_BUTTON_TILE element parameters. * @param colour The colour for the face of the button. + * @param flags The formatting and layout flags for the button. * @param cursor The mouse cursor to use when the player clicks the button and the game is ready for the player to select a tile. * @return A reference value usable with the #NewElement and #UpdateElement functions. */ @@ -330,6 +332,7 @@ public: /** * Create a reference value for SPET_BUTTON_VEHICLE element parameters. * @param colour The colour for the face of the button. + * @param flags The formatting and layout flags for the button. * @param cursor The mouse cursor to use when the player clicks the button and the game is ready for the player to select a vehicle. * @param vehtype The type of vehicle that will be selectable, or \c VT_INVALID to allow all types. * @return A reference value usable with the #NewElement and #UpdateElement functions. diff --git a/src/script/api/script_viewport.hpp b/src/script/api/script_viewport.hpp index 81612031dc..8f3248fb4e 100644 --- a/src/script/api/script_viewport.hpp +++ b/src/script/api/script_viewport.hpp @@ -35,6 +35,7 @@ public: * @param tile The tile to put in the center of the screen. * @pre ScriptObject::GetCompany() == OWNER_DEITY * @pre ScriptMap::IsValidTile(tile) + * @return True iff the command was executed successfully. */ static bool ScrollEveryoneTo(TileIndex tile); @@ -46,6 +47,7 @@ public: * @pre ScriptObject::GetCompany() == OWNER_DEITY * @pre ScriptMap::IsValidTile(tile) * @pre ResolveCompanyID(company) != COMPANY_INVALID + * @return True iff the command was executed successfully. */ static bool ScrollCompanyClientsTo(ScriptCompany::CompanyID company, TileIndex tile); @@ -58,6 +60,7 @@ public: * @pre ScriptObject::GetCompany() == OWNER_DEITY * @pre ScriptMap::IsValidTile(tile) * @pre ResolveClientID(client) != CLIENT_INVALID + * @return True iff the command was executed successfully. */ static bool ScrollClientTo(ScriptClient::ClientID client, TileIndex tile); }; From 2fd99467eac301390b8c0fa0f8eb1dbedc21e0e6 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Wed, 25 Jan 2023 23:44:58 +0100 Subject: [PATCH 06/12] Fix: scripts are not aware of nullptr, they only know null --- src/script/api/script_basestation.hpp | 2 +- src/script/api/script_company.hpp | 4 ++-- src/script/api/script_goal.hpp | 10 +++++----- src/script/api/script_group.hpp | 2 +- src/script/api/script_league.hpp | 10 +++++----- src/script/api/script_list.hpp | 4 ++-- src/script/api/script_newgrf.hpp | 2 +- src/script/api/script_news.hpp | 2 +- src/script/api/script_sign.hpp | 4 ++-- src/script/api/script_story_page.hpp | 4 ++-- src/script/api/script_town.hpp | 2 +- src/script/api/script_vehicle.hpp | 2 +- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/script/api/script_basestation.hpp b/src/script/api/script_basestation.hpp index 85a34eac4f..b04ae8477c 100644 --- a/src/script/api/script_basestation.hpp +++ b/src/script/api/script_basestation.hpp @@ -50,7 +50,7 @@ public: * @param station_id The basestation to set the name of. * @param name The new name of the station (can be either a raw string, or a ScriptText object). * @pre IsValidBaseStation(station_id). - * @pre name != nullptr && len(name) != 0. + * @pre name != null && len(name) != 0. * @game @pre Valid ScriptCompanyMode active in scope. * @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE * @return True if the name was changed. diff --git a/src/script/api/script_company.hpp b/src/script/api/script_company.hpp index 947698b171..4fc496d967 100644 --- a/src/script/api/script_company.hpp +++ b/src/script/api/script_company.hpp @@ -137,7 +137,7 @@ public: /** * Set the name of your company. * @param name The new name of the company (can be either a raw string, or a ScriptText object). - * @pre name != nullptr && len(name) != 0. + * @pre name != null && len(name) != 0. * @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE * @return True if the name was changed. */ @@ -154,7 +154,7 @@ public: /** * Set the name of your president. * @param name The new name of the president (can be either a raw string, or a ScriptText object). - * @pre name != nullptr && len(name) != 0. + * @pre name != null && len(name) != 0. * @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE * @return True if the name was changed. */ diff --git a/src/script/api/script_goal.hpp b/src/script/api/script_goal.hpp index 2261dcc00f..dda8498fe4 100644 --- a/src/script/api/script_goal.hpp +++ b/src/script/api/script_goal.hpp @@ -97,7 +97,7 @@ public: * @param destination The destination of the \a type type. * @return The new GoalID, or GOAL_INVALID if it failed. * @pre No ScriptCompanyMode may be in scope. - * @pre goal != nullptr && len(goal) != 0. + * @pre goal != null && len(goal) != 0. * @pre company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID. * @pre if type is GT_STORY_PAGE, the company of the goal and the company of the story page need to match: * \li Global goals can only reference global story pages. @@ -120,7 +120,7 @@ public: * @param goal The new goal text (can be either a raw string, or a ScriptText object). * @return True if the action succeeded. * @pre No ScriptCompanyMode may be in scope. - * @pre goal != nullptr && len(goal) != 0. + * @pre goal != null && len(goal) != 0. * @pre IsValidGoal(goal_id). */ static bool SetText(GoalID goal_id, Text *goal); @@ -131,7 +131,7 @@ public: * the progress string short. * @param goal_id The goal to update. * @param progress The new progress text for the goal (can be either a raw string, - * or a ScriptText object). To clear the progress string you can pass nullptr or an + * or a ScriptText object). To clear the progress string you can pass null or an * empty string. * @return True if the action succeeded. * @pre No ScriptCompanyMode may be in scope. @@ -167,7 +167,7 @@ public: * @param buttons Any combinations (at least 1, up to 3) of buttons defined in QuestionButton. Like BUTTON_YES + BUTTON_NO. * @return True if the action succeeded. * @pre No ScriptCompanyMode may be in scope. - * @pre question != nullptr && len(question) != 0. + * @pre question != null && len(question) != 0. * @pre company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID. * @pre CountBits(buttons) >= 1 && CountBits(buttons) <= 3. * @note Replies to the question are given by you via the event ScriptEvent_GoalQuestionAnswer. @@ -185,7 +185,7 @@ public: * @return True if the action succeeded. * @pre No ScriptCompanyMode may be in scope. * @pre ScriptGame::IsMultiplayer() - * @pre question != nullptr && len(question) != 0. + * @pre question != null && len(question) != 0. * @pre ResolveClientID(client) != CLIENT_INVALID. * @pre CountBits(buttons) >= 1 && CountBits(buttons) <= 3. * @note Replies to the question are given by you via the event ScriptEvent_GoalQuestionAnswer. diff --git a/src/script/api/script_group.hpp b/src/script/api/script_group.hpp index df3ddc3303..997bdf3c82 100644 --- a/src/script/api/script_group.hpp +++ b/src/script/api/script_group.hpp @@ -69,7 +69,7 @@ public: * @param group_id The group to set the name for. * @param name The name for the group (can be either a raw string, or a ScriptText object). * @pre IsValidGroup(group_id). - * @pre name != nullptr && len(name) != 0 + * @pre name != null && len(name) != 0 * @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE * @return True if and only if the name was changed. */ diff --git a/src/script/api/script_league.hpp b/src/script/api/script_league.hpp index 4c16e288b8..045408d66b 100644 --- a/src/script/api/script_league.hpp +++ b/src/script/api/script_league.hpp @@ -72,7 +72,7 @@ public: * @param footer The optional footer text for the table (null is allowed). * @return The new LeagueTableID, or LEAGUE_TABLE_INVALID if it failed. * @pre No ScriptCompanyMode may be in scope. - * @pre title != nullptr && len(title) != 0. + * @pre title != null && len(title) != 0. */ static LeagueTableID New(Text *title, Text *header, Text *footer); @@ -88,8 +88,8 @@ public: * @return The new LeagueTableElementID, or LEAGUE_TABLE_ELEMENT_INVALID if it failed. * @pre No ScriptCompanyMode may be in scope. * @pre IsValidLeagueTable(table). - * @pre text != nullptr && len(text) != 0. - * @pre score != nullptr && len(score) != 0. + * @pre text != null && len(text) != 0. + * @pre score != null && len(score) != 0. * @pre IsValidLink(Link(link_type, link_target)). */ static LeagueTableElementID NewElement(LeagueTableID table, int64 rating, ScriptCompany::CompanyID company, Text *text, Text *score, LinkType link_type, LinkTargetID link_target); @@ -104,7 +104,7 @@ public: * @return True if the action succeeded. * @pre No ScriptCompanyMode may be in scope. * @pre IsValidLeagueTableElement(element). - * @pre text != nullptr && len(text) != 0. + * @pre text != null && len(text) != 0. * @pre IsValidLink(Link(link_type, link_target)). */ static bool UpdateElementData(LeagueTableElementID element, ScriptCompany::CompanyID company, Text *text, LinkType link_type, LinkTargetID link_target); @@ -117,7 +117,7 @@ public: * @return True if the action succeeded. * @pre No ScriptCompanyMode may be in scope. * @pre IsValidLeagueTableElement(element). - * @pre score != nullptr && len(score) != 0. + * @pre score != null && len(score) != 0. */ static bool UpdateElementScore(LeagueTableElementID element, int64 rating, Text *score); diff --git a/src/script/api/script_list.hpp b/src/script/api/script_list.hpp index 0dbb2c45d7..7b2fde636a 100644 --- a/src/script/api/script_list.hpp +++ b/src/script/api/script_list.hpp @@ -196,7 +196,7 @@ public: /** * Remove everything that is in the given list from this list (same item index that is). * @param list the list of items to remove. - * @pre list != nullptr + * @pre list != null */ void RemoveList(ScriptList *list); @@ -240,7 +240,7 @@ public: /** * Keeps everything that is in the given list from this list (same item index that is). * @param list the list of items to keep. - * @pre list != nullptr + * @pre list != null */ void KeepList(ScriptList *list); diff --git a/src/script/api/script_newgrf.hpp b/src/script/api/script_newgrf.hpp index d1a9336ecc..5fc5596f82 100644 --- a/src/script/api/script_newgrf.hpp +++ b/src/script/api/script_newgrf.hpp @@ -48,7 +48,7 @@ public: * Get the name of a loaded NewGRF. * @param grfid The NewGRF to query. * @pre ScriptNewGRF::IsLoaded(grfid). - * @return The name of the NewGRF or nullptr if no name is defined. + * @return The name of the NewGRF or null if no name is defined. */ static char *GetName(uint32 grfid); }; diff --git a/src/script/api/script_news.hpp b/src/script/api/script_news.hpp index 6b7b39af01..630c068c9a 100644 --- a/src/script/api/script_news.hpp +++ b/src/script/api/script_news.hpp @@ -59,7 +59,7 @@ public: * - For #NR_TOWN this parameter should be a valid townID (ScriptTown::IsValidTown). * @return True if the action succeeded. * @pre type must be #NT_ECONOMY, #NT_SUBSIDIES, or #NT_GENERAL. - * @pre text != nullptr. + * @pre text != null. * @pre company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID. * @pre The \a reference condition must be fulfilled. */ diff --git a/src/script/api/script_sign.hpp b/src/script/api/script_sign.hpp index 5913e45a4f..06a17da92b 100644 --- a/src/script/api/script_sign.hpp +++ b/src/script/api/script_sign.hpp @@ -43,7 +43,7 @@ public: * @param sign_id The sign to set the name for. * @param name The name for the sign (can be either a raw string, or a ScriptText object). * @pre IsValidSign(sign_id). - * @pre name != nullptr && len(name) != 0. + * @pre name != null && len(name) != 0. * @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE * @return True if and only if the name was changed. */ @@ -79,7 +79,7 @@ public: * @param location The place to build the sign. * @param name The text to place on the sign (can be either a raw string, or a ScriptText object). * @pre ScriptMap::IsValidTile(location). - * @pre name != nullptr && len(name) != 0. + * @pre name != null && len(name) != 0. * @exception ScriptSign::ERR_SIGN_TOO_MANY_SIGNS * @return The SignID of the build sign (use IsValidSign() to check for validity). * In test-mode it returns 0 if successful, or any other value to indicate diff --git a/src/script/api/script_story_page.hpp b/src/script/api/script_story_page.hpp index f0f235c130..ac6d2d64f5 100644 --- a/src/script/api/script_story_page.hpp +++ b/src/script/api/script_story_page.hpp @@ -202,7 +202,7 @@ public: * @return The new StoryPageElementID, or STORY_PAGE_ELEMENT_INVALID if it failed. * @pre No ScriptCompanyMode may be in scope. * @pre IsValidStoryPage(story_page). - * @pre (type != SPET_TEXT && type != SPET_LOCATION) || (text != nullptr && len(text) != 0). + * @pre (type != SPET_TEXT && type != SPET_LOCATION) || (text != null && len(text) != 0). * @pre type != SPET_LOCATION || ScriptMap::IsValidTile(reference). * @pre type != SPET_GOAL || ScriptGoal::IsValidGoal(reference). * @pre if type is SPET_GOAL and story_page is a global page, then referenced goal must be global. @@ -217,7 +217,7 @@ public: * @return True if the action succeeded. * @pre No ScriptCompanyMode may be in scope. * @pre IsValidStoryPage(story_page). - * @pre (type != SPET_TEXT && type != SPET_LOCATION) || (text != nullptr && len(text) != 0). + * @pre (type != SPET_TEXT && type != SPET_LOCATION) || (text != null && len(text) != 0). * @pre type != SPET_LOCATION || ScriptMap::IsValidTile(reference). * @pre type != SPET_GOAL || ScriptGoal::IsValidGoal(reference). * @pre if type is SPET_GOAL and story_page is a global page, then referenced goal must be global. diff --git a/src/script/api/script_town.hpp b/src/script/api/script_town.hpp index 6ae7ee33f5..6e7fc67781 100644 --- a/src/script/api/script_town.hpp +++ b/src/script/api/script_town.hpp @@ -400,7 +400,7 @@ public: * @param size The town size of the new town. * @param city True if the new town should be a city. * @param layout The town layout of the new town. - * @param name The name of the new town. Pass nullptr to use a random town name. + * @param name The name of the new town. Pass null to use a random town name. * @game @pre no company mode in scope || ScriptSettings.GetValue("economy.found_town") != 0. * @ai @pre ScriptSettings.GetValue("economy.found_town") != 0. * @game @pre no company mode in scope || size != TOWN_SIZE_LARGE. diff --git a/src/script/api/script_vehicle.hpp b/src/script/api/script_vehicle.hpp index 3c242d56fe..02616e8b4d 100644 --- a/src/script/api/script_vehicle.hpp +++ b/src/script/api/script_vehicle.hpp @@ -113,7 +113,7 @@ public: * @param vehicle_id The vehicle to set the name for. * @param name The name for the vehicle (can be either a raw string, or a ScriptText object). * @pre IsValidVehicle(vehicle_id). - * @pre name != nullptr && len(name) != 0. + * @pre name != null && len(name) != 0. * @game @pre Valid ScriptCompanyMode active in scope. * @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE * @return True if and only if the name was changed. From 07940726d3f5a53f63e90b9b710e1f947d0cb8fc Mon Sep 17 00:00:00 2001 From: translators Date: Thu, 26 Jan 2023 18:45:34 +0000 Subject: [PATCH 07/12] Update: Translations from eints korean: 4 changes by telk5093 --- src/lang/korean.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lang/korean.txt b/src/lang/korean.txt index 911a41d693..96d99a6917 100644 --- a/src/lang/korean.txt +++ b/src/lang/korean.txt @@ -2699,6 +2699,10 @@ STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_INCREASE_TOOLTIP :{BLACK}드래 STR_SELECT_RAIL_BRIDGE_CAPTION :{WHITE}철교 선택 STR_SELECT_ROAD_BRIDGE_CAPTION :{WHITE}다리 종류를 선택하세요 STR_SELECT_BRIDGE_SELECTION_TOOLTIP :{BLACK}다리 건설 - 원하는 다리 종류를 선택하세요 +STR_SELECT_BRIDGE_INFO_NAME :{GOLD}{STRING} +STR_SELECT_BRIDGE_INFO_NAME_MAX_SPEED :{GOLD}{STRING},{} {VELOCITY} +STR_SELECT_BRIDGE_INFO_NAME_COST :{GOLD}{0:STRING},{} {WHITE}{2:CURRENCY_LONG} +STR_SELECT_BRIDGE_INFO_NAME_MAX_SPEED_COST :{GOLD}{STRING},{} {VELOCITY} {WHITE}{CURRENCY_LONG} STR_BRIDGE_NAME_SUSPENSION_STEEL :강철 현수교 STR_BRIDGE_NAME_GIRDER_STEEL :강철 거더교 STR_BRIDGE_NAME_CANTILEVER_STEEL :강철 캔틸레버교 From eedb7868720ee1d9eda6195c04013411bd1be7b8 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 21 Jan 2023 16:05:28 +0000 Subject: [PATCH 08/12] Codechange: Use vector for NewGRF spec overrides. This replaces C-style memory management. --- src/newgrf_commons.cpp | 27 +++++++-------------------- src/newgrf_commons.h | 12 ++++++------ 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp index 4fa37000a7..7dd5e22cbc 100644 --- a/src/newgrf_commons.cpp +++ b/src/newgrf_commons.cpp @@ -44,21 +44,10 @@ OverrideManagerBase::OverrideManagerBase(uint16 offset, uint16 maximum, uint16 i max_new_entities = maximum; invalid_ID = invalid; - mapping_ID = CallocT(max_new_entities); - entity_overrides = MallocT(max_offset); - for (size_t i = 0; i < max_offset; i++) entity_overrides[i] = invalid; - grfid_overrides = CallocT(max_offset); -} - -/** - * Destructor of the generic class. - * Frees allocated memory of constructor - */ -OverrideManagerBase::~OverrideManagerBase() -{ - free(mapping_ID); - free(entity_overrides); - free(grfid_overrides); + this->mapping_ID.resize(this->max_new_entities); + this->entity_overrides.resize(this->max_offset); + std::fill(this->entity_overrides.begin(), this->entity_overrides.end(), this->invalid_ID); + this->grfid_overrides.resize(this->max_offset); } /** @@ -81,16 +70,14 @@ void OverrideManagerBase::Add(uint8 local_id, uint32 grfid, uint entity_type) /** Resets the mapping, which is used while initializing game */ void OverrideManagerBase::ResetMapping() { - memset(mapping_ID, 0, (max_new_entities - 1) * sizeof(EntityIDMapping)); + std::fill(this->mapping_ID.begin(), this->mapping_ID.end(), EntityIDMapping{}); } /** Resets the override, which is used while initializing game */ void OverrideManagerBase::ResetOverride() { - for (uint16 i = 0; i < max_offset; i++) { - entity_overrides[i] = invalid_ID; - grfid_overrides[i] = 0; - } + std::fill(this->entity_overrides.begin(), this->entity_overrides.end(), this->invalid_ID); + std::fill(this->grfid_overrides.begin(), this->grfid_overrides.end(), uint32()); } /** diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h index ff241369a2..6a908417b1 100644 --- a/src/newgrf_commons.h +++ b/src/newgrf_commons.h @@ -191,8 +191,8 @@ struct EntityIDMapping { class OverrideManagerBase { protected: - uint16 *entity_overrides; - uint32 *grfid_overrides; + std::vector entity_overrides; + std::vector grfid_overrides; uint16 max_offset; ///< what is the length of the original entity's array of specs uint16 max_new_entities; ///< what is the amount of entities, old and new summed @@ -201,10 +201,10 @@ protected: virtual bool CheckValidNewID(uint16 testid) { return true; } public: - EntityIDMapping *mapping_ID; ///< mapping of ids from grf files. Public out of convenience + std::vector mapping_ID; ///< mapping of ids from grf files. Public out of convenience OverrideManagerBase(uint16 offset, uint16 maximum, uint16 invalid); - virtual ~OverrideManagerBase(); + virtual ~OverrideManagerBase() {} void ResetOverride(); void ResetMapping(); @@ -267,7 +267,7 @@ public: struct AirportTileSpec; class AirportTileOverrideManager : public OverrideManagerBase { protected: - virtual bool CheckValidNewID(uint16 testid) { return testid != 0xFF; } + virtual bool CheckValidNewID(uint16 testid) override { return testid != 0xFF; } public: AirportTileOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) : OverrideManagerBase(offset, maximum, invalid) {} @@ -278,7 +278,7 @@ public: struct ObjectSpec; class ObjectOverrideManager : public OverrideManagerBase { protected: - virtual bool CheckValidNewID(uint16 testid) { return testid != 0xFF; } + virtual bool CheckValidNewID(uint16 testid) override { return testid != 0xFF; } public: ObjectOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) : OverrideManagerBase(offset, maximum, invalid) {} From bcc53c5ad5fa65d76cf692b4746019694f08d8bb Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 22 Jan 2023 17:03:48 +0000 Subject: [PATCH 09/12] Codechange: Add missing `this->` in override manager. Variable scope is also tweaked in a couple of cases reducing line count. --- src/newgrf_airport.cpp | 10 ++--- src/newgrf_airporttiles.cpp | 10 ++--- src/newgrf_commons.cpp | 83 +++++++++++++++++-------------------- src/newgrf_commons.h | 4 +- 4 files changed, 51 insertions(+), 56 deletions(-) diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp index e72b3a7e85..d757f0e9c3 100644 --- a/src/newgrf_airport.cpp +++ b/src/newgrf_airport.cpp @@ -175,7 +175,7 @@ void AirportOverrideManager::SetEntitySpec(AirportSpec *as) { byte airport_id = this->AddEntityID(as->grf_prop.local_id, as->grf_prop.grffile->grfid, as->grf_prop.subst_id); - if (airport_id == invalid_ID) { + if (airport_id == this->invalid_ID) { grfmsg(1, "Airport.SetEntitySpec: Too many airports allocated. Ignoring."); return; } @@ -183,15 +183,15 @@ void AirportOverrideManager::SetEntitySpec(AirportSpec *as) memcpy(AirportSpec::GetWithoutOverride(airport_id), as, sizeof(*as)); /* Now add the overrides. */ - for (int i = 0; i < max_offset; i++) { + for (int i = 0; i < this->max_offset; i++) { AirportSpec *overridden_as = AirportSpec::GetWithoutOverride(i); - if (entity_overrides[i] != as->grf_prop.local_id || grfid_overrides[i] != as->grf_prop.grffile->grfid) continue; + if (this->entity_overrides[i] != as->grf_prop.local_id || this->grfid_overrides[i] != as->grf_prop.grffile->grfid) continue; overridden_as->grf_prop.override = airport_id; overridden_as->enabled = false; - entity_overrides[i] = invalid_ID; - grfid_overrides[i] = 0; + this->entity_overrides[i] = this->invalid_ID; + this->grfid_overrides[i] = 0; } } diff --git a/src/newgrf_airporttiles.cpp b/src/newgrf_airporttiles.cpp index 01d4baedc9..e6aa049112 100644 --- a/src/newgrf_airporttiles.cpp +++ b/src/newgrf_airporttiles.cpp @@ -67,7 +67,7 @@ void AirportTileOverrideManager::SetEntitySpec(const AirportTileSpec *airpts) { StationGfx airpt_id = this->AddEntityID(airpts->grf_prop.local_id, airpts->grf_prop.grffile->grfid, airpts->grf_prop.subst_id); - if (airpt_id == invalid_ID) { + if (airpt_id == this->invalid_ID) { grfmsg(1, "AirportTile.SetEntitySpec: Too many airport tiles allocated. Ignoring."); return; } @@ -75,15 +75,15 @@ void AirportTileOverrideManager::SetEntitySpec(const AirportTileSpec *airpts) memcpy(&AirportTileSpec::tiles[airpt_id], airpts, sizeof(*airpts)); /* Now add the overrides. */ - for (int i = 0; i < max_offset; i++) { + for (int i = 0; i < this->max_offset; i++) { AirportTileSpec *overridden_airpts = &AirportTileSpec::tiles[i]; - if (entity_overrides[i] != airpts->grf_prop.local_id || grfid_overrides[i] != airpts->grf_prop.grffile->grfid) continue; + if (this->entity_overrides[i] != airpts->grf_prop.local_id || this->grfid_overrides[i] != airpts->grf_prop.grffile->grfid) continue; overridden_airpts->grf_prop.override = airpt_id; overridden_airpts->enabled = false; - entity_overrides[i] = invalid_ID; - grfid_overrides[i] = 0; + this->entity_overrides[i] = this->invalid_ID; + this->grfid_overrides[i] = 0; } } diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp index 7dd5e22cbc..907e7093c4 100644 --- a/src/newgrf_commons.cpp +++ b/src/newgrf_commons.cpp @@ -40,9 +40,9 @@ */ OverrideManagerBase::OverrideManagerBase(uint16 offset, uint16 maximum, uint16 invalid) { - max_offset = offset; - max_new_entities = maximum; - invalid_ID = invalid; + this->max_offset = offset; + this->max_new_entities = maximum; + this->invalid_ID = invalid; this->mapping_ID.resize(this->max_new_entities); this->entity_overrides.resize(this->max_offset); @@ -60,11 +60,11 @@ OverrideManagerBase::OverrideManagerBase(uint16 offset, uint16 maximum, uint16 i */ void OverrideManagerBase::Add(uint8 local_id, uint32 grfid, uint entity_type) { - assert(entity_type < max_offset); + assert(entity_type < this->max_offset); /* An override can be set only once */ - if (entity_overrides[entity_type] != invalid_ID) return; - entity_overrides[entity_type] = local_id; - grfid_overrides[entity_type] = grfid; + if (this->entity_overrides[entity_type] != this->invalid_ID) return; + this->entity_overrides[entity_type] = local_id; + this->grfid_overrides[entity_type] = grfid; } /** Resets the mapping, which is used while initializing game */ @@ -88,16 +88,14 @@ void OverrideManagerBase::ResetOverride() */ uint16 OverrideManagerBase::GetID(uint8 grf_local_id, uint32 grfid) const { - const EntityIDMapping *map; - - for (uint16 id = 0; id < max_new_entities; id++) { - map = &mapping_ID[id]; + for (uint16 id = 0; id < this->max_new_entities; id++) { + const EntityIDMapping *map = &this->mapping_ID[id]; if (map->entity_id == grf_local_id && map->grfid == grfid) { return id; } } - return invalid_ID; + return this->invalid_ID; } /** @@ -110,19 +108,16 @@ uint16 OverrideManagerBase::GetID(uint8 grf_local_id, uint32 grfid) const uint16 OverrideManagerBase::AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id) { uint16 id = this->GetID(grf_local_id, grfid); - EntityIDMapping *map; /* Look to see if this entity has already been added. This is done * separately from the loop below in case a GRF has been deleted, and there * are any gaps in the array. */ - if (id != invalid_ID) { - return id; - } + if (id != this->invalid_ID) return id; /* This entity hasn't been defined before, so give it an ID now. */ - for (id = max_offset; id < max_new_entities; id++) { - map = &mapping_ID[id]; + for (id = this->max_offset; id < this->max_new_entities; id++) { + EntityIDMapping *map = &this->mapping_ID[id]; if (CheckValidNewID(id) && map->entity_id == 0 && map->grfid == 0) { map->entity_id = grf_local_id; @@ -132,7 +127,7 @@ uint16 OverrideManagerBase::AddEntityID(byte grf_local_id, uint32 grfid, byte su } } - return invalid_ID; + return this->invalid_ID; } /** @@ -142,7 +137,7 @@ uint16 OverrideManagerBase::AddEntityID(byte grf_local_id, uint32 grfid, byte su */ uint32 OverrideManagerBase::GetGRFID(uint16 entity_id) const { - return mapping_ID[entity_id].grfid; + return this->mapping_ID[entity_id].grfid; } /** @@ -152,7 +147,7 @@ uint32 OverrideManagerBase::GetGRFID(uint16 entity_id) const */ uint16 OverrideManagerBase::GetSubstituteID(uint16 entity_id) const { - return mapping_ID[entity_id].substitute_id; + return this->mapping_ID[entity_id].substitute_id; } /** @@ -164,7 +159,7 @@ void HouseOverrideManager::SetEntitySpec(const HouseSpec *hs) { HouseID house_id = this->AddEntityID(hs->grf_prop.local_id, hs->grf_prop.grffile->grfid, hs->grf_prop.subst_id); - if (house_id == invalid_ID) { + if (house_id == this->invalid_ID) { grfmsg(1, "House.SetEntitySpec: Too many houses allocated. Ignoring."); return; } @@ -172,14 +167,14 @@ void HouseOverrideManager::SetEntitySpec(const HouseSpec *hs) MemCpyT(HouseSpec::Get(house_id), hs); /* Now add the overrides. */ - for (int i = 0; i != max_offset; i++) { + for (int i = 0; i < this->max_offset; i++) { HouseSpec *overridden_hs = HouseSpec::Get(i); - if (entity_overrides[i] != hs->grf_prop.local_id || grfid_overrides[i] != hs->grf_prop.grffile->grfid) continue; + if (this->entity_overrides[i] != hs->grf_prop.local_id || this->grfid_overrides[i] != hs->grf_prop.grffile->grfid) continue; overridden_hs->grf_prop.override = house_id; - entity_overrides[i] = invalid_ID; - grfid_overrides[i] = 0; + this->entity_overrides[i] = this->invalid_ID; + this->grfid_overrides[i] = 0; } } @@ -192,14 +187,14 @@ void HouseOverrideManager::SetEntitySpec(const HouseSpec *hs) uint16 IndustryOverrideManager::GetID(uint8 grf_local_id, uint32 grfid) const { uint16 id = OverrideManagerBase::GetID(grf_local_id, grfid); - if (id != invalid_ID) return id; + if (id != this->invalid_ID) return id; /* No mapping found, try the overrides */ - for (id = 0; id < max_offset; id++) { - if (entity_overrides[id] == grf_local_id && grfid_overrides[id] == grfid) return id; + for (id = 0; id < this->max_offset; id++) { + if (this->entity_overrides[id] == grf_local_id && this->grfid_overrides[id] == grfid) return id; } - return invalid_ID; + return this->invalid_ID; } /** @@ -212,9 +207,9 @@ uint16 IndustryOverrideManager::GetID(uint8 grf_local_id, uint32 grfid) const uint16 IndustryOverrideManager::AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id) { /* This entity hasn't been defined before, so give it an ID now. */ - for (uint16 id = 0; id < max_new_entities; id++) { + for (uint16 id = 0; id < this->max_new_entities; id++) { /* Skip overridden industries */ - if (id < max_offset && entity_overrides[id] != invalid_ID) continue; + if (id < this->max_offset && this->entity_overrides[id] != this->invalid_ID) continue; /* Get the real live industry */ const IndustrySpec *inds = GetIndustrySpec(id); @@ -223,7 +218,7 @@ uint16 IndustryOverrideManager::AddEntityID(byte grf_local_id, uint32 grfid, byt * And it must not already be used by a grf (grffile == nullptr). * So reserve this slot here, as it is the chosen one */ if (!inds->enabled && inds->grf_prop.grffile == nullptr) { - EntityIDMapping *map = &mapping_ID[id]; + EntityIDMapping *map = &this->mapping_ID[id]; if (map->entity_id == 0 && map->grfid == 0) { /* winning slot, mark it as been used */ @@ -235,7 +230,7 @@ uint16 IndustryOverrideManager::AddEntityID(byte grf_local_id, uint32 grfid, byt } } - return invalid_ID; + return this->invalid_ID; } /** @@ -249,16 +244,16 @@ void IndustryOverrideManager::SetEntitySpec(IndustrySpec *inds) /* First step : We need to find if this industry is already specified in the savegame data. */ IndustryType ind_id = this->GetID(inds->grf_prop.local_id, inds->grf_prop.grffile->grfid); - if (ind_id == invalid_ID) { + if (ind_id == this->invalid_ID) { /* Not found. * Or it has already been overridden, so you've lost your place. * Or it is a simple substitute. * We need to find a free available slot */ ind_id = this->AddEntityID(inds->grf_prop.local_id, inds->grf_prop.grffile->grfid, inds->grf_prop.subst_id); - inds->grf_prop.override = invalid_ID; // make sure it will not be detected as overridden + inds->grf_prop.override = this->invalid_ID; // make sure it will not be detected as overridden } - if (ind_id == invalid_ID) { + if (ind_id == this->invalid_ID) { grfmsg(1, "Industry.SetEntitySpec: Too many industries allocated. Ignoring."); return; } @@ -273,7 +268,7 @@ void IndustryTileOverrideManager::SetEntitySpec(const IndustryTileSpec *its) { IndustryGfx indt_id = this->AddEntityID(its->grf_prop.local_id, its->grf_prop.grffile->grfid, its->grf_prop.subst_id); - if (indt_id == invalid_ID) { + if (indt_id == this->invalid_ID) { grfmsg(1, "IndustryTile.SetEntitySpec: Too many industry tiles allocated. Ignoring."); return; } @@ -281,15 +276,15 @@ void IndustryTileOverrideManager::SetEntitySpec(const IndustryTileSpec *its) memcpy(&_industry_tile_specs[indt_id], its, sizeof(*its)); /* Now add the overrides. */ - for (int i = 0; i < max_offset; i++) { + for (int i = 0; i < this->max_offset; i++) { IndustryTileSpec *overridden_its = &_industry_tile_specs[i]; - if (entity_overrides[i] != its->grf_prop.local_id || grfid_overrides[i] != its->grf_prop.grffile->grfid) continue; + if (this->entity_overrides[i] != its->grf_prop.local_id || this->grfid_overrides[i] != its->grf_prop.grffile->grfid) continue; overridden_its->grf_prop.override = indt_id; overridden_its->enabled = false; - entity_overrides[i] = invalid_ID; - grfid_overrides[i] = 0; + this->entity_overrides[i] = this->invalid_ID; + this->grfid_overrides[i] = 0; } } @@ -304,7 +299,7 @@ void ObjectOverrideManager::SetEntitySpec(ObjectSpec *spec) /* First step : We need to find if this object is already specified in the savegame data. */ ObjectType type = this->GetID(spec->grf_prop.local_id, spec->grf_prop.grffile->grfid); - if (type == invalid_ID) { + if (type == this->invalid_ID) { /* Not found. * Or it has already been overridden, so you've lost your place. * Or it is a simple substitute. @@ -312,7 +307,7 @@ void ObjectOverrideManager::SetEntitySpec(ObjectSpec *spec) type = this->AddEntityID(spec->grf_prop.local_id, spec->grf_prop.grffile->grfid, OBJECT_TRANSMITTER); } - if (type == invalid_ID) { + if (type == this->invalid_ID) { grfmsg(1, "Object.SetEntitySpec: Too many objects allocated. Ignoring."); return; } diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h index 6a908417b1..3fdff6c78a 100644 --- a/src/newgrf_commons.h +++ b/src/newgrf_commons.h @@ -216,8 +216,8 @@ public: uint16 GetSubstituteID(uint16 entity_id) const; virtual uint16 GetID(uint8 grf_local_id, uint32 grfid) const; - inline uint16 GetMaxMapping() const { return max_new_entities; } - inline uint16 GetMaxOffset() const { return max_offset; } + inline uint16 GetMaxMapping() const { return this->max_new_entities; } + inline uint16 GetMaxOffset() const { return this->max_offset; } }; From ede1201b6aa8cf90364fae3ebc312f1b43d923a3 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 22 Jan 2023 17:20:23 +0000 Subject: [PATCH 10/12] Codechange: Rename override manager variables. --- src/newgrf_airport.cpp | 4 +-- src/newgrf_airporttiles.cpp | 4 +-- src/newgrf_commons.cpp | 62 ++++++++++++++++++------------------- src/newgrf_commons.h | 10 +++--- src/saveload/newgrf_sl.cpp | 8 ++--- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp index d757f0e9c3..f41ab15714 100644 --- a/src/newgrf_airport.cpp +++ b/src/newgrf_airport.cpp @@ -175,7 +175,7 @@ void AirportOverrideManager::SetEntitySpec(AirportSpec *as) { byte airport_id = this->AddEntityID(as->grf_prop.local_id, as->grf_prop.grffile->grfid, as->grf_prop.subst_id); - if (airport_id == this->invalid_ID) { + if (airport_id == this->invalid_id) { grfmsg(1, "Airport.SetEntitySpec: Too many airports allocated. Ignoring."); return; } @@ -190,7 +190,7 @@ void AirportOverrideManager::SetEntitySpec(AirportSpec *as) overridden_as->grf_prop.override = airport_id; overridden_as->enabled = false; - this->entity_overrides[i] = this->invalid_ID; + this->entity_overrides[i] = this->invalid_id; this->grfid_overrides[i] = 0; } } diff --git a/src/newgrf_airporttiles.cpp b/src/newgrf_airporttiles.cpp index e6aa049112..91ae79f2d8 100644 --- a/src/newgrf_airporttiles.cpp +++ b/src/newgrf_airporttiles.cpp @@ -67,7 +67,7 @@ void AirportTileOverrideManager::SetEntitySpec(const AirportTileSpec *airpts) { StationGfx airpt_id = this->AddEntityID(airpts->grf_prop.local_id, airpts->grf_prop.grffile->grfid, airpts->grf_prop.subst_id); - if (airpt_id == this->invalid_ID) { + if (airpt_id == this->invalid_id) { grfmsg(1, "AirportTile.SetEntitySpec: Too many airport tiles allocated. Ignoring."); return; } @@ -82,7 +82,7 @@ void AirportTileOverrideManager::SetEntitySpec(const AirportTileSpec *airpts) overridden_airpts->grf_prop.override = airpt_id; overridden_airpts->enabled = false; - this->entity_overrides[i] = this->invalid_ID; + this->entity_overrides[i] = this->invalid_id; this->grfid_overrides[i] = 0; } } diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp index 907e7093c4..eb8d3f8c40 100644 --- a/src/newgrf_commons.cpp +++ b/src/newgrf_commons.cpp @@ -41,12 +41,12 @@ OverrideManagerBase::OverrideManagerBase(uint16 offset, uint16 maximum, uint16 invalid) { this->max_offset = offset; - this->max_new_entities = maximum; - this->invalid_ID = invalid; + this->max_entities = maximum; + this->invalid_id = invalid; - this->mapping_ID.resize(this->max_new_entities); + this->mappings.resize(this->max_entities); this->entity_overrides.resize(this->max_offset); - std::fill(this->entity_overrides.begin(), this->entity_overrides.end(), this->invalid_ID); + std::fill(this->entity_overrides.begin(), this->entity_overrides.end(), this->invalid_id); this->grfid_overrides.resize(this->max_offset); } @@ -62,7 +62,7 @@ void OverrideManagerBase::Add(uint8 local_id, uint32 grfid, uint entity_type) { assert(entity_type < this->max_offset); /* An override can be set only once */ - if (this->entity_overrides[entity_type] != this->invalid_ID) return; + if (this->entity_overrides[entity_type] != this->invalid_id) return; this->entity_overrides[entity_type] = local_id; this->grfid_overrides[entity_type] = grfid; } @@ -70,13 +70,13 @@ void OverrideManagerBase::Add(uint8 local_id, uint32 grfid, uint entity_type) /** Resets the mapping, which is used while initializing game */ void OverrideManagerBase::ResetMapping() { - std::fill(this->mapping_ID.begin(), this->mapping_ID.end(), EntityIDMapping{}); + std::fill(this->mappings.begin(), this->mappings.end(), EntityIDMapping{}); } /** Resets the override, which is used while initializing game */ void OverrideManagerBase::ResetOverride() { - std::fill(this->entity_overrides.begin(), this->entity_overrides.end(), this->invalid_ID); + std::fill(this->entity_overrides.begin(), this->entity_overrides.end(), this->invalid_id); std::fill(this->grfid_overrides.begin(), this->grfid_overrides.end(), uint32()); } @@ -88,14 +88,14 @@ void OverrideManagerBase::ResetOverride() */ uint16 OverrideManagerBase::GetID(uint8 grf_local_id, uint32 grfid) const { - for (uint16 id = 0; id < this->max_new_entities; id++) { - const EntityIDMapping *map = &this->mapping_ID[id]; + for (uint16 id = 0; id < this->max_entities; id++) { + const EntityIDMapping *map = &this->mappings[id]; if (map->entity_id == grf_local_id && map->grfid == grfid) { return id; } } - return this->invalid_ID; + return this->invalid_id; } /** @@ -113,11 +113,11 @@ uint16 OverrideManagerBase::AddEntityID(byte grf_local_id, uint32 grfid, byte su * separately from the loop below in case a GRF has been deleted, and there * are any gaps in the array. */ - if (id != this->invalid_ID) return id; + if (id != this->invalid_id) return id; /* This entity hasn't been defined before, so give it an ID now. */ - for (id = this->max_offset; id < this->max_new_entities; id++) { - EntityIDMapping *map = &this->mapping_ID[id]; + for (id = this->max_offset; id < this->max_entities; id++) { + EntityIDMapping *map = &this->mappings[id]; if (CheckValidNewID(id) && map->entity_id == 0 && map->grfid == 0) { map->entity_id = grf_local_id; @@ -127,7 +127,7 @@ uint16 OverrideManagerBase::AddEntityID(byte grf_local_id, uint32 grfid, byte su } } - return this->invalid_ID; + return this->invalid_id; } /** @@ -137,7 +137,7 @@ uint16 OverrideManagerBase::AddEntityID(byte grf_local_id, uint32 grfid, byte su */ uint32 OverrideManagerBase::GetGRFID(uint16 entity_id) const { - return this->mapping_ID[entity_id].grfid; + return this->mappings[entity_id].grfid; } /** @@ -147,7 +147,7 @@ uint32 OverrideManagerBase::GetGRFID(uint16 entity_id) const */ uint16 OverrideManagerBase::GetSubstituteID(uint16 entity_id) const { - return this->mapping_ID[entity_id].substitute_id; + return this->mappings[entity_id].substitute_id; } /** @@ -159,7 +159,7 @@ void HouseOverrideManager::SetEntitySpec(const HouseSpec *hs) { HouseID house_id = this->AddEntityID(hs->grf_prop.local_id, hs->grf_prop.grffile->grfid, hs->grf_prop.subst_id); - if (house_id == this->invalid_ID) { + if (house_id == this->invalid_id) { grfmsg(1, "House.SetEntitySpec: Too many houses allocated. Ignoring."); return; } @@ -173,7 +173,7 @@ void HouseOverrideManager::SetEntitySpec(const HouseSpec *hs) if (this->entity_overrides[i] != hs->grf_prop.local_id || this->grfid_overrides[i] != hs->grf_prop.grffile->grfid) continue; overridden_hs->grf_prop.override = house_id; - this->entity_overrides[i] = this->invalid_ID; + this->entity_overrides[i] = this->invalid_id; this->grfid_overrides[i] = 0; } } @@ -187,14 +187,14 @@ void HouseOverrideManager::SetEntitySpec(const HouseSpec *hs) uint16 IndustryOverrideManager::GetID(uint8 grf_local_id, uint32 grfid) const { uint16 id = OverrideManagerBase::GetID(grf_local_id, grfid); - if (id != this->invalid_ID) return id; + if (id != this->invalid_id) return id; /* No mapping found, try the overrides */ for (id = 0; id < this->max_offset; id++) { if (this->entity_overrides[id] == grf_local_id && this->grfid_overrides[id] == grfid) return id; } - return this->invalid_ID; + return this->invalid_id; } /** @@ -207,9 +207,9 @@ uint16 IndustryOverrideManager::GetID(uint8 grf_local_id, uint32 grfid) const uint16 IndustryOverrideManager::AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id) { /* This entity hasn't been defined before, so give it an ID now. */ - for (uint16 id = 0; id < this->max_new_entities; id++) { + for (uint16 id = 0; id < this->max_entities; id++) { /* Skip overridden industries */ - if (id < this->max_offset && this->entity_overrides[id] != this->invalid_ID) continue; + if (id < this->max_offset && this->entity_overrides[id] != this->invalid_id) continue; /* Get the real live industry */ const IndustrySpec *inds = GetIndustrySpec(id); @@ -218,7 +218,7 @@ uint16 IndustryOverrideManager::AddEntityID(byte grf_local_id, uint32 grfid, byt * And it must not already be used by a grf (grffile == nullptr). * So reserve this slot here, as it is the chosen one */ if (!inds->enabled && inds->grf_prop.grffile == nullptr) { - EntityIDMapping *map = &this->mapping_ID[id]; + EntityIDMapping *map = &this->mappings[id]; if (map->entity_id == 0 && map->grfid == 0) { /* winning slot, mark it as been used */ @@ -230,7 +230,7 @@ uint16 IndustryOverrideManager::AddEntityID(byte grf_local_id, uint32 grfid, byt } } - return this->invalid_ID; + return this->invalid_id; } /** @@ -244,16 +244,16 @@ void IndustryOverrideManager::SetEntitySpec(IndustrySpec *inds) /* First step : We need to find if this industry is already specified in the savegame data. */ IndustryType ind_id = this->GetID(inds->grf_prop.local_id, inds->grf_prop.grffile->grfid); - if (ind_id == this->invalid_ID) { + if (ind_id == this->invalid_id) { /* Not found. * Or it has already been overridden, so you've lost your place. * Or it is a simple substitute. * We need to find a free available slot */ ind_id = this->AddEntityID(inds->grf_prop.local_id, inds->grf_prop.grffile->grfid, inds->grf_prop.subst_id); - inds->grf_prop.override = this->invalid_ID; // make sure it will not be detected as overridden + inds->grf_prop.override = this->invalid_id; // make sure it will not be detected as overridden } - if (ind_id == this->invalid_ID) { + if (ind_id == this->invalid_id) { grfmsg(1, "Industry.SetEntitySpec: Too many industries allocated. Ignoring."); return; } @@ -268,7 +268,7 @@ void IndustryTileOverrideManager::SetEntitySpec(const IndustryTileSpec *its) { IndustryGfx indt_id = this->AddEntityID(its->grf_prop.local_id, its->grf_prop.grffile->grfid, its->grf_prop.subst_id); - if (indt_id == this->invalid_ID) { + if (indt_id == this->invalid_id) { grfmsg(1, "IndustryTile.SetEntitySpec: Too many industry tiles allocated. Ignoring."); return; } @@ -283,7 +283,7 @@ void IndustryTileOverrideManager::SetEntitySpec(const IndustryTileSpec *its) overridden_its->grf_prop.override = indt_id; overridden_its->enabled = false; - this->entity_overrides[i] = this->invalid_ID; + this->entity_overrides[i] = this->invalid_id; this->grfid_overrides[i] = 0; } } @@ -299,7 +299,7 @@ void ObjectOverrideManager::SetEntitySpec(ObjectSpec *spec) /* First step : We need to find if this object is already specified in the savegame data. */ ObjectType type = this->GetID(spec->grf_prop.local_id, spec->grf_prop.grffile->grfid); - if (type == this->invalid_ID) { + if (type == this->invalid_id) { /* Not found. * Or it has already been overridden, so you've lost your place. * Or it is a simple substitute. @@ -307,7 +307,7 @@ void ObjectOverrideManager::SetEntitySpec(ObjectSpec *spec) type = this->AddEntityID(spec->grf_prop.local_id, spec->grf_prop.grffile->grfid, OBJECT_TRANSMITTER); } - if (type == this->invalid_ID) { + if (type == this->invalid_id) { grfmsg(1, "Object.SetEntitySpec: Too many objects allocated. Ignoring."); return; } diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h index 3fdff6c78a..bf338c2da5 100644 --- a/src/newgrf_commons.h +++ b/src/newgrf_commons.h @@ -194,14 +194,14 @@ protected: std::vector entity_overrides; std::vector grfid_overrides; - uint16 max_offset; ///< what is the length of the original entity's array of specs - uint16 max_new_entities; ///< what is the amount of entities, old and new summed + uint16 max_offset; ///< what is the length of the original entity's array of specs + uint16 max_entities; ///< what is the amount of entities, old and new summed - uint16 invalid_ID; ///< ID used to detected invalid entities; + uint16 invalid_id; ///< ID used to detected invalid entities; virtual bool CheckValidNewID(uint16 testid) { return true; } public: - std::vector mapping_ID; ///< mapping of ids from grf files. Public out of convenience + std::vector mappings; ///< mapping of ids from grf files. Public out of convenience OverrideManagerBase(uint16 offset, uint16 maximum, uint16 invalid); virtual ~OverrideManagerBase() {} @@ -216,7 +216,7 @@ public: uint16 GetSubstituteID(uint16 entity_id) const; virtual uint16 GetID(uint8 grf_local_id, uint32 grfid) const; - inline uint16 GetMaxMapping() const { return this->max_new_entities; } + inline uint16 GetMaxMapping() const { return this->max_entities; } inline uint16 GetMaxOffset() const { return this->max_offset; } }; diff --git a/src/saveload/newgrf_sl.cpp b/src/saveload/newgrf_sl.cpp index 5dde97132c..d15057564a 100644 --- a/src/saveload/newgrf_sl.cpp +++ b/src/saveload/newgrf_sl.cpp @@ -32,10 +32,10 @@ void NewGRFMappingChunkHandler::Save() const SlTableHeader(_newgrf_mapping_desc); for (uint i = 0; i < this->mapping.GetMaxMapping(); i++) { - if (this->mapping.mapping_ID[i].grfid == 0 && - this->mapping.mapping_ID[i].entity_id == 0) continue; + if (this->mapping.mappings[i].grfid == 0 && + this->mapping.mappings[i].entity_id == 0) continue; SlSetArrayIndex(i); - SlObject(&this->mapping.mapping_ID[i], _newgrf_mapping_desc); + SlObject(&this->mapping.mappings[i], _newgrf_mapping_desc); } } @@ -55,7 +55,7 @@ void NewGRFMappingChunkHandler::Load() const int index; while ((index = SlIterateArray()) != -1) { if ((uint)index >= max_id) SlErrorCorrupt("Too many NewGRF entity mappings"); - SlObject(&this->mapping.mapping_ID[index], slt); + SlObject(&this->mapping.mappings[index], slt); } } From 46dc6da270c09f289051eb4b26ce92fd1584e259 Mon Sep 17 00:00:00 2001 From: SamuXarick <43006711+SamuXarick@users.noreply.github.com> Date: Thu, 26 Jan 2023 20:57:25 +0000 Subject: [PATCH 11/12] Codechange: Make void tiles flood edge tiles, instead of edge tiles flooding themselves (#8517) --- src/clear_cmd.cpp | 10 ---------- src/void_cmd.cpp | 4 +++- src/water_cmd.cpp | 7 +++++-- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index 30edb95069..8e87f42f49 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -13,7 +13,6 @@ #include "landscape.h" #include "genworld.h" #include "viewport_func.h" -#include "water.h" #include "core/random_func.hpp" #include "newgrf_generic.h" #include "landscape_cmd.h" @@ -248,15 +247,6 @@ static void TileLoopClearDesert(TileIndex tile) static void TileLoop_Clear(TileIndex tile) { - /* If the tile is at any edge flood it to prevent maps without water. */ - if (_settings_game.construction.freeform_edges && DistanceFromEdge(tile) == 1) { - int z; - if (IsTileFlat(tile, &z) && z == 0) { - DoFloodTile(tile); - MarkTileDirtyByTile(tile); - return; - } - } AmbientSoundEffect(tile); switch (_settings_game.game_creation.landscape) { diff --git a/src/void_cmd.cpp b/src/void_cmd.cpp index cf159d69cc..f5716e3f8d 100644 --- a/src/void_cmd.cpp +++ b/src/void_cmd.cpp @@ -12,6 +12,7 @@ #include "command_func.h" #include "viewport_func.h" #include "slope_func.h" +#include "water.h" #include "table/strings.h" #include "table/sprites.h" @@ -53,7 +54,8 @@ static void GetTileDesc_Void(TileIndex tile, TileDesc *td) static void TileLoop_Void(TileIndex tile) { - /* not used */ + /* Floods adjacent edge tile to prevent maps without water. */ + TileLoop_Water(tile); } static void ChangeTileOwner_Void(TileIndex tile, Owner old_owner, Owner new_owner) diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index e34c3c103c..85d9fa6f7b 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -1089,6 +1089,9 @@ FloodingBehaviour GetFloodingBehaviour(TileIndex tile) case MP_TREES: return (GetTreeGround(tile) == TREE_GROUND_SHORE ? FLOOD_DRYUP : FLOOD_NONE); + case MP_VOID: + return FLOOD_ACTIVE; + default: return FLOOD_NONE; } @@ -1240,7 +1243,7 @@ void TileLoop_Water(TileIndex tile) Slope slope_here = GetFoundationSlope(tile) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP; for (uint dir : SetBitIterator(_flood_from_dirs[slope_here])) { TileIndex dest = tile + TileOffsByDir((Direction)dir); - if (!IsValidTile(dest)) continue; + if (dest >= Map::Size()) continue; FloodingBehaviour dest_behaviour = GetFloodingBehaviour(dest); if ((dest_behaviour == FLOOD_ACTIVE) || (dest_behaviour == FLOOD_PASSIVE)) return; @@ -1279,7 +1282,7 @@ void ConvertGroundTilesIntoWaterTiles() for (uint dir : SetBitIterator(_flood_from_dirs[slope & ~SLOPE_STEEP])) { TileIndex dest = TileAddByDir(tile, (Direction)dir); Slope slope_dest = GetTileSlope(dest) & ~SLOPE_STEEP; - if (slope_dest == SLOPE_FLAT || IsSlopeWithOneCornerRaised(slope_dest)) { + if (slope_dest == SLOPE_FLAT || IsSlopeWithOneCornerRaised(slope_dest) || IsTileType(dest, MP_VOID)) { MakeShore(tile); break; } From 0b2567d882827f3a2c8b9e927c4d7f354e498a58 Mon Sep 17 00:00:00 2001 From: Henry Wilson Date: Wed, 16 Nov 2022 22:28:22 +0000 Subject: [PATCH 12/12] Codechange: Remove shift as fast-forward key when _DEBUG is defined --- src/video/allegro_v.cpp | 4 ---- src/video/cocoa/cocoa_v.mm | 4 ---- src/video/sdl2_v.cpp | 4 ---- src/video/sdl_v.cpp | 4 ---- src/video/win32_v.cpp | 4 ---- 5 files changed, 20 deletions(-) diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp index 07a1271f1a..84c55492fb 100644 --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -467,13 +467,9 @@ void VideoDriver_Allegro::InputLoop() _ctrl_pressed = !!(key_shifts & KB_CTRL_FLAG); _shift_pressed = !!(key_shifts & KB_SHIFT_FLAG); -#if defined(_DEBUG) - this->fast_forward_key_pressed = _shift_pressed; -#else /* Speedup when pressing tab, except when using ALT+TAB * to switch to another application. */ this->fast_forward_key_pressed = key[KEY_TAB] && (key_shifts & KB_ALT_FLAG) == 0; -#endif /* Determine which directional keys are down. */ _dirkeys = diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm index 0636f2cc0f..ca8df18311 100644 --- a/src/video/cocoa/cocoa_v.mm +++ b/src/video/cocoa/cocoa_v.mm @@ -484,11 +484,7 @@ void VideoDriver_Cocoa::InputLoop() _ctrl_pressed = (cur_mods & ( _settings_client.gui.right_mouse_btn_emulation != RMBE_CONTROL ? NSEventModifierFlagControl : NSEventModifierFlagCommand)) != 0; _shift_pressed = (cur_mods & NSEventModifierFlagShift) != 0; -#if defined(_DEBUG) - this->fast_forward_key_pressed = _shift_pressed; -#else this->fast_forward_key_pressed = _tab_is_down; -#endif if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); } diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index 51c490d231..6f6cb51561 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -577,13 +577,9 @@ void VideoDriver_SDL_Base::InputLoop() _ctrl_pressed = !!(mod & KMOD_CTRL); _shift_pressed = !!(mod & KMOD_SHIFT); -#if defined(_DEBUG) - this->fast_forward_key_pressed = _shift_pressed; -#else /* Speedup when pressing tab, except when using ALT+TAB * to switch to another application. */ this->fast_forward_key_pressed = keys[SDL_SCANCODE_TAB] && (mod & KMOD_ALT) == 0; -#endif /* defined(_DEBUG) */ /* Determine which directional keys are down. */ _dirkeys = diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index 1b180d3b8b..667b738145 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -624,13 +624,9 @@ void VideoDriver_SDL::InputLoop() _ctrl_pressed = !!(mod & KMOD_CTRL); _shift_pressed = !!(mod & KMOD_SHIFT); -#if defined(_DEBUG) - this->fast_forward_key_pressed = _shift_pressed; -#else /* Speedup when pressing tab, except when using ALT+TAB * to switch to another application. */ this->fast_forward_key_pressed = keys[SDLK_TAB] && (mod & KMOD_ALT) == 0; -#endif /* defined(_DEBUG) */ /* Determine which directional keys are down. */ _dirkeys = diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 8d8a78a0ca..07743255c6 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -844,13 +844,9 @@ void VideoDriver_Win32Base::InputLoop() _ctrl_pressed = this->has_focus && GetAsyncKeyState(VK_CONTROL) < 0; _shift_pressed = this->has_focus && GetAsyncKeyState(VK_SHIFT) < 0; -#if defined(_DEBUG) - this->fast_forward_key_pressed = _shift_pressed; -#else /* Speedup when pressing tab, except when using ALT+TAB * to switch to another application. */ this->fast_forward_key_pressed = this->has_focus && GetAsyncKeyState(VK_TAB) < 0 && GetAsyncKeyState(VK_MENU) >= 0; -#endif /* Determine which directional keys are down. */ if (this->has_focus) {