From 2fd99467eac301390b8c0fa0f8eb1dbedc21e0e6 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Wed, 25 Jan 2023 23:44:58 +0100 Subject: [PATCH] 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.