mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 07:29:44 +00:00
(svn r19423) -Codechange: Move error message reporting of industry build in SE to a callback.
This commit is contained in:
parent
6ef68f5d42
commit
db1c6b7a81
@ -107,6 +107,9 @@ CommandCallback CcCloneVehicle;
|
|||||||
/* group_gui.cpp */
|
/* group_gui.cpp */
|
||||||
CommandCallback CcCreateGroup;
|
CommandCallback CcCreateGroup;
|
||||||
|
|
||||||
|
/* industry_gui.cpp */
|
||||||
|
CommandCallback CcBuildIndustry;
|
||||||
|
|
||||||
/* main_gui.cpp */
|
/* main_gui.cpp */
|
||||||
CommandCallback CcPlaySound10;
|
CommandCallback CcPlaySound10;
|
||||||
CommandCallback CcPlaceSign;
|
CommandCallback CcPlaceSign;
|
||||||
|
@ -96,6 +96,26 @@ static inline void GetAllCargoSuffixes(uint cb_offset, CargoSuffixType cst, cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Command callback. In case of failure to build an industry, show an error message.
|
||||||
|
* @param result Result of the command.
|
||||||
|
* @param tile Tile where the industry is placed.
|
||||||
|
* @param p1 Additional data of the #CMD_BUILD_INDUSTRY command.
|
||||||
|
* @param p2 Additional data of the #CMD_BUILD_INDUSTRY command.
|
||||||
|
*/
|
||||||
|
void CcBuildIndustry(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
|
{
|
||||||
|
if (result.Succeeded()) return;
|
||||||
|
|
||||||
|
uint8 indtype = GB(p1, 0, 8);
|
||||||
|
if (indtype < NUM_INDUSTRYTYPES) {
|
||||||
|
const IndustrySpec *indsp = GetIndustrySpec(indtype);
|
||||||
|
if (indsp->enabled) {
|
||||||
|
SetDParam(0, indsp->name);
|
||||||
|
ShowErrorMessage(STR_ERROR_CAN_T_BUILD_HERE, result.GetErrorMessage(), WL_INFO, TileX(tile) * TILE_SIZE, TileY(tile) * TILE_SIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Names of the widgets of the dynamic place industries gui */
|
/** Names of the widgets of the dynamic place industries gui */
|
||||||
enum DynamicPlaceIndustriesWidgets {
|
enum DynamicPlaceIndustriesWidgets {
|
||||||
DPIW_MATRIX_WIDGET,
|
DPIW_MATRIX_WIDGET,
|
||||||
@ -465,11 +485,8 @@ public:
|
|||||||
_current_company = OWNER_NONE;
|
_current_company = OWNER_NONE;
|
||||||
_generating_world = true;
|
_generating_world = true;
|
||||||
_ignore_restrictions = true;
|
_ignore_restrictions = true;
|
||||||
success = DoCommandP(tile, (InteractiveRandomRange(indsp->num_table) << 8) | this->selected_type, seed, CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY));
|
DoCommandP(tile, (InteractiveRandomRange(indsp->num_table) << 8) | this->selected_type, seed,
|
||||||
if (!success) {
|
CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY), &CcBuildIndustry);
|
||||||
SetDParam(0, indsp->name);
|
|
||||||
ShowErrorMessage(STR_ERROR_CAN_T_BUILD_HERE, _error_message, WL_INFO, pt.x, pt.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
_ignore_restrictions = false;
|
_ignore_restrictions = false;
|
||||||
_generating_world = false;
|
_generating_world = false;
|
||||||
|
@ -48,6 +48,7 @@ static CommandCallback * const _callback_table[] = {
|
|||||||
/* 0x15 */ CcCreateGroup,
|
/* 0x15 */ CcCreateGroup,
|
||||||
/* 0x16 */ CcFoundRandomTown,
|
/* 0x16 */ CcFoundRandomTown,
|
||||||
/* 0x17 */ CcRoadStop,
|
/* 0x17 */ CcRoadStop,
|
||||||
|
/* 0x18 */ CcBuildIndustry,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Local queue of packets */
|
/** Local queue of packets */
|
||||||
|
Loading…
Reference in New Issue
Block a user