command.c
author tron
Sun, 15 May 2005 18:50:55 +0000
changeset 1820 9b6458526480
parent 1804 7810fc0aa941
child 1834 33612fb9c7d7
permissions -rw-r--r--
(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.
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     1
#include "stdafx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     2
#include "ttd.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 467
diff changeset
     3
#include "table/strings.h"
679
e959706a3e4d (svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents: 652
diff changeset
     4
#include "map.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     6
#include "command.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "player.h"
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
     8
#include "network.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
1820
9b6458526480 (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
    10
const char* _cmd_text = NULL;
9b6458526480 (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
    11
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#define DEF_COMMAND(yyyy) int32 yyyy(int x, int y, uint32 flags, uint32 p1, uint32 p2)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
DEF_COMMAND(CmdBuildRailroadTrack);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
DEF_COMMAND(CmdRemoveRailroadTrack);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
DEF_COMMAND(CmdBuildSingleRail);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
DEF_COMMAND(CmdRemoveSingleRail);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
DEF_COMMAND(CmdLandscapeClear);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    20
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
DEF_COMMAND(CmdBuildBridge);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    23
DEF_COMMAND(CmdBuildRailroadStation);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    24
DEF_COMMAND(CmdRemoveFromRailroadStation);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
DEF_COMMAND(CmdConvertRail);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
1227
3552f20fcfcb (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
    27
DEF_COMMAND(CmdBuildSingleSignal);
3552f20fcfcb (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
    28
DEF_COMMAND(CmdRemoveSingleSignal);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
DEF_COMMAND(CmdTerraformLand);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
DEF_COMMAND(CmdPurchaseLandArea);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
DEF_COMMAND(CmdSellLandArea);
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(CmdBuildTunnel);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
DEF_COMMAND(CmdBuildTrainDepot);
395
4c990f33dab7 (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
    38
DEF_COMMAND(CmdBuildTrainWaypoint);
4c990f33dab7 (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
    39
DEF_COMMAND(CmdRenameWaypoint);
4c990f33dab7 (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
    40
DEF_COMMAND(CmdRemoveTrainWaypoint);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    42
DEF_COMMAND(CmdBuildRoadStop);
0
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(CmdBuildLongRoad);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
DEF_COMMAND(CmdRemoveLongRoad);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
DEF_COMMAND(CmdBuildRoad);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
DEF_COMMAND(CmdRemoveRoad);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
DEF_COMMAND(CmdBuildRoadDepot);
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(CmdBuildAirport);
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(CmdBuildDock);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
DEF_COMMAND(CmdBuildShipDepot);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
DEF_COMMAND(CmdBuildBuoy);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
DEF_COMMAND(CmdPlantTree);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
DEF_COMMAND(CmdBuildRailVehicle);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
DEF_COMMAND(CmdMoveRailVehicle);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
DEF_COMMAND(CmdStartStopTrain);
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(CmdSellRailWagon);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
1794
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1786
diff changeset
    68
DEF_COMMAND(CmdSendTrainToDepot);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
DEF_COMMAND(CmdForceTrainProceed);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
DEF_COMMAND(CmdReverseTrainDirection);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
DEF_COMMAND(CmdModifyOrder);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
DEF_COMMAND(CmdSkipOrder);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
DEF_COMMAND(CmdDeleteOrder);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
DEF_COMMAND(CmdInsertOrder);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
DEF_COMMAND(CmdChangeTrainServiceInt);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
DEF_COMMAND(CmdRestoreOrderIndex);
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(CmdBuildIndustry);
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(CmdBuildCompanyHQ);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
DEF_COMMAND(CmdSetPlayerFace);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
DEF_COMMAND(CmdSetPlayerColor);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
DEF_COMMAND(CmdIncreaseLoan);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
DEF_COMMAND(CmdDecreaseLoan);
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(CmdWantEnginePreview);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
DEF_COMMAND(CmdNameVehicle);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
DEF_COMMAND(CmdRenameEngine);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
DEF_COMMAND(CmdChangeCompanyName);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
DEF_COMMAND(CmdChangePresidentName);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
DEF_COMMAND(CmdRenameStation);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
DEF_COMMAND(CmdSellAircraft);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
DEF_COMMAND(CmdStartStopAircraft);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
DEF_COMMAND(CmdBuildAircraft);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
DEF_COMMAND(CmdSendAircraftToHangar);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
DEF_COMMAND(CmdChangeAircraftServiceInt);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
DEF_COMMAND(CmdRefitAircraft);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
DEF_COMMAND(CmdPlaceSign);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
DEF_COMMAND(CmdRenameSign);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
DEF_COMMAND(CmdBuildRoadVeh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
DEF_COMMAND(CmdStartStopRoadVeh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
DEF_COMMAND(CmdSellRoadVeh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
DEF_COMMAND(CmdSendRoadVehToDepot);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
DEF_COMMAND(CmdTurnRoadVeh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
DEF_COMMAND(CmdChangeRoadVehServiceInt);
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(CmdPause);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
DEF_COMMAND(CmdBuyShareInCompany);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
DEF_COMMAND(CmdSellShareInCompany);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
DEF_COMMAND(CmdBuyCompany);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
DEF_COMMAND(CmdBuildTown);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
DEF_COMMAND(CmdRenameTown);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
DEF_COMMAND(CmdDoTownAction);
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(CmdSetRoadDriveSide);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
DEF_COMMAND(CmdChangeDifficultyLevel);
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   129
DEF_COMMAND(CmdChangePatchSetting);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
DEF_COMMAND(CmdStartStopShip);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
DEF_COMMAND(CmdSellShip);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
DEF_COMMAND(CmdBuildShip);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
DEF_COMMAND(CmdSendShipToDepot);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
DEF_COMMAND(CmdChangeShipServiceInt);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
DEF_COMMAND(CmdRefitShip);
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(CmdCloneOrder);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
DEF_COMMAND(CmdClearArea);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   142
DEF_COMMAND(CmdGiveMoney);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
DEF_COMMAND(CmdMoneyCheat);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
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
   145
DEF_COMMAND(CmdBuildLock);
0
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(CmdPlayerCtrl);
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(CmdLevelLand);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
DEF_COMMAND(CmdRefitRailVehicle);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
1227
3552f20fcfcb (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
   153
DEF_COMMAND(CmdBuildSignalTrack);
3552f20fcfcb (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
   154
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
   155
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 826
diff changeset
   156
DEF_COMMAND(CmdReplaceVehicle);
812
79c99885ad00 (svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents: 679
diff changeset
   157
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
/* The master command table */
1804
7810fc0aa941 (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
   159
static const Command _command_proc_table[] = {
7810fc0aa941 (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
   160
	{CmdBuildRailroadTrack,                  0}, /*   0 */
7810fc0aa941 (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
   161
	{CmdRemoveRailroadTrack,                 0}, /*   1 */
7810fc0aa941 (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
   162
	{CmdBuildSingleRail,                     0}, /*   2 */
7810fc0aa941 (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
   163
	{CmdRemoveSingleRail,                    0}, /*   3 */
7810fc0aa941 (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
   164
	{CmdLandscapeClear,                      0}, /*   4 */
7810fc0aa941 (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
   165
	{CmdBuildBridge,                         0}, /*   5 */
7810fc0aa941 (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
   166
	{CmdBuildRailroadStation,                0}, /*   6 */
7810fc0aa941 (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
   167
	{CmdBuildTrainDepot,                     0}, /*   7 */
7810fc0aa941 (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
   168
	{CmdBuildSingleSignal,                   0}, /*   8 */
7810fc0aa941 (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
   169
	{CmdRemoveSingleSignal,                  0}, /*   9 */
7810fc0aa941 (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
   170
	{CmdTerraformLand,                       0}, /*  10 */
7810fc0aa941 (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
   171
	{CmdPurchaseLandArea,                    0}, /*  11 */
7810fc0aa941 (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
   172
	{CmdSellLandArea,                        0}, /*  12 */
7810fc0aa941 (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
   173
	{CmdBuildTunnel,                         0}, /*  13 */
7810fc0aa941 (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
   174
	{CmdRemoveFromRailroadStation,           0}, /*  14 */
7810fc0aa941 (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
   175
	{CmdConvertRail,                         0}, /*  15 */
7810fc0aa941 (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
   176
	{CmdBuildTrainWaypoint,                  0}, /*  16 */
7810fc0aa941 (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
   177
	{CmdRenameWaypoint,                      0}, /*  17 */
7810fc0aa941 (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
   178
	{CmdRemoveTrainWaypoint,                 0}, /*  18 */
7810fc0aa941 (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
   179
	{NULL,                                   0}, /*  19 */
7810fc0aa941 (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
   180
	{NULL,                                   0}, /*  20 */
7810fc0aa941 (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
   181
	{CmdBuildRoadStop,                       0}, /*  21 */
7810fc0aa941 (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
   182
	{NULL,                                   0}, /*  22 */
7810fc0aa941 (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
   183
	{CmdBuildLongRoad,                       0}, /*  23 */
7810fc0aa941 (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
   184
	{CmdRemoveLongRoad,                      0}, /*  24 */
7810fc0aa941 (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
   185
	{CmdBuildRoad,                           0}, /*  25 */
7810fc0aa941 (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
   186
	{CmdRemoveRoad,                          0}, /*  26 */
7810fc0aa941 (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
   187
	{CmdBuildRoadDepot,                      0}, /*  27 */
7810fc0aa941 (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
   188
	{NULL,                                   0}, /*  28 */
7810fc0aa941 (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
   189
	{CmdBuildAirport,                        0}, /*  29 */
7810fc0aa941 (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
   190
	{CmdBuildDock,                           0}, /*  30 */
7810fc0aa941 (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
   191
	{CmdBuildShipDepot,                      0}, /*  31 */
7810fc0aa941 (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
   192
	{CmdBuildBuoy,                           0}, /*  32 */
7810fc0aa941 (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
   193
	{CmdPlantTree,                           0}, /*  33 */
7810fc0aa941 (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
   194
	{CmdBuildRailVehicle,                    0}, /*  34 */
7810fc0aa941 (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
   195
	{CmdMoveRailVehicle,                     0}, /*  35 */
7810fc0aa941 (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
   196
	{CmdStartStopTrain,                      0}, /*  36 */
7810fc0aa941 (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
	{NULL,                                   0}, /*  37 */
7810fc0aa941 (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
   198
	{CmdSellRailWagon,                       0}, /*  38 */
7810fc0aa941 (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
   199
	{CmdSendTrainToDepot,                    0}, /*  39 */
7810fc0aa941 (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
   200
	{CmdForceTrainProceed,                   0}, /*  40 */
7810fc0aa941 (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
   201
	{CmdReverseTrainDirection,               0}, /*  41 */
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
   202
1804
7810fc0aa941 (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
   203
	{CmdModifyOrder,                         0}, /*  42 */
7810fc0aa941 (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
   204
	{CmdSkipOrder,                           0}, /*  43 */
7810fc0aa941 (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
   205
	{CmdDeleteOrder,                         0}, /*  44 */
7810fc0aa941 (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
   206
	{CmdInsertOrder,                         0}, /*  45 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
1804
7810fc0aa941 (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
   208
	{CmdChangeTrainServiceInt,               0}, /*  46 */
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
   209
1804
7810fc0aa941 (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
   210
	{CmdBuildIndustry,                       0}, /*  47 */
7810fc0aa941 (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
   211
	{CmdBuildCompanyHQ,                      0}, /*  48 */
7810fc0aa941 (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
   212
	{CmdSetPlayerFace,                       0}, /*  49 */
7810fc0aa941 (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
   213
	{CmdSetPlayerColor,                      0}, /*  50 */
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1794
diff changeset
   214
1804
7810fc0aa941 (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
   215
	{CmdIncreaseLoan,                        0}, /*  51 */
7810fc0aa941 (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
   216
	{CmdDecreaseLoan,                        0}, /*  52 */
7810fc0aa941 (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
   217
7810fc0aa941 (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
   218
	{CmdWantEnginePreview,                   0}, /*  53 */
7810fc0aa941 (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
   219
7810fc0aa941 (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
   220
	{CmdNameVehicle,                         0}, /*  54 */
7810fc0aa941 (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
   221
	{CmdRenameEngine,                        0}, /*  55 */
7810fc0aa941 (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
   222
7810fc0aa941 (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
   223
	{CmdChangeCompanyName,                   0}, /*  56 */
7810fc0aa941 (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
   224
	{CmdChangePresidentName,                 0}, /*  57 */
7810fc0aa941 (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
   225
7810fc0aa941 (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
   226
	{CmdRenameStation,                       0}, /*  58 */
7810fc0aa941 (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
   227
7810fc0aa941 (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
   228
	{CmdSellAircraft,                        0}, /*  59 */
7810fc0aa941 (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
   229
	{CmdStartStopAircraft,                   0}, /*  60 */
7810fc0aa941 (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
   230
7810fc0aa941 (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
   231
	{CmdBuildAircraft,                       0}, /*  61 */
7810fc0aa941 (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
   232
	{CmdSendAircraftToHangar,                0}, /*  62 */
7810fc0aa941 (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
   233
	{CmdChangeAircraftServiceInt,            0}, /*  63 */
7810fc0aa941 (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
   234
	{CmdRefitAircraft,                       0}, /*  64 */
7810fc0aa941 (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
   235
7810fc0aa941 (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
   236
	{CmdPlaceSign,                           0}, /*  65 */
7810fc0aa941 (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
   237
	{CmdRenameSign,                          0}, /*  66 */
7810fc0aa941 (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
   238
7810fc0aa941 (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
   239
	{CmdBuildRoadVeh,                        0}, /*  67 */
7810fc0aa941 (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
   240
	{CmdStartStopRoadVeh,                    0}, /*  68 */
7810fc0aa941 (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
   241
	{CmdSellRoadVeh,                         0}, /*  69 */
7810fc0aa941 (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
   242
	{CmdSendRoadVehToDepot,                  0}, /*  70 */
7810fc0aa941 (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
   243
	{CmdTurnRoadVeh,                         0}, /*  71 */
7810fc0aa941 (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
   244
	{CmdChangeRoadVehServiceInt,             0}, /*  72 */
7810fc0aa941 (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
   245
7810fc0aa941 (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
   246
	{CmdPause,                      CMD_SERVER}, /*  73 */
7810fc0aa941 (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
   247
7810fc0aa941 (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
	{CmdBuyShareInCompany,                   0}, /*  74 */
7810fc0aa941 (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
   249
	{CmdSellShareInCompany,                  0}, /*  75 */
7810fc0aa941 (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
   250
	{CmdBuyCompany,                          0}, /*  76 */
7810fc0aa941 (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
   251
7810fc0aa941 (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
   252
	{CmdBuildTown,                 CMD_OFFLINE}, /*  77 */
7810fc0aa941 (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
	{NULL,                                   0}, /*  78 */
7810fc0aa941 (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
   254
	{NULL,                                   0}, /*  79 */
7810fc0aa941 (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
   255
	{CmdRenameTown,                 CMD_SERVER}, /*  80 */
7810fc0aa941 (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
   256
	{CmdDoTownAction,                        0}, /*  81 */
7810fc0aa941 (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
   257
7810fc0aa941 (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
   258
	{CmdSetRoadDriveSide,           CMD_SERVER}, /*  82 */
7810fc0aa941 (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
   259
	{NULL,                                   0}, /*  83 */
7810fc0aa941 (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
   260
	{NULL,                                   0}, /*  84 */
7810fc0aa941 (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
   261
	{CmdChangeDifficultyLevel,      CMD_SERVER}, /*  85 */
7810fc0aa941 (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
   262
7810fc0aa941 (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
   263
	{CmdStartStopShip,                       0}, /*  86 */
7810fc0aa941 (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
   264
	{CmdSellShip,                            0}, /*  87 */
7810fc0aa941 (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
   265
	{CmdBuildShip,                           0}, /*  88 */
7810fc0aa941 (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
   266
	{CmdSendShipToDepot,                     0}, /*  89 */
7810fc0aa941 (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
   267
	{CmdChangeShipServiceInt,                0}, /*  90 */
7810fc0aa941 (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
   268
	{CmdRefitShip,                           0}, /*  91 */
7810fc0aa941 (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
   269
7810fc0aa941 (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
   270
	{NULL,                                   0}, /*  92 */
7810fc0aa941 (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
   271
	{NULL,                                   0}, /*  93 */
7810fc0aa941 (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
   272
	{NULL,                                   0}, /*  94 */
7810fc0aa941 (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
   273
	{NULL,                                   0}, /*  95 */
7810fc0aa941 (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
   274
	{NULL,                                   0}, /*  96 */
7810fc0aa941 (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
   275
	{NULL,                                   0}, /*  97 */
7810fc0aa941 (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
   276
	{NULL,                                   0}, /*  98 */
7810fc0aa941 (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
   277
7810fc0aa941 (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
   278
	{CmdCloneOrder,                          0}, /*  99 */
7810fc0aa941 (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
   279
7810fc0aa941 (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
   280
	{CmdClearArea,                           0}, /* 100 */
7810fc0aa941 (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
   281
	{NULL,                                   0}, /* 101 */
7810fc0aa941 (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
   282
7810fc0aa941 (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
   283
	{CmdMoneyCheat,                CMD_OFFLINE}, /* 102 */
7810fc0aa941 (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
   284
	{CmdBuildCanal,                          0}, /* 103 */
7810fc0aa941 (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
   285
	{CmdPlayerCtrl,                          0}, /* 104 */
7810fc0aa941 (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
   286
7810fc0aa941 (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
   287
	{CmdLevelLand,                           0}, /* 105 */
7810fc0aa941 (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
   288
7810fc0aa941 (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
   289
	{CmdRefitRailVehicle,                    0}, /* 106 */
7810fc0aa941 (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
   290
	{CmdRestoreOrderIndex,                   0}, /* 107 */
7810fc0aa941 (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
   291
	{CmdBuildLock,                           0}, /* 108 */
7810fc0aa941 (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
   292
	{NULL,                                   0}, /* 109 */
7810fc0aa941 (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
   293
	{CmdBuildSignalTrack,                    0}, /* 110 */
7810fc0aa941 (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
   294
	{CmdRemoveSignalTrack,                   0}, /* 111 */
7810fc0aa941 (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
   295
	{NULL,                                   0}, /* 112 */
7810fc0aa941 (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
   296
	{CmdGiveMoney,                           0}, /* 113 */
7810fc0aa941 (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
   297
	{CmdChangePatchSetting,         CMD_SERVER}, /* 114 */
7810fc0aa941 (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
   298
	{CmdReplaceVehicle,                      0}, /* 115 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
903
f860c7234167 (svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents: 889
diff changeset
   301
/* This function range-checks a cmd, and checks if the cmd is not NULL */
959
b031d88c76f3 (svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents: 926
diff changeset
   302
bool IsValidCommand(uint cmd)
903
f860c7234167 (svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents: 889
diff changeset
   303
{
f860c7234167 (svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents: 889
diff changeset
   304
	cmd = cmd & 0xFF;
f860c7234167 (svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents: 889
diff changeset
   305
1804
7810fc0aa941 (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
   306
	if (cmd >= lengthof(_command_proc_table) || _command_proc_table[cmd].proc == NULL)
903
f860c7234167 (svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents: 889
diff changeset
   307
		return false;
f860c7234167 (svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents: 889
diff changeset
   308
f860c7234167 (svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents: 889
diff changeset
   309
	return true;
f860c7234167 (svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents: 889
diff changeset
   310
}
f860c7234167 (svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents: 889
diff changeset
   311
1804
7810fc0aa941 (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
   312
byte GetCommandFlags(uint cmd) {return _command_proc_table[cmd & 0xFF].flags;}
7810fc0aa941 (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
   313
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
int32 DoCommandByTile(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
{
926
bd4312619522 (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents: 903
diff changeset
   316
	return DoCommand(TileX(tile) * 16, TileY(tile) * 16, p1, p2, flags, procc);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   317
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
//extern void _stdcall Sleep(int s);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
	int32 res;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
	CommandProc *proc;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   326
1776
fa776997bba2 (svn r2280) - Fix: Check if the passed tile to DoCommand is within the current mapsize
Darkvater
parents: 1728
diff changeset
   327
	/* Do not even think about executing out-of-bounds tile-commands */
1820
9b6458526480 (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
   328
	if (TILE_FROM_XY(x,y) > MapSize()) {
9b6458526480 (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
   329
		_cmd_text = NULL;
9b6458526480 (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
   330
		return CMD_ERROR;
9b6458526480 (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
   331
	}
1776
fa776997bba2 (svn r2280) - Fix: Check if the passed tile to DoCommand is within the current mapsize
Darkvater
parents: 1728
diff changeset
   332
1804
7810fc0aa941 (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
   333
	proc = _command_proc_table[procc].proc;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
	if (_docommand_recursive == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
		_error_message = INVALID_STRING_ID;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
		// update last build coord of player
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   338
		if ( (x|y) != 0 && _current_player < MAX_PLAYERS) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
			DEREF_PLAYER(_current_player)->last_build_coordinate = TILE_FROM_XY(x,y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   343
	_docommand_recursive++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
	// only execute the test call if it's toplevel, or we're not execing.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
	if (_docommand_recursive == 1 || !(flags & DC_EXEC) || (flags & DC_FORCETEST) ) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
		res = proc(x, y, flags&~DC_EXEC, p1, p2);
1691
fcd9fefaed02 (svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents: 1623
diff changeset
   348
		if (CmdFailed(res)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   349
			if (res & 0xFFFF) _error_message = res & 0xFFFF;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
			goto error;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
		if (_docommand_recursive == 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
			if (!(flags&DC_QUERY_COST) && res != 0 && !CheckPlayerHasMoney(res))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
				goto error;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
		if (!(flags & DC_EXEC)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
			_docommand_recursive--;
1820
9b6458526480 (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
   360
			_cmd_text = NULL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
			return res;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   364
889
7f8630bfea41 (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
   365
	/* Execute the command here. All cost-relevant functions set the expenses type
7f8630bfea41 (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
   366
	 * themselves with "SET_EXPENSES_TYPE(...);" at the beginning of the function */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
	res = proc(x, y, flags, p1, p2);
1691
fcd9fefaed02 (svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents: 1623
diff changeset
   368
	if (CmdFailed(res)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   369
		if (res & 0xFFFF) _error_message = res & 0xFFFF;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
error:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
		_docommand_recursive--;
1820
9b6458526480 (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
   372
		_cmd_text = NULL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
		return CMD_ERROR;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
	// if toplevel, subtract the money.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
	if (--_docommand_recursive == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   378
		SubtractMoneyFromPlayer(res);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
1820
9b6458526480 (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
   381
	_cmd_text = NULL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
	return res;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 959
diff changeset
   385
int32 GetAvailableMoneyForCommand(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   386
{
1794
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1786
diff changeset
   387
	PlayerID pid = _current_player;
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
   388
	if (pid >= MAX_PLAYERS) return 0x7FFFFFFF; // max int
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   389
	return DEREF_PLAYER(pid)->player_money;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   390
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
// toplevel network safe docommand function for the current player. must not be called recursively.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
// the callback is called when the command succeeded or failed.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
	int32 res = 0,res2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   397
	CommandProc *proc;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
	uint32 flags;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
	bool notest;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
926
bd4312619522 (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents: 903
diff changeset
   401
	int x = TileX(tile) * 16;
bd4312619522 (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents: 903
diff changeset
   402
	int y = TileY(tile) * 16;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
1776
fa776997bba2 (svn r2280) - Fix: Check if the passed tile to DoCommand is within the current mapsize
Darkvater
parents: 1728
diff changeset
   404
	/* Do not even think about executing out-of-bounds tile-commands */
1820
9b6458526480 (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
   405
	if (tile > MapSize()) {
9b6458526480 (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
   406
		_cmd_text = NULL;
9b6458526480 (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
   407
		return false;
9b6458526480 (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
   408
	}
1776
fa776997bba2 (svn r2280) - Fix: Check if the passed tile to DoCommand is within the current mapsize
Darkvater
parents: 1728
diff changeset
   409
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   410
	assert(_docommand_recursive == 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
	_error_message = INVALID_STRING_ID;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
	_error_message_2 = cmd >> 16;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
	_additional_cash_required = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   415
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   416
	// spectator has no rights.
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
   417
	if (_current_player == OWNER_SPECTATOR) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   418
		ShowErrorMessage(_error_message, _error_message_2, x, y);
1820
9b6458526480 (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
   419
		_cmd_text = NULL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   420
		return false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
	flags = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
	if (cmd & CMD_AUTO) flags |= DC_AUTO;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   425
	if (cmd & CMD_NO_WATER) flags |= DC_NO_WATER;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   426
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
	// get pointer to command handler
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   428
	assert((cmd & 0xFF) < lengthof(_command_proc_table));
1804
7810fc0aa941 (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
   429
	proc = _command_proc_table[cmd & 0xFF].proc;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
826
0e2b569b737b (svn r1297) Language fixes in the source.. (ln-)
miham
parents: 812
diff changeset
   431
	// Some commands have a different output in dryrun than the realrun
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   432
	//  e.g.: if you demolish a whole town, the dryrun would say okay.
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   433
	//  but by really destroying, your rating drops and at a certain point
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   434
	//  it will fail. so res and res2 are different
467
6f3e282fdce4 (svn r697) Fix the town road removal crash _still_ present there.
pasky
parents: 395
diff changeset
   435
	// CMD_REMOVE_ROAD: This command has special local authority
6f3e282fdce4 (svn r697) Fix the town road removal crash _still_ present there.
pasky
parents: 395
diff changeset
   436
	// restrictions which may cause the test run to fail (the previous
6f3e282fdce4 (svn r697) Fix the town road removal crash _still_ present there.
pasky
parents: 395
diff changeset
   437
	// road fragments still stay there and the town won't let you
6f3e282fdce4 (svn r697) Fix the town road removal crash _still_ present there.
pasky
parents: 395
diff changeset
   438
	// disconnect the road system), but the exec will succeed and this
6f3e282fdce4 (svn r697) Fix the town road removal crash _still_ present there.
pasky
parents: 395
diff changeset
   439
	// fact will trigger an assertion failure. --pasky
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   440
	notest =
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   441
		(cmd & 0xFF) == CMD_CLEAR_AREA ||
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   442
		(cmd & 0xFF) == CMD_CONVERT_RAIL ||
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
		(cmd & 0xFF) == CMD_LEVEL_LAND ||
1701
e46ac9ca353e (svn r2205) - Fixup of revision 2200, not twice CMD_REMOVE_LONG_ROAD :p. Thanks TrueLight.
Darkvater
parents: 1696
diff changeset
   444
		(cmd & 0xFF) == CMD_REMOVE_ROAD ||
1696
b3979425aa5a (svn r2200) - Fix [ 1179892 ] click & drag removal of road assertion fail. Add CMD_REMOVE_LONG_ROAD to the 'notest' section as it might have difficulties with town ratings, etc. Read the comment for more info (mgasterix)
Darkvater
parents: 1691
diff changeset
   445
		(cmd & 0xFF) == CMD_REMOVE_LONG_ROAD;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   447
	_docommand_recursive = 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   448
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
	// cost estimation only?
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 826
diff changeset
   450
	if (_shift_pressed && _current_player == _local_player && !(cmd & (CMD_NETWORK_COMMAND | CMD_SHOW_NO_ERROR))) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
		// estimate the cost.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
		res = proc(x, y, flags, p1, p2);
1691
fcd9fefaed02 (svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents: 1623
diff changeset
   453
		if (CmdFailed(res)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
			if (res & 0xFFFF) _error_message = res & 0xFFFF;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
			ShowErrorMessage(_error_message, _error_message_2, x, y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   456
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   457
			ShowEstimatedCostOrIncome(res, x, y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   458
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   459
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   460
		_docommand_recursive = 0;
1820
9b6458526480 (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
   461
		_cmd_text = NULL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   462
		return false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   463
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   464
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   465
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   466
	if (!((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
		// first test if the command can be executed.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
		res = proc(x,y, flags, p1, p2);
1691
fcd9fefaed02 (svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents: 1623
diff changeset
   469
		if (CmdFailed(res)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
			if (res & 0xFFFF) _error_message = res & 0xFFFF;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
			goto show_error;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
		}
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   473
		// no money? Only check if notest is off
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   474
		if (!notest && res != 0 && !CheckPlayerHasMoney(res)) goto show_error;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   476
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   477
#ifdef ENABLE_NETWORK
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   478
	// If we are in network, and the command is not from the network
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   479
	//   send it to the command-queue and abort execution
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   480
	if (_networking && !(cmd & CMD_NETWORK_COMMAND)) {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   481
		NetworkSend_Command(tile, p1, p2, cmd, callback);
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   482
		_docommand_recursive = 0;
1820
9b6458526480 (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
   483
		_cmd_text = NULL;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   484
		return true;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   485
	}
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   486
#endif /* ENABLE_NETWORK */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   487
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   488
	// update last build coordinate of player.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   489
	if ( tile != 0 && _current_player < MAX_PLAYERS) DEREF_PLAYER(_current_player)->last_build_coordinate = tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   490
889
7f8630bfea41 (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
   491
	/* Actually try and execute the command. If no cost-type is given
7f8630bfea41 (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
   492
	 * use the construction one */
7f8630bfea41 (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
   493
	_yearly_expenses_type = EXPENSES_CONSTRUCTION;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   494
	res2 = proc(x,y, flags|DC_EXEC, p1, p2);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   495
826
0e2b569b737b (svn r1297) Language fixes in the source.. (ln-)
miham
parents: 812
diff changeset
   496
	// If notest is on, it means the result of the test can be different than
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 534
diff changeset
   497
	//   the real command.. so ignore the test
652
0f553238c98a (svn r1085) -Fix: [Network] [ 1084834 ] If IF_IN_NETWORK flag was on, an error
truelight
parents: 601
diff changeset
   498
	if (!notest && !((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   499
		assert(res == res2); // sanity check
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   500
	} else {
1702
6402cfbb9772 (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
   501
		if (CmdFailed(res2)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   502
			if (res2 & 0xFFFF) _error_message = res2 & 0xFFFF;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   503
			goto show_error;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   504
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   506
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   507
	SubtractMoneyFromPlayer(res2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   508
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   509
	if (_current_player == _local_player && _game_mode != GM_EDITOR) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
		if (res2 != 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   511
			ShowCostOrIncomeAnimation(x, y, GetSlopeZ(x, y), res2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   512
		if (_additional_cash_required) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   513
			SetDParam(0, _additional_cash_required);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   514
			ShowErrorMessage(STR_0003_NOT_ENOUGH_CASH_REQUIRES, _error_message_2, x,y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   515
			if (res2 == 0) goto callb_err;
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
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
	_docommand_recursive = 0;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   520
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   521
	if (callback) callback(true, tile, p1, p2);
1820
9b6458526480 (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
   522
	_cmd_text = NULL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   523
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   524
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   525
show_error:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   526
	// show error message if the command fails?
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   527
	if (_current_player == _local_player && _error_message_2 != 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   528
		ShowErrorMessage(_error_message, _error_message_2, x,y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   530
callb_err:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
	_docommand_recursive = 0;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 147
diff changeset
   532
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   533
	if (callback) callback(false, tile, p1, p2);
1820
9b6458526480 (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
   534
	_cmd_text = NULL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   535
	return false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   536
}