diff --git a/src/ai/api/ai_bridge.cpp b/src/ai/api/ai_bridge.cpp index 56fe7061b2..e67794e2a4 100644 --- a/src/ai/api/ai_bridge.cpp +++ b/src/ai/api/ai_bridge.cpp @@ -120,7 +120,7 @@ static void _DoCommandReturnBuildBridge1(class AIInstance *instance) return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR); } -/* static */ const char *AIBridge::GetName(BridgeID bridge_id) +/* static */ char *AIBridge::GetName(BridgeID bridge_id) { if (!IsValidBridge(bridge_id)) return NULL; diff --git a/src/ai/api/ai_bridge.hpp b/src/ai/api/ai_bridge.hpp index 7bd6372771..819242e79b 100644 --- a/src/ai/api/ai_bridge.hpp +++ b/src/ai/api/ai_bridge.hpp @@ -57,7 +57,7 @@ public: * @pre IsValidBridge(bridge_id). * @return The name the bridge has. */ - static const char *GetName(BridgeID bridge_id); + static char *GetName(BridgeID bridge_id); /** * Get the maximum speed of a bridge (in km/h). diff --git a/src/ai/api/ai_cargo.cpp b/src/ai/api/ai_cargo.cpp index 6843f7134e..dccf2af6ec 100644 --- a/src/ai/api/ai_cargo.cpp +++ b/src/ai/api/ai_cargo.cpp @@ -15,7 +15,7 @@ return (cargo_type < NUM_CARGO && ::GetCargo(cargo_type)->IsValid()); } -/* static */ const char *AICargo::GetCargoLabel(CargoID cargo_type) +/* static */ char *AICargo::GetCargoLabel(CargoID cargo_type) { if (!IsValidCargo(cargo_type)) return NULL; const CargoSpec *cargo = ::GetCargo(cargo_type); diff --git a/src/ai/api/ai_cargo.hpp b/src/ai/api/ai_cargo.hpp index bde235758d..c8f8a04dd9 100644 --- a/src/ai/api/ai_cargo.hpp +++ b/src/ai/api/ai_cargo.hpp @@ -56,7 +56,7 @@ public: * @note Never use this to check if it is a certain cargo. NewGRF can * redefine all of the names. */ - static const char *GetCargoLabel(CargoID cargo_type); + static char *GetCargoLabel(CargoID cargo_type); /** * Checks whether the give cargo is a freight or not. diff --git a/src/ai/api/ai_company.cpp b/src/ai/api/ai_company.cpp index 4040ab9c10..439215a7e6 100644 --- a/src/ai/api/ai_company.cpp +++ b/src/ai/api/ai_company.cpp @@ -43,13 +43,13 @@ return AIObject::DoCommand(0, 0, 0, CMD_RENAME_COMPANY, name); } -/* static */ const char *AICompany::GetCompanyName(AICompany::CompanyID company) +/* static */ char *AICompany::GetCompanyName(AICompany::CompanyID company) { AILog::Error("AICompany::GetCompanyName is obsolete. Use AICompany::GetName instead."); return AICompany::GetName(company); } -/* static */ const char *AICompany::GetName(AICompany::CompanyID company) +/* static */ char *AICompany::GetName(AICompany::CompanyID company) { company = ResolveCompanyID(company); if (company == COMPANY_INVALID) return NULL; @@ -69,7 +69,7 @@ return AIObject::DoCommand(0, 0, 0, CMD_RENAME_PRESIDENT, name); } -/* static */ const char *AICompany::GetPresidentName(AICompany::CompanyID company) +/* static */ char *AICompany::GetPresidentName(AICompany::CompanyID company) { company = ResolveCompanyID(company); diff --git a/src/ai/api/ai_company.hpp b/src/ai/api/ai_company.hpp index bc08e96304..9a3e324eab 100644 --- a/src/ai/api/ai_company.hpp +++ b/src/ai/api/ai_company.hpp @@ -61,7 +61,7 @@ public: /** * Obsolete, use AICompany::GetName instead. */ - static const char *GetCompanyName(CompanyID company); + static char *GetCompanyName(CompanyID company); /** * Get the name of the given company. @@ -69,7 +69,7 @@ public: * @pre ResolveCompanyID(company) != COMPANY_INVALID * @return The name of the given company. */ - static const char *GetName(CompanyID company); + static char *GetName(CompanyID company); /** * Set the name of your president. @@ -86,7 +86,7 @@ public: * @pre ResolveCompanyID(company) != COMPANY_INVALID * @return The name of the president of the given company. */ - static const char *GetPresidentName(CompanyID company); + static char *GetPresidentName(CompanyID company); /** * Sets the amount to loan. diff --git a/src/ai/api/ai_engine.cpp b/src/ai/api/ai_engine.cpp index 443f034827..06ed3d7287 100644 --- a/src/ai/api/ai_engine.cpp +++ b/src/ai/api/ai_engine.cpp @@ -25,7 +25,7 @@ return ::IsEngineIndex(engine_id) && HasBit(::GetEngine(engine_id)->company_avail, _current_company); } -/* static */ const char *AIEngine::GetName(EngineID engine_id) +/* static */ char *AIEngine::GetName(EngineID engine_id) { if (!IsValidEngine(engine_id)) return NULL; diff --git a/src/ai/api/ai_engine.hpp b/src/ai/api/ai_engine.hpp index 1dfe76e088..7e49558a19 100644 --- a/src/ai/api/ai_engine.hpp +++ b/src/ai/api/ai_engine.hpp @@ -31,7 +31,7 @@ public: * @pre IsValidEngine(engine_id). * @return The name the engine has. */ - static const char *GetName(EngineID engine_id); + static char *GetName(EngineID engine_id); /** * Get the cargo-type of an engine. In case it can transport 2 cargos, it diff --git a/src/ai/api/ai_error.cpp b/src/ai/api/ai_error.cpp index 4c21db726c..e060532d42 100644 --- a/src/ai/api/ai_error.cpp +++ b/src/ai/api/ai_error.cpp @@ -14,9 +14,9 @@ AIError::AIErrorMapString AIError::error_map_string = AIError::AIErrorMapString( return AIObject::GetLastError(); } -/* static */ const char *AIError::GetLastErrorString() +/* static */ char *AIError::GetLastErrorString() { - return (*error_map_string.find(AIError::GetLastError())).second; + return strdup((*error_map_string.find(AIError::GetLastError())).second); } /* static */ AIErrorType AIError::StringToError(StringID internal_string_id) diff --git a/src/ai/api/ai_error.hpp b/src/ai/api/ai_error.hpp index 6a448ff3a8..b9fd572bb7 100644 --- a/src/ai/api/ai_error.hpp +++ b/src/ai/api/ai_error.hpp @@ -134,7 +134,7 @@ public: * Get the last error in string format (for human readability). * @return An ErrorMessage enum item, as string. */ - static const char *GetLastErrorString(); + static char *GetLastErrorString(); /** * Get the error based on the OpenTTD StringID. diff --git a/src/ai/api/ai_event_types.cpp b/src/ai/api/ai_event_types.cpp index b865ca59df..09d801e70f 100644 --- a/src/ai/api/ai_event_types.cpp +++ b/src/ai/api/ai_event_types.cpp @@ -19,7 +19,7 @@ bool AIEventVehicleCrashed::CloneCrashedVehicle(TileIndex depot) return false; } -const char *AIEventEnginePreview::GetName() +char *AIEventEnginePreview::GetName() { static const int len = 64; char *engine_name = MallocT(len); diff --git a/src/ai/api/ai_event_types.hpp b/src/ai/api/ai_event_types.hpp index 9c0e8a3964..6fbf5be3f4 100644 --- a/src/ai/api/ai_event_types.hpp +++ b/src/ai/api/ai_event_types.hpp @@ -254,7 +254,7 @@ public: * Get the name of the offered engine. * @return The name the engine has. */ - const char *GetName(); + char *GetName(); /** * Get the cargo-type of the offered engine. In case it can transport 2 cargos, it diff --git a/src/ai/api/ai_group.cpp b/src/ai/api/ai_group.cpp index 5dc6763038..ea3af7d8c4 100644 --- a/src/ai/api/ai_group.cpp +++ b/src/ai/api/ai_group.cpp @@ -52,7 +52,7 @@ return AIObject::DoCommand(0, group_id, 0, CMD_RENAME_GROUP, name); } -/* static */ const char *AIGroup::GetName(GroupID group_id) +/* static */ char *AIGroup::GetName(GroupID group_id) { if (!IsValidGroup(group_id)) return NULL; diff --git a/src/ai/api/ai_group.hpp b/src/ai/api/ai_group.hpp index 51a4c47aa5..85202d2f0b 100644 --- a/src/ai/api/ai_group.hpp +++ b/src/ai/api/ai_group.hpp @@ -77,7 +77,7 @@ public: * @pre IsValidGroup(group_id). * @return The name the group has. */ - static const char *GetName(GroupID group_id); + static char *GetName(GroupID group_id); /** * Enable or disable autoreplace protected. If the protection is diff --git a/src/ai/api/ai_industry.cpp b/src/ai/api/ai_industry.cpp index 068a928651..772df722e1 100644 --- a/src/ai/api/ai_industry.cpp +++ b/src/ai/api/ai_industry.cpp @@ -27,7 +27,7 @@ return ::IsValidIndustryID(industry_id); } -/* static */ const char *AIIndustry::GetName(IndustryID industry_id) +/* static */ char *AIIndustry::GetName(IndustryID industry_id) { if (!IsValidIndustry(industry_id)) return NULL; static const int len = 64; diff --git a/src/ai/api/ai_industry.hpp b/src/ai/api/ai_industry.hpp index 1b3365a97b..ed44cada52 100644 --- a/src/ai/api/ai_industry.hpp +++ b/src/ai/api/ai_industry.hpp @@ -43,7 +43,7 @@ public: * @pre IsValidIndustry(industry_id). * @return The name of the industry. */ - static const char *GetName(IndustryID industry_id); + static char *GetName(IndustryID industry_id); /** * Gets the production of a cargo of the industry. diff --git a/src/ai/api/ai_industrytype.cpp b/src/ai/api/ai_industrytype.cpp index 34d69f5f82..18ea41de5d 100644 --- a/src/ai/api/ai_industrytype.cpp +++ b/src/ai/api/ai_industrytype.cpp @@ -40,7 +40,7 @@ return ::GetIndustrySpec(industry_type)->GetConstructionCost(); } -/* static */ const char *AIIndustryType::GetName(IndustryType industry_type) +/* static */ char *AIIndustryType::GetName(IndustryType industry_type) { if (!IsValidIndustryType(industry_type)) return NULL; static const int len = 64; diff --git a/src/ai/api/ai_industrytype.hpp b/src/ai/api/ai_industrytype.hpp index 88ba6d730e..2e38166b36 100644 --- a/src/ai/api/ai_industrytype.hpp +++ b/src/ai/api/ai_industrytype.hpp @@ -29,7 +29,7 @@ public: * @pre IsValidIndustryType(industry_type). * @return The name of an industry. */ - static const char *GetName(IndustryType industry_type); + static char *GetName(IndustryType industry_type); /** * Get a list of CargoID possible produced by this industry-type. diff --git a/src/ai/api/ai_sign.cpp b/src/ai/api/ai_sign.cpp index 561b5c8575..4683e2d322 100644 --- a/src/ai/api/ai_sign.cpp +++ b/src/ai/api/ai_sign.cpp @@ -33,7 +33,7 @@ return AIObject::DoCommand(0, sign_id, 0, CMD_RENAME_SIGN, name); } -/* static */ const char *AISign::GetName(SignID sign_id) +/* static */ char *AISign::GetName(SignID sign_id) { if (!IsValidSign(sign_id)) return NULL; diff --git a/src/ai/api/ai_sign.hpp b/src/ai/api/ai_sign.hpp index 8bf7e0b79d..441b9b3493 100644 --- a/src/ai/api/ai_sign.hpp +++ b/src/ai/api/ai_sign.hpp @@ -60,7 +60,7 @@ public: * @pre IsValidSign(sign_id). * @return The name of the sign. */ - static const char *GetName(SignID sign_id); + static char *GetName(SignID sign_id); /** * Gets the location of the sign. diff --git a/src/ai/api/ai_station.cpp b/src/ai/api/ai_station.cpp index aaaedd972e..4086b56a20 100644 --- a/src/ai/api/ai_station.cpp +++ b/src/ai/api/ai_station.cpp @@ -30,7 +30,7 @@ return ::GetStationIndex(tile); } -/* static */ const char *AIStation::GetName(StationID station_id) +/* static */ char *AIStation::GetName(StationID station_id) { if (!IsValidStation(station_id)) return NULL; diff --git a/src/ai/api/ai_station.hpp b/src/ai/api/ai_station.hpp index 6e263c9126..5a25f16ed8 100644 --- a/src/ai/api/ai_station.hpp +++ b/src/ai/api/ai_station.hpp @@ -70,7 +70,7 @@ public: * @pre IsValidStation(station_id). * @return The name of the station. */ - static const char *GetName(StationID station_id); + static char *GetName(StationID station_id); /** * Set the name this station. diff --git a/src/ai/api/ai_town.cpp b/src/ai/api/ai_town.cpp index 921e5a73e7..bb7dee9f29 100644 --- a/src/ai/api/ai_town.cpp +++ b/src/ai/api/ai_town.cpp @@ -30,7 +30,7 @@ return ::IsValidTownID(town_id); } -/* static */ const char *AITown::GetName(TownID town_id) +/* static */ char *AITown::GetName(TownID town_id) { if (!IsValidTown(town_id)) return NULL; static const int len = 64; diff --git a/src/ai/api/ai_town.hpp b/src/ai/api/ai_town.hpp index f9152106fe..a4516f94b7 100644 --- a/src/ai/api/ai_town.hpp +++ b/src/ai/api/ai_town.hpp @@ -112,7 +112,7 @@ public: * @pre IsValidTown(town_id). * @return The name of the town. */ - static const char *GetName(TownID town_id); + static char *GetName(TownID town_id); /** * Gets the number of inhabitants in the town. diff --git a/src/ai/api/ai_vehicle.cpp b/src/ai/api/ai_vehicle.cpp index 7427025af0..ec5d42f655 100644 --- a/src/ai/api/ai_vehicle.cpp +++ b/src/ai/api/ai_vehicle.cpp @@ -227,7 +227,7 @@ return ::GetVehicle(vehicle_id)->unitnumber; } -/* static */ const char *AIVehicle::GetName(VehicleID vehicle_id) +/* static */ char *AIVehicle::GetName(VehicleID vehicle_id) { if (!IsValidVehicle(vehicle_id)) return NULL; diff --git a/src/ai/api/ai_vehicle.hpp b/src/ai/api/ai_vehicle.hpp index 1336e9efea..f0be433da9 100644 --- a/src/ai/api/ai_vehicle.hpp +++ b/src/ai/api/ai_vehicle.hpp @@ -126,7 +126,7 @@ public: * @pre IsValidVehicle(vehicle_id). * @return The name the vehicle has. */ - static const char *GetName(VehicleID vehicle_id); + static char *GetName(VehicleID vehicle_id); /** * Get the current location of a vehicle.