mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r26240) -Codechange: Pass the GRFFile to GetErrorMessageFromLocationCallbackResult instead of the GRFID.
This commit is contained in:
parent
477c15383d
commit
73c6565cf2
|
@ -473,16 +473,16 @@ uint32 GetCompanyInfo(CompanyID owner, const Livery *l)
|
||||||
/**
|
/**
|
||||||
* Get the error message from a shape/location/slope check callback result.
|
* Get the error message from a shape/location/slope check callback result.
|
||||||
* @param cb_res Callback result to translate. If bit 10 is set this is a standard error message, otherwise a NewGRF provided string.
|
* @param cb_res Callback result to translate. If bit 10 is set this is a standard error message, otherwise a NewGRF provided string.
|
||||||
* @param grfid grfID to use to resolve a custom error message.
|
* @param grffile NewGRF to use to resolve a custom error message.
|
||||||
* @param default_error Error message to use for the generic error.
|
* @param default_error Error message to use for the generic error.
|
||||||
* @return CommandCost indicating success or the error message.
|
* @return CommandCost indicating success or the error message.
|
||||||
*/
|
*/
|
||||||
CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, uint32 grfid, StringID default_error)
|
CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, const GRFFile *grffile, StringID default_error)
|
||||||
{
|
{
|
||||||
CommandCost res;
|
CommandCost res;
|
||||||
|
|
||||||
if (cb_res < 0x400) {
|
if (cb_res < 0x400) {
|
||||||
res = CommandCost(GetGRFStringID(grfid, 0xD000 + cb_res));
|
res = CommandCost(GetGRFStringID(grffile->grfid, 0xD000 + cb_res));
|
||||||
} else {
|
} else {
|
||||||
switch (cb_res) {
|
switch (cb_res) {
|
||||||
case 0x400: return res; // No error.
|
case 0x400: return res; // No error.
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include "direction_type.h"
|
#include "direction_type.h"
|
||||||
#include "company_type.h"
|
#include "company_type.h"
|
||||||
|
|
||||||
|
struct GRFFile;
|
||||||
|
|
||||||
/** Context for tile accesses */
|
/** Context for tile accesses */
|
||||||
enum TileContext {
|
enum TileContext {
|
||||||
TCX_NORMAL, ///< Nothing special.
|
TCX_NORMAL, ///< Nothing special.
|
||||||
|
@ -297,7 +299,7 @@ uint32 GetTerrainType(TileIndex tile, TileContext context = TCX_NORMAL);
|
||||||
TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets = true, Axis axis = INVALID_AXIS);
|
TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets = true, Axis axis = INVALID_AXIS);
|
||||||
uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8);
|
uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8);
|
||||||
uint32 GetCompanyInfo(CompanyID owner, const struct Livery *l = NULL);
|
uint32 GetCompanyInfo(CompanyID owner, const struct Livery *l = NULL);
|
||||||
CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, uint32 grfid, StringID default_error);
|
CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, const GRFFile *grffile, StringID default_error);
|
||||||
|
|
||||||
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res);
|
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res);
|
||||||
bool ConvertBooleanCallback(const struct GRFFile *grffile, uint16 cbid, uint16 cb_res);
|
bool ConvertBooleanCallback(const struct GRFFile *grffile, uint16 cbid, uint16 cb_res);
|
||||||
|
|
|
@ -531,7 +531,7 @@ CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uin
|
||||||
uint16 result = group->GetCallbackResult();
|
uint16 result = group->GetCallbackResult();
|
||||||
if (result == CALLBACK_FAILED) return CommandCost();
|
if (result == CALLBACK_FAILED) return CommandCost();
|
||||||
|
|
||||||
return GetErrorMessageFromLocationCallbackResult(result, indspec->grf_prop.grffile->grfid, STR_ERROR_SITE_UNSUITABLE);
|
return GetErrorMessageFromLocationCallbackResult(result, indspec->grf_prop.grffile, STR_ERROR_SITE_UNSUITABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -256,7 +256,7 @@ CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind
|
||||||
return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
|
return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetErrorMessageFromLocationCallbackResult(callback_res, its->grf_prop.grffile->grfid, STR_ERROR_SITE_UNSUITABLE);
|
return GetErrorMessageFromLocationCallbackResult(callback_res, its->grf_prop.grffile, STR_ERROR_SITE_UNSUITABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Simple wrapper for GetHouseCallback to keep the animation unified. */
|
/* Simple wrapper for GetHouseCallback to keep the animation unified. */
|
||||||
|
|
|
@ -680,7 +680,7 @@ CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_til
|
||||||
|
|
||||||
/* The meaning of bit 10 is inverted for a grf version < 8. */
|
/* The meaning of bit 10 is inverted for a grf version < 8. */
|
||||||
if (statspec->grf_prop.grffile->grf_version < 8) ToggleBit(cb_res, 10);
|
if (statspec->grf_prop.grffile->grf_version < 8) ToggleBit(cb_res, 10);
|
||||||
return GetErrorMessageFromLocationCallbackResult(cb_res, statspec->grf_prop.grffile->grfid, STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
return GetErrorMessageFromLocationCallbackResult(cb_res, statspec->grf_prop.grffile, STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -270,7 +270,7 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
} else {
|
} else {
|
||||||
/* The meaning of bit 10 is inverted for a grf version < 8. */
|
/* The meaning of bit 10 is inverted for a grf version < 8. */
|
||||||
if (spec->grf_prop.grffile->grf_version < 8) ToggleBit(callback, 10);
|
if (spec->grf_prop.grffile->grf_version < 8) ToggleBit(callback, 10);
|
||||||
CommandCost ret = GetErrorMessageFromLocationCallbackResult(callback, spec->grf_prop.grffile->grfid, STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
CommandCost ret = GetErrorMessageFromLocationCallbackResult(callback, spec->grf_prop.grffile, STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue