src/command.cpp
author glx
Wed, 09 Jan 2008 17:47:05 +0000
changeset 8232 a4883a0598db
parent 8230 64f28fe2d5c8
child 8247 16e1c8db6f55
permissions -rw-r--r--
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
     3
/** @file command.cpp */
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1877
diff changeset
     6
#include "openttd.h"
507
04b5403aaf6b (svn r815) Include strings.h only in the files which need it.
tron
parents: 467
diff changeset
     7
#include "table/strings.h"
6453
226bcddeba32 (svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros
parents: 6444
diff changeset
     8
#include "landscape.h"
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8107
diff changeset
     9
#include "tile_map.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
#include "gui.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    11
#include "command_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "player.h"
5469
7edfc643abbc (svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents: 5067
diff changeset
    13
#include "network/network.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 1980
diff changeset
    14
#include "variables.h"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4000
diff changeset
    15
#include "genworld.h"
7609
b70ffc13652a (svn r11138) -Codechange: prepare some subsystems for persistent storage for NewGRFs.
rubidium
parents: 7559
diff changeset
    16
#include "newgrf_storage.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8108
diff changeset
    17
#include "strings_func.h"
8123
ce31d2843a95 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8116
diff changeset
    18
#include "gfx_func.h"
8131
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8123
diff changeset
    19
#include "functions.h"
8232
a4883a0598db (svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents: 8230
diff changeset
    20
#include "town.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
7559
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
    22
const char *_cmd_text = NULL;
1820
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1804
diff changeset
    23
7559
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
    24
/**
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
    25
 * Helper macro to define the header of all command handler macros.
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
    26
 *
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
    27
 * This macro create the function header for a given command handler function, as
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
    28
 * all command handler functions got the parameters from the #CommandProc callback
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
    29
 * type.
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
    30
 *
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
    31
 * @param yyyy The desired function name of the new command handler function.
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
    32
 */
6943
1914f26aee04 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 6832
diff changeset
    33
#define DEF_COMMAND(yyyy) CommandCost yyyy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
DEF_COMMAND(CmdBuildRailroadTrack);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
DEF_COMMAND(CmdRemoveRailroadTrack);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
DEF_COMMAND(CmdBuildSingleRail);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
DEF_COMMAND(CmdRemoveSingleRail);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
DEF_COMMAND(CmdLandscapeClear);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
DEF_COMMAND(CmdBuildBridge);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
DEF_COMMAND(CmdBuildRailroadStation);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
DEF_COMMAND(CmdRemoveFromRailroadStation);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
DEF_COMMAND(CmdConvertRail);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
1227
1d940a5e02d2 (svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents: 1217
diff changeset
    48
DEF_COMMAND(CmdBuildSingleSignal);
1d940a5e02d2 (svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents: 1217
diff changeset
    49
DEF_COMMAND(CmdRemoveSingleSignal);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
DEF_COMMAND(CmdTerraformLand);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
DEF_COMMAND(CmdPurchaseLandArea);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
DEF_COMMAND(CmdSellLandArea);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
DEF_COMMAND(CmdBuildTunnel);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
DEF_COMMAND(CmdBuildTrainDepot);
395
788a9bba0889 (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents: 215
diff changeset
    59
DEF_COMMAND(CmdBuildTrainWaypoint);
788a9bba0889 (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents: 215
diff changeset
    60
DEF_COMMAND(CmdRenameWaypoint);
788a9bba0889 (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents: 215
diff changeset
    61
DEF_COMMAND(CmdRemoveTrainWaypoint);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
1217
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    63
DEF_COMMAND(CmdBuildRoadStop);
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5587
diff changeset
    64
DEF_COMMAND(CmdRemoveRoadStop);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
DEF_COMMAND(CmdBuildLongRoad);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
DEF_COMMAND(CmdRemoveLongRoad);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
DEF_COMMAND(CmdBuildRoad);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
DEF_COMMAND(CmdRemoveRoad);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
DEF_COMMAND(CmdBuildRoadDepot);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
DEF_COMMAND(CmdBuildAirport);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
DEF_COMMAND(CmdBuildDock);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
DEF_COMMAND(CmdBuildShipDepot);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
DEF_COMMAND(CmdBuildBuoy);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
DEF_COMMAND(CmdPlantTree);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
DEF_COMMAND(CmdBuildRailVehicle);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
DEF_COMMAND(CmdMoveRailVehicle);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
DEF_COMMAND(CmdStartStopTrain);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
DEF_COMMAND(CmdSellRailWagon);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
1794
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1786
diff changeset
    90
DEF_COMMAND(CmdSendTrainToDepot);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
DEF_COMMAND(CmdForceTrainProceed);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
DEF_COMMAND(CmdReverseTrainDirection);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
DEF_COMMAND(CmdModifyOrder);
6794
feec0fe8e824 (svn r10033) -Feature [FS#760]: skip to the selected order in the order list when clicking on the "skip" button while pressing CTRL.
rubidium
parents: 6667
diff changeset
    95
DEF_COMMAND(CmdSkipToOrder);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
DEF_COMMAND(CmdDeleteOrder);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
DEF_COMMAND(CmdInsertOrder);
2819
f25fb6ee397f (svn r3367) Unify the 4 distinct CMD_CHANGE_{AIRCRAFT,ROADVEH,SHIP,TRAIN}_SERVICE_INT commands into one CMD_CHANGE_SERVICE_INT command.
tron
parents: 2809
diff changeset
    98
DEF_COMMAND(CmdChangeServiceInt);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
DEF_COMMAND(CmdRestoreOrderIndex);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
DEF_COMMAND(CmdBuildIndustry);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
DEF_COMMAND(CmdBuildCompanyHQ);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
DEF_COMMAND(CmdSetPlayerFace);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
DEF_COMMAND(CmdSetPlayerColor);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
DEF_COMMAND(CmdIncreaseLoan);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
DEF_COMMAND(CmdDecreaseLoan);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
DEF_COMMAND(CmdWantEnginePreview);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
DEF_COMMAND(CmdNameVehicle);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
DEF_COMMAND(CmdRenameEngine);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
DEF_COMMAND(CmdChangeCompanyName);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
DEF_COMMAND(CmdChangePresidentName);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
DEF_COMMAND(CmdRenameStation);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
DEF_COMMAND(CmdSellAircraft);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
DEF_COMMAND(CmdStartStopAircraft);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
DEF_COMMAND(CmdBuildAircraft);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
DEF_COMMAND(CmdSendAircraftToHangar);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
DEF_COMMAND(CmdRefitAircraft);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
DEF_COMMAND(CmdPlaceSign);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
DEF_COMMAND(CmdRenameSign);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
DEF_COMMAND(CmdBuildRoadVeh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
DEF_COMMAND(CmdStartStopRoadVeh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
DEF_COMMAND(CmdSellRoadVeh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
DEF_COMMAND(CmdSendRoadVehToDepot);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
DEF_COMMAND(CmdTurnRoadVeh);
3990
a317e665fb77 (svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents: 3491
diff changeset
   134
DEF_COMMAND(CmdRefitRoadVeh);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
DEF_COMMAND(CmdPause);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
DEF_COMMAND(CmdBuyShareInCompany);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
DEF_COMMAND(CmdSellShareInCompany);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
DEF_COMMAND(CmdBuyCompany);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
DEF_COMMAND(CmdBuildTown);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
DEF_COMMAND(CmdRenameTown);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
DEF_COMMAND(CmdDoTownAction);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
DEF_COMMAND(CmdSetRoadDriveSide);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
DEF_COMMAND(CmdChangeDifficultyLevel);
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   150
DEF_COMMAND(CmdChangePatchSetting);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
DEF_COMMAND(CmdStartStopShip);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
DEF_COMMAND(CmdSellShip);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
DEF_COMMAND(CmdBuildShip);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
DEF_COMMAND(CmdSendShipToDepot);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
DEF_COMMAND(CmdRefitShip);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
4712
4335ad42e163 (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4662
diff changeset
   158
DEF_COMMAND(CmdOrderRefit);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
DEF_COMMAND(CmdCloneOrder);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
DEF_COMMAND(CmdClearArea);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   163
DEF_COMMAND(CmdGiveMoney);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
DEF_COMMAND(CmdMoneyCheat);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
DEF_COMMAND(CmdBuildCanal);
147
d0c8100d18cf (svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents: 58
diff changeset
   166
DEF_COMMAND(CmdBuildLock);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
DEF_COMMAND(CmdPlayerCtrl);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
DEF_COMMAND(CmdLevelLand);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
DEF_COMMAND(CmdRefitRailVehicle);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
1227
1d940a5e02d2 (svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents: 1217
diff changeset
   174
DEF_COMMAND(CmdBuildSignalTrack);
1d940a5e02d2 (svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents: 1217
diff changeset
   175
DEF_COMMAND(CmdRemoveSignalTrack);
58
b9fdcc9b5c90 (svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents: 0
diff changeset
   176
4661
89c3cbba9846 (svn r6544) - Codechange: Rename CmdReplaceVehicle to CmdSetAutoReplace, to reflect what it does.
peter1138
parents: 4659
diff changeset
   177
DEF_COMMAND(CmdSetAutoReplace);
812
65ecc321b3db (svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents: 679
diff changeset
   178
2244
417a472e7cb5 (svn r2764) -Feature: Clone vehicles
bjarni
parents: 2204
diff changeset
   179
DEF_COMMAND(CmdCloneVehicle);
4640
4e380e2ecfa7 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4300
diff changeset
   180
DEF_COMMAND(CmdMassStartStopVehicle);
4659
e476c76389a8 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4640
diff changeset
   181
DEF_COMMAND(CmdDepotSellAllVehicles);
4662
e36935c7bdde (svn r6552) -Feature: [depot window] added a "autoreplace all vehicles in depot" button
bjarni
parents: 4661
diff changeset
   182
DEF_COMMAND(CmdDepotMassAutoReplace);
2244
417a472e7cb5 (svn r2764) -Feature: Clone vehicles
bjarni
parents: 2204
diff changeset
   183
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6630
diff changeset
   184
DEF_COMMAND(CmdCreateGroup);
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6630
diff changeset
   185
DEF_COMMAND(CmdRenameGroup);
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6630
diff changeset
   186
DEF_COMMAND(CmdDeleteGroup);
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6630
diff changeset
   187
DEF_COMMAND(CmdAddVehicleGroup);
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6630
diff changeset
   188
DEF_COMMAND(CmdAddSharedVehicleGroup);
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6630
diff changeset
   189
DEF_COMMAND(CmdRemoveAllVehiclesGroup);
6667
dba8ef60ffd2 (svn r9898) -Fix (r9874): Many...
peter1138
parents: 6643
diff changeset
   190
DEF_COMMAND(CmdSetGroupReplaceProtection);
dba8ef60ffd2 (svn r9898) -Fix (r9874): Many...
peter1138
parents: 6643
diff changeset
   191
6832
fec0caeac27d (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 6794
diff changeset
   192
DEF_COMMAND(CmdMoveOrder);
6980
c7c4f3bf5901 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 6957
diff changeset
   193
DEF_COMMAND(CmdChangeTimetable);
c7c4f3bf5901 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 6957
diff changeset
   194
DEF_COMMAND(CmdSetVehicleOnTime);
7066
e5d16aa8d6ca (svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents: 7002
diff changeset
   195
DEF_COMMAND(CmdAutofillTimetable);
7559
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   196
#undef DEF_COMMAND
1804
fbe724472bb4 (svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents: 1802
diff changeset
   197
7559
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   198
/**
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   199
 * The master command table
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   200
 *
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   201
 * This table contains all possible CommandProc functions with
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   202
 * the flags which belongs to it. The indizes are the same
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   203
 * as the value from the CMD_* enums.
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   204
 */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   205
static const Command _command_proc_table[] = {
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   206
	{CmdBuildRailroadTrack,           CMD_AUTO}, /*   0, CMD_BUILD_RAILROAD_TRACK */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   207
	{CmdRemoveRailroadTrack,          CMD_AUTO}, /*   1, CMD_REMOVE_RAILROAD_TRACK */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   208
	{CmdBuildSingleRail,              CMD_AUTO}, /*   2, CMD_BUILD_SINGLE_RAIL */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   209
	{CmdRemoveSingleRail,             CMD_AUTO}, /*   3, CMD_REMOVE_SINGLE_RAIL */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   210
	{CmdLandscapeClear,                      0}, /*   4, CMD_LANDSCAPE_CLEAR */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   211
	{CmdBuildBridge,                  CMD_AUTO}, /*   5, CMD_BUILD_BRIDGE */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   212
	{CmdBuildRailroadStation,         CMD_AUTO}, /*   6, CMD_BUILD_RAILROAD_STATION */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   213
	{CmdBuildTrainDepot,              CMD_AUTO}, /*   7, CMD_BUILD_TRAIN_DEPOT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   214
	{CmdBuildSingleSignal,            CMD_AUTO}, /*   8, CMD_BUILD_SIGNALS */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   215
	{CmdRemoveSingleSignal,           CMD_AUTO}, /*   9, CMD_REMOVE_SIGNALS */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   216
	{CmdTerraformLand,                CMD_AUTO}, /*  10, CMD_TERRAFORM_LAND */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   217
	{CmdPurchaseLandArea,             CMD_AUTO}, /*  11, CMD_PURCHASE_LAND_AREA */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   218
	{CmdSellLandArea,                        0}, /*  12, CMD_SELL_LAND_AREA */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   219
	{CmdBuildTunnel,                  CMD_AUTO}, /*  13, CMD_BUILD_TUNNEL */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   220
	{CmdRemoveFromRailroadStation,           0}, /*  14, CMD_REMOVE_FROM_RAILROAD_STATION */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   221
	{CmdConvertRail,                         0}, /*  15, CMD_CONVERT_RAILD */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   222
	{CmdBuildTrainWaypoint,                  0}, /*  16, CMD_BUILD_TRAIN_WAYPOINT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   223
	{CmdRenameWaypoint,                      0}, /*  17, CMD_RENAME_WAYPOINT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   224
	{CmdRemoveTrainWaypoint,                 0}, /*  18, CMD_REMOVE_TRAIN_WAYPOINT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   225
	{NULL,                                   0}, /*  19, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   226
	{NULL,                                   0}, /*  20, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   227
	{CmdBuildRoadStop,                CMD_AUTO}, /*  21, CMD_BUILD_ROAD_STOP */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   228
	{CmdRemoveRoadStop,                      0}, /*  22, CMD_REMOVE_ROAD_STOP */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   229
	{CmdBuildLongRoad,                CMD_AUTO}, /*  23, CMD_BUILD_LONG_ROAD */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   230
	{CmdRemoveLongRoad,               CMD_AUTO}, /*  24, CMD_REMOVE_LONG_ROAD */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   231
	{CmdBuildRoad,                           0}, /*  25, CMD_BUILD_ROAD */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   232
	{CmdRemoveRoad,                          0}, /*  26, CMD_REMOVE_ROAD */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   233
	{CmdBuildRoadDepot,               CMD_AUTO}, /*  27, CMD_BUILD_ROAD_DEPOT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   234
	{NULL,                                   0}, /*  28, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   235
	{CmdBuildAirport,                 CMD_AUTO}, /*  29, CMD_BUILD_AIRPORT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   236
	{CmdBuildDock,                    CMD_AUTO}, /*  30, CMD_BUILD_DOCK */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   237
	{CmdBuildShipDepot,               CMD_AUTO}, /*  31, CMD_BUILD_SHIP_DEPOT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   238
	{CmdBuildBuoy,                    CMD_AUTO}, /*  32, CMD_BUILD_BUOY */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   239
	{CmdPlantTree,                    CMD_AUTO}, /*  33, CMD_PLANT_TREE */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   240
	{CmdBuildRailVehicle,                    0}, /*  34, CMD_BUILD_RAIL_VEHICLE */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   241
	{CmdMoveRailVehicle,                     0}, /*  35, CMD_MOVE_RAIL_VEHICLE */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   242
	{CmdStartStopTrain,                      0}, /*  36, CMD_START_STOP_TRAIN */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   243
	{NULL,                                   0}, /*  37, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   244
	{CmdSellRailWagon,                       0}, /*  38, CMD_SELL_RAIL_WAGON */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   245
	{CmdSendTrainToDepot,                    0}, /*  39, CMD_SEND_TRAIN_TO_DEPOT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   246
	{CmdForceTrainProceed,                   0}, /*  40, CMD_FORCE_TRAIN_PROCEED */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   247
	{CmdReverseTrainDirection,               0}, /*  41, CMD_REVERSE_TRAIN_DIRECTION */
1804
fbe724472bb4 (svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents: 1802
diff changeset
   248
7559
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   249
	{CmdModifyOrder,                         0}, /*  42, CMD_MODIFY_ORDER */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   250
	{CmdSkipToOrder,                         0}, /*  43, CMD_SKIP_TO_ORDER */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   251
	{CmdDeleteOrder,                         0}, /*  44, CMD_DELETE_ORDER */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   252
	{CmdInsertOrder,                         0}, /*  45, CMD_INSERT_ORDER */
1804
fbe724472bb4 (svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents: 1802
diff changeset
   253
7559
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   254
	{CmdChangeServiceInt,                    0}, /*  46, CMD_CHANGE_SERVICE_INT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   255
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   256
	{CmdBuildIndustry,                       0}, /*  47, CMD_BUILD_INDUSTRY */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   257
	{CmdBuildCompanyHQ,               CMD_AUTO}, /*  48, CMD_BUILD_COMPANY_HQ */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   258
	{CmdSetPlayerFace,                       0}, /*  49, CMD_SET_PLAYER_FACE */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   259
	{CmdSetPlayerColor,                      0}, /*  50, CMD_SET_PLAYER_COLOR */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   260
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   261
	{CmdIncreaseLoan,                        0}, /*  51, CMD_INCREASE_LOAN */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   262
	{CmdDecreaseLoan,                        0}, /*  52, CMD_DECREASE_LOAN */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   263
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   264
	{CmdWantEnginePreview,                   0}, /*  53, CMD_WANT_ENGINE_PREVIEW */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   265
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   266
	{CmdNameVehicle,                         0}, /*  54, CMD_NAME_VEHICLE */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   267
	{CmdRenameEngine,                        0}, /*  55, CMD_RENAME_ENGINE */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   268
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   269
	{CmdChangeCompanyName,                   0}, /*  56, CMD_CHANGE_COMPANY_NAME */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   270
	{CmdChangePresidentName,                 0}, /*  57, CMD_CHANGE_PRESIDENT_NAME */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   271
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   272
	{CmdRenameStation,                       0}, /*  58, CMD_RENAME_STATION */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   273
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   274
	{CmdSellAircraft,                        0}, /*  59, CMD_SELL_AIRCRAFT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   275
	{CmdStartStopAircraft,                   0}, /*  60, CMD_START_STOP_AIRCRAFT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   276
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   277
	{CmdBuildAircraft,                       0}, /*  61, CMD_BUILD_AIRCRAFT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   278
	{CmdSendAircraftToHangar,                0}, /*  62, CMD_SEND_AIRCRAFT_TO_HANGAR */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   279
	{NULL,                                   0}, /*  63, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   280
	{CmdRefitAircraft,                       0}, /*  64, CMD_REFIT_AIRCRAFT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   281
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   282
	{CmdPlaceSign,                           0}, /*  65, CMD_PLACE_SIGN */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   283
	{CmdRenameSign,                          0}, /*  66, CMD_RENAME_SIGN */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   284
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   285
	{CmdBuildRoadVeh,                        0}, /*  67, CMD_BUILD_ROAD_VEH */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   286
	{CmdStartStopRoadVeh,                    0}, /*  68, CMD_START_STOP_ROADVEH */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   287
	{CmdSellRoadVeh,                         0}, /*  69, CMD_SELL_ROAD_VEH */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   288
	{CmdSendRoadVehToDepot,                  0}, /*  70, CMD_SEND_ROADVEH_TO_DEPOT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   289
	{CmdTurnRoadVeh,                         0}, /*  71, CMD_TURN_ROADVEH */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   290
	{CmdRefitRoadVeh,                        0}, /*  72, CMD_REFIT_ROAD_VEH */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   291
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   292
	{CmdPause,                      CMD_SERVER}, /*  73, CMD_PAUSE */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   293
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   294
	{CmdBuyShareInCompany,                   0}, /*  74, CMD_BUY_SHARE_IN_COMPANY */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   295
	{CmdSellShareInCompany,                  0}, /*  75, CMD_SELL_SHARE_IN_COMPANY */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   296
	{CmdBuyCompany,                          0}, /*  76, CMD_BUY_COMANY */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   297
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   298
	{CmdBuildTown,                 CMD_OFFLINE}, /*  77, CMD_BUILD_TOWN */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   299
	{NULL,                                   0}, /*  78, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   300
	{NULL,                                   0}, /*  79, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   301
	{CmdRenameTown,                 CMD_SERVER}, /*  80, CMD_RENAME_TOWN */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   302
	{CmdDoTownAction,                        0}, /*  81, CMD_DO_TOWN_ACTION */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   303
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   304
	{CmdSetRoadDriveSide,           CMD_SERVER}, /*  82, CMD_SET_ROAD_DRIVE_SIDE */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   305
	{NULL,                                   0}, /*  83, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   306
	{NULL,                                   0}, /*  84, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   307
	{CmdChangeDifficultyLevel,      CMD_SERVER}, /*  85, CMD_CHANGE_DIFFICULTY_LEVEL */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   308
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   309
	{CmdStartStopShip,                       0}, /*  86, CMD_START_STOP_SHIP */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   310
	{CmdSellShip,                            0}, /*  87, CMD_SELL_SHIP */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   311
	{CmdBuildShip,                           0}, /*  88, CMD_BUILD_SHIP */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   312
	{CmdSendShipToDepot,                     0}, /*  89, CMD_SEND_SHIP_TO_DEPOT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   313
	{NULL,                                   0}, /*  90, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   314
	{CmdRefitShip,                           0}, /*  91, CMD_REFIT_SHIP */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   315
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   316
	{NULL,                                   0}, /*  92, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   317
	{NULL,                                   0}, /*  93, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   318
	{NULL,                                   0}, /*  94, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   319
	{NULL,                                   0}, /*  95, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   320
	{NULL,                                   0}, /*  96, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   321
	{NULL,                                   0}, /*  97, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   322
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   323
	{CmdOrderRefit,                          0}, /*  98, CMD_ORDER_REFIT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   324
	{CmdCloneOrder,                          0}, /*  99, CMD_CLONE_ORDER */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   325
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   326
	{CmdClearArea,                           0}, /* 100, CMD_CLEAR_AREA */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   327
	{NULL,                                   0}, /* 101, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   328
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   329
	{CmdMoneyCheat,                CMD_OFFLINE}, /* 102, CMD_MONEY_CHEAT */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   330
	{CmdBuildCanal,                   CMD_AUTO}, /* 103, CMD_BUILD_CANAL */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   331
	{CmdPlayerCtrl,                          0}, /* 104, CMD_PLAYER_CTRL */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   332
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   333
	{CmdLevelLand,                    CMD_AUTO}, /* 105, CMD_LEVEL_LAND */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   334
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   335
	{CmdRefitRailVehicle,                    0}, /* 106, CMD_REFIT_RAIL_VEHICLE */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   336
	{CmdRestoreOrderIndex,                   0}, /* 107, CMD_RESTORE_ORDER_INDEX */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   337
	{CmdBuildLock,                    CMD_AUTO}, /* 108, CMD_BUILD_LOCK */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   338
	{NULL,                                   0}, /* 109, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   339
	{CmdBuildSignalTrack,             CMD_AUTO}, /* 110, CMD_BUILD_SIGNAL_TRACK */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   340
	{CmdRemoveSignalTrack,            CMD_AUTO}, /* 111, CMD_REMOVE_SIGNAL_TRACK */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   341
	{NULL,                                   0}, /* 112, unused */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   342
	{CmdGiveMoney,                           0}, /* 113, CMD_GIVE_MONEY */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   343
	{CmdChangePatchSetting,         CMD_SERVER}, /* 114, CMD_CHANGE_PATCH_SETTING */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   344
	{CmdSetAutoReplace,                      0}, /* 115, CMD_SET_AUTOREPLACE */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   345
	{CmdCloneVehicle,                        0}, /* 116, CMD_CLONE_VEHICLE */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   346
	{CmdMassStartStopVehicle,                0}, /* 117, CMD_MASS_START_STOP */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   347
	{CmdDepotSellAllVehicles,                0}, /* 118, CMD_DEPOT_SELL_ALL_VEHICLES */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   348
	{CmdDepotMassAutoReplace,                0}, /* 119, CMD_DEPOT_MASS_AUTOREPLACE */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   349
	{CmdCreateGroup,                         0}, /* 120, CMD_CREATE_GROUP */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   350
	{CmdDeleteGroup,                         0}, /* 121, CMD_DELETE_GROUP */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   351
	{CmdRenameGroup,                         0}, /* 122, CMD_RENAME_GROUP */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   352
	{CmdAddVehicleGroup,                     0}, /* 123, CMD_ADD_VEHICLE_GROUP */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   353
	{CmdAddSharedVehicleGroup,               0}, /* 124, CMD_ADD_SHARE_VEHICLE_GROUP */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   354
	{CmdRemoveAllVehiclesGroup,              0}, /* 125, CMD_REMOVE_ALL_VEHICLES_GROUP */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   355
	{CmdSetGroupReplaceProtection,           0}, /* 126, CMD_SET_GROUP_REPLACE_PROTECTION */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   356
	{CmdMoveOrder,                           0}, /* 127, CMD_MOVE_ORDER */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   357
	{CmdChangeTimetable,                     0}, /* 128, CMD_CHANGE_TIMETABLE */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   358
	{CmdSetVehicleOnTime,                    0}, /* 129, CMD_SET_VEHICLE_ON_TIME */
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   359
	{CmdAutofillTimetable,                   0}, /* 130, CMD_AUTOFILL_TIMETABLE */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
7559
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   362
/*!
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   363
 * This function range-checks a cmd, and checks if the cmd is not NULL
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   364
 *
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   365
 * @param cmd The integervalue of a command
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   366
 * @return true if the command is valid (and got a CommandProc function)
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   367
 */
959
e6a3bbda610f (svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents: 926
diff changeset
   368
bool IsValidCommand(uint cmd)
903
a301a264e0fc (svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents: 889
diff changeset
   369
{
2645
841087328e0e (svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents: 2425
diff changeset
   370
	cmd &= 0xFF;
903
a301a264e0fc (svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents: 889
diff changeset
   371
2645
841087328e0e (svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents: 2425
diff changeset
   372
	return
841087328e0e (svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents: 2425
diff changeset
   373
		cmd < lengthof(_command_proc_table) &&
841087328e0e (svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents: 2425
diff changeset
   374
		_command_proc_table[cmd].proc != NULL;
903
a301a264e0fc (svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents: 889
diff changeset
   375
}
a301a264e0fc (svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents: 889
diff changeset
   376
7559
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   377
/*!
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   378
 * This function mask the parameter with 0xFF and returns
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   379
 * the flags which belongs to the given command.
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   380
 *
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   381
 * @param cmd The integer value of the command
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   382
 * @return The flags for this command
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   383
 * @bug integervalues which are less equals 0xFF and greater than the
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   384
 *      size of _command_proc_table can result in an index out of bounce
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   385
 *      error (which doesn't happend anyway). Check function #IsValidCommand(). (Progman)
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   386
 */
4000
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3991
diff changeset
   387
byte GetCommandFlags(uint cmd)
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3991
diff changeset
   388
{
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3991
diff changeset
   389
	return _command_proc_table[cmd & 0xFF].flags;
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3991
diff changeset
   390
}
1804
fbe724472bb4 (svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents: 1802
diff changeset
   391
8232
a4883a0598db (svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents: 8230
diff changeset
   392
static int _docommand_recursive = 0;
2304
bebc1ee33ab2 (svn r2828) Only command.c needs to know about _docommand_recursive, so make it static. Tell me if there's a problem, because i removed it from network_server.c, but afaict it should be ok
tron
parents: 2244
diff changeset
   393
7559
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   394
/*!
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   395
 * This function executes a given command with the parameters from the #CommandProc parameter list.
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   396
 * Depending on the flags parameter it execute or test a command.
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   397
 *
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   398
 * @param tile The tile to apply the command on (for the #CommandProc)
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   399
 * @param p1 Additional data for the command (for the #CommandProc)
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   400
 * @param p2 Additional data for the command (for the #CommandProc)
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   401
 * @param flags Flags for the command and how to execute the command
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   402
 * @param procc The command-id to execute (a value of the CMD_* enums)
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   403
 * @see CommandProc
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   404
 */
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
   405
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
{
6943
1914f26aee04 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 6832
diff changeset
   407
	CommandCost res;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   408
	CommandProc *proc;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   409
1776
956f8589024d (svn r2280) - Fix: Check if the passed tile to DoCommand is within the current mapsize
Darkvater
parents: 1728
diff changeset
   410
	/* Do not even think about executing out-of-bounds tile-commands */
6630
265be601dc89 (svn r9855) -Fix: [FS#779] do not perform any commands on MP_VOID tiles.
rubidium
parents: 6546
diff changeset
   411
	if (tile >= MapSize() || IsTileType(tile, MP_VOID)) {
1820
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1804
diff changeset
   412
		_cmd_text = NULL;
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1804
diff changeset
   413
		return CMD_ERROR;
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1804
diff changeset
   414
	}
1776
956f8589024d (svn r2280) - Fix: Check if the passed tile to DoCommand is within the current mapsize
Darkvater
parents: 1728
diff changeset
   415
1804
fbe724472bb4 (svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents: 1802
diff changeset
   416
	proc = _command_proc_table[procc].proc;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
2749
c9312a4a1efe (svn r3294) - Fix: use INVALID_STRING_ID instead of -1.
Darkvater
parents: 2715
diff changeset
   418
	if (_docommand_recursive == 0) _error_message = INVALID_STRING_ID;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   419
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   420
	_docommand_recursive++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   422
	/* only execute the test call if it's toplevel, or we're not execing. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
	if (_docommand_recursive == 1 || !(flags & DC_EXEC) || (flags & DC_FORCETEST) ) {
8232
a4883a0598db (svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents: 8230
diff changeset
   424
		SetTownRatingTestMode(true);
3491
35d747bb5e82 (svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents: 3421
diff changeset
   425
		res = proc(tile, flags & ~DC_EXEC, p1, p2);
8232
a4883a0598db (svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents: 8230
diff changeset
   426
		SetTownRatingTestMode(false);
1691
852ca27d6eef (svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents: 1623
diff changeset
   427
		if (CmdFailed(res)) {
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   428
			res.SetGlobalErrorMessage();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   429
			goto error;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   431
4000
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3991
diff changeset
   432
		if (_docommand_recursive == 1 &&
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3991
diff changeset
   433
				!(flags & DC_QUERY_COST) &&
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   434
				res.GetCost() != 0 &&
4000
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3991
diff changeset
   435
				!CheckPlayerHasMoney(res)) {
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3991
diff changeset
   436
			goto error;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   437
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
		if (!(flags & DC_EXEC)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   440
			_docommand_recursive--;
1820
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1804
diff changeset
   441
			_cmd_text = NULL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   442
			return res;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   445
889
64d2f7d5f02b (svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents: 842
diff changeset
   446
	/* Execute the command here. All cost-relevant functions set the expenses type
8230
64f28fe2d5c8 (svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents: 8199
diff changeset
   447
	 * themselves to the cost object at some point */
3491
35d747bb5e82 (svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents: 3421
diff changeset
   448
	res = proc(tile, flags, p1, p2);
1691
852ca27d6eef (svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents: 1623
diff changeset
   449
	if (CmdFailed(res)) {
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   450
		res.SetGlobalErrorMessage();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
error:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
		_docommand_recursive--;
1820
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1804
diff changeset
   453
		_cmd_text = NULL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
		return CMD_ERROR;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   456
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   457
	/* if toplevel, subtract the money. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   458
	if (--_docommand_recursive == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   459
		SubtractMoneyFromPlayer(res);
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   460
		/* XXX - Old AI hack which doesn't use DoCommandDP; update last build coord of player */
4850
93095755db8c (svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents: 4848
diff changeset
   461
		if (tile != 0 && IsValidPlayer(_current_player)) {
3491
35d747bb5e82 (svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents: 3421
diff changeset
   462
			GetPlayer(_current_player)->last_build_coordinate = tile;
2772
593f2304e5ea (svn r3319) - Fix (regression): "Unnamed Competitors". A result of revision r3224 which allowed AI's for multiplayer. Old AI's didn't function correctly anymore. The update of last-built tile is moved back, but to a slightly different place so it is only executed when the command is actually successfully executed. This code shouldn't be neccessary, but alas, the old AI doesn't use DoCommandDP() functions.
Darkvater
parents: 2767
diff changeset
   463
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   464
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   465
1820
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1804
diff changeset
   466
	_cmd_text = NULL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
	return res;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
7559
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   470
/*!
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   471
 * This functions returns the money which can be used to execute a command.
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   472
 * This is either the money of the current player or INT64_MAX if there
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   473
 * is no such a player "at the moment" like the server itself.
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   474
 *
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   475
 * @return The available money of a player or INT64_MAX
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   476
 */
6990
136a08baf0ed (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents: 6980
diff changeset
   477
Money GetAvailableMoneyForCommand()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   478
{
1794
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1786
diff changeset
   479
	PlayerID pid = _current_player;
6990
136a08baf0ed (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents: 6980
diff changeset
   480
	if (!IsValidPlayer(pid)) return INT64_MAX;
1962
8254df1b359b (svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents: 1891
diff changeset
   481
	return GetPlayer(pid)->player_money;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   482
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   483
7559
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   484
/*!
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   485
 * Toplevel network safe docommand function for the current player. Must not be called recursively.
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   486
 * The callback is called when the command succeeded or failed. The parameters
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   487
 * tile, p1 and p2 are from the #CommandProc function. The paramater cmd is the command to execute.
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   488
 * The parameter my_cmd is used to indicate if the command is from a player or the server.
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   489
 *
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   490
 * @param tile The tile to perform a command on (see #CommandProc)
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   491
 * @param p1 Additional data for the command (see #CommandProc)
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   492
 * @param p2 Additional data for the command (see #CommandProc)
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   493
 * @param callback A callback function to call after the command is finished
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   494
 * @param cmd The command to execute (a CMD_* value)
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   495
 * @param my_cmd indicator if the command is from a player or server (to display error messages for a user)
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   496
 * @return true if the command succeeded, else false
40d62002dad3 (svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents: 7521
diff changeset
   497
 */
7222
d46753675bf7 (svn r10501) -Fix [FS#1015]: error dialog was sometimes shown on all clients when a command failed instead of only the client that actually did the command.
rubidium
parents: 7066
diff changeset
   498
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   499
{
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   500
	CommandCost res, res2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   501
	CommandProc *proc;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   502
	uint32 flags;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   503
	bool notest;
3182
0cec126ca9a9 (svn r3827) Remove the global variable _error_message_2, it's only used as local variable
tron
parents: 2820
diff changeset
   504
	StringID error_part1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
3421
7968a4b5ff0a (svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents: 3182
diff changeset
   506
	int x = TileX(tile) * TILE_SIZE;
7968a4b5ff0a (svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents: 3182
diff changeset
   507
	int y = TileY(tile) * TILE_SIZE;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   508
1776
956f8589024d (svn r2280) - Fix: Check if the passed tile to DoCommand is within the current mapsize
Darkvater
parents: 1728
diff changeset
   509
	/* Do not even think about executing out-of-bounds tile-commands */
6630
265be601dc89 (svn r9855) -Fix: [FS#779] do not perform any commands on MP_VOID tiles.
rubidium
parents: 6546
diff changeset
   510
	if (tile >= MapSize() || IsTileType(tile, MP_VOID)) {
1820
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1804
diff changeset
   511
		_cmd_text = NULL;
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1804
diff changeset
   512
		return false;
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1804
diff changeset
   513
	}
1776
956f8589024d (svn r2280) - Fix: Check if the passed tile to DoCommand is within the current mapsize
Darkvater
parents: 1728
diff changeset
   514
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   515
	assert(_docommand_recursive == 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   516
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   517
	_error_message = INVALID_STRING_ID;
3182
0cec126ca9a9 (svn r3827) Remove the global variable _error_message_2, it's only used as local variable
tron
parents: 2820
diff changeset
   518
	error_part1 = GB(cmd, 16, 16);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
	_additional_cash_required = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   520
5067
f3816e74ad32 (svn r7125) -Fix: Several errors/glitches related to multiplayer and bankrupcy, mainly such a
Darkvater
parents: 4850
diff changeset
   521
	/** Spectator has no rights except for the (dedicated) server which
f3816e74ad32 (svn r7125) -Fix: Several errors/glitches related to multiplayer and bankrupcy, mainly such a
Darkvater
parents: 4850
diff changeset
   522
	 * is/can be a spectator but as the server it can do anything */
f3816e74ad32 (svn r7125) -Fix: Several errors/glitches related to multiplayer and bankrupcy, mainly such a
Darkvater
parents: 4850
diff changeset
   523
	if (_current_player == PLAYER_SPECTATOR && !_network_server) {
7222
d46753675bf7 (svn r10501) -Fix [FS#1015]: error dialog was sometimes shown on all clients when a command failed instead of only the client that actually did the command.
rubidium
parents: 7066
diff changeset
   524
		if (my_cmd) ShowErrorMessage(_error_message, error_part1, x, y);
1820
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1804
diff changeset
   525
		_cmd_text = NULL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   526
		return false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   527
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   528
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
	flags = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   530
	if (cmd & CMD_NO_WATER) flags |= DC_NO_WATER;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   532
	/* get pointer to command handler */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   533
	assert((cmd & 0xFF) < lengthof(_command_proc_table));
1804
fbe724472bb4 (svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents: 1802
diff changeset
   534
	proc = _command_proc_table[cmd & 0xFF].proc;
1877
ab6a315fa930 (svn r2383) - Fix: Monkey-testing turned up some command crashes.
Darkvater
parents: 1838
diff changeset
   535
	if (proc == NULL) {
ab6a315fa930 (svn r2383) - Fix: Monkey-testing turned up some command crashes.
Darkvater
parents: 1838
diff changeset
   536
		_cmd_text = NULL;
ab6a315fa930 (svn r2383) - Fix: Monkey-testing turned up some command crashes.
Darkvater
parents: 1838
diff changeset
   537
		return false;
ab6a315fa930 (svn r2383) - Fix: Monkey-testing turned up some command crashes.
Darkvater
parents: 1838
diff changeset
   538
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   539
7521
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7506
diff changeset
   540
	if (GetCommandFlags(cmd) & CMD_AUTO) flags |= DC_AUTO;
0da1e91510e4 (svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents: 7506
diff changeset
   541
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   542
	/* Some commands have a different output in dryrun than the realrun
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   543
	 *  e.g.: if you demolish a whole town, the dryrun would say okay.
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   544
	 *  but by really destroying, your rating drops and at a certain point
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   545
	 *  it will fail. so res and res2 are different
8232
a4883a0598db (svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents: 8230
diff changeset
   546
	 * CMD_REMOVE_LONG_ROAD: This command has special local authority
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   547
	 * restrictions which may cause the test run to fail (the previous
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   548
	 * road fragments still stay there and the town won't let you
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   549
	 * disconnect the road system), but the exec will succeed and this
6546
4c6d90bde803 (svn r9742) -Fix (r9689) [FS#739]: Fix cloning with refit costs again, hopefully for good this time.
maedhros
parents: 6491
diff changeset
   550
	 * fact will trigger an assertion failure. --pasky
4c6d90bde803 (svn r9742) -Fix (r9689) [FS#739]: Fix cloning with refit costs again, hopefully for good this time.
maedhros
parents: 6491
diff changeset
   551
	 * CMD_CLONE_VEHICLE: Both building new vehicles and refitting them can be
4c6d90bde803 (svn r9742) -Fix (r9689) [FS#739]: Fix cloning with refit costs again, hopefully for good this time.
maedhros
parents: 6491
diff changeset
   552
	 * influenced by newgrf callbacks, which makes it impossible to accurately
4c6d90bde803 (svn r9742) -Fix (r9689) [FS#739]: Fix cloning with refit costs again, hopefully for good this time.
maedhros
parents: 6491
diff changeset
   553
	 * estimate the cost of cloning a vehicle. */
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   554
	notest =
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   555
		(cmd & 0xFF) == CMD_CLEAR_AREA ||
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
		(cmd & 0xFF) == CMD_LEVEL_LAND ||
6546
4c6d90bde803 (svn r9742) -Fix (r9689) [FS#739]: Fix cloning with refit costs again, hopefully for good this time.
maedhros
parents: 6491
diff changeset
   557
		(cmd & 0xFF) == CMD_REMOVE_LONG_ROAD ||
4c6d90bde803 (svn r9742) -Fix (r9689) [FS#739]: Fix cloning with refit costs again, hopefully for good this time.
maedhros
parents: 6491
diff changeset
   558
		(cmd & 0xFF) == CMD_CLONE_VEHICLE;
8187
ebae31fc6f0b (svn r11750) -Revert (r11749): commited too much
glx
parents: 8186
diff changeset
   559
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   560
	_docommand_recursive = 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   561
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   562
	/* cost estimation only? */
5580
b7e597116b9c (svn r8027) -Fix (FS#486) If a pause command is issues, it will now pause the game even if shift is pressed instead of giving a cost estimate of 0. This fixes a problem where the server does not pause_on_join when the player on the interactive server has the shift button pressed. (Thanks to pvz for the report and the fix)
celestar
parents: 5475
diff changeset
   563
	if (!IsGeneratingWorld() &&
b7e597116b9c (svn r8027) -Fix (FS#486) If a pause command is issues, it will now pause the game even if shift is pressed instead of giving a cost estimate of 0. This fixes a problem where the server does not pause_on_join when the player on the interactive server has the shift button pressed. (Thanks to pvz for the report and the fix)
celestar
parents: 5475
diff changeset
   564
			_shift_pressed &&
b7e597116b9c (svn r8027) -Fix (FS#486) If a pause command is issues, it will now pause the game even if shift is pressed instead of giving a cost estimate of 0. This fixes a problem where the server does not pause_on_join when the player on the interactive server has the shift button pressed. (Thanks to pvz for the report and the fix)
celestar
parents: 5475
diff changeset
   565
			IsLocalPlayer() &&
b7e597116b9c (svn r8027) -Fix (FS#486) If a pause command is issues, it will now pause the game even if shift is pressed instead of giving a cost estimate of 0. This fixes a problem where the server does not pause_on_join when the player on the interactive server has the shift button pressed. (Thanks to pvz for the report and the fix)
celestar
parents: 5475
diff changeset
   566
			!(cmd & (CMD_NETWORK_COMMAND | CMD_SHOW_NO_ERROR)) &&
b7e597116b9c (svn r8027) -Fix (FS#486) If a pause command is issues, it will now pause the game even if shift is pressed instead of giving a cost estimate of 0. This fixes a problem where the server does not pause_on_join when the player on the interactive server has the shift button pressed. (Thanks to pvz for the report and the fix)
celestar
parents: 5475
diff changeset
   567
			(cmd & 0xFF) != CMD_PAUSE) {
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   568
		/* estimate the cost. */
3491
35d747bb5e82 (svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents: 3421
diff changeset
   569
		res = proc(tile, flags, p1, p2);
1691
852ca27d6eef (svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents: 1623
diff changeset
   570
		if (CmdFailed(res)) {
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   571
			res.SetGlobalErrorMessage();
3182
0cec126ca9a9 (svn r3827) Remove the global variable _error_message_2, it's only used as local variable
tron
parents: 2820
diff changeset
   572
			ShowErrorMessage(_error_message, error_part1, x, y);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   573
		} else {
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   574
			ShowEstimatedCostOrIncome(res.GetCost(), x, y);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   575
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   576
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   577
		_docommand_recursive = 0;
1820
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1804
diff changeset
   578
		_cmd_text = NULL;
7609
b70ffc13652a (svn r11138) -Codechange: prepare some subsystems for persistent storage for NewGRFs.
rubidium
parents: 7559
diff changeset
   579
		ClearStorageChanges(false);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   580
		return false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   581
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   582
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   583
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   584
	if (!((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   585
		/* first test if the command can be executed. */
8232
a4883a0598db (svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents: 8230
diff changeset
   586
		SetTownRatingTestMode(true);
3491
35d747bb5e82 (svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents: 3421
diff changeset
   587
		res = proc(tile, flags, p1, p2);
8232
a4883a0598db (svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents: 8230
diff changeset
   588
		SetTownRatingTestMode(false);
1691
852ca27d6eef (svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents: 1623
diff changeset
   589
		if (CmdFailed(res)) {
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   590
			res.SetGlobalErrorMessage();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   591
			goto show_error;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   592
		}
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   593
		/* no money? Only check if notest is off */
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   594
		if (!notest && res.GetCost() != 0 && !CheckPlayerHasMoney(res)) goto show_error;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   595
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   596
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   597
#ifdef ENABLE_NETWORK
1838
4aed9afd0744 (svn r2343) - Fix (regression): dedicated server caused desyncs with its commands, because the player sent over the network is OWNER_SPECTATOR as well, which on clients cannot execute anything. So *hack*hack* it into temporarily player 0.
Darkvater
parents: 1834
diff changeset
   598
	/** If we are in network, and the command is not from the network
4aed9afd0744 (svn r2343) - Fix (regression): dedicated server caused desyncs with its commands, because the player sent over the network is OWNER_SPECTATOR as well, which on clients cannot execute anything. So *hack*hack* it into temporarily player 0.
Darkvater
parents: 1834
diff changeset
   599
	 * send it to the command-queue and abort execution
4aed9afd0744 (svn r2343) - Fix (regression): dedicated server caused desyncs with its commands, because the player sent over the network is OWNER_SPECTATOR as well, which on clients cannot execute anything. So *hack*hack* it into temporarily player 0.
Darkvater
parents: 1834
diff changeset
   600
	 * If we are a dedicated server temporarily switch local player, otherwise
4aed9afd0744 (svn r2343) - Fix (regression): dedicated server caused desyncs with its commands, because the player sent over the network is OWNER_SPECTATOR as well, which on clients cannot execute anything. So *hack*hack* it into temporarily player 0.
Darkvater
parents: 1834
diff changeset
   601
	 * the other parties won't be able to execute our command and will desync.
5067
f3816e74ad32 (svn r7125) -Fix: Several errors/glitches related to multiplayer and bankrupcy, mainly such a
Darkvater
parents: 4850
diff changeset
   602
	 * We also need to do this if the server's company has gone bankrupt
f3816e74ad32 (svn r7125) -Fix: Several errors/glitches related to multiplayer and bankrupcy, mainly such a
Darkvater
parents: 4850
diff changeset
   603
	 * @todo Rewrite (dedicated) server to something more than a dirty hack!
1838
4aed9afd0744 (svn r2343) - Fix (regression): dedicated server caused desyncs with its commands, because the player sent over the network is OWNER_SPECTATOR as well, which on clients cannot execute anything. So *hack*hack* it into temporarily player 0.
Darkvater
parents: 1834
diff changeset
   604
	 */
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   605
	if (_networking && !(cmd & CMD_NETWORK_COMMAND)) {
5067
f3816e74ad32 (svn r7125) -Fix: Several errors/glitches related to multiplayer and bankrupcy, mainly such a
Darkvater
parents: 4850
diff changeset
   606
		PlayerID pbck = _local_player;
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   607
		if (_network_dedicated || (_network_server && pbck == PLAYER_SPECTATOR)) _local_player = PLAYER_FIRST;
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   608
		NetworkSend_Command(tile, p1, p2, cmd, callback);
5067
f3816e74ad32 (svn r7125) -Fix: Several errors/glitches related to multiplayer and bankrupcy, mainly such a
Darkvater
parents: 4850
diff changeset
   609
		if (_network_dedicated || (_network_server && pbck == PLAYER_SPECTATOR)) _local_player = pbck;
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   610
		_docommand_recursive = 0;
1820
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1804
diff changeset
   611
		_cmd_text = NULL;
7609
b70ffc13652a (svn r11138) -Codechange: prepare some subsystems for persistent storage for NewGRFs.
rubidium
parents: 7559
diff changeset
   612
		ClearStorageChanges(false);
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   613
		return true;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   614
	}
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   615
#endif /* ENABLE_NETWORK */
8024
5feb155012fe (svn r11584) -Change: add some extra checking in the hope to find the cause of FS#1482.
rubidium
parents: 7763
diff changeset
   616
#ifdef DEBUG_DUMP_COMMANDS
8199
3c13a496ca80 (svn r11762) -Fix: compilation with DEBUG_DUMP_COMMANDS was broken
glx
parents: 8187
diff changeset
   617
	extern Date      _date;
3c13a496ca80 (svn r11762) -Fix: compilation with DEBUG_DUMP_COMMANDS was broken
glx
parents: 8187
diff changeset
   618
	extern DateFract _date_fract;
8024
5feb155012fe (svn r11584) -Change: add some extra checking in the hope to find the cause of FS#1482.
rubidium
parents: 7763
diff changeset
   619
	debug_dump_commands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)_current_player, tile, p1, p2, cmd, _cmd_text);
5feb155012fe (svn r11584) -Change: add some extra checking in the hope to find the cause of FS#1482.
rubidium
parents: 7763
diff changeset
   620
#endif /* DUMP_COMMANDS */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   621
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   622
	/* update last build coordinate of player. */
4850
93095755db8c (svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents: 4848
diff changeset
   623
	if (tile != 0 && IsValidPlayer(_current_player)) {
4000
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3991
diff changeset
   624
		GetPlayer(_current_player)->last_build_coordinate = tile;
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3991
diff changeset
   625
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   626
889
64d2f7d5f02b (svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents: 842
diff changeset
   627
	/* Actually try and execute the command. If no cost-type is given
64d2f7d5f02b (svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents: 842
diff changeset
   628
	 * use the construction one */
4000
4009d092b306 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3991
diff changeset
   629
	res2 = proc(tile, flags | DC_EXEC, p1, p2);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   630
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   631
	/* If notest is on, it means the result of the test can be different than
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   632
	 *  the real command.. so ignore the test */
652
206a7c2016ba (svn r1085) -Fix: [Network] [ 1084834 ] If IF_IN_NETWORK flag was on, an error
truelight
parents: 601
diff changeset
   633
	if (!notest && !((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   634
		assert(res.GetCost() == res2.GetCost() && CmdFailed(res) == CmdFailed(res2)); // sanity check
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   635
	} else {
1702
be148d0fbf9d (svn r2206) - Regression Fix: slight typo of res2 into res, this also fixes recent bug "[ 1183396 ] Train can't find depot, it gives money in Multiplayer"
Darkvater
parents: 1701
diff changeset
   636
		if (CmdFailed(res2)) {
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   637
			res.SetGlobalErrorMessage();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   638
			goto show_error;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   639
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   640
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   641
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   642
	SubtractMoneyFromPlayer(res2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   643
2425
e755ee29133a (svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents: 2304
diff changeset
   644
	if (IsLocalPlayer() && _game_mode != GM_EDITOR) {
7506
93b2cbcce3d6 (svn r11021) -Fix [FS#1175]: do not display income/expenses when they do not belong to a "valid" tile, like the money cheat/giving money.
rubidium
parents: 7266
diff changeset
   645
		if (res2.GetCost() != 0 && tile != 0) ShowCostOrIncomeAnimation(x, y, GetSlopeZ(x, y), res2.GetCost());
6990
136a08baf0ed (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents: 6980
diff changeset
   646
		if (_additional_cash_required != 0) {
7002
1bf6a62b0fcb (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents: 6991
diff changeset
   647
			SetDParam(0, _additional_cash_required);
7222
d46753675bf7 (svn r10501) -Fix [FS#1015]: error dialog was sometimes shown on all clients when a command failed instead of only the client that actually did the command.
rubidium
parents: 7066
diff changeset
   648
			if (my_cmd) ShowErrorMessage(STR_0003_NOT_ENOUGH_CASH_REQUIRES, error_part1, x, y);
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   649
			if (res2.GetCost() == 0) goto callb_err;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   650
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   651
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   652
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   653
	_docommand_recursive = 0;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   654
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   655
	if (callback) callback(true, tile, p1, p2);
1820
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1804
diff changeset
   656
	_cmd_text = NULL;
7609
b70ffc13652a (svn r11138) -Codechange: prepare some subsystems for persistent storage for NewGRFs.
rubidium
parents: 7559
diff changeset
   657
	ClearStorageChanges(true);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   658
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   659
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   660
show_error:
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6012
diff changeset
   661
	/* show error message if the command fails? */
7222
d46753675bf7 (svn r10501) -Fix [FS#1015]: error dialog was sometimes shown on all clients when a command failed instead of only the client that actually did the command.
rubidium
parents: 7066
diff changeset
   662
	if (IsLocalPlayer() && error_part1 != 0 && my_cmd) {
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6453
diff changeset
   663
		ShowErrorMessage(_error_message, error_part1, x, y);
3182
0cec126ca9a9 (svn r3827) Remove the global variable _error_message_2, it's only used as local variable
tron
parents: 2820
diff changeset
   664
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   665
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   666
callb_err:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   667
	_docommand_recursive = 0;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   668
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   669
	if (callback) callback(false, tile, p1, p2);
1820
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1804
diff changeset
   670
	_cmd_text = NULL;
7609
b70ffc13652a (svn r11138) -Codechange: prepare some subsystems for persistent storage for NewGRFs.
rubidium
parents: 7559
diff changeset
   671
	ClearStorageChanges(false);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   672
	return false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   673
}
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   674
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   675
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   676
CommandCost CommandCost::AddCost(CommandCost ret)
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   677
{
6957
a9af2426bf77 (svn r10212) -Fix [FS#723]: money overflow bugs in many locations.
rubidium
parents: 6953
diff changeset
   678
	this->AddCost(ret.cost);
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   679
	if (this->success && !ret.success) {
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   680
		this->message = ret.message;
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   681
		this->success = false;
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   682
	}
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   683
	return *this;
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   684
}
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   685
6953
230d1e3ac86c (svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents: 6950
diff changeset
   686
CommandCost CommandCost::AddCost(Money cost)
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   687
{
7763
342e5357b592 (svn r11312) -Codechange: implement a overflow safe integer and use that for money and don't misuses CommandCost to have a overflow safe integer. Based on a patch by Noldo.
rubidium
parents: 7609
diff changeset
   688
	this->cost += cost;
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   689
	return *this;
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   690
}
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   691
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   692
CommandCost CommandCost::MultiplyCost(int factor)
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   693
{
7763
342e5357b592 (svn r11312) -Codechange: implement a overflow safe integer and use that for money and don't misuses CommandCost to have a overflow safe integer. Based on a patch by Noldo.
rubidium
parents: 7609
diff changeset
   694
	this->cost *= factor;
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   695
	return *this;
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   696
}
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   697
6953
230d1e3ac86c (svn r10208) -Codechange: replace int32 with Money where appropriate.
rubidium
parents: 6950
diff changeset
   698
Money CommandCost::GetCost() const
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   699
{
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   700
	return this->cost;
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   701
}
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   702
8230
64f28fe2d5c8 (svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents: 8199
diff changeset
   703
ExpensesType CommandCost::GetExpensesType() const
64f28fe2d5c8 (svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents: 8199
diff changeset
   704
{
64f28fe2d5c8 (svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents: 8199
diff changeset
   705
	return this->expense_type;
64f28fe2d5c8 (svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents: 8199
diff changeset
   706
}
64f28fe2d5c8 (svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents: 8199
diff changeset
   707
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   708
void CommandCost::SetGlobalErrorMessage() const
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   709
{
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   710
	extern StringID _error_message;
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   711
	if (this->message != INVALID_STRING_ID) _error_message = this->message;
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   712
}
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   713
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   714
bool CommandCost::Succeeded() const
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   715
{
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   716
	return this->success;
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   717
}
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   718
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   719
bool CommandCost::Failed() const
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   720
{
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   721
	return !this->success;
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   722
}