(svn r26240) -Codechange: Pass the GRFFile to GetErrorMessageFromLocationCallbackResult instead of the GRFID.

This commit is contained in:
frosch 2014-01-12 18:00:19 +00:00
parent 477c15383d
commit 73c6565cf2
6 changed files with 10 additions and 8 deletions

View File

@ -473,16 +473,16 @@ uint32 GetCompanyInfo(CompanyID owner, const Livery *l)
/**
* 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 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.
* @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;
if (cb_res < 0x400) {
res = CommandCost(GetGRFStringID(grfid, 0xD000 + cb_res));
res = CommandCost(GetGRFStringID(grffile->grfid, 0xD000 + cb_res));
} else {
switch (cb_res) {
case 0x400: return res; // No error.

View File

@ -22,6 +22,8 @@
#include "direction_type.h"
#include "company_type.h"
struct GRFFile;
/** Context for tile accesses */
enum TileContext {
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);
uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8);
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);
bool ConvertBooleanCallback(const struct GRFFile *grffile, uint16 cbid, uint16 cb_res);

View File

@ -531,7 +531,7 @@ CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uin
uint16 result = group->GetCallbackResult();
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);
}
/**

View File

@ -256,7 +256,7 @@ CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind
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. */

View File

@ -680,7 +680,7 @@ CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_til
/* The meaning of bit 10 is inverted for a grf version < 8. */
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);
}

View File

@ -270,7 +270,7 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
} else {
/* The meaning of bit 10 is inverted for a grf version < 8. */
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;
}
}