summaryrefslogtreecommitdiff
path: root/src/road_cmd.h
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-10-05 22:02:27 +0200
committerMichael Lutz <michi@icosahedron.de>2021-12-16 22:28:32 +0100
commit33ca4f2b9950d98fed902962c847833667ccca9f (patch)
tree503825bff107d7a296c4bf7a0c6e64bd957e0454 /src/road_cmd.h
parent5ddfdc8516e35c4f5de2613692d104486151171b (diff)
downloadopenttd-33ca4f2b9950d98fed902962c847833667ccca9f.tar.xz
Codechange: Let the compile generate the master command table out of templated command traits.
This is using a non-intrusive type-traits like templated system, which allows compile-time validation that the command table and the command enum match up.
Diffstat (limited to 'src/road_cmd.h')
-rw-r--r--src/road_cmd.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/road_cmd.h b/src/road_cmd.h
index 753ebd21d..4908f72e3 100644
--- a/src/road_cmd.h
+++ b/src/road_cmd.h
@@ -12,8 +12,21 @@
#include "direction_type.h"
#include "road_type.h"
+#include "command_type.h"
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt);
void UpdateNearestTownForRoadTiles(bool invalidate);
+CommandProc CmdBuildLongRoad;
+CommandProc CmdRemoveLongRoad;
+CommandProc CmdBuildRoad;
+CommandProc CmdBuildRoadDepot;
+CommandProc CmdConvertRoad;
+
+DEF_CMD_TRAIT(CMD_BUILD_LONG_ROAD, CmdBuildLongRoad, CMD_AUTO | CMD_NO_WATER | CMD_DEITY, CMDT_LANDSCAPE_CONSTRUCTION)
+DEF_CMD_TRAIT(CMD_REMOVE_LONG_ROAD, CmdRemoveLongRoad, CMD_AUTO | CMD_NO_TEST, CMDT_LANDSCAPE_CONSTRUCTION) // towns may disallow removing road bits (as they are connected) in test, but in exec they're removed and thus removing is allowed.
+DEF_CMD_TRAIT(CMD_BUILD_ROAD, CmdBuildRoad, CMD_AUTO | CMD_NO_WATER | CMD_DEITY, CMDT_LANDSCAPE_CONSTRUCTION)
+DEF_CMD_TRAIT(CMD_BUILD_ROAD_DEPOT, CmdBuildRoadDepot, CMD_AUTO | CMD_NO_WATER, CMDT_LANDSCAPE_CONSTRUCTION)
+DEF_CMD_TRAIT(CMD_CONVERT_ROAD, CmdConvertRoad, 0, CMDT_LANDSCAPE_CONSTRUCTION)
+
#endif /* ROAD_CMD_H */