mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
(svn r15123) -Fix [NoAI]: 'const char *' implies that the return value should not be free'd, which is should .. so make them 'char *'
This commit is contained in:
parent
ef75a7af90
commit
eb0d82ada0
@ -120,7 +120,7 @@ static void _DoCommandReturnBuildBridge1(class AIInstance *instance)
|
|||||||
return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
|
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;
|
if (!IsValidBridge(bridge_id)) return NULL;
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public:
|
|||||||
* @pre IsValidBridge(bridge_id).
|
* @pre IsValidBridge(bridge_id).
|
||||||
* @return The name the bridge has.
|
* @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).
|
* Get the maximum speed of a bridge (in km/h).
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
return (cargo_type < NUM_CARGO && ::GetCargo(cargo_type)->IsValid());
|
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;
|
if (!IsValidCargo(cargo_type)) return NULL;
|
||||||
const CargoSpec *cargo = ::GetCargo(cargo_type);
|
const CargoSpec *cargo = ::GetCargo(cargo_type);
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
* @note Never use this to check if it is a certain cargo. NewGRF can
|
* @note Never use this to check if it is a certain cargo. NewGRF can
|
||||||
* redefine all of the names.
|
* 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.
|
* Checks whether the give cargo is a freight or not.
|
||||||
|
@ -43,13 +43,13 @@
|
|||||||
return AIObject::DoCommand(0, 0, 0, CMD_RENAME_COMPANY, name);
|
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.");
|
AILog::Error("AICompany::GetCompanyName is obsolete. Use AICompany::GetName instead.");
|
||||||
return AICompany::GetName(company);
|
return AICompany::GetName(company);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ const char *AICompany::GetName(AICompany::CompanyID company)
|
/* static */ char *AICompany::GetName(AICompany::CompanyID company)
|
||||||
{
|
{
|
||||||
company = ResolveCompanyID(company);
|
company = ResolveCompanyID(company);
|
||||||
if (company == COMPANY_INVALID) return NULL;
|
if (company == COMPANY_INVALID) return NULL;
|
||||||
@ -69,7 +69,7 @@
|
|||||||
return AIObject::DoCommand(0, 0, 0, CMD_RENAME_PRESIDENT, name);
|
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);
|
company = ResolveCompanyID(company);
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Obsolete, use AICompany::GetName instead.
|
* Obsolete, use AICompany::GetName instead.
|
||||||
*/
|
*/
|
||||||
static const char *GetCompanyName(CompanyID company);
|
static char *GetCompanyName(CompanyID company);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the given company.
|
* Get the name of the given company.
|
||||||
@ -69,7 +69,7 @@ public:
|
|||||||
* @pre ResolveCompanyID(company) != COMPANY_INVALID
|
* @pre ResolveCompanyID(company) != COMPANY_INVALID
|
||||||
* @return The name of the given company.
|
* @return The name of the given company.
|
||||||
*/
|
*/
|
||||||
static const char *GetName(CompanyID company);
|
static char *GetName(CompanyID company);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the name of your president.
|
* Set the name of your president.
|
||||||
@ -86,7 +86,7 @@ public:
|
|||||||
* @pre ResolveCompanyID(company) != COMPANY_INVALID
|
* @pre ResolveCompanyID(company) != COMPANY_INVALID
|
||||||
* @return The name of the president of the given company.
|
* @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.
|
* Sets the amount to loan.
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
return ::IsEngineIndex(engine_id) && HasBit(::GetEngine(engine_id)->company_avail, _current_company);
|
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;
|
if (!IsValidEngine(engine_id)) return NULL;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public:
|
|||||||
* @pre IsValidEngine(engine_id).
|
* @pre IsValidEngine(engine_id).
|
||||||
* @return The name the engine has.
|
* @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
|
* Get the cargo-type of an engine. In case it can transport 2 cargos, it
|
||||||
|
@ -14,9 +14,9 @@ AIError::AIErrorMapString AIError::error_map_string = AIError::AIErrorMapString(
|
|||||||
return AIObject::GetLastError();
|
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)
|
/* static */ AIErrorType AIError::StringToError(StringID internal_string_id)
|
||||||
|
@ -134,7 +134,7 @@ public:
|
|||||||
* Get the last error in string format (for human readability).
|
* Get the last error in string format (for human readability).
|
||||||
* @return An ErrorMessage enum item, as string.
|
* @return An ErrorMessage enum item, as string.
|
||||||
*/
|
*/
|
||||||
static const char *GetLastErrorString();
|
static char *GetLastErrorString();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the error based on the OpenTTD StringID.
|
* Get the error based on the OpenTTD StringID.
|
||||||
|
@ -19,7 +19,7 @@ bool AIEventVehicleCrashed::CloneCrashedVehicle(TileIndex depot)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *AIEventEnginePreview::GetName()
|
char *AIEventEnginePreview::GetName()
|
||||||
{
|
{
|
||||||
static const int len = 64;
|
static const int len = 64;
|
||||||
char *engine_name = MallocT<char>(len);
|
char *engine_name = MallocT<char>(len);
|
||||||
|
@ -254,7 +254,7 @@ public:
|
|||||||
* Get the name of the offered engine.
|
* Get the name of the offered engine.
|
||||||
* @return The name the engine has.
|
* @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
|
* Get the cargo-type of the offered engine. In case it can transport 2 cargos, it
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
return AIObject::DoCommand(0, group_id, 0, CMD_RENAME_GROUP, name);
|
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;
|
if (!IsValidGroup(group_id)) return NULL;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public:
|
|||||||
* @pre IsValidGroup(group_id).
|
* @pre IsValidGroup(group_id).
|
||||||
* @return The name the group has.
|
* @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
|
* Enable or disable autoreplace protected. If the protection is
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
return ::IsValidIndustryID(industry_id);
|
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;
|
if (!IsValidIndustry(industry_id)) return NULL;
|
||||||
static const int len = 64;
|
static const int len = 64;
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
* @pre IsValidIndustry(industry_id).
|
* @pre IsValidIndustry(industry_id).
|
||||||
* @return The name of the industry.
|
* @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.
|
* Gets the production of a cargo of the industry.
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
return ::GetIndustrySpec(industry_type)->GetConstructionCost();
|
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;
|
if (!IsValidIndustryType(industry_type)) return NULL;
|
||||||
static const int len = 64;
|
static const int len = 64;
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
* @pre IsValidIndustryType(industry_type).
|
* @pre IsValidIndustryType(industry_type).
|
||||||
* @return The name of an industry.
|
* @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.
|
* Get a list of CargoID possible produced by this industry-type.
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
return AIObject::DoCommand(0, sign_id, 0, CMD_RENAME_SIGN, name);
|
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;
|
if (!IsValidSign(sign_id)) return NULL;
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
* @pre IsValidSign(sign_id).
|
* @pre IsValidSign(sign_id).
|
||||||
* @return The name of the sign.
|
* @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.
|
* Gets the location of the sign.
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
return ::GetStationIndex(tile);
|
return ::GetStationIndex(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ const char *AIStation::GetName(StationID station_id)
|
/* static */ char *AIStation::GetName(StationID station_id)
|
||||||
{
|
{
|
||||||
if (!IsValidStation(station_id)) return NULL;
|
if (!IsValidStation(station_id)) return NULL;
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ public:
|
|||||||
* @pre IsValidStation(station_id).
|
* @pre IsValidStation(station_id).
|
||||||
* @return The name of the station.
|
* @return The name of the station.
|
||||||
*/
|
*/
|
||||||
static const char *GetName(StationID station_id);
|
static char *GetName(StationID station_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the name this station.
|
* Set the name this station.
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
return ::IsValidTownID(town_id);
|
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;
|
if (!IsValidTown(town_id)) return NULL;
|
||||||
static const int len = 64;
|
static const int len = 64;
|
||||||
|
@ -112,7 +112,7 @@ public:
|
|||||||
* @pre IsValidTown(town_id).
|
* @pre IsValidTown(town_id).
|
||||||
* @return The name of the town.
|
* @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.
|
* Gets the number of inhabitants in the town.
|
||||||
|
@ -227,7 +227,7 @@
|
|||||||
return ::GetVehicle(vehicle_id)->unitnumber;
|
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;
|
if (!IsValidVehicle(vehicle_id)) return NULL;
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ public:
|
|||||||
* @pre IsValidVehicle(vehicle_id).
|
* @pre IsValidVehicle(vehicle_id).
|
||||||
* @return The name the vehicle has.
|
* @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.
|
* Get the current location of a vehicle.
|
||||||
|
Loading…
Reference in New Issue
Block a user