(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:
truebrain 2009-01-17 15:31:30 +00:00
parent ef75a7af90
commit eb0d82ada0
26 changed files with 31 additions and 31 deletions

View File

@ -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;

View File

@ -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).

View File

@ -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);

View File

@ -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.

View File

@ -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);

View File

@ -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.

View File

@ -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;

View File

@ -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

View File

@ -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)

View File

@ -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.

View File

@ -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<char>(len);

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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.

View File

@ -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;

View File

@ -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.

View File

@ -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;

View File

@ -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.

View File

@ -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;

View File

@ -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.

View File

@ -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;

View File

@ -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.

View File

@ -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;

View File

@ -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.