OpenTTD Source: src/command.cpp Source File

OpenTTD Source 12.2

command.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #include "stdafx.h"
11 #include "landscape.h"
12 #include "error.h"
13 #include "gui.h"
14 #include "command_func.h"
15 #include "network/network_type.h"
16 #include "network/network.h"
17 #include "genworld.h"
18 #include "strings_func.h"
19 #include "texteff.hpp"
20 #include "town.h"
21 #include "date_func.h"
22 #include "company_func.h"
23 #include "company_base.h"
24 #include "signal_func.h"
25 #include "core/backup_type.hpp"
26 #include "object_base.h"
27
28 #include "table/strings.h"
29
30 #include "safeguards.h"
31
32 CommandProc CmdBuildRailroadTrack;
33 CommandProc CmdRemoveRailroadTrack;
34 CommandProc CmdBuildSingleRail;
35 CommandProc CmdRemoveSingleRail;
36
37 CommandProc CmdLandscapeClear;
38
39 CommandProc CmdBuildBridge;
40
41 CommandProc CmdBuildRailStation;
42 CommandProc CmdRemoveFromRailStation;
43 CommandProc CmdConvertRail;
44
45 CommandProc CmdBuildSingleSignal;
46 CommandProc CmdRemoveSingleSignal;
47
48 CommandProc CmdTerraformLand;
49
50 CommandProc CmdBuildObject;
51 CommandProc CmdSellLandArea;
52
53 CommandProc CmdBuildTunnel;
54
55 CommandProc CmdBuildTrainDepot;
56 CommandProc CmdBuildRailWaypoint;
57 CommandProc CmdRenameWaypoint;
58 CommandProc CmdRemoveFromRailWaypoint;
59
60 CommandProc CmdBuildRoadStop;
61 CommandProc CmdRemoveRoadStop;
62
63 CommandProc CmdBuildLongRoad;
64 CommandProc CmdRemoveLongRoad;
65 CommandProc CmdBuildRoad;
66
67 CommandProc CmdBuildRoadDepot;
68
69 CommandProc CmdConvertRoad;
70
71 CommandProc CmdBuildAirport;
72
73 CommandProc CmdBuildDock;
74
75 CommandProc CmdBuildShipDepot;
76
77 CommandProc CmdBuildBuoy;
78
79 CommandProc CmdPlantTree;
80
81 CommandProc CmdMoveRailVehicle;
82
83 CommandProc CmdBuildVehicle;
84 CommandProc CmdSellVehicle;
85 CommandProc CmdRefitVehicle;
86 CommandProc CmdSendVehicleToDepot;
87 CommandProc CmdSetVehicleVisibility;
88
89 CommandProc CmdForceTrainProceed;
90 CommandProc CmdReverseTrainDirection;
91
92 CommandProc CmdClearOrderBackup;
93 CommandProc CmdModifyOrder;
94 CommandProc CmdSkipToOrder;
95 CommandProc CmdDeleteOrder;
96 CommandProc CmdInsertOrder;
97 CommandProc CmdChangeServiceInt;
98
99 CommandProc CmdBuildIndustry;
100 CommandProc CmdIndustryCtrl;
101
102 CommandProc CmdSetCompanyManagerFace;
103 CommandProc CmdSetCompanyColour;
104
105 CommandProc CmdIncreaseLoan;
106 CommandProc CmdDecreaseLoan;
107
108 CommandProc CmdWantEnginePreview;
109 CommandProc CmdEngineCtrl;
110
111 CommandProc CmdRenameVehicle;
112 CommandProc CmdRenameEngine;
113
114 CommandProc CmdRenameCompany;
115 CommandProc CmdRenamePresident;
116
117 CommandProc CmdRenameStation;
118 CommandProc CmdRenameDepot;
119
120 CommandProc CmdPlaceSign;
121 CommandProc CmdRenameSign;
122
123 CommandProc CmdTurnRoadVeh;
124
125 CommandProc CmdPause;
126
127 CommandProc CmdBuyShareInCompany;
128 CommandProc CmdSellShareInCompany;
129 CommandProc CmdBuyCompany;
130
131 CommandProc CmdFoundTown;
132 CommandProc CmdRenameTown;
133 CommandProc CmdDoTownAction;
134 CommandProc CmdTownGrowthRate;
135 CommandProc CmdTownRating;
136 CommandProc CmdTownCargoGoal;
137 CommandProc CmdTownSetText;
138 CommandProc CmdExpandTown;
139 CommandProc CmdDeleteTown;
140
141 CommandProc CmdChangeSetting;
142 CommandProc CmdChangeCompanySetting;
143
144 CommandProc CmdOrderRefit;
145 CommandProc CmdCloneOrder;
146
147 CommandProc CmdClearArea;
148
149 CommandProc CmdGiveMoney;
150 CommandProc CmdMoneyCheat;
151 CommandProc CmdChangeBankBalance;
152 CommandProc CmdBuildCanal;
153 CommandProc CmdBuildLock;
154
155 CommandProc CmdCreateSubsidy;
156 CommandProc CmdCompanyCtrl;
157 CommandProc CmdCustomNewsItem;
158 CommandProc CmdCreateGoal;
159 CommandProc CmdRemoveGoal;
160 CommandProc CmdSetGoalText;
161 CommandProc CmdSetGoalProgress;
162 CommandProc CmdSetGoalCompleted;
163 CommandProc CmdGoalQuestion;
164 CommandProc CmdGoalQuestionAnswer;
165 CommandProc CmdCreateStoryPage;
166 CommandProc CmdCreateStoryPageElement;
167 CommandProc CmdUpdateStoryPageElement;
168 CommandProc CmdSetStoryPageTitle;
169 CommandProc CmdSetStoryPageDate;
170 CommandProc CmdShowStoryPage;
171 CommandProc CmdRemoveStoryPage;
172 CommandProc CmdRemoveStoryPageElement;
173 CommandProc CmdScrollViewport;
174 CommandProc CmdStoryPageButton;
175
176 CommandProc CmdLevelLand;
177
178 CommandProc CmdBuildSignalTrack;
179 CommandProc CmdRemoveSignalTrack;
180
181 CommandProc CmdSetAutoReplace;
182
183 CommandProc CmdCloneVehicle;
184 CommandProc CmdStartStopVehicle;
185 CommandProc CmdMassStartStopVehicle;
186 CommandProc CmdAutoreplaceVehicle;
187 CommandProc CmdDepotSellAllVehicles;
188 CommandProc CmdDepotMassAutoReplace;
189
190 CommandProc CmdCreateGroup;
191 CommandProc CmdAlterGroup;
192 CommandProc CmdDeleteGroup;
193 CommandProc CmdAddVehicleGroup;
194 CommandProc CmdAddSharedVehicleGroup;
195 CommandProc CmdRemoveAllVehiclesGroup;
196 CommandProc CmdSetGroupFlag;
197 CommandProc CmdSetGroupLivery;
198
199 CommandProc CmdMoveOrder;
200 CommandProc CmdChangeTimetable;
201 CommandProc CmdSetVehicleOnTime;
202 CommandProc CmdAutofillTimetable;
203 CommandProc CmdSetTimetableStart;
204
205 CommandProc CmdOpenCloseAirport;
206
207 #define DEF_CMD(proc, flags, type) {proc, #proc, (CommandFlags)flags, type}
208
216 static const Command _command_proc_table[] = {
217 DEF_CMD(CmdBuildRailroadTrack, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_RAILROAD_TRACK
218 DEF_CMD(CmdRemoveRailroadTrack, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_RAILROAD_TRACK
219 DEF_CMD(CmdBuildSingleRail, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_SINGLE_RAIL
220 DEF_CMD(CmdRemoveSingleRail, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_SINGLE_RAIL
221 DEF_CMD(CmdLandscapeClear, CMD_DEITY, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_LANDSCAPE_CLEAR
222 DEF_CMD(CmdBuildBridge, CMD_DEITY | CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_BRIDGE
223 DEF_CMD(CmdBuildRailStation, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_RAIL_STATION
224 DEF_CMD(CmdBuildTrainDepot, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_TRAIN_DEPOT
225 DEF_CMD(CmdBuildSingleSignal, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_SIGNALS
226 DEF_CMD(CmdRemoveSingleSignal, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_SIGNALS
227 DEF_CMD(CmdTerraformLand, CMD_ALL_TILES | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_TERRAFORM_LAND
228 DEF_CMD(CmdBuildObject, CMD_DEITY | CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_OBJECT
229 DEF_CMD(CmdBuildTunnel, CMD_DEITY | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_TUNNEL
230 DEF_CMD(CmdRemoveFromRailStation, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_FROM_RAIL_STATION
231 DEF_CMD(CmdConvertRail, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_CONVERT_RAILD
232 DEF_CMD(CmdBuildRailWaypoint, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_RAIL_WAYPOINT
233 DEF_CMD(CmdRenameWaypoint, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_WAYPOINT
234 DEF_CMD(CmdRemoveFromRailWaypoint, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_FROM_RAIL_WAYPOINT
235
236 DEF_CMD(CmdBuildRoadStop, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_ROAD_STOP
237 DEF_CMD(CmdRemoveRoadStop, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_ROAD_STOP
238 DEF_CMD(CmdBuildLongRoad,CMD_DEITY | CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_LONG_ROAD
239 DEF_CMD(CmdRemoveLongRoad, CMD_NO_TEST | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_LONG_ROAD; towns may disallow removing road bits (as they are connected) in test, but in exec they're removed and thus removing is allowed.
240 DEF_CMD(CmdBuildRoad, CMD_DEITY | CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_ROAD
241 DEF_CMD(CmdBuildRoadDepot, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_ROAD_DEPOT
242 DEF_CMD(CmdConvertRoad, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_CONVERT_ROAD
243
244 DEF_CMD(CmdBuildAirport, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_AIRPORT
245 DEF_CMD(CmdBuildDock, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_DOCK
246 DEF_CMD(CmdBuildShipDepot, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_SHIP_DEPOT
247 DEF_CMD(CmdBuildBuoy, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_BUOY
248 DEF_CMD(CmdPlantTree, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_PLANT_TREE
249
250 DEF_CMD(CmdBuildVehicle, CMD_CLIENT_ID, CMDT_VEHICLE_CONSTRUCTION ), // CMD_BUILD_VEHICLE
251 DEF_CMD(CmdSellVehicle, CMD_CLIENT_ID, CMDT_VEHICLE_CONSTRUCTION ), // CMD_SELL_VEHICLE
252 DEF_CMD(CmdRefitVehicle, 0, CMDT_VEHICLE_CONSTRUCTION ), // CMD_REFIT_VEHICLE
253 DEF_CMD(CmdSendVehicleToDepot, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_SEND_VEHICLE_TO_DEPOT
254 DEF_CMD(CmdSetVehicleVisibility, 0, CMDT_COMPANY_SETTING ), // CMD_SET_VEHICLE_VISIBILITY
255
256 DEF_CMD(CmdMoveRailVehicle, 0, CMDT_VEHICLE_CONSTRUCTION ), // CMD_MOVE_RAIL_VEHICLE
257 DEF_CMD(CmdForceTrainProceed, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_FORCE_TRAIN_PROCEED
258 DEF_CMD(CmdReverseTrainDirection, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_REVERSE_TRAIN_DIRECTION
259
260 DEF_CMD(CmdClearOrderBackup, CMD_CLIENT_ID, CMDT_SERVER_SETTING ), // CMD_CLEAR_ORDER_BACKUP
261 DEF_CMD(CmdModifyOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_MODIFY_ORDER
262 DEF_CMD(CmdSkipToOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SKIP_TO_ORDER
263 DEF_CMD(CmdDeleteOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_DELETE_ORDER
264 DEF_CMD(CmdInsertOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_INSERT_ORDER
265
266 DEF_CMD(CmdChangeServiceInt, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_CHANGE_SERVICE_INT
267
268 DEF_CMD(CmdBuildIndustry, CMD_DEITY, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_INDUSTRY
269 DEF_CMD(CmdIndustryCtrl, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_INDUSTRY_CTRL
270
271 DEF_CMD(CmdSetCompanyManagerFace, 0, CMDT_OTHER_MANAGEMENT ), // CMD_SET_COMPANY_MANAGER_FACE
272 DEF_CMD(CmdSetCompanyColour, 0, CMDT_OTHER_MANAGEMENT ), // CMD_SET_COMPANY_COLOUR
273
274 DEF_CMD(CmdIncreaseLoan, 0, CMDT_MONEY_MANAGEMENT ), // CMD_INCREASE_LOAN
275 DEF_CMD(CmdDecreaseLoan, 0, CMDT_MONEY_MANAGEMENT ), // CMD_DECREASE_LOAN
276
277 DEF_CMD(CmdWantEnginePreview, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_WANT_ENGINE_PREVIEW
278 DEF_CMD(CmdEngineCtrl, CMD_DEITY, CMDT_VEHICLE_MANAGEMENT ), // CMD_ENGINE_CTRL
279
280 DEF_CMD(CmdRenameVehicle, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_VEHICLE
281 DEF_CMD(CmdRenameEngine, CMD_SERVER, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_ENGINE
282
283 DEF_CMD(CmdRenameCompany, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_COMPANY
284 DEF_CMD(CmdRenamePresident, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_PRESIDENT
285
286 DEF_CMD(CmdRenameStation, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_STATION
287 DEF_CMD(CmdRenameDepot, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_DEPOT
288
289 DEF_CMD(CmdPlaceSign, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_PLACE_SIGN
290 DEF_CMD(CmdRenameSign, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_SIGN
291
292 DEF_CMD(CmdTurnRoadVeh, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_TURN_ROADVEH
293
294 DEF_CMD(CmdPause, CMD_SERVER | CMD_NO_EST, CMDT_SERVER_SETTING ), // CMD_PAUSE
295
296 DEF_CMD(CmdBuyShareInCompany, 0, CMDT_MONEY_MANAGEMENT ), // CMD_BUY_SHARE_IN_COMPANY
297 DEF_CMD(CmdSellShareInCompany, 0, CMDT_MONEY_MANAGEMENT ), // CMD_SELL_SHARE_IN_COMPANY
298 DEF_CMD(CmdBuyCompany, 0, CMDT_MONEY_MANAGEMENT ), // CMD_BUY_COMANY
299
300 DEF_CMD(CmdFoundTown, CMD_DEITY | CMD_NO_TEST, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_FOUND_TOWN; founding random town can fail only in exec run
301 DEF_CMD(CmdRenameTown, CMD_DEITY | CMD_SERVER, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_TOWN
302 DEF_CMD(CmdDoTownAction, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_DO_TOWN_ACTION
303 DEF_CMD(CmdTownCargoGoal, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_TOWN_CARGO_GOAL
304 DEF_CMD(CmdTownGrowthRate, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_TOWN_GROWTH_RATE
305 DEF_CMD(CmdTownRating, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_TOWN_RATING
306 DEF_CMD(CmdTownSetText, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_TOWN_SET_TEXT
307 DEF_CMD(CmdExpandTown, CMD_DEITY, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_EXPAND_TOWN
308 DEF_CMD(CmdDeleteTown, CMD_OFFLINE, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_DELETE_TOWN
309
310 DEF_CMD(CmdOrderRefit, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_ORDER_REFIT
311 DEF_CMD(CmdCloneOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_CLONE_ORDER
312
313 DEF_CMD(CmdClearArea, CMD_NO_TEST, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_CLEAR_AREA; destroying multi-tile houses makes town rating differ between test and execution
314
315 DEF_CMD(CmdMoneyCheat, CMD_OFFLINE, CMDT_CHEAT ), // CMD_MONEY_CHEAT
316 DEF_CMD(CmdChangeBankBalance, CMD_DEITY, CMDT_MONEY_MANAGEMENT ), // CMD_CHANGE_BANK_BALANCE
317 DEF_CMD(CmdBuildCanal, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_CANAL
318 DEF_CMD(CmdCreateSubsidy, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_CREATE_SUBSIDY
319 DEF_CMD(CmdCompanyCtrl, CMD_SPECTATOR | CMD_CLIENT_ID | CMD_NO_EST, CMDT_SERVER_SETTING ), // CMD_COMPANY_CTRL
320 DEF_CMD(CmdCustomNewsItem, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_CUSTOM_NEWS_ITEM
321 DEF_CMD(CmdCreateGoal, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_CREATE_GOAL
322 DEF_CMD(CmdRemoveGoal, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_REMOVE_GOAL
323 DEF_CMD(CmdSetGoalText, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_SET_GOAL_TEXT
324 DEF_CMD(CmdSetGoalProgress, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_SET_GOAL_PROGRESS
325 DEF_CMD(CmdSetGoalCompleted, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_SET_GOAL_COMPLETED
326 DEF_CMD(CmdGoalQuestion, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_GOAL_QUESTION
327 DEF_CMD(CmdGoalQuestionAnswer, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_GOAL_QUESTION_ANSWER
328 DEF_CMD(CmdCreateStoryPage, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_CREATE_STORY_PAGE
329 DEF_CMD(CmdCreateStoryPageElement, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_CREATE_STORY_PAGE_ELEMENT
330 DEF_CMD(CmdUpdateStoryPageElement, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_UPDATE_STORY_PAGE_ELEMENT
331 DEF_CMD(CmdSetStoryPageTitle, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_SET_STORY_PAGE_TITLE
332 DEF_CMD(CmdSetStoryPageDate, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_SET_STORY_PAGE_DATE
333 DEF_CMD(CmdShowStoryPage, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_SHOW_STORY_PAGE
334 DEF_CMD(CmdRemoveStoryPage, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_REMOVE_STORY_PAGE
335 DEF_CMD(CmdRemoveStoryPageElement, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_REMOVE_STORY_ELEMENT_PAGE
336 DEF_CMD(CmdScrollViewport, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_SCROLL_VIEWPORT
337 DEF_CMD(CmdStoryPageButton, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_STORY_PAGE_BUTTON
338
339 DEF_CMD(CmdLevelLand, CMD_ALL_TILES | CMD_NO_TEST | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_LEVEL_LAND; test run might clear tiles multiple times, in execution that only happens once
340
341 DEF_CMD(CmdBuildLock, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_LOCK
342
343 DEF_CMD(CmdBuildSignalTrack, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_SIGNAL_TRACK
344 DEF_CMD(CmdRemoveSignalTrack, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_SIGNAL_TRACK
345
346 DEF_CMD(CmdGiveMoney, 0, CMDT_MONEY_MANAGEMENT ), // CMD_GIVE_MONEY
347 DEF_CMD(CmdChangeSetting, CMD_SERVER, CMDT_SERVER_SETTING ), // CMD_CHANGE_SETTING
348 DEF_CMD(CmdChangeCompanySetting, 0, CMDT_COMPANY_SETTING ), // CMD_CHANGE_COMPANY_SETTING
349 DEF_CMD(CmdSetAutoReplace, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_SET_AUTOREPLACE
350 DEF_CMD(CmdCloneVehicle, CMD_NO_TEST, CMDT_VEHICLE_CONSTRUCTION ), // CMD_CLONE_VEHICLE; NewGRF callbacks influence building and refitting making it impossible to correctly estimate the cost
351 DEF_CMD(CmdStartStopVehicle, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_START_STOP_VEHICLE
352 DEF_CMD(CmdMassStartStopVehicle, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_MASS_START_STOP
353 DEF_CMD(CmdAutoreplaceVehicle, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_AUTOREPLACE_VEHICLE
354 DEF_CMD(CmdDepotSellAllVehicles, 0, CMDT_VEHICLE_CONSTRUCTION ), // CMD_DEPOT_SELL_ALL_VEHICLES
355 DEF_CMD(CmdDepotMassAutoReplace, 0, CMDT_VEHICLE_CONSTRUCTION ), // CMD_DEPOT_MASS_AUTOREPLACE
356 DEF_CMD(CmdCreateGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_CREATE_GROUP
357 DEF_CMD(CmdDeleteGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_DELETE_GROUP
358 DEF_CMD(CmdAlterGroup, 0, CMDT_OTHER_MANAGEMENT ), // CMD_ALTER_GROUP
359 DEF_CMD(CmdAddVehicleGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_ADD_VEHICLE_GROUP
360 DEF_CMD(CmdAddSharedVehicleGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_ADD_SHARE_VEHICLE_GROUP
361 DEF_CMD(CmdRemoveAllVehiclesGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_REMOVE_ALL_VEHICLES_GROUP
362 DEF_CMD(CmdSetGroupFlag, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_GROUP_FLAG
363 DEF_CMD(CmdSetGroupLivery, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_GROUP_LIVERY
364 DEF_CMD(CmdMoveOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_MOVE_ORDER
365 DEF_CMD(CmdChangeTimetable, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_CHANGE_TIMETABLE
366 DEF_CMD(CmdSetVehicleOnTime, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_VEHICLE_ON_TIME
367 DEF_CMD(CmdAutofillTimetable, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_AUTOFILL_TIMETABLE
368 DEF_CMD(CmdSetTimetableStart, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_TIMETABLE_START
369
370 DEF_CMD(CmdOpenCloseAirport, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_OPEN_CLOSE_AIRPORT
371 };
372
379 bool IsValidCommand(uint32 cmd)
380 {
381 cmd &= CMD_ID_MASK;
382
383 return cmd < lengthof(_command_proc_table) && _command_proc_table[cmd].proc != nullptr;
384 }
385
393 CommandFlags GetCommandFlags(uint32 cmd)
394 {
395 assert(IsValidCommand(cmd));
396
397 return _command_proc_table[cmd & CMD_ID_MASK].flags;
398 }
399
407 const char *GetCommandName(uint32 cmd)
408 {
409 assert(IsValidCommand(cmd));
410
411 return _command_proc_table[cmd & CMD_ID_MASK].name;
412 }
413
419 bool IsCommandAllowedWhilePaused(uint32 cmd)
420 {
421 /* Lookup table for the command types that are allowed for a given pause level setting. */
422 static const int command_type_lookup[] = {
423 CMDPL_ALL_ACTIONS,
424 CMDPL_NO_LANDSCAPING,
425 CMDPL_NO_LANDSCAPING,
426 CMDPL_NO_CONSTRUCTION,
427 CMDPL_NO_CONSTRUCTION,
428 CMDPL_NO_CONSTRUCTION,
429 CMDPL_NO_CONSTRUCTION,
430 CMDPL_NO_ACTIONS,
431 CMDPL_NO_ACTIONS,
432 };
433 static_assert(lengthof(command_type_lookup) == CMDT_END);
434
435 assert(IsValidCommand(cmd));
436 return _game_mode == GM_EDITOR || command_type_lookup[_command_proc_table[cmd & CMD_ID_MASK].type] <= _settings_game.construction.command_pause_level;
437 }
438
439
440 static int _docommand_recursive = 0;
441
450 CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
451 {
452 return DoCommand(container->tile, container->p1, container->p2, flags, container->cmd & CMD_ID_MASK, container->text);
453 }
454
468 CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const std::string &text)
469 {
470 CommandCost res;
471
472 /* Do not even think about executing out-of-bounds tile-commands */
473 if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (flags & DC_ALL_TILES) == 0))) return CMD_ERROR;
474
475 /* Chop of any CMD_MSG or other flags; we don't need those here */
476 CommandProc *proc = _command_proc_table[cmd & CMD_ID_MASK].proc;
477
478 _docommand_recursive++;
479
480 /* only execute the test call if it's toplevel, or we're not execing. */
481 if (_docommand_recursive == 1 || !(flags & DC_EXEC) ) {
482 if (_docommand_recursive == 1) _cleared_object_areas.clear();
483 SetTownRatingTestMode(true);
484 res = proc(tile, flags & ~DC_EXEC, p1, p2, text);
485 SetTownRatingTestMode(false);
486 if (res.Failed()) {
487 goto error;
488 }
489
490 if (_docommand_recursive == 1 &&
491 !(flags & DC_QUERY_COST) &&
492 !(flags & DC_BANKRUPT) &&
493 !CheckCompanyHasMoney(res)) { // CheckCompanyHasMoney() modifies 'res' to an error if it fails.
494 goto error;
495 }
496
497 if (!(flags & DC_EXEC)) {
498 _docommand_recursive--;
499 return res;
500 }
501 }
502
503 /* Execute the command here. All cost-relevant functions set the expenses type
504 * themselves to the cost object at some point */
505 if (_docommand_recursive == 1) _cleared_object_areas.clear();
506 res = proc(tile, flags, p1, p2, text);
507 if (res.Failed()) {
508 error:
509 _docommand_recursive--;
510 return res;
511 }
512
513 /* if toplevel, subtract the money. */
514 if (--_docommand_recursive == 0 && !(flags & DC_BANKRUPT)) {
515 SubtractMoneyFromCompany(res);
516 }
517
518 return res;
519 }
520
528 Money GetAvailableMoneyForCommand()
529 {
530 CompanyID company = _current_company;
531 if (!Company::IsValidID(company)) return INT64_MAX;
532 return Company::Get(company)->money;
533 }
534
541 bool DoCommandP(const CommandContainer *container, bool my_cmd)
542 {
543 return DoCommandP(container->tile, container->p1, container->p2, container->cmd, container->callback, container->text, my_cmd);
544 }
545
561 bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, bool my_cmd)
562 {
563 /* Cost estimation is generally only done when the
564 * local user presses shift while doing something.
565 * However, in case of incoming network commands,
566 * map generation or the pause button we do want
567 * to execute. */
568 bool estimate_only = _shift_pressed && IsLocalCompany() &&
569 !_generating_world &&
570 !(cmd & CMD_NETWORK_COMMAND) &&
571 !(GetCommandFlags(cmd) & CMD_NO_EST);
572
573 /* We're only sending the command, so don't do
574 * fancy things for 'success'. */
575 bool only_sending = _networking && !(cmd & CMD_NETWORK_COMMAND);
576
577 /* Where to show the message? */
578 int x = TileX(tile) * TILE_SIZE;
579 int y = TileY(tile) * TILE_SIZE;
580
581 if (_pause_mode != PM_UNPAUSED && !IsCommandAllowedWhilePaused(cmd) && !estimate_only) {
582 ShowErrorMessage(GB(cmd, 16, 16), STR_ERROR_NOT_ALLOWED_WHILE_PAUSED, WL_INFO, x, y);
583 return false;
584 }
585
586 /* Only set p2 when the command does not come from the network. */
587 if (!(cmd & CMD_NETWORK_COMMAND) && GetCommandFlags(cmd) & CMD_CLIENT_ID && p2 == 0) p2 = CLIENT_ID_SERVER;
588
589 CommandCost res = DoCommandPInternal(tile, p1, p2, cmd, callback, text, my_cmd, estimate_only);
590 if (res.Failed()) {
591 /* Only show the error when it's for us. */
592 StringID error_part1 = GB(cmd, 16, 16);
593 if (estimate_only || (IsLocalCompany() && error_part1 != 0 && my_cmd)) {
594 ShowErrorMessage(error_part1, res.GetErrorMessage(), WL_INFO, x, y, res.GetTextRefStackGRF(), res.GetTextRefStackSize(), res.GetTextRefStack());
595 }
596 } else if (estimate_only) {
597 ShowEstimatedCostOrIncome(res.GetCost(), x, y);
598 } else if (!only_sending && res.GetCost() != 0 && tile != 0 && IsLocalCompany() && _game_mode != GM_EDITOR) {
599 /* Only show the cost animation when we did actually
600 * execute the command, i.e. we're not sending it to
601 * the server, when it has cost the local company
602 * something. Furthermore in the editor there is no
603 * concept of cost, so don't show it there either. */
604 ShowCostOrIncomeAnimation(x, y, GetSlopePixelZ(x, y), res.GetCost());
605 }
606
607 if (!estimate_only && !only_sending && callback != nullptr) {
608 callback(res, tile, p1, p2, cmd);
609 }
610
611 return res.Succeeded();
612 }
613
614
619 #define return_dcpi(cmd) { _docommand_recursive = 0; return cmd; }
620
634 CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, bool my_cmd, bool estimate_only)
635 {
636 /* Prevent recursion; it gives a mess over the network */
637 assert(_docommand_recursive == 0);
638 _docommand_recursive = 1;
639
640 /* Reset the state. */
641 _additional_cash_required = 0;
642
643 /* Get pointer to command handler */
644 byte cmd_id = cmd & CMD_ID_MASK;
645 assert(cmd_id < lengthof(_command_proc_table));
646
647 CommandProc *proc = _command_proc_table[cmd_id].proc;
648 /* Shouldn't happen, but you never know when someone adds
649 * NULLs to the _command_proc_table. */
650 assert(proc != nullptr);
651
652 /* Command flags are used internally */
653 CommandFlags cmd_flags = GetCommandFlags(cmd);
654 /* Flags get send to the DoCommand */
655 DoCommandFlag flags = CommandFlagsToDCFlags(cmd_flags);
656
657 /* Make sure p2 is properly set to a ClientID. */
658 assert(!(cmd_flags & CMD_CLIENT_ID) || p2 != 0);
659
660 /* Do not even think about executing out-of-bounds tile-commands */
661 if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (cmd_flags & CMD_ALL_TILES) == 0))) return_dcpi(CMD_ERROR);
662
663 /* Always execute server and spectator commands as spectator */
664 bool exec_as_spectator = (cmd_flags & (CMD_SPECTATOR | CMD_SERVER)) != 0;
665
666 /* If the company isn't valid it may only do server command or start a new company!
667 * The server will ditch any server commands a client sends to it, so effectively
668 * this guards the server from executing functions for an invalid company. */
669 if (_game_mode == GM_NORMAL && !exec_as_spectator && !Company::IsValidID(_current_company) && !(_current_company == OWNER_DEITY && (cmd_flags & CMD_DEITY) != 0)) {
670 return_dcpi(CMD_ERROR);
671 }
672
673 Backup<CompanyID> cur_company(_current_company, FILE_LINE);
674 if (exec_as_spectator) cur_company.Change(COMPANY_SPECTATOR);
675
676 bool test_and_exec_can_differ = (cmd_flags & CMD_NO_TEST) != 0;
677
678 /* Test the command. */
679 _cleared_object_areas.clear();
680 SetTownRatingTestMode(true);
681 BasePersistentStorageArray::SwitchMode(PSM_ENTER_TESTMODE);
682 CommandCost res = proc(tile, flags, p1, p2, text);
683 BasePersistentStorageArray::SwitchMode(PSM_LEAVE_TESTMODE);
684 SetTownRatingTestMode(false);
685
686 /* Make sure we're not messing things up here. */
687 assert(exec_as_spectator ? _current_company == COMPANY_SPECTATOR : cur_company.Verify());
688
689 /* If the command fails, we're doing an estimate
690 * or the player does not have enough money
691 * (unless it's a command where the test and
692 * execution phase might return different costs)
693 * we bail out here. */
694 if (res.Failed() || estimate_only ||
695 (!test_and_exec_can_differ && !CheckCompanyHasMoney(res))) {
696 if (!_networking || _generating_world || (cmd & CMD_NETWORK_COMMAND) != 0) {
697 /* Log the failed command as well. Just to be able to be find
698 * causes of desyncs due to bad command test implementations. */
699 Debug(desync, 1, "cmdf: {:08x}; {:02x}; {:02x}; {:06x}; {:08x}; {:08x}; {:08x}; \"{}\" ({})", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
700 }
701 cur_company.Restore();
702 return_dcpi(res);
703 }
704
705 /*
706 * If we are in network, and the command is not from the network
707 * send it to the command-queue and abort execution
708 */
709 if (_networking && !_generating_world && !(cmd & CMD_NETWORK_COMMAND)) {
710 NetworkSendCommand(tile, p1, p2, cmd & ~CMD_FLAGS_MASK, callback, text, _current_company);
711 cur_company.Restore();
712
713 /* Don't return anything special here; no error, no costs.
714 * This way it's not handled by DoCommand and only the
715 * actual execution of the command causes messages. Also
716 * reset the storages as we've not executed the command. */
717 return_dcpi(CommandCost());
718 }
719 Debug(desync, 1, "cmd: {:08x}; {:02x}; {:02x}; {:06x}; {:08x}; {:08x}; {:08x}; \"{}\" ({})", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
720
721 /* Actually try and execute the command. If no cost-type is given
722 * use the construction one */
723 _cleared_object_areas.clear();
724 BasePersistentStorageArray::SwitchMode(PSM_ENTER_COMMAND);
725 CommandCost res2 = proc(tile, flags | DC_EXEC, p1, p2, text);
726 BasePersistentStorageArray::SwitchMode(PSM_LEAVE_COMMAND);
727
728 if (cmd_id == CMD_COMPANY_CTRL) {
729 cur_company.Trash();
730 /* We are a new company -> Switch to new local company.
731 * We were closed down -> Switch to spectator
732 * Some other company opened/closed down -> The outside function will switch back */
733 _current_company = _local_company;
734 } else {
735 /* Make sure nothing bad happened, like changing the current company. */
736 assert(exec_as_spectator ? _current_company == COMPANY_SPECTATOR : cur_company.Verify());
737 cur_company.Restore();
738 }
739
740 /* If the test and execution can differ we have to check the
741 * return of the command. Otherwise we can check whether the
742 * test and execution have yielded the same result,
743 * i.e. cost and error state are the same. */
744 if (!test_and_exec_can_differ) {
745 assert(res.GetCost() == res2.GetCost() && res.Failed() == res2.Failed()); // sanity check
746 } else if (res2.Failed()) {
747 return_dcpi(res2);
748 }
749
750 /* If we're needing more money and we haven't done
751 * anything yet, ask for the money! */
752 if (_additional_cash_required != 0 && res2.GetCost() == 0) {
753 /* It could happen we removed rail, thus gained money, and deleted something else.
754 * So make sure the signal buffer is empty even in this case */
755 UpdateSignalsInBuffer();
756 SetDParam(0, _additional_cash_required);
757 return_dcpi(CommandCost(STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY));
758 }
759
760 /* update last build coordinate of company. */
761 if (tile != 0) {
762 Company *c = Company::GetIfValid(_current_company);
763 if (c != nullptr) c->last_build_coordinate = tile;
764 }
765
766 SubtractMoneyFromCompany(res2);
767
768 /* update signals if needed */
769 UpdateSignalsInBuffer();
770
771 return_dcpi(res2);
772 }
773 #undef return_dcpi
774
775
781 void CommandCost::AddCost(const CommandCost &ret)
782 {
783 this->AddCost(ret.cost);
784 if (this->success && !ret.success) {
785 this->message = ret.message;
786 this->success = false;
787 }
788 }
789
795 uint32 CommandCost::textref_stack[16];
796
802 void CommandCost::UseTextRefStack(const GRFFile *grffile, uint num_registers)
803 {
804 extern TemporaryStorageArray<int32, 0x110> _temp_store;
805
806 assert(num_registers < lengthof(textref_stack));
807 this->textref_stack_grffile = grffile;
808 this->textref_stack_size = num_registers;
809 for (uint i = 0; i < num_registers; i++) {
810 textref_stack[i] = _temp_store.GetValue(0x100 + i);
811 }
812 }
CmdSellShareInCompany
CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Sell shares in an opposing company.
Definition: economy.cpp:2071
CmdDeleteTown
CommandCost CmdDeleteTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Delete a town (scenario editor or worldgen only).
Definition: town_cmd.cpp:2963
CmdExpandTown
CommandCost CmdExpandTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Expand a town (scenario editor only).
Definition: town_cmd.cpp:2923
PSM_LEAVE_TESTMODE
@ PSM_LEAVE_TESTMODE
Leave command test mode, revert to previous mode.
Definition: newgrf_storage.h:25
Backup::Change
void Change(const U &new_value)
Change the value of the variable.
Definition: backup_type.hpp:84
CmdSetAutoReplace
CommandCost CmdSetAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Change engine renewal parameters.
Definition: autoreplace_cmd.cpp:810
CmdRenameCompany
CommandCost CmdRenameCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Change the name of the company.
Definition: company_cmd.cpp:1066
CmdCloneVehicle
CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Clone a vehicle.
Definition: vehicle_cmd.cpp:825
CmdBuildRoad
CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build a piece of road.
Definition: road_cmd.cpp:613
CmdChangeBankBalance
CommandCost CmdChangeBankBalance(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Change the bank bank balance of a company by inserting or removing money without affecting the loan.
Definition: misc_cmd.cpp:220
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:83
CommandContainer::cmd
uint32 cmd
command being executed.
Definition: command_type.h:483
CmdBuildRailWaypoint
CommandCost CmdBuildRailWaypoint(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Convert existing rail to waypoint.
Definition: waypoint_cmd.cpp:177
CmdSetTimetableStart
CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Set the start date of the timetable.
Definition: timetable_cmd.cpp:261
CmdRefitVehicle
CommandProc CmdRefitVehicle
Refits a vehicle to the specified cargo type.
Definition: command.cpp:85
CmdRemoveLongRoad
CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Remove a long piece of road.
Definition: road_cmd.cpp:1089
DoCommand
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
Definition: command.cpp:450
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:337
CMDPL_NO_ACTIONS
@ CMDPL_NO_ACTIONS
No user actions may be executed.
Definition: command_type.h:422
CmdSetGroupFlag
CommandCost CmdSetGroupFlag(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
(Un)set group flag from a group
Definition: group_cmd.cpp:700
CmdRenameTown
CommandCost CmdRenameTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Rename a town (server-only).
Definition: town_cmd.cpp:2744
GB
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
UpdateSignalsInBuffer
static SigSegState UpdateSignalsInBuffer(Owner owner)
Updates blocks in _globset buffer.
Definition: signal.cpp:468
command_func.h
CmdInsertOrder
CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Add an order to the orderlist of a vehicle.
Definition: order_cmd.cpp:740
Pool::PoolItem<&_company_pool >::GetIfValid
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:348
CMD_ERROR
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
Definition: command_func.h:23
CmdBuildSignalTrack
CommandCost CmdBuildSignalTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build signals on a stretch of track.
Definition: rail_cmd.cpp:1454
CmdBuildBuoy
CommandCost CmdBuildBuoy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build a buoy.
Definition: waypoint_cmd.cpp:305
Backup
Class to backup a specific variable and restore it later.
Definition: backup_type.hpp:21
CmdBuildShipDepot
CommandCost CmdBuildShipDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build a ship depot.
Definition: water_cmd.cpp:101
CmdMassStartStopVehicle
CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Starts or stops a lot of vehicles.
Definition: vehicle_cmd.cpp:643
company_base.h
CmdTownCargoGoal
CommandCost CmdTownCargoGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Change the cargo goal of a town.
Definition: town_cmd.cpp:2797
CMD_OFFLINE
@ CMD_OFFLINE
the command cannot be executed in a multiplayer game; single-player only
Definition: command_type.h:393
_date_fract
DateFract _date_fract
Fractional part of the day.
Definition: date.cpp:29
CMDT_VEHICLE_CONSTRUCTION
@ CMDT_VEHICLE_CONSTRUCTION
Construction, modification (incl. refit) and destruction of vehicles.
Definition: command_type.h:408
GetCommandName
const char * GetCommandName(uint32 cmd)
Definition: command.cpp:407
CmdFoundTown
CommandCost CmdFoundTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Create a new town.
Definition: town_cmd.cpp:1935
CmdRenamePresident
CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Change the name of the president.
Definition: company_cmd.cpp:1112
_command_proc_table
static const Command _command_proc_table[]
The master command table.
Definition: command.cpp:216
CmdRenameVehicle
CommandCost CmdRenameVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Give a custom name to your vehicle.
Definition: vehicle_cmd.cpp:1072
CmdBuildIndustry
CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build/Fund an industry.
Definition: industry_cmd.cpp:1985
CmdClearOrderBackup
CommandCost CmdClearOrderBackup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Clear an OrderBackup.
Definition: order_backup.cpp:150
return_dcpi
#define return_dcpi(cmd)
Helper to deduplicate the code for returning.
Definition: command.cpp:619
CmdAlterGroup
CommandCost CmdAlterGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Alter a group.
Definition: group_cmd.cpp:407
CommandCallback
void CommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Define a callback function for the client, after the command is finished.
Definition: command_type.h:474
CMD_NO_EST
@ CMD_NO_EST
the command is never estimated.
Definition: command_type.h:401
CommandContainer::p2
uint32 p2
parameter p2.
Definition: command_type.h:482
TILE_SIZE
static const uint TILE_SIZE
Tile size in world coordinates.
Definition: tile_type.h:13
CommandContainer
Structure for buffering the build command when selecting a station to join.
Definition: command_type.h:479
CmdCreateStoryPageElement
CommandCost CmdCreateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Create a new story page element.
Definition: story.cpp:253
CmdRemoveGoal
CommandCost CmdRemoveGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Remove a goal.
Definition: goal.cpp:119
CmdTownRating
CommandCost CmdTownRating(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Change the rating of a company in a town.
Definition: town_cmd.cpp:2894
CmdRenameWaypoint
CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Rename a waypoint.
Definition: waypoint_cmd.cpp:416
Backup::Verify
bool Verify() const
Check whether the variable is currently equals the backup.
Definition: backup_type.hpp:132
Command::flags
CommandFlags flags
The (command) flags to that apply to this command.
Definition: command_type.h:457
town.h
CmdRenameSign
CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Rename a sign.
Definition: signs_cmd.cpp:78
TileY
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition: map_func.h:215
DC_ALL_TILES
@ DC_ALL_TILES
allow this command also on MP_VOID tiles
Definition: command_type.h:357
CompanyProperties::last_build_coordinate
TileIndex last_build_coordinate
Coordinate of the last build thing by this company.
Definition: company_base.h:75
CmdCreateGroup
CommandCost CmdCreateGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Create a new vehicle group.
Definition: group_cmd.cpp:303
CmdStoryPageButton
CommandCost CmdStoryPageButton(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Clicked/used a button on a story page.
Definition: story.cpp:472
CMDT_CHEAT
@ CMDT_CHEAT
A cheat of some sorts.
Definition: command_type.h:415
CMDT_COMPANY_SETTING
@ CMDT_COMPANY_SETTING
Changing settings related to a company.
Definition: command_type.h:413
CommandCost::GetTextRefStack
const uint32 * GetTextRefStack() const
Returns a pointer to the values for the TextRefStack of the error message.
Definition: command_type.h:131
CmdAutoreplaceVehicle
CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Autoreplaces a vehicle Trains are replaced as a whole chain, free wagons in depot are replaced on the...
Definition: autoreplace_cmd.cpp:717
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
CmdRemoveFromRailWaypoint
CommandCost CmdRemoveFromRailWaypoint(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Remove a single tile from a waypoint.
Definition: station_cmd.cpp:1705
DC_EXEC
@ DC_EXEC
execute the given command
Definition: command_type.h:348
IsCommandAllowedWhilePaused
bool IsCommandAllowedWhilePaused(uint32 cmd)
Returns whether the command is allowed while the game is paused.
Definition: command.cpp:419
CommandCost::GetErrorMessage
StringID GetErrorMessage() const
Returns the error message of a command.
Definition: command_type.h:140
IsLocalCompany
static bool IsLocalCompany()
Is the current company the local company?
Definition: company_func.h:43
CommandCost::textref_stack
static uint32 textref_stack[16]
Values to put on the TextRefStack for the error message.
Definition: command_type.h:31
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:196
NetworkSendCommand
void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, CompanyID company)
Prepare a DoCommand to be send over the network.
Definition: network_command.cpp:136
DoCommandFlag
DoCommandFlag
List of flags for a command.
Definition: command_type.h:346
CmdCreateGoal
CommandCost CmdCreateGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Create a new goal.
Definition: goal.cpp:46
genworld.h
CmdDeleteGroup
CommandCost CmdDeleteGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Add all vehicles in the given group to the default group and then deletes the group.
Definition: group_cmd.cpp:353
DoCommandPInternal
CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, bool my_cmd, bool estimate_only)
Definition: command.cpp:634
CmdRemoveRoadStop
CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Remove bus or truck stops.
Definition: station_cmd.cpp:2094
CmdSellVehicle
CommandCost CmdSellVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Sell a vehicle.
Definition: vehicle_cmd.cpp:209
CmdBuildLock
CommandCost CmdBuildLock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Builds a lock.
Definition: water_cmd.cpp:420
CommandCost::Succeeded
bool Succeeded() const
Did this command succeed?
Definition: command_type.h:150
CmdLevelLand
CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Levels a selected (rectangle) area of land.
Definition: terraform_cmd.cpp:345
CMD_DEITY
@ CMD_DEITY
the command may be executed by COMPANY_DEITY
Definition: command_type.h:399
object_base.h
TileX
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition: map_func.h:205
ShowErrorMessage
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
Definition: error_gui.cpp:383
CmdCloneOrder
CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Clone/share/copy an order-list of another vehicle.
Definition: order_cmd.cpp:1533
CmdOrderRefit
CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Add/remove refit orders from an order.
Definition: order_cmd.cpp:1680
CmdTownGrowthRate
CommandCost CmdTownGrowthRate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Change the growth rate of the town.
Definition: town_cmd.cpp:2854
CMDT_END
@ CMDT_END
Magic end marker.
Definition: command_type.h:417
PM_UNPAUSED
@ PM_UNPAUSED
A normal unpaused game.
Definition: openttd.h:61
CmdBuyShareInCompany
CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Acquire shares in an opposing company.
Definition: economy.cpp:2019
CommandContainer::text
std::string text
possible text sent for name changes etc.
Definition: command_type.h:485
CmdRemoveSingleRail
CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Remove a single piece of track.
Definition: rail_cmd.cpp:625
CmdCreateSubsidy
CommandCost CmdCreateSubsidy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Create a new subsidy.
Definition: subsidy.cpp:245
IsValidCommand
bool IsValidCommand(uint32 cmd)
Definition: command.cpp:379
CmdModifyOrder
CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Modify an order in the orderlist of a vehicle.
Definition: order_cmd.cpp:1264
CommandFlags
CommandFlags
Command flags for the command table _command_proc_table.
Definition: command_type.h:390
CmdBuildAirport
CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Place an Airport.
Definition: station_cmd.cpp:2253
CommandContainer::p1
uint32 p1
parameter p1.
Definition: command_type.h:481
MapSize
static uint MapSize()
Get the size of the map.
Definition: map_func.h:92
CommandCost::UseTextRefStack
void UseTextRefStack(const GRFFile *grffile, uint num_registers)
Activate usage of the NewGRF TextRefStack for the error message.
Definition: command.cpp:802
CommandCost
Common return value for all commands.
Definition: command_type.h:23
CommandCost::textref_stack_size
uint textref_stack_size
Number of uint32 values to put on the TextRefStack for the error message.
Definition: command_type.h:29
_date
Date _date
Current date in days (day counter)
Definition: date.cpp:28
CMDT_OTHER_MANAGEMENT
@ CMDT_OTHER_MANAGEMENT
Renaming stuff, changing company colours, placing signs, etc.
Definition: command_type.h:412
DoCommandP
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Definition: command.cpp:541
CMD_AUTO
@ CMD_AUTO
set the DC_AUTO flag on this command
Definition: command_type.h:394
Command
Define a command with the flags which belongs to it.
Definition: command_type.h:454
CmdRemoveSingleSignal
CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Remove signals.
Definition: rail_cmd.cpp:1471
CommandCost::GetTextRefStackSize
uint GetTextRefStackSize() const
Returns the number of uint32 values for the TextRefStack of the error message.
Definition: command_type.h:122
CmdLandscapeClear
CommandCost CmdLandscapeClear(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Clear a piece of landscape.
Definition: landscape.cpp:693
CmdCustomNewsItem
CommandCost CmdCustomNewsItem(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Create a new custom news item.
Definition: news_gui.cpp:847
CmdOpenCloseAirport
CommandCost CmdOpenCloseAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Open/close an airport to incoming aircraft.
Definition: station_cmd.cpp:2470
Command::type
CommandType type
The type of command.
Definition: command_type.h:458
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition: command_type.h:159
CmdMoveRailVehicle
CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Move a rail vehicle around inside the depot.
Definition: train_cmd.cpp:1171
CmdAddSharedVehicleGroup
CommandCost CmdAddSharedVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Add all shared vehicles of all vehicles from a group.
Definition: group_cmd.cpp:568
CMDPL_NO_LANDSCAPING
@ CMDPL_NO_LANDSCAPING
No landscaping actions may be executed.
Definition: command_type.h:424
_pause_mode
PauseMode _pause_mode
The current pause mode.
Definition: gfx.cpp:48
CommandCost::GetTextRefStackGRF
const GRFFile * GetTextRefStackGRF() const
Returns the NewGRF providing the TextRefStack of the error message.
Definition: command_type.h:113
CMDT_ROUTE_MANAGEMENT
@ CMDT_ROUTE_MANAGEMENT
Modifications to route management (orders, groups, etc).
Definition: command_type.h:411
PSM_LEAVE_COMMAND
@ PSM_LEAVE_COMMAND
Leave command scope, revert to previous mode.
Definition: newgrf_storage.h:23
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:53
CmdGoalQuestionAnswer
CommandCost CmdGoalQuestionAnswer(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Reply to a goal question.
Definition: goal.cpp:292
CmdChangeSetting
CommandCost CmdChangeSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Network-safe changing of settings (server-only).
Definition: settings.cpp:1501
WL_INFO
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
Definition: error.h:22
CmdSendVehicleToDepot
CommandCost CmdSendVehicleToDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Send a vehicle to the depot.
Definition: vehicle_cmd.cpp:1047
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
CmdRemoveFromRailStation
CommandCost CmdRemoveFromRailStation(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Remove a single tile from a rail station.
Definition: station_cmd.cpp:1670
safeguards.h
CMD_CLIENT_ID
@ CMD_CLIENT_ID
set p2 with the ClientID of the sending client.
Definition: command_type.h:398
IsValidTile
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
Definition: tile_map.h:161
CommandCost::GetCost
Money GetCost() const
The costs as made up to this moment.
Definition: command_type.h:82
CLIENT_ID_SERVER
@ CLIENT_ID_SERVER
Servers always have this ID.
Definition: network_type.h:49
CmdCreateStoryPage
CommandCost CmdCreateStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Create a new story page.
Definition: story.cpp:207
CmdDoTownAction
CommandCost CmdDoTownAction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Do a town action.
Definition: town_cmd.cpp:3349
_networking
bool _networking
are we in networking mode?
Definition: network.cpp:57
_shift_pressed
bool _shift_pressed
Is Shift pressed?
Definition: gfx.cpp:37
CmdGoalQuestion
CommandCost CmdGoalQuestion(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Ask a goal related question.
Definition: goal.cpp:245
GetAvailableMoneyForCommand
Money GetAvailableMoneyForCommand()
Definition: command.cpp:528
CmdChangeTimetable
CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Change timetable data of an order.
Definition: timetable_cmd.cpp:100
CmdIncreaseLoan
CommandCost CmdIncreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Increase the loan of your company.
Definition: misc_cmd.cpp:45
CMD_FLAGS_MASK
@ CMD_FLAGS_MASK
mask for all command flags
Definition: command_type.h:381
error.h
date_func.h
CommandCost::AddCost
void AddCost(const Money &cost)
Adds the given cost to the cost of the command.
Definition: command_type.h:62
CmdSetGroupLivery
CommandCost CmdSetGroupLivery(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Set the livery for a vehicle group.
Definition: group_cmd.cpp:639
stdafx.h
ShowCostOrIncomeAnimation
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost)
Display animated income or costs on the map.
Definition: misc_gui.cpp:574
CmdBuildRailStation
CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build rail station.
Definition: station_cmd.cpp:1260
landscape.h
GetCommandFlags
CommandFlags GetCommandFlags(uint32 cmd)
Definition: command.cpp:393
CmdRemoveRailroadTrack
CommandCost CmdRemoveRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build rail on a stretch of track.
Definition: rail_cmd.cpp:967
CmdRenameEngine
CommandCost CmdRenameEngine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Rename an engine.
Definition: engine.cpp:1081
CmdShowStoryPage
CommandCost CmdShowStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Display a story page for all clients that are allowed to view the story page.
Definition: story.cpp:390
DC_BANKRUPT
@ DC_BANKRUPT
company bankrupts, skip money check, skip vehicle on tile check in some cases
Definition: command_type.h:354
CheckCompanyHasMoney
bool CheckCompanyHasMoney(CommandCost &cost)
Verify whether the company can pay the bill.
Definition: company_cmd.cpp:196
CmdSetStoryPageTitle
CommandCost CmdSetStoryPageTitle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Update title of a story page.
Definition: story.cpp:333
CmdSetCompanyColour
CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Change the company's company-colour.
Definition: company_cmd.cpp:955
CmdSetGoalCompleted
CommandCost CmdSetGoalCompleted(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Update completed state of a goal.
Definition: goal.cpp:212
CmdAutofillTimetable
CommandCost CmdAutofillTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Start or stop filling the timetable automatically from the time the vehicle actually takes to complet...
Definition: timetable_cmd.cpp:326
CommandContainer::callback
CommandCallback * callback
any callback function executed upon successful completion of the command.
Definition: command_type.h:484
CmdSetVehicleOnTime
CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Clear the lateness counter to make the vehicle on time.
Definition: timetable_cmd.cpp:194
CmdIndustryCtrl
CommandCost CmdIndustryCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Change industry properties.
Definition: industry_cmd.cpp:2077
_generating_world
bool _generating_world
Whether we are generating the map or not.
Definition: genworld.cpp:61
CmdTownSetText
CommandCost CmdTownSetText(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Set a custom text in the Town window.
Definition: town_cmd.cpp:2830
CmdBuildTunnel
CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build Tunnel.
Definition: tunnelbridge_cmd.cpp:633
CmdClearArea
CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Clear a big piece of landscape.
Definition: landscape.cpp:743
CommandCost::textref_stack_grffile
const GRFFile * textref_stack_grffile
NewGRF providing the TextRefStack content.
Definition: command_type.h:28
texteff.hpp
CmdRenameDepot
CommandCost CmdRenameDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Rename a depot.
Definition: depot_cmd.cpp:47
CmdSetCompanyManagerFace
CommandCost CmdSetCompanyManagerFace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Change the company manager's face.
Definition: company_cmd.cpp:931
CmdCompanyCtrl
CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Control the companies: add, delete, etc.
Definition: company_cmd.cpp:807
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
CmdDeleteOrder
CommandCost CmdDeleteOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Delete an order from the orderlist of a vehicle.
Definition: order_cmd.cpp:1015
_current_company
CompanyID _current_company
Company currently doing an action.
Definition: company_cmd.cpp:47
CmdPause
CommandCost CmdPause(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Pause/Unpause the game (server-only).
Definition: misc_cmd.cpp:153
CMDT_VEHICLE_MANAGEMENT
@ CMDT_VEHICLE_MANAGEMENT
Stopping, starting, sending to depot, turning around, replace orders etc.
Definition: command_type.h:410
CmdPlantTree
CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Plant a tree.
Definition: tree_cmd.cpp:388
strings_func.h
CMD_NO_WATER
@ CMD_NO_WATER
set the DC_NO_WATER flag on this command
Definition: command_type.h:397
Backup::Trash
void Trash()
Trash the backup.
Definition: backup_type.hpp:103
CMD_NETWORK_COMMAND
@ CMD_NETWORK_COMMAND
execute the command without sending it on the network
Definition: command_type.h:380
CommandCost::message
StringID message
Warning message for when success is unset.
Definition: command_type.h:26
CmdDepotMassAutoReplace
CommandCost CmdDepotMassAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Autoreplace all vehicles in the depot.
Definition: vehicle_cmd.cpp:721
CmdBuildSingleRail
CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build a single piece of rail.
Definition: rail_cmd.cpp:437
CmdSetVehicleVisibility
CommandCost CmdSetVehicleVisibility(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Set the visibility of an engine.
Definition: engine.cpp:884
Backup::Restore
void Restore()
Restore the variable.
Definition: backup_type.hpp:112
CMD_ALL_TILES
@ CMD_ALL_TILES
allow this command also on MP_VOID tiles
Definition: command_type.h:395
CMD_ID_MASK
@ CMD_ID_MASK
mask for the command ID
Definition: command_type.h:382
CmdWantEnginePreview
CommandCost CmdWantEnginePreview(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Accept an engine prototype.
Definition: engine.cpp:908
CmdRemoveStoryPageElement
CommandCost CmdRemoveStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Remove a story page element.
Definition: story.cpp:445
CmdSetGoalText
CommandCost CmdSetGoalText(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Update goal text of a goal.
Definition: goal.cpp:149
COMPANY_SPECTATOR
@ COMPANY_SPECTATOR
The client is spectating.
Definition: company_type.h:35
CmdAddVehicleGroup
CommandCost CmdAddVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Add a vehicle to a group.
Definition: group_cmd.cpp:511
CmdChangeCompanySetting
CommandCost CmdChangeCompanySetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Change one of the per-company settings.
Definition: settings.cpp:1529
CmdDepotSellAllVehicles
CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Sells all vehicles in a depot.
Definition: vehicle_cmd.cpp:683
CmdBuildSingleSignal
CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build signals, alternate between double/single, signal/semaphore, pre/exit/combo-signals,...
Definition: rail_cmd.cpp:1058
CmdBuildBridge
CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build a Bridge.
Definition: tunnelbridge_cmd.cpp:260
CMDT_SERVER_SETTING
@ CMDT_SERVER_SETTING
Pausing/removing companies/server settings.
Definition: command_type.h:414
signal_func.h
CmdBuildTrainDepot
CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build a train depot.
Definition: rail_cmd.cpp:984
CmdBuildCanal
CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build a piece of canal.
Definition: water_cmd.cpp:446
OWNER_DEITY
@ OWNER_DEITY
The object is owned by a superuser / goal script.
Definition: company_type.h:27
CMD_NO_TEST
@ CMD_NO_TEST
the command's output may differ between test and execute due to town rating changes etc.
Definition: command_type.h:396
CmdMoveOrder
CommandCost CmdMoveOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Move an order inside the orderlist.
Definition: order_cmd.cpp:1161
company_func.h
CmdTerraformLand
CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Terraform land.
Definition: terraform_cmd.cpp:188
CMD_COMPANY_CTRL
@ CMD_COMPANY_CTRL
used in multiplayer to create a new companies etc.
Definition: command_type.h:281
CmdForceTrainProceed
CommandCost CmdForceTrainProceed(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Force a train through a red signal.
Definition: train_cmd.cpp:1991
CmdBuildRoadDepot
CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build a road depot.
Definition: road_cmd.cpp:1172
CmdBuyCompany
CommandCost CmdBuyCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Buy up another company.
Definition: economy.cpp:2112
CmdConvertRail
CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Convert one rail type to the other.
Definition: rail_cmd.cpp:1574
error
void CDECL error(const char *s,...)
Error handling for fatal non-user errors.
Definition: openttd.cpp:132
CmdScrollViewport
CommandCost CmdScrollViewport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Scroll players main viewport.
Definition: viewport.cpp:3475
network.h
ShowEstimatedCostOrIncome
void ShowEstimatedCostOrIncome(Money cost, int x, int y)
Display estimated costs.
Definition: misc_gui.cpp:555
CommandCost::cost
Money cost
The cost of this action.
Definition: command_type.h:25
CommandFlagsToDCFlags
static DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
Definition: command_func.h:58
Debug
#define Debug(name, level, format_string,...)
Ouptut a line of debugging information.
Definition: debug.h:37
CmdRemoveSignalTrack
CommandCost CmdRemoveSignalTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Remove signals on a stretch of track.
Definition: rail_cmd.cpp:1546
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:378
CMDPL_ALL_ACTIONS
@ CMDPL_ALL_ACTIONS
All actions may be executed.
Definition: command_type.h:425
CmdSetGoalProgress
CommandCost CmdSetGoalProgress(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Update progress text of a goal.
Definition: goal.cpp:179
OverflowSafeInt< int64 >
Command::name
const char * name
A human readable name for the procedure.
Definition: command_type.h:456
TemporaryStorageArray
Class for temporary storage of data.
Definition: newgrf_storage.h:150
BasePersistentStorageArray::SwitchMode
static void SwitchMode(PersistentStorageMode mode, bool ignore_prev_mode=false)
Clear temporary changes made since the last call to SwitchMode, and set whether subsequent changes sh...
Definition: newgrf_storage.cpp:55
CmdConvertRoad
CommandCost CmdConvertRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Convert one road subtype to another.
Definition: road_cmd.cpp:2359
CmdRemoveAllVehiclesGroup
CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Remove all vehicles from a group.
Definition: group_cmd.cpp:605
CmdStartStopVehicle
CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Start/Stop a vehicle.
Definition: vehicle_cmd.cpp:559
gui.h
CmdBuildObject
CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build an object object.
Definition: object_cmd.cpp:205
PSM_ENTER_COMMAND
@ PSM_ENTER_COMMAND
Enter command scope, changes will be permanent.
Definition: newgrf_storage.h:22
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition: settings_type.h:578
CmdPlaceSign
CommandCost CmdPlaceSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Place a sign at the given coordinates.
Definition: signs_cmd.cpp:39
CommandProc
CommandCost CommandProc(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Defines the callback type for all command handler functions.
Definition: command_type.h:446
CmdUpdateStoryPageElement
CommandCost CmdUpdateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Update a new story page element.
Definition: story.cpp:303
CmdBuildVehicle
CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build a vehicle.
Definition: vehicle_cmd.cpp:89
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:326
SubtractMoneyFromCompany
void SubtractMoneyFromCompany(const CommandCost &cost)
Subtract money from the _current_company, if the company is valid.
Definition: company_cmd.cpp:243
CmdMoneyCheat
CommandCost CmdMoneyCheat(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Change the financial flow of your company.
Definition: misc_cmd.cpp:205
CmdGiveMoney
CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Transfer funds (money) from one company to another.
Definition: company_cmd.cpp:1197
CMD_SERVER
@ CMD_SERVER
the command can only be initiated by the server
Definition: command_type.h:391
CmdBuildRailroadTrack
CommandCost CmdBuildRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build rail on a stretch of track.
Definition: rail_cmd.cpp:948
CMD_SPECTATOR
@ CMD_SPECTATOR
the command may be initiated by a spectator
Definition: command_type.h:392
DC_QUERY_COST
@ DC_QUERY_COST
query cost only, don't build.
Definition: command_type.h:350
CommandContainer::tile
TileIndex tile
tile command being executed on.
Definition: command_type.h:480
CMD_STR_CTRL
@ CMD_STR_CTRL
the command's string may contain control strings
Definition: command_type.h:400
ConstructionSettings::command_pause_level
uint8 command_pause_level
level/amount of commands that can't be executed while paused
Definition: settings_type.h:348
Company
Definition: company_base.h:115
PSM_ENTER_TESTMODE
@ PSM_ENTER_TESTMODE
Enter command test mode, changes will be temporary.
Definition: newgrf_storage.h:24
CmdBuildLongRoad
CommandCost CmdBuildLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build a long piece of road.
Definition: road_cmd.cpp:984
CMDPL_NO_CONSTRUCTION
@ CMDPL_NO_CONSTRUCTION
No construction actions may be executed.
Definition: command_type.h:423
CmdRemoveStoryPage
CommandCost CmdRemoveStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Remove a story page and associated story page elements.
Definition: story.cpp:412
CmdTurnRoadVeh
CommandCost CmdTurnRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Turn a roadvehicle around.
Definition: roadveh_cmd.cpp:369
CmdEngineCtrl
CommandCost CmdEngineCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Allow or forbid a specific company to use an engine.
Definition: engine.cpp:929
CMDT_MONEY_MANAGEMENT
@ CMDT_MONEY_MANAGEMENT
Management of money, i.e. loans and shares.
Definition: command_type.h:409
SetTownRatingTestMode
void SetTownRatingTestMode(bool mode)
Switch the town rating to test-mode, to allow commands to be tested without affecting current ratings...
Definition: town_cmd.cpp:3633
CmdDecreaseLoan
CommandCost CmdDecreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Decrease the loan of your company.
Definition: misc_cmd.cpp:93
CmdReverseTrainDirection
CommandCost CmdReverseTrainDirection(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Reverse train.
Definition: train_cmd.cpp:1918
CmdSetStoryPageDate
CommandCost CmdSetStoryPageDate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Update date of a story page.
Definition: story.cpp:363
CMDT_LANDSCAPE_CONSTRUCTION
@ CMDT_LANDSCAPE_CONSTRUCTION
Construction and destruction of objects on the map.
Definition: command_type.h:407
CmdBuildRoadStop
CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build a bus or truck stop.
Definition: station_cmd.cpp:1844
network_type.h
GRFFile
Dynamic data of a loaded NewGRF.
Definition: newgrf.h:105
CmdRenameStation
CommandCost CmdRenameStation(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Rename a station.
Definition: station_cmd.cpp:3944
Command::proc
CommandProc * proc
The procedure to actually executing.
Definition: command_type.h:455
CmdSkipToOrder
CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Goto order of order-list.
Definition: order_cmd.cpp:1120
CommandCost::success
bool success
Whether the comment went fine up to this moment.
Definition: command_type.h:27
CmdChangeServiceInt
CommandCost CmdChangeServiceInt(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Change the service interval of a vehicle.
Definition: vehicle_cmd.cpp:1113
CmdBuildDock
CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build a dock/haven.
Definition: station_cmd.cpp:2525
backup_type.hpp