Fix compilation errors

This commit is contained in:
Pavel Stupnikov
2022-12-02 19:55:21 +04:00
parent 4dea7601c0
commit 4e047eec9b
29 changed files with 981 additions and 221 deletions

View File

@@ -3,6 +3,7 @@ from pathlib import Path
from pprint import pprint from pprint import pprint
RX_COMMAND = re.compile(r'(?P<returns>CommandCost|std::tuple<CommandCost, [^>]*>) (?P<name>Cmd\w*)\((?P<args>[^)]*)\);') RX_COMMAND = re.compile(r'(?P<returns>CommandCost|std::tuple<CommandCost, [^>]*>) (?P<name>Cmd\w*)\((?P<args>[^)]*)\);')
RX_DEF_TRAIT = re.compile(r'DEF_CMD_TRAIT\((?P<constant>\w+),\s+(?P<function>\w+),\s+[^,]*,\s+(?P<category>\w+)\)')
RX_ARG = re.compile(r'(?P<type>(:?const |)[\w:]* &?)(?P<name>\w*)') RX_ARG = re.compile(r'(?P<type>(:?const |)[\w:]* &?)(?P<name>\w*)')
RX_CAMEL_TO_SNAKE = re.compile(r'(?<!^)(?=[A-Z])') RX_CAMEL_TO_SNAKE = re.compile(r'(?<!^)(?=[A-Z])')
@@ -10,7 +11,11 @@ FILES = [
'src/misc_cmd.h', 'src/misc_cmd.h',
'src/object_cmd.h', 'src/object_cmd.h',
'src/order_cmd.h', 'src/order_cmd.h',
'src/rail_cmd.h',
'src/road_cmd.h',
'src/station_cmd.h',
'src/town_cmd.h', 'src/town_cmd.h',
'src/tunnelbridge_cmd.h',
] ]
BASE_DIR = Path(__file__).parent BASE_DIR = Path(__file__).parent
@@ -20,17 +25,28 @@ OUTPUT = BASE_DIR / 'src/citymania/generated/cm_gen_commands'
def parse_commands(): def parse_commands():
res = [] res = []
for f in FILES: for f in FILES:
for returns, name, args_str in RX_COMMAND.findall(open(BASE_DIR / f).read()): data = open(BASE_DIR / f).read()
traits = {}
for constant, name, category in RX_DEF_TRAIT.findall(data):
traits[name] = constant
for returns, name, args_str in RX_COMMAND.findall(data):
if returns.startswith('std::tuple'): if returns.startswith('std::tuple'):
ret_type = returns[24: -1] ret_type = returns[24: -1]
else: else:
ret_type = None ret_type = None
args = [RX_ARG.fullmatch(x).group('type', 'name') for x in args_str.split(', ')] args = [RX_ARG.fullmatch(x).group('type', 'name') for x in args_str.split(', ')]
args = args[1:] args = args[1:] # flags
if args[0][0].strip() == 'TileIndex': first_tile_arg = (args[0][0].strip() == 'TileIndex')
if first_tile_arg:
args = args[1:] args = args[1:]
print(name, args) print(name, traits[name], args)
res.append((ret_type, name[3:], args)) res.append({
'name': name[3:],
'constant': traits[name],
'args': args,
'first_tile_arg': first_tile_arg,
'returns': ret_type,
})
return res return res
@@ -45,22 +61,31 @@ def run():
'namespace citymania {\n' 'namespace citymania {\n'
'namespace cmd {\n\n' 'namespace cmd {\n\n'
) )
for rt, name, args in commands: for cmd in commands:
args_list = ', '.join(f'{at} {an}' for at, an in args) name = cmd['name']
args_init = ', '.join(f'{an}{{{an}}}' for _, an in args) args_list = ', '.join(f'{at}{an}' for at, an in cmd['args'])
args_init = ', '.join(f'{an}{{{an}}}' for _, an in cmd['args'])
f.write( f.write(
f'class {name}: public Command {{\n' f'class {name}: public Command {{\n'
f'public:\n' f'public:\n'
) )
for at, an in args: for at, an in cmd['args']:
f.write(f' {at}{an};\n') f.write(f' {at}{an};\n')
f.write( f.write(
f'\n' f'\n'
f' {name}({args_list})\n' f' {name}({args_list})\n'
f' :{args_init} {{}}\n' f' :{args_init} {{}}\n'
)
if cmd.get('first_tile_arg'):
f.write(
f' {name}(TileIndex tile, {args_list})\n'
f' :Command{{tile}}, {args_init} {{}}\n'
)
f.write(
f' ~{name}() override {{}}\n' f' ~{name}() override {{}}\n'
f'\n' f'\n'
f' bool DoPost() override;\n' f' bool DoPost() override;\n'
f' bool DoTest() override;\n'
f'}};\n\n' f'}};\n\n'
) )
f.write( f.write(
@@ -81,14 +106,27 @@ def run():
'namespace citymania {\n' 'namespace citymania {\n'
'namespace cmd {\n\n' 'namespace cmd {\n\n'
) )
for rt, name, args in commands: for cmd in commands:
constant = 'CMD_' + RX_CAMEL_TO_SNAKE.sub('_', name).upper() name = cmd['name']
args_list = ', '.join(f'this->{an}' for _, an in args) constant = cmd['constant']
# constant = 'CMD_' + RX_CAMEL_TO_SNAKE.sub('_', name).upper()
args_list = ', '.join(f'this->{an}' for _, an in cmd['args'])
test_args_list = args_list
if cmd.get('first_tile_arg'):
test_args_list = f'this->tile, ' + args_list
cost_getter = '' if cmd['returns'] is None else 'std::get<0>'
f.write( f.write(
f'bool {name}::DoPost() {{\n' f'bool {name}::DoPost() {{\n'
f' return ::Command<{constant}>::Post(this->error, this->tile, {args_list});\n' f' return ::Command<{constant}>::Post(this->error, this->tile, {args_list});\n'
'}\n' '}\n'
) )
f.write(
f'bool {name}::DoTest() {{\n'
f' return {cost_getter}(::Command<{constant}>::Do(DC_NONE, {test_args_list})).Succeeded();\n'
'}\n'
)
f.write('\n') f.write('\n')
f.write( f.write(
'} // namespace cmd\n' '} // namespace cmd\n'

View File

@@ -71,7 +71,7 @@ void CcBuildBridge(Commands cmd, const CommandCost &result, TileIndex end_tile,
ConnectRoadToStructure(tile_start, start_direction); ConnectRoadToStructure(tile_start, start_direction);
} }
StoreRailPlacementEndpoints(p1, end_tile, (TileX(p1) == TileX(end_tile)) ? TRACK_Y : TRACK_X, false); StoreRailPlacementEndpoints(tile_start, end_tile, (TileX(tile_start) == TileX(end_tile)) ? TRACK_Y : TRACK_X, false);
} }
/** Window class for handling the bridge-build GUI. */ /** Window class for handling the bridge-build GUI. */

View File

@@ -9,6 +9,7 @@
#include "../debug.h" #include "../debug.h"
#include "../direction_type.h" #include "../direction_type.h"
#include "../rail_map.h" #include "../rail_map.h"
#include "../station_cmd.h"
#include "../station_map.h" #include "../station_map.h"
#include "../station_base.h" #include "../station_base.h"
#include "../tilearea_type.h" #include "../tilearea_type.h"
@@ -21,6 +22,17 @@ extern TileHighlightData _thd;
extern RailType _cur_railtype; extern RailType _cur_railtype;
extern void GetStationLayout(byte *layout, uint numtracks, uint plat_len, const StationSpec *statspec); extern void GetStationLayout(byte *layout, uint numtracks, uint plat_len, const StationSpec *statspec);
// from rail_gui.cpp
struct RailStationGUISettings {
Axis orientation; ///< Currently selected rail station orientation
bool newstations; ///< Are custom station definitions available?
StationClassID station_class; ///< Currently selected custom station class (if newstations is \c true )
byte station_type; ///< %Station type within the currently selected custom station class (if newstations is \c true )
byte station_count; ///< Number of custom stations (if newstations is \c true )
};
extern RailStationGUISettings _railstation; ///< Settings of the station builder GUI
namespace citymania { namespace citymania {
@@ -92,7 +104,7 @@ void Blueprint::Add(TileIndex source_tile, Blueprint::Item item) {
} }
} }
CommandContainer GetBlueprintCommand(TileIndex start, const Blueprint::Item &item) { up<Command> GetBlueprintCommand(TileIndex start, const Blueprint::Item &item) {
static const Track SIGNAL_POS_TRACK[] = { static const Track SIGNAL_POS_TRACK[] = {
TRACK_LEFT, TRACK_LEFT, TRACK_RIGHT, TRACK_RIGHT, TRACK_LEFT, TRACK_LEFT, TRACK_RIGHT, TRACK_RIGHT,
TRACK_UPPER, TRACK_UPPER, TRACK_LOWER, TRACK_LOWER, TRACK_UPPER, TRACK_UPPER, TRACK_LOWER, TRACK_LOWER,
@@ -116,71 +128,76 @@ CommandContainer GetBlueprintCommand(TileIndex start, const Blueprint::Item &ite
end_tile = new_tile; end_tile = new_tile;
tdir = NextTrackdir(tdir); tdir = NextTrackdir(tdir);
} }
return CommandContainer { return make_up<cmd::BuildRailroadTrack>(
start_tile,
end_tile, end_tile,
(uint32)(_cur_railtype) | ((uint32)TrackdirToTrack(item.u.rail.track.start_dir) << 6), start_tile,
CMD_BUILD_RAILROAD_TRACK, _cur_railtype,
nullptr, "" TrackdirToTrack(item.u.rail.track.start_dir),
}; true, // auto_remove_signals
false // fail_on_obastacle
);
} }
case Blueprint::Item::Type::RAIL_DEPOT: case Blueprint::Item::Type::RAIL_DEPOT:
return CommandContainer { return make_up<cmd::BuildTrainDepot>(
AddTileIndexDiffCWrap(start, item.tdiff), AddTileIndexDiffCWrap(start, item.tdiff),
_cur_railtype, _cur_railtype,
item.u.rail.depot.ddir, item.u.rail.depot.ddir
CMD_BUILD_TRAIN_DEPOT, );
nullptr, ""
};
case Blueprint::Item::Type::RAIL_TUNNEL: case Blueprint::Item::Type::RAIL_TUNNEL:
// TODO check that other end is where it should be // TODO check that other end is where it should be
return CommandContainer { return make_up<cmd::BuildTunnel>(
AddTileIndexDiffCWrap(start, item.tdiff), AddTileIndexDiffCWrap(start, item.tdiff),
(uint32)_cur_railtype | ((uint32)TRANSPORT_RAIL << 8), TRANSPORT_RAIL,
0, _cur_railtype
CMD_BUILD_TUNNEL, );
nullptr, ""
};
case Blueprint::Item::Type::RAIL_BRIDGE: case Blueprint::Item::Type::RAIL_BRIDGE:
return CommandContainer { return make_up<cmd::BuildBridge>(
AddTileIndexDiffCWrap(start, item.u.rail.bridge.other_end), AddTileIndexDiffCWrap(start, item.u.rail.bridge.other_end),
AddTileIndexDiffCWrap(start, item.tdiff), AddTileIndexDiffCWrap(start, item.tdiff),
item.u.rail.bridge.type | (_cur_railtype << 8) | (TRANSPORT_RAIL << 15), TRANSPORT_RAIL,
CMD_BUILD_BRIDGE, item.u.rail.bridge.type,
nullptr, "" _cur_railtype
}; );
case Blueprint::Item::Type::RAIL_STATION_PART: case Blueprint::Item::Type::RAIL_STATION_PART:
return CommandContainer { return make_up<cmd::BuildRailStation>(
AddTileIndexDiffCWrap(start, item.tdiff), AddTileIndexDiffCWrap(start, item.tdiff),
(uint32)_cur_railtype _cur_railtype,
| ((uint32)item.u.rail.station_part.axis << 6) item.u.rail.station_part.axis,
| ((uint32)item.u.rail.station_part.numtracks << 8) item.u.rail.station_part.numtracks,
| ((uint32)item.u.rail.station_part.plat_len << 16), item.u.rail.station_part.plat_len,
(uint32)NEW_STATION << 16, _railstation.station_class,
CMD_BUILD_RAIL_STATION, _railstation.station_type,
nullptr, "" NEW_STATION,
}; true
);
case Blueprint::Item::Type::RAIL_STATION: case Blueprint::Item::Type::RAIL_STATION:
// TODO station types // TODO station types
return CommandContainer { return make_up<cmd::BuildRailStation>(
AddTileIndexDiffCWrap(start, item.tdiff), AddTileIndexDiffCWrap(start, item.tdiff),
(uint32)_cur_railtype | ((uint32)1 << 8) | ((uint32)1 << 16) | ((uint32)1 << 24), _cur_railtype,
(uint32)NEW_STATION << 16, AXIS_X,
CMD_BUILD_RAIL_STATION, 1,
nullptr, "" 1,
}; _railstation.station_class,
_railstation.station_type,
NEW_STATION,
true
);
case Blueprint::Item::Type::RAIL_SIGNAL: case Blueprint::Item::Type::RAIL_SIGNAL:
return CommandContainer { return make_up<cmd::BuildSingleSignal>(
AddTileIndexDiffCWrap(start, item.tdiff), AddTileIndexDiffCWrap(start, item.tdiff),
SIGNAL_POS_TRACK[item.u.rail.signal.pos] SIGNAL_POS_TRACK[item.u.rail.signal.pos],
| (item.u.rail.signal.variant << 4) item.u.rail.signal.type,
| (item.u.rail.signal.type << 5) item.u.rail.signal.variant,
| (SIGNAL_POS_NUM[item.u.rail.signal.pos] + (item.u.rail.signal.type <= SIGTYPE_LAST_NOPBS && !item.u.rail.signal.twoway ? 1 : 0)) << 15 false, // convert_signal
| 1 << 17, true, // skip_existing_signals
0, false, // ctrl_pressed
CMD_BUILD_SIGNALS, SIGTYPE_NORMAL, // cycle_start
nullptr, "" SIGTYPE_NORMAL, // cycle_stop
}; SIGNAL_POS_NUM[item.u.rail.signal.pos] +
(item.u.rail.signal.type <= SIGTYPE_LAST_NOPBS && !item.u.rail.signal.twoway ? 1 : 0),
false // signals_copy
);
default: default:
NOT_REACHED(); NOT_REACHED();
} }
@@ -198,14 +215,14 @@ std::multimap<TileIndex, ObjectTileHighlight> Blueprint::GetTiles(TileIndex tile
std::set<StationID> can_build_station_sign; std::set<StationID> can_build_station_sign;
for (auto &item: this->items) { for (auto &item: this->items) {
if (item.type != Item::Type::RAIL_STATION) continue; if (item.type != Item::Type::RAIL_STATION) continue;
if (CanBuild(GetBlueprintCommand(tile, item))) if (GetBlueprintCommand(tile, item)->Test())
can_build_station_sign.insert(item.u.rail.station.id); can_build_station_sign.insert(item.u.rail.station.id);
} }
for (auto &o: this->items) { for (auto &o: this->items) {
auto otile = AddTileIndexDiffCWrap(tile, o.tdiff); auto otile = AddTileIndexDiffCWrap(tile, o.tdiff);
auto palette = CM_PALETTE_TINT_WHITE; auto palette = CM_PALETTE_TINT_WHITE;
if (o.type != Item::Type::RAIL_SIGNAL && !CanBuild(GetBlueprintCommand(tile, o))) if (o.type != Item::Type::RAIL_SIGNAL && !GetBlueprintCommand(tile, o)->Test())
palette = CM_PALETTE_TINT_RED_DEEP; palette = CM_PALETTE_TINT_RED_DEEP;
switch(o.type) { switch(o.type) {
@@ -575,7 +592,7 @@ void SetBlueprintHighlight(const TileInfo *ti, TileHighlight &th) {
} }
void BuildBlueprint(sp<Blueprint> &blueprint, TileIndex start) { void BuildBlueprint(sp<Blueprint> &blueprint, TileIndex start) {
CommandContainer last_rail = {INVALID_TILE, 0, 0, CMD_END, nullptr, ""}; up<Command> last_rail = nullptr;
for (auto &item : blueprint->items) { for (auto &item : blueprint->items) {
switch (item.type) { switch (item.type) {
case Blueprint::Item::Type::RAIL_TRACK: case Blueprint::Item::Type::RAIL_TRACK:
@@ -583,15 +600,16 @@ void BuildBlueprint(sp<Blueprint> &blueprint, TileIndex start) {
case Blueprint::Item::Type::RAIL_TUNNEL: case Blueprint::Item::Type::RAIL_TUNNEL:
case Blueprint::Item::Type::RAIL_BRIDGE: { case Blueprint::Item::Type::RAIL_BRIDGE: {
auto cc = GetBlueprintCommand(start, item); auto cc = GetBlueprintCommand(start, item);
if (item.type == Blueprint::Item::Type::RAIL_TRACK) last_rail = cc; cc->Post();
DoCommandP(&cc); if (item.type == Blueprint::Item::Type::RAIL_TRACK) last_rail = std::move(cc);
break; break;
} }
case Blueprint::Item::Type::RAIL_STATION: { case Blueprint::Item::Type::RAIL_STATION: {
// TODO station types // TODO station types
TileIndex tile = AddTileIndexDiffCWrap(start, item.tdiff); TileIndex tile = AddTileIndexDiffCWrap(start, item.tdiff);
auto cc = GetBlueprintCommand(start, item); auto cc = GetBlueprintCommand(start, item);
DoCommandWithCallback(cc, // FIXME
/* DoCommandWithCallback(cc,
[blueprint, tile, start, sign_part=item.u.rail.station.has_part, sid=item.u.rail.station.id] (bool res)->bool { [blueprint, tile, start, sign_part=item.u.rail.station.has_part, sid=item.u.rail.station.id] (bool res)->bool {
if (!res) return false; if (!res) return false;
StationID station_id = GetStationIndex(tile); StationID station_id = GetStationIndex(tile);
@@ -599,12 +617,12 @@ void BuildBlueprint(sp<Blueprint> &blueprint, TileIndex start) {
if (item.type != Blueprint::Item::Type::RAIL_STATION_PART) continue; if (item.type != Blueprint::Item::Type::RAIL_STATION_PART) continue;
if (item.u.rail.station_part.id != sid) continue; if (item.u.rail.station_part.id != sid) continue;
auto cc = GetBlueprintCommand(start, item); auto cc = GetBlueprintCommand(start, item);
DoCommandP(cc.tile, cc.p1 | (1 << 24), station_id << 16, cc.cmd); // FIXME DoCommandP(cc.tile, cc.p1 | (1 << 24), station_id << 16, cc.cmd);
} }
if (!sign_part) DoCommandP(tile, 0, 0, CMD_REMOVE_FROM_RAIL_STATION); if (!sign_part) ::Command<CMD_REMOVE_FROM_RAIL_STATION>::Post(tile, 0, false);
return true; return true;
} }
); );*/
break; break;
} }
default: default:
@@ -616,12 +634,12 @@ void BuildBlueprint(sp<Blueprint> &blueprint, TileIndex start) {
for (auto &item : blueprint->items) { for (auto &item : blueprint->items) {
if (item.type != Blueprint::Item::Type::RAIL_SIGNAL) continue; if (item.type != Blueprint::Item::Type::RAIL_SIGNAL) continue;
auto cc = GetBlueprintCommand(start, item); auto cc = GetBlueprintCommand(start, item);
DoCommandP(&cc); cc->Post();
} }
return true; return true;
}; };
if (last_rail.cmd != CMD_END) { // there can't be any signals if there are no rails if (last_rail != nullptr) { // there can't be any signals if there are no rails
AddCommandCallback(last_rail.tile, last_rail.p1, last_rail.p2, last_rail.cmd, "", signal_callback); // FIXME AddCommandCallback(last_rail.tile, last_rail.p1, last_rail.p2, last_rail.cmd, "", signal_callback);
} }
} }

View File

@@ -1,10 +1,17 @@
#ifndef CM_COMMAND_TYPE_HPP #ifndef CM_COMMAND_TYPE_HPP
#define CM_COMMAND_TYPE_HPP #define CM_COMMAND_TYPE_HPP
#include "../bridge.h"
#include "../command_func.h" #include "../command_func.h"
#include "../misc_cmd.h" #include "../misc_cmd.h"
#include "../object_type.h" #include "../object_type.h"
#include "../order_type.h" #include "../order_type.h"
#include "../road_type.h"
#include "../road_type.h"
#include "../station_type.h"
#include "../track_type.h"
enum StationClassID : byte;
namespace citymania { namespace citymania {
@@ -15,8 +22,11 @@ public:
CompanyID as_company = INVALID_COMPANY; CompanyID as_company = INVALID_COMPANY;
StringID error = (StringID)0; StringID error = (StringID)0;
Command() {}
Command(TileIndex tile) :tile{tile} {}
virtual ~Command() {} virtual ~Command() {}
virtual bool DoPost()=0; virtual bool DoPost()=0;
virtual bool DoTest()=0;
bool Post() { bool Post() {
CompanyID old = _current_company; CompanyID old = _current_company;
@@ -27,6 +37,15 @@ public:
return res; return res;
} }
bool Test() {
CompanyID old = _current_company;
if (this->as_company != INVALID_COMPANY)
_current_company = as_company;
bool res = this->DoTest();
_current_company = old;
return res;
}
Command &WithTile(TileIndex tile) { Command &WithTile(TileIndex tile) {
this->tile = tile; this->tile = tile;
return *this; return *this;

View File

@@ -26,7 +26,7 @@ void hash_combine(std::size_t& seed, const T& v, const Rest&... rest)
size_t GetCommandHash(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, const std::string &text) { size_t GetCommandHash(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, const std::string &text) {
size_t res = 0; size_t res = 0;
hash_combine(res, tile, p1, p2, cmd, text); // hash_combine(res, tile, p1, p2, cmd, text);
return res; return res;
} }
/* /*
@@ -58,13 +58,14 @@ bool DoCommandWithCallback(const CommandContainer &cc, CommandCallback callback)
} }
*/ */
void HandleCommandExecution(bool res, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, const std::string &text) { void HandleCommandExecution(bool res, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, const std::string &text) {
/* FIXME
auto hash = GetCommandHash(tile, p1, p2, cmd & CMD_ID_MASK, text); auto hash = GetCommandHash(tile, p1, p2, cmd & CMD_ID_MASK, text);
auto p = _command_callbacks.find(hash); auto p = _command_callbacks.find(hash);
// fprintf(stderr, "EXECUTED %lu (%u %u %u %u %s) %u\n", hash, tile, p1, p2, (uint)(cmd & CMD_ID_MASK), text.c_str(), (int)(p == _command_callbacks.end())); // fprintf(stderr, "EXECUTED %lu (%u %u %u %u %s) %u\n", hash, tile, p1, p2, (uint)(cmd & CMD_ID_MASK), text.c_str(), (int)(p == _command_callbacks.end()));
if (p == _command_callbacks.end()) return; if (p == _command_callbacks.end()) return;
for (auto &cb : p->second.second) for (auto &cb : p->second.second)
cb(res); cb(res);
_command_callbacks.erase(p); _command_callbacks.erase(p); */
} }
void ClearOldCallbacks() { void ClearOldCallbacks() {
@@ -118,24 +119,4 @@ void HandleNextClientFrame() {
_outgoing_queue.push(*cp); _outgoing_queue.push(*cp);
}*/ }*/
namespace cmd {
bool Pause::Post(bool automati) {
return ::Command<CMD_PAUSE>::Post(this->mode, this->pause);
}
bool DoTownAction::Post(bool automatic) {
return ::Command<CMD_DO_TOWN_ACTION>::Post(this->town_id, this->town_action);
}
bool SkipToOrder::Post(bool automatic) {
return ::Command<CMD_SKIP_TO_ORDER>::Post(
this->veh_id, this->sel_ord
_ctrl_pressed ? STR_ERROR_CAN_T_SKIP_TO_ORDER : STR_ERROR_CAN_T_SKIP_ORDER,
this->vehicle->tile, this->vehicle->index, citymania::_fn_mod ? this->OrderGetSel() : ((this->vehicle->cur_implicit_order_index + 1) % this->vehicle->GetNumOrders()));
}
} // namespace cmd
} // namespace citymania } // namespace citymania

View File

@@ -3,6 +3,7 @@
#include "cm_highlight.hpp" #include "cm_highlight.hpp"
#include "cm_blueprint.hpp" #include "cm_blueprint.hpp"
#include "cm_commands.hpp"
#include "cm_main.hpp" #include "cm_main.hpp"
#include "cm_station_gui.hpp" #include "cm_station_gui.hpp"
#include "cm_zoning.hpp" #include "cm_zoning.hpp"
@@ -309,23 +310,6 @@ static const DiagDirection _place_depot_extra_dir[12] = {
DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_NE,
}; };
bool CanBuild(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd) {
return DoCommandPInternal(
tile,
p1,
p2,
cmd,
nullptr, // callback
"", // text
true, // my_cmd
true // estimate_only
).Succeeded();
}
bool CanBuild(const CommandContainer &cc) {
return CanBuild(cc.tile, cc.p1, cc.p2, cc.cmd);
}
void ObjectHighlight::AddTile(TileIndex tile, ObjectTileHighlight &&oh) { void ObjectHighlight::AddTile(TileIndex tile, ObjectTileHighlight &&oh) {
if (tile >= MapSize()) return; if (tile >= MapSize()) return;
this->tiles.insert(std::make_pair(tile, std::move(oh))); this->tiles.insert(std::make_pair(tile, std::move(oh)));
@@ -341,12 +325,11 @@ void ObjectHighlight::UpdateTiles() {
case Type::RAIL_DEPOT: { case Type::RAIL_DEPOT: {
auto dir = this->ddir; auto dir = this->ddir;
auto palette = (CanBuild( auto palette = (cmd::BuildTrainDepot(
this->tile, this->tile,
_cur_railtype, _cur_railtype,
dir, dir
CMD_BUILD_TRAIN_DEPOT ).Test() ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
) ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
this->tiles.insert(std::make_pair(this->tile, ObjectTileHighlight::make_rail_depot(palette, dir))); this->tiles.insert(std::make_pair(this->tile, ObjectTileHighlight::make_rail_depot(palette, dir)));
auto tile = this->tile + TileOffsByDiagDir(dir); auto tile = this->tile + TileOffsByDiagDir(dir);
@@ -363,15 +346,17 @@ void ObjectHighlight::UpdateTiles() {
auto plat_len = ta.h; auto plat_len = ta.h;
if (this->axis == AXIS_X) Swap(numtracks, plat_len); if (this->axis == AXIS_X) Swap(numtracks, plat_len);
auto palette = (CanBuild( auto palette = (cmd::BuildRailStation(
this->tile, this->tile,
_cur_railtype _cur_railtype,
| (this->axis << 6) this->axis,
| ((uint32)numtracks << 8) numtracks,
| ((uint32)plat_len << 16), plat_len,
NEW_STATION << 16, _railstation.station_class,
CMD_BUILD_RAIL_STATION _railstation.station_type,
) ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP); NEW_STATION,
true
).Test() ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
auto layout_ptr = AllocaM(byte, (int)numtracks * plat_len); auto layout_ptr = AllocaM(byte, (int)numtracks * plat_len);
GetStationLayout(layout_ptr, numtracks, plat_len, nullptr); // TODO statspec GetStationLayout(layout_ptr, numtracks, plat_len, nullptr); // TODO statspec
@@ -393,12 +378,17 @@ void ObjectHighlight::UpdateTiles() {
} }
case Type::ROAD_STOP: { case Type::ROAD_STOP: {
auto ta = OrthogonalTileArea(this->tile, this->end_tile); auto ta = OrthogonalTileArea(this->tile, this->end_tile);
auto palette = (CanBuild( auto palette = (cmd::BuildRoadStop(
this->tile, this->tile,
(uint32)(ta.w | ta.h << 8), ta.w,
(this->is_truck ? 1 : 0) | (this->ddir >= DIAGDIR_END ? 2 : 0) | (((uint)this->ddir % 4) << 3) | (NEW_STATION << 16), ta.h,
CMD_BUILD_ROAD_STOP (this->is_truck ? ROADSTOP_TRUCK : ROADSTOP_BUS),
) ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP); (this->ddir >= DIAGDIR_END), // is_drive_through
(DiagDirection)(this->ddir % 4),
this->roadtype,
NEW_STATION,
true
).Test() ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
for (TileIndex tile : ta) { for (TileIndex tile : ta) {
this->AddTile(tile, ObjectTileHighlight::make_road_stop(palette, this->roadtype, this->ddir, this->is_truck)); this->AddTile(tile, ObjectTileHighlight::make_road_stop(palette, this->roadtype, this->ddir, this->is_truck));
} }
@@ -406,23 +396,23 @@ void ObjectHighlight::UpdateTiles() {
} }
case Type::ROAD_DEPOT: { case Type::ROAD_DEPOT: {
auto palette = (CanBuild( auto palette = (cmd::BuildRoadDepot(
this->tile, this->tile,
this->roadtype << 2 | this->ddir, this->roadtype,
0, this->ddir
CMD_BUILD_ROAD_DEPOT ).Test() ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
) ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
this->AddTile(this->tile, ObjectTileHighlight::make_road_depot(palette, this->roadtype, this->ddir)); this->AddTile(this->tile, ObjectTileHighlight::make_road_depot(palette, this->roadtype, this->ddir));
break; break;
} }
case Type::AIRPORT: { case Type::AIRPORT: {
auto palette = (CanBuild( auto palette = (cmd::BuildAirport(
this->tile, this->tile,
this->airport_type | ((uint)this->airport_layout << 8), this->airport_type,
1 | (NEW_STATION << 16), this->airport_layout,
CMD_BUILD_AIRPORT NEW_STATION,
) ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP); true
).Test() ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
const AirportSpec *as = AirportSpec::Get(this->airport_type); const AirportSpec *as = AirportSpec::Get(this->airport_type);
if (!as->IsAvailable() || this->airport_layout >= as->num_table) break; if (!as->IsAvailable() || this->airport_layout >= as->num_table) break;

View File

@@ -72,9 +72,6 @@ DECLARE_ENUM_AS_BIT_SET(ZoningBorder);
// SMALL = 3, // SMALL = 3,
// }; // };
bool CanBuild(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd);
bool CanBuild(const CommandContainer &cc);
TileHighlight GetTileHighlight(const TileInfo *ti, TileType tile_type); TileHighlight GetTileHighlight(const TileInfo *ti, TileType tile_type);
void DrawTileZoning(const TileInfo *ti, const TileHighlight &th, TileType tile_type); void DrawTileZoning(const TileInfo *ti, const TileHighlight &th, TileType tile_type);
bool DrawTileSelection(const TileInfo *ti, const TileHighlightType &tht); bool DrawTileSelection(const TileInfo *ti, const TileHighlightType &tht);

View File

@@ -71,7 +71,7 @@ public:
} signal; } signal;
struct { struct {
DiagDirection ddir; DiagDirection ddir;
TileIndexWrapper other_end; uint32 other_end;
BridgeType type; BridgeType type;
} bridge_head; } bridge_head;
struct { struct {

View File

@@ -226,7 +226,7 @@ void BuildLinkStatsLegend()
for (; i < _smallmap_cargo_count + lengthof(_linkstat_colours_in_legenda); ++i) { for (; i < _smallmap_cargo_count + lengthof(_linkstat_colours_in_legenda); ++i) {
_legend_linkstats[i].legend = STR_EMPTY; _legend_linkstats[i].legend = STR_EMPTY;
_legend_linkstats[i].colour = LinkGraphOverlay::LINK_COLOURS[_linkstat_colours_in_legenda[i - _smallmap_cargo_count]]; _legend_linkstats[i].colour = LinkGraphOverlay::LINK_COLOURS[_settings_client.gui.linkgraph_colours][_linkstat_colours_in_legenda[i - _smallmap_cargo_count]];
_legend_linkstats[i].show_on_map = true; _legend_linkstats[i].show_on_map = true;
} }

View File

@@ -2,6 +2,7 @@
#include "cm_misc_gui.hpp" #include "cm_misc_gui.hpp"
#include "../landscape_cmd.h"
#include "../command_func.h" #include "../command_func.h"
#include "../company_base.h" #include "../company_base.h"
#include "../debug.h" #include "../debug.h"
@@ -189,7 +190,7 @@ public:
Company *c = Company::GetIfValid(_local_company); Company *c = Company::GetIfValid(_local_company);
if (c != nullptr) { if (c != nullptr) {
assert(_current_company == _local_company); assert(_current_company == _local_company);
CommandCost costclear = DoCommand(tile, 0, 0, DC_QUERY_COST, CMD_LANDSCAPE_CLEAR); CommandCost costclear = ::Command<CMD_LANDSCAPE_CLEAR>::Do(DC_QUERY_COST, tile);
if (costclear.Succeeded()) { if (costclear.Succeeded()) {
Money cost = costclear.GetCost(); Money cost = costclear.GetCost();
if (cost < 0) { if (cost < 0) {

View File

@@ -17,6 +17,7 @@
#include "../object_type.h" #include "../object_type.h"
#include "../object_map.h" #include "../object_map.h"
#include "../station_base.h" #include "../station_base.h"
#include "../station_cmd.h"
#include "../strings_func.h" // GetString, SetDParam #include "../strings_func.h" // GetString, SetDParam
#include "../tilehighlight_type.h" #include "../tilehighlight_type.h"
#include "../town_map.h" #include "../town_map.h"
@@ -42,7 +43,7 @@ extern ViewportSignKdtree _viewport_sign_kdtree;
extern AirportClassID _selected_airport_class; extern AirportClassID _selected_airport_class;
extern int _selected_airport_index; extern int _selected_airport_index;
extern byte _selected_airport_layout; extern byte _selected_airport_layout;
extern void CcBuildAirport(Commands cmd, const CommandCost &result, TileIndex tile);
extern RailType _cur_railtype; // rail_gui.cpp extern RailType _cur_railtype; // rail_gui.cpp
struct RailStationGUISettings { struct RailStationGUISettings {
@@ -148,13 +149,14 @@ void OnStationTileSetChange(const Station *station, bool adding, StationType typ
if (station == _viewport_highlight_station) MarkCoverageAreaDirty(_viewport_highlight_station); if (station == _viewport_highlight_station) MarkCoverageAreaDirty(_viewport_highlight_station);
} }
CommandContainer _last_station_bulid_cmd; // CommandContainer _last_station_bulid_cmd;
void OnStationPartBuilt(const Station *station, TileIndex tile, uint32 p1, uint32 p2) { void OnStationPartBuilt(const Station *station, TileIndex tile, uint32 p1, uint32 p2) {
if (_current_company != _local_company) return; if (_current_company != _local_company) return;
if (tile != _last_station_bulid_cmd.tile || // FIXME
p1 != _last_station_bulid_cmd.p1 || // if (tile != _last_station_bulid_cmd.tile ||
p2 != _last_station_bulid_cmd.p2) return; // p1 != _last_station_bulid_cmd.p1 ||
// p2 != _last_station_bulid_cmd.p2) return;
_station_to_join = station; _station_to_join = station;
CheckRedrawStationCoverage(); CheckRedrawStationCoverage();
} }
@@ -212,7 +214,7 @@ void JoinAndBuild(JoinAndBuildCmdProc proc) {
if (citymania::_fn_mod) to_join = NEW_STATION; if (citymania::_fn_mod) to_join = NEW_STATION;
else if (join_to) to_join = join_to->index; else if (join_to) to_join = join_to->index;
FIXME _last_station_bulid_cmd = cmdcont; //FIXME _last_station_bulid_cmd = cmdcont;
proc(false, to_join, adjacent); proc(false, to_join, adjacent);
} }
@@ -354,8 +356,9 @@ void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, uint32 p2, uint32 c
} }
p2 |= ddir << 3; // Set the DiagDirecion into p2 bits 3 and 4. p2 |= ddir << 3; // Set the DiagDirecion into p2 bits 3 and 4.
CommandContainer cmdcont = { ta.tile, (uint32)(ta.w | ta.h << 8), p2, cmd, CcRoadStop, "" }; // FIXME
JoinAndBuild(cmdcont); // CommandContainer cmdcont = { ta.tile, (uint32)(ta.w | ta.h << 8), p2, cmd, CcRoadStop, "" };
// JoinAndBuild(cmdcont);
} }
void HandleStationPlacement(TileIndex start, TileIndex end) void HandleStationPlacement(TileIndex start, TileIndex end)
@@ -371,8 +374,9 @@ void HandleStationPlacement(TileIndex start, TileIndex end)
uint32 p1 = _cur_railtype | _railstation.orientation << 6 | numtracks << 8 | platlength << 16 | (citymania::_fn_mod ? 1 << 24 : 0); uint32 p1 = _cur_railtype | _railstation.orientation << 6 | numtracks << 8 | platlength << 16 | (citymania::_fn_mod ? 1 << 24 : 0);
uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16; uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16;
CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" }; // FIXME
JoinAndBuild(cmdcont); // CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" };
// JoinAndBuild(cmdcont);
} }
void PlaceRail_Station(TileIndex tile) { void PlaceRail_Station(TileIndex tile) {
@@ -385,8 +389,9 @@ void PlaceRail_Station(TileIndex tile) {
int h = _settings_client.gui.station_platlength; int h = _settings_client.gui.station_platlength;
if (!_railstation.orientation) Swap(w, h); if (!_railstation.orientation) Swap(w, h);
CommandContainer cmdcont = { tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" }; // FIXME
JoinAndBuild(cmdcont); // CommandContainer cmdcont = { tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" };
// JoinAndBuild(cmdcont);
} }
void PlaceDock(TileIndex tile) { void PlaceDock(TileIndex tile) {
@@ -395,17 +400,18 @@ void PlaceDock(TileIndex tile) {
uint32 p2 = (uint32)INVALID_STATION << 16; // no station to join uint32 p2 = (uint32)INVALID_STATION << 16; // no station to join
/* tile is always the land tile, so need to evaluate _thd.pos */ /* tile is always the land tile, so need to evaluate _thd.pos */
CommandContainer cmdcont = { tile, citymania::_fn_mod, p2, CMD_BUILD_DOCK | CMD_MSG(STR_ERROR_CAN_T_BUILD_DOCK_HERE), CcBuildDocks, "" }; // CommandContainer cmdcont = { tile, citymania::_fn_mod, p2, CMD_BUILD_DOCK | CMD_MSG(STR_ERROR_CAN_T_BUILD_DOCK_HERE), CcBuildDocks, "" };
/* Determine the watery part of the dock. */ /* Determine the watery part of the dock. */
// DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile)); // DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile));
// TileIndex tile_to = (dir != INVALID_DIAGDIR ? TileAddByDiagDir(tile, ReverseDiagDir(dir)) : tile); // TileIndex tile_to = (dir != INVALID_DIAGDIR ? TileAddByDiagDir(tile, ReverseDiagDir(dir)) : tile);
JoinAndBuild(cmdcont); // FIXME
// JoinAndBuild(cmdcont);
} }
void PlaceAirport(TileIndex tile) { void PlaceAirport(TileIndex tile) {
FIXME // FIXME
if (CheckStationJoin(tile, tile)) return; if (CheckStationJoin(tile, tile)) return;
if (_selected_airport_index == -1) return; if (_selected_airport_index == -1) return;
@@ -421,7 +427,7 @@ void PlaceAirport(TileIndex tile) {
} }
}; };
JoinAndBuild(cmdcont); // FIXME JoinAndBuild(cmdcont);
} }
static void FindStationsAroundSelection(const TileArea &location) static void FindStationsAroundSelection(const TileArea &location)
@@ -605,7 +611,7 @@ CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad)
} }
std::string GetStationCoverageProductionText(TileIndex tile, int w, int h, int rad, StationCoverageType sct) { std::string GetStationCoverageProductionText(TileIndex tile, int w, int h, int rad, StationCoverageType sct) {
auto production = GetProductionAroundTiles(tile, w, h, rad); auto production = citymania::GetProductionAroundTiles(tile, w, h, rad);
std::ostringstream s; std::ostringstream s;
char buffer[DRAW_STRING_BUFFER]; char buffer[DRAW_STRING_BUFFER];

View File

@@ -5,105 +5,356 @@
#include "../../src/misc_cmd.h" #include "../../src/misc_cmd.h"
#include "../../src/object_cmd.h" #include "../../src/object_cmd.h"
#include "../../src/order_cmd.h" #include "../../src/order_cmd.h"
#include "../../src/rail_cmd.h"
#include "../../src/road_cmd.h"
#include "../../src/station_cmd.h"
#include "../../src/town_cmd.h" #include "../../src/town_cmd.h"
#include "../../src/tunnelbridge_cmd.h"
namespace citymania { namespace citymania {
namespace cmd { namespace cmd {
bool MoneyCheat::DoPost() { bool MoneyCheat::DoPost() {
return ::Command<CMD_MONEY_CHEAT>::Post(this->error, this->tile, this->amount); return ::Command<CMD_MONEY_CHEAT>::Post(this->error, this->tile, this->amount);
} }
bool MoneyCheat::DoTest() {
return (::Command<CMD_MONEY_CHEAT>::Do(DC_NONE, this->amount)).Succeeded();
}
bool ChangeBankBalance::DoPost() { bool ChangeBankBalance::DoPost() {
return ::Command<CMD_CHANGE_BANK_BALANCE>::Post(this->error, this->tile, this->delta, this->company, this->expenses_type); return ::Command<CMD_CHANGE_BANK_BALANCE>::Post(this->error, this->tile, this->delta, this->company, this->expenses_type);
} }
bool ChangeBankBalance::DoTest() {
return (::Command<CMD_CHANGE_BANK_BALANCE>::Do(DC_NONE, this->tile, this->delta, this->company, this->expenses_type)).Succeeded();
}
bool IncreaseLoan::DoPost() { bool IncreaseLoan::DoPost() {
return ::Command<CMD_INCREASE_LOAN>::Post(this->error, this->tile, this->cmd, this->amount); return ::Command<CMD_INCREASE_LOAN>::Post(this->error, this->tile, this->cmd, this->amount);
} }
bool IncreaseLoan::DoTest() {
return (::Command<CMD_INCREASE_LOAN>::Do(DC_NONE, this->cmd, this->amount)).Succeeded();
}
bool DecreaseLoan::DoPost() { bool DecreaseLoan::DoPost() {
return ::Command<CMD_DECREASE_LOAN>::Post(this->error, this->tile, this->cmd, this->amount); return ::Command<CMD_DECREASE_LOAN>::Post(this->error, this->tile, this->cmd, this->amount);
} }
bool DecreaseLoan::DoTest() {
return (::Command<CMD_DECREASE_LOAN>::Do(DC_NONE, this->cmd, this->amount)).Succeeded();
}
bool Pause::DoPost() { bool Pause::DoPost() {
return ::Command<CMD_PAUSE>::Post(this->error, this->tile, this->mode, this->pause); return ::Command<CMD_PAUSE>::Post(this->error, this->tile, this->mode, this->pause);
} }
bool Pause::DoTest() {
return (::Command<CMD_PAUSE>::Do(DC_NONE, this->mode, this->pause)).Succeeded();
}
bool BuildObject::DoPost() { bool BuildObject::DoPost() {
return ::Command<CMD_BUILD_OBJECT>::Post(this->error, this->tile, this->type, this->view); return ::Command<CMD_BUILD_OBJECT>::Post(this->error, this->tile, this->type, this->view);
} }
bool BuildObject::DoTest() {
return (::Command<CMD_BUILD_OBJECT>::Do(DC_NONE, this->tile, this->type, this->view)).Succeeded();
}
bool BuildObjectArea::DoPost() { bool BuildObjectArea::DoPost() {
return ::Command<CMD_BUILD_OBJECT_AREA>::Post(this->error, this->tile, this->start_tile, this->type, this->view, this->diagonal); return ::Command<CMD_BUILD_OBJECT_AREA>::Post(this->error, this->tile, this->start_tile, this->type, this->view, this->diagonal);
} }
bool BuildObjectArea::DoTest() {
return (::Command<CMD_BUILD_OBJECT_AREA>::Do(DC_NONE, this->tile, this->start_tile, this->type, this->view, this->diagonal)).Succeeded();
}
bool ModifyOrder::DoPost() { bool ModifyOrder::DoPost() {
return ::Command<CMD_MODIFY_ORDER>::Post(this->error, this->tile, this->veh, this->sel_ord, this->mof, this->data); return ::Command<CMD_MODIFY_ORDER>::Post(this->error, this->tile, this->veh, this->sel_ord, this->mof, this->data);
} }
bool ModifyOrder::DoTest() {
return (::Command<CMD_MODIFY_ORDER>::Do(DC_NONE, this->veh, this->sel_ord, this->mof, this->data)).Succeeded();
}
bool SkipToOrder::DoPost() { bool SkipToOrder::DoPost() {
return ::Command<CMD_SKIP_TO_ORDER>::Post(this->error, this->tile, this->veh_id, this->sel_ord); return ::Command<CMD_SKIP_TO_ORDER>::Post(this->error, this->tile, this->veh_id, this->sel_ord);
} }
bool SkipToOrder::DoTest() {
return (::Command<CMD_SKIP_TO_ORDER>::Do(DC_NONE, this->veh_id, this->sel_ord)).Succeeded();
}
bool DeleteOrder::DoPost() { bool DeleteOrder::DoPost() {
return ::Command<CMD_DELETE_ORDER>::Post(this->error, this->tile, this->veh_id, this->sel_ord); return ::Command<CMD_DELETE_ORDER>::Post(this->error, this->tile, this->veh_id, this->sel_ord);
} }
bool DeleteOrder::DoTest() {
return (::Command<CMD_DELETE_ORDER>::Do(DC_NONE, this->veh_id, this->sel_ord)).Succeeded();
}
bool InsertOrder::DoPost() { bool InsertOrder::DoPost() {
return ::Command<CMD_INSERT_ORDER>::Post(this->error, this->tile, this->veh, this->sel_ord, this->new_order); return ::Command<CMD_INSERT_ORDER>::Post(this->error, this->tile, this->veh, this->sel_ord, this->new_order);
} }
bool InsertOrder::DoTest() {
return (::Command<CMD_INSERT_ORDER>::Do(DC_NONE, this->veh, this->sel_ord, this->new_order)).Succeeded();
}
bool OrderRefit::DoPost() { bool OrderRefit::DoPost() {
return ::Command<CMD_ORDER_REFIT>::Post(this->error, this->tile, this->veh, this->order_number, this->cargo); return ::Command<CMD_ORDER_REFIT>::Post(this->error, this->tile, this->veh, this->order_number, this->cargo);
} }
bool OrderRefit::DoTest() {
return (::Command<CMD_ORDER_REFIT>::Do(DC_NONE, this->veh, this->order_number, this->cargo)).Succeeded();
}
bool CloneOrder::DoPost() { bool CloneOrder::DoPost() {
return ::Command<CMD_CLONE_ORDER>::Post(this->error, this->tile, this->action, this->veh_dst, this->veh_src); return ::Command<CMD_CLONE_ORDER>::Post(this->error, this->tile, this->action, this->veh_dst, this->veh_src);
} }
bool CloneOrder::DoTest() {
return (::Command<CMD_CLONE_ORDER>::Do(DC_NONE, this->action, this->veh_dst, this->veh_src)).Succeeded();
}
bool MoveOrder::DoPost() { bool MoveOrder::DoPost() {
return ::Command<CMD_MOVE_ORDER>::Post(this->error, this->tile, this->veh, this->moving_order, this->target_order); return ::Command<CMD_MOVE_ORDER>::Post(this->error, this->tile, this->veh, this->moving_order, this->target_order);
} }
bool MoveOrder::DoTest() {
return (::Command<CMD_MOVE_ORDER>::Do(DC_NONE, this->veh, this->moving_order, this->target_order)).Succeeded();
}
bool ClearOrderBackup::DoPost() { bool ClearOrderBackup::DoPost() {
return ::Command<CMD_CLEAR_ORDER_BACKUP>::Post(this->error, this->tile, this->user_id); return ::Command<CMD_CLEAR_ORDER_BACKUP>::Post(this->error, this->tile, this->user_id);
} }
bool ClearOrderBackup::DoTest() {
return (::Command<CMD_CLEAR_ORDER_BACKUP>::Do(DC_NONE, this->tile, this->user_id)).Succeeded();
}
bool BuildRailroadTrack::DoPost() {
return ::Command<CMD_BUILD_RAILROAD_TRACK>::Post(this->error, this->tile, this->start_tile, this->railtype, this->track, this->auto_remove_signals, this->fail_on_obstacle);
}
bool BuildRailroadTrack::DoTest() {
return (::Command<CMD_BUILD_RAILROAD_TRACK>::Do(DC_NONE, this->tile, this->start_tile, this->railtype, this->track, this->auto_remove_signals, this->fail_on_obstacle)).Succeeded();
}
bool RemoveRailroadTrack::DoPost() {
return ::Command<CMD_REMOVE_RAILROAD_TRACK>::Post(this->error, this->tile, this->start_tile, this->track);
}
bool RemoveRailroadTrack::DoTest() {
return (::Command<CMD_REMOVE_RAILROAD_TRACK>::Do(DC_NONE, this->tile, this->start_tile, this->track)).Succeeded();
}
bool BuildSingleRail::DoPost() {
return ::Command<CMD_BUILD_SINGLE_RAIL>::Post(this->error, this->tile, this->railtype, this->track, this->auto_remove_signals);
}
bool BuildSingleRail::DoTest() {
return (::Command<CMD_BUILD_SINGLE_RAIL>::Do(DC_NONE, this->tile, this->railtype, this->track, this->auto_remove_signals)).Succeeded();
}
bool RemoveSingleRail::DoPost() {
return ::Command<CMD_REMOVE_SINGLE_RAIL>::Post(this->error, this->tile, this->track);
}
bool RemoveSingleRail::DoTest() {
return (::Command<CMD_REMOVE_SINGLE_RAIL>::Do(DC_NONE, this->tile, this->track)).Succeeded();
}
bool BuildTrainDepot::DoPost() {
return ::Command<CMD_BUILD_TRAIN_DEPOT>::Post(this->error, this->tile, this->railtype, this->dir);
}
bool BuildTrainDepot::DoTest() {
return (::Command<CMD_BUILD_TRAIN_DEPOT>::Do(DC_NONE, this->tile, this->railtype, this->dir)).Succeeded();
}
bool BuildSingleSignal::DoPost() {
return ::Command<CMD_BUILD_SIGNALS>::Post(this->error, this->tile, this->track, this->sigtype, this->sigvar, this->convert_signal, this->skip_existing_signals, this->ctrl_pressed, this->cycle_start, this->cycle_stop, this->num_dir_cycle, this->signals_copy);
}
bool BuildSingleSignal::DoTest() {
return (::Command<CMD_BUILD_SIGNALS>::Do(DC_NONE, this->tile, this->track, this->sigtype, this->sigvar, this->convert_signal, this->skip_existing_signals, this->ctrl_pressed, this->cycle_start, this->cycle_stop, this->num_dir_cycle, this->signals_copy)).Succeeded();
}
bool RemoveSingleSignal::DoPost() {
return ::Command<CMD_REMOVE_SIGNALS>::Post(this->error, this->tile, this->track);
}
bool RemoveSingleSignal::DoTest() {
return (::Command<CMD_REMOVE_SIGNALS>::Do(DC_NONE, this->tile, this->track)).Succeeded();
}
bool ConvertRail::DoPost() {
return ::Command<CMD_CONVERT_RAIL>::Post(this->error, this->tile, this->area_start, this->totype, this->diagonal);
}
bool ConvertRail::DoTest() {
return (::Command<CMD_CONVERT_RAIL>::Do(DC_NONE, this->tile, this->area_start, this->totype, this->diagonal)).Succeeded();
}
bool BuildSignalTrack::DoPost() {
return ::Command<CMD_BUILD_SIGNAL_TRACK>::Post(this->error, this->tile, this->end_tile, this->track, this->sigtype, this->sigvar, this->mode, this->autofill, this->minimise_gaps, this->signal_density);
}
bool BuildSignalTrack::DoTest() {
return (::Command<CMD_BUILD_SIGNAL_TRACK>::Do(DC_NONE, this->tile, this->end_tile, this->track, this->sigtype, this->sigvar, this->mode, this->autofill, this->minimise_gaps, this->signal_density)).Succeeded();
}
bool RemoveSignalTrack::DoPost() {
return ::Command<CMD_REMOVE_SIGNAL_TRACK>::Post(this->error, this->tile, this->end_tile, this->track, this->autofill);
}
bool RemoveSignalTrack::DoTest() {
return (::Command<CMD_REMOVE_SIGNAL_TRACK>::Do(DC_NONE, this->tile, this->end_tile, this->track, this->autofill)).Succeeded();
}
bool BuildLongRoad::DoPost() {
return ::Command<CMD_BUILD_LONG_ROAD>::Post(this->error, this->tile, this->start_tile, this->rt, this->axis, this->drd, this->start_half, this->end_half, this->is_ai);
}
bool BuildLongRoad::DoTest() {
return (::Command<CMD_BUILD_LONG_ROAD>::Do(DC_NONE, this->tile, this->start_tile, this->rt, this->axis, this->drd, this->start_half, this->end_half, this->is_ai)).Succeeded();
}
bool RemoveLongRoad::DoPost() {
return ::Command<CMD_REMOVE_LONG_ROAD>::Post(this->error, this->tile, this->start_tile, this->rt, this->axis, this->start_half, this->end_half);
}
bool RemoveLongRoad::DoTest() {
return std::get<0>(::Command<CMD_REMOVE_LONG_ROAD>::Do(DC_NONE, this->tile, this->start_tile, this->rt, this->axis, this->start_half, this->end_half)).Succeeded();
}
bool BuildRoad::DoPost() {
return ::Command<CMD_BUILD_ROAD>::Post(this->error, this->tile, this->pieces, this->rt, this->toggle_drd, this->town_id);
}
bool BuildRoad::DoTest() {
return (::Command<CMD_BUILD_ROAD>::Do(DC_NONE, this->tile, this->pieces, this->rt, this->toggle_drd, this->town_id)).Succeeded();
}
bool BuildRoadDepot::DoPost() {
return ::Command<CMD_BUILD_ROAD_DEPOT>::Post(this->error, this->tile, this->rt, this->dir);
}
bool BuildRoadDepot::DoTest() {
return (::Command<CMD_BUILD_ROAD_DEPOT>::Do(DC_NONE, this->tile, this->rt, this->dir)).Succeeded();
}
bool ConvertRoad::DoPost() {
return ::Command<CMD_CONVERT_ROAD>::Post(this->error, this->tile, this->area_start, this->to_type);
}
bool ConvertRoad::DoTest() {
return (::Command<CMD_CONVERT_ROAD>::Do(DC_NONE, this->tile, this->area_start, this->to_type)).Succeeded();
}
bool BuildAirport::DoPost() {
return ::Command<CMD_BUILD_AIRPORT>::Post(this->error, this->tile, this->airport_type, this->layout, this->station_to_join, this->allow_adjacent);
}
bool BuildAirport::DoTest() {
return (::Command<CMD_BUILD_AIRPORT>::Do(DC_NONE, this->tile, this->airport_type, this->layout, this->station_to_join, this->allow_adjacent)).Succeeded();
}
bool BuildDock::DoPost() {
return ::Command<CMD_BUILD_DOCK>::Post(this->error, this->tile, this->station_to_join, this->adjacent);
}
bool BuildDock::DoTest() {
return (::Command<CMD_BUILD_DOCK>::Do(DC_NONE, this->tile, this->station_to_join, this->adjacent)).Succeeded();
}
bool BuildRailStation::DoPost() {
return ::Command<CMD_BUILD_RAIL_STATION>::Post(this->error, this->tile, this->rt, this->axis, this->numtracks, this->plat_len, this->spec_class, this->spec_index, this->station_to_join, this->adjacent);
}
bool BuildRailStation::DoTest() {
return (::Command<CMD_BUILD_RAIL_STATION>::Do(DC_NONE, this->tile, this->rt, this->axis, this->numtracks, this->plat_len, this->spec_class, this->spec_index, this->station_to_join, this->adjacent)).Succeeded();
}
bool RemoveFromRailStation::DoPost() {
return ::Command<CMD_REMOVE_FROM_RAIL_STATION>::Post(this->error, this->tile, this->end, this->keep_rail);
}
bool RemoveFromRailStation::DoTest() {
return (::Command<CMD_REMOVE_FROM_RAIL_STATION>::Do(DC_NONE, this->tile, this->end, this->keep_rail)).Succeeded();
}
bool BuildRoadStop::DoPost() {
return ::Command<CMD_BUILD_ROAD_STOP>::Post(this->error, this->tile, this->width, this->length, this->stop_type, this->is_drive_through, this->ddir, this->rt, this->station_to_join, this->adjacent);
}
bool BuildRoadStop::DoTest() {
return (::Command<CMD_BUILD_ROAD_STOP>::Do(DC_NONE, this->tile, this->width, this->length, this->stop_type, this->is_drive_through, this->ddir, this->rt, this->station_to_join, this->adjacent)).Succeeded();
}
bool RemoveRoadStop::DoPost() {
return ::Command<CMD_REMOVE_ROAD_STOP>::Post(this->error, this->tile, this->width, this->height, this->stop_type, this->remove_road);
}
bool RemoveRoadStop::DoTest() {
return (::Command<CMD_REMOVE_ROAD_STOP>::Do(DC_NONE, this->tile, this->width, this->height, this->stop_type, this->remove_road)).Succeeded();
}
bool RenameStation::DoPost() {
return ::Command<CMD_RENAME_STATION>::Post(this->error, this->tile, this->station_id, this->text);
}
bool RenameStation::DoTest() {
return (::Command<CMD_RENAME_STATION>::Do(DC_NONE, this->station_id, this->text)).Succeeded();
}
bool OpenCloseAirport::DoPost() {
return ::Command<CMD_OPEN_CLOSE_AIRPORT>::Post(this->error, this->tile, this->station_id);
}
bool OpenCloseAirport::DoTest() {
return (::Command<CMD_OPEN_CLOSE_AIRPORT>::Do(DC_NONE, this->station_id)).Succeeded();
}
bool FoundTown::DoPost() { bool FoundTown::DoPost() {
return ::Command<CMD_FOUND_TOWN>::Post(this->error, this->tile, this->size, this->city, this->layout, this->random_location, this->townnameparts, this->text); return ::Command<CMD_FOUND_TOWN>::Post(this->error, this->tile, this->size, this->city, this->layout, this->random_location, this->townnameparts, this->text);
} }
bool FoundTown::DoTest() {
return std::get<0>(::Command<CMD_FOUND_TOWN>::Do(DC_NONE, this->tile, this->size, this->city, this->layout, this->random_location, this->townnameparts, this->text)).Succeeded();
}
bool RenameTown::DoPost() { bool RenameTown::DoPost() {
return ::Command<CMD_RENAME_TOWN>::Post(this->error, this->tile, this->town_id, this->text); return ::Command<CMD_RENAME_TOWN>::Post(this->error, this->tile, this->town_id, this->text);
} }
bool RenameTown::DoTest() {
return (::Command<CMD_RENAME_TOWN>::Do(DC_NONE, this->town_id, this->text)).Succeeded();
}
bool DoTownAction::DoPost() { bool DoTownAction::DoPost() {
return ::Command<CMD_DO_TOWN_ACTION>::Post(this->error, this->tile, this->town_id, this->action); return ::Command<CMD_DO_TOWN_ACTION>::Post(this->error, this->tile, this->town_id, this->action);
} }
bool DoTownAction::DoTest() {
return (::Command<CMD_DO_TOWN_ACTION>::Do(DC_NONE, this->town_id, this->action)).Succeeded();
}
bool TownGrowthRate::DoPost() { bool TownGrowthRate::DoPost() {
return ::Command<CMD_TOWN_GROWTH_RATE>::Post(this->error, this->tile, this->town_id, this->growth_rate); return ::Command<CMD_TOWN_GROWTH_RATE>::Post(this->error, this->tile, this->town_id, this->growth_rate);
} }
bool TownGrowthRate::DoTest() {
return (::Command<CMD_TOWN_GROWTH_RATE>::Do(DC_NONE, this->town_id, this->growth_rate)).Succeeded();
}
bool TownRating::DoPost() { bool TownRating::DoPost() {
return ::Command<CMD_TOWN_RATING>::Post(this->error, this->tile, this->town_id, this->company_id, this->rating); return ::Command<CMD_TOWN_RATING>::Post(this->error, this->tile, this->town_id, this->company_id, this->rating);
} }
bool TownRating::DoTest() {
return (::Command<CMD_TOWN_RATING>::Do(DC_NONE, this->town_id, this->company_id, this->rating)).Succeeded();
}
bool TownCargoGoal::DoPost() { bool TownCargoGoal::DoPost() {
return ::Command<CMD_TOWN_CARGO_GOAL>::Post(this->error, this->tile, this->town_id, this->te, this->goal); return ::Command<CMD_TOWN_CARGO_GOAL>::Post(this->error, this->tile, this->town_id, this->te, this->goal);
} }
bool TownCargoGoal::DoTest() {
return (::Command<CMD_TOWN_CARGO_GOAL>::Do(DC_NONE, this->town_id, this->te, this->goal)).Succeeded();
}
bool TownSetText::DoPost() { bool TownSetText::DoPost() {
return ::Command<CMD_TOWN_SET_TEXT>::Post(this->error, this->tile, this->town_id, this->text); return ::Command<CMD_TOWN_SET_TEXT>::Post(this->error, this->tile, this->town_id, this->text);
} }
bool TownSetText::DoTest() {
return (::Command<CMD_TOWN_SET_TEXT>::Do(DC_NONE, this->town_id, this->text)).Succeeded();
}
bool ExpandTown::DoPost() { bool ExpandTown::DoPost() {
return ::Command<CMD_EXPAND_TOWN>::Post(this->error, this->tile, this->town_id, this->grow_amount); return ::Command<CMD_EXPAND_TOWN>::Post(this->error, this->tile, this->town_id, this->grow_amount);
} }
bool ExpandTown::DoTest() {
return (::Command<CMD_EXPAND_TOWN>::Do(DC_NONE, this->town_id, this->grow_amount)).Succeeded();
}
bool DeleteTown::DoPost() { bool DeleteTown::DoPost() {
return ::Command<CMD_DELETE_TOWN>::Post(this->error, this->tile, this->town_id); return ::Command<CMD_DELETE_TOWN>::Post(this->error, this->tile, this->town_id);
} }
bool DeleteTown::DoTest() {
return (::Command<CMD_DELETE_TOWN>::Do(DC_NONE, this->town_id)).Succeeded();
}
bool BuildBridge::DoPost() {
return ::Command<CMD_BUILD_BRIDGE>::Post(this->error, this->tile, this->tile_start, this->transport_type, this->bridge_type, this->road_rail_type);
}
bool BuildBridge::DoTest() {
return (::Command<CMD_BUILD_BRIDGE>::Do(DC_NONE, this->tile, this->tile_start, this->transport_type, this->bridge_type, this->road_rail_type)).Succeeded();
}
bool BuildTunnel::DoPost() {
return ::Command<CMD_BUILD_TUNNEL>::Post(this->error, this->tile, this->transport_type, this->road_rail_type);
}
bool BuildTunnel::DoTest() {
return (::Command<CMD_BUILD_TUNNEL>::Do(DC_NONE, this->tile, this->transport_type, this->road_rail_type)).Succeeded();
}
} // namespace cmd } // namespace cmd
} // namespace citymania } // namespace citymania

View File

@@ -10,11 +10,12 @@ class MoneyCheat: public Command {
public: public:
Money amount; Money amount;
MoneyCheat(Money amount) MoneyCheat(Money amount)
:amount{amount} {} :amount{amount} {}
~MoneyCheat() override {} ~MoneyCheat() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class ChangeBankBalance: public Command { class ChangeBankBalance: public Command {
@@ -23,11 +24,14 @@ public:
CompanyID company; CompanyID company;
ExpensesType expenses_type; ExpensesType expenses_type;
ChangeBankBalance(Money delta, CompanyID company, ExpensesType expenses_type) ChangeBankBalance(Money delta, CompanyID company, ExpensesType expenses_type)
:delta{delta}, company{company}, expenses_type{expenses_type} {} :delta{delta}, company{company}, expenses_type{expenses_type} {}
ChangeBankBalance(TileIndex tile, Money delta, CompanyID company, ExpensesType expenses_type)
:Command{tile}, delta{delta}, company{company}, expenses_type{expenses_type} {}
~ChangeBankBalance() override {} ~ChangeBankBalance() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class IncreaseLoan: public Command { class IncreaseLoan: public Command {
@@ -35,11 +39,12 @@ public:
LoanCommand cmd; LoanCommand cmd;
Money amount; Money amount;
IncreaseLoan(LoanCommand cmd, Money amount) IncreaseLoan(LoanCommand cmd, Money amount)
:cmd{cmd}, amount{amount} {} :cmd{cmd}, amount{amount} {}
~IncreaseLoan() override {} ~IncreaseLoan() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class DecreaseLoan: public Command { class DecreaseLoan: public Command {
@@ -47,11 +52,12 @@ public:
LoanCommand cmd; LoanCommand cmd;
Money amount; Money amount;
DecreaseLoan(LoanCommand cmd, Money amount) DecreaseLoan(LoanCommand cmd, Money amount)
:cmd{cmd}, amount{amount} {} :cmd{cmd}, amount{amount} {}
~DecreaseLoan() override {} ~DecreaseLoan() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class Pause: public Command { class Pause: public Command {
@@ -59,11 +65,12 @@ public:
PauseMode mode; PauseMode mode;
bool pause; bool pause;
Pause(PauseMode mode, bool pause) Pause(PauseMode mode, bool pause)
:mode{mode}, pause{pause} {} :mode{mode}, pause{pause} {}
~Pause() override {} ~Pause() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class BuildObject: public Command { class BuildObject: public Command {
@@ -71,11 +78,14 @@ public:
ObjectType type; ObjectType type;
uint8 view; uint8 view;
BuildObject(ObjectType type, uint8 view) BuildObject(ObjectType type, uint8 view)
:type{type}, view{view} {} :type{type}, view{view} {}
BuildObject(TileIndex tile, ObjectType type, uint8 view)
:Command{tile}, type{type}, view{view} {}
~BuildObject() override {} ~BuildObject() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class BuildObjectArea: public Command { class BuildObjectArea: public Command {
@@ -85,11 +95,14 @@ public:
uint8 view; uint8 view;
bool diagonal; bool diagonal;
BuildObjectArea(TileIndex start_tile, ObjectType type, uint8 view, bool diagonal) BuildObjectArea(TileIndex start_tile, ObjectType type, uint8 view, bool diagonal)
:start_tile{start_tile}, type{type}, view{view}, diagonal{diagonal} {} :start_tile{start_tile}, type{type}, view{view}, diagonal{diagonal} {}
BuildObjectArea(TileIndex tile, TileIndex start_tile, ObjectType type, uint8 view, bool diagonal)
:Command{tile}, start_tile{start_tile}, type{type}, view{view}, diagonal{diagonal} {}
~BuildObjectArea() override {} ~BuildObjectArea() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class ModifyOrder: public Command { class ModifyOrder: public Command {
@@ -99,11 +112,12 @@ public:
ModifyOrderFlags mof; ModifyOrderFlags mof;
uint16 data; uint16 data;
ModifyOrder(VehicleID veh, VehicleOrderID sel_ord, ModifyOrderFlags mof, uint16 data) ModifyOrder(VehicleID veh, VehicleOrderID sel_ord, ModifyOrderFlags mof, uint16 data)
:veh{veh}, sel_ord{sel_ord}, mof{mof}, data{data} {} :veh{veh}, sel_ord{sel_ord}, mof{mof}, data{data} {}
~ModifyOrder() override {} ~ModifyOrder() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class SkipToOrder: public Command { class SkipToOrder: public Command {
@@ -111,11 +125,12 @@ public:
VehicleID veh_id; VehicleID veh_id;
VehicleOrderID sel_ord; VehicleOrderID sel_ord;
SkipToOrder(VehicleID veh_id, VehicleOrderID sel_ord) SkipToOrder(VehicleID veh_id, VehicleOrderID sel_ord)
:veh_id{veh_id}, sel_ord{sel_ord} {} :veh_id{veh_id}, sel_ord{sel_ord} {}
~SkipToOrder() override {} ~SkipToOrder() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class DeleteOrder: public Command { class DeleteOrder: public Command {
@@ -123,11 +138,12 @@ public:
VehicleID veh_id; VehicleID veh_id;
VehicleOrderID sel_ord; VehicleOrderID sel_ord;
DeleteOrder(VehicleID veh_id, VehicleOrderID sel_ord) DeleteOrder(VehicleID veh_id, VehicleOrderID sel_ord)
:veh_id{veh_id}, sel_ord{sel_ord} {} :veh_id{veh_id}, sel_ord{sel_ord} {}
~DeleteOrder() override {} ~DeleteOrder() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class InsertOrder: public Command { class InsertOrder: public Command {
@@ -136,11 +152,12 @@ public:
VehicleOrderID sel_ord; VehicleOrderID sel_ord;
const Order &new_order; const Order &new_order;
InsertOrder(VehicleID veh, VehicleOrderID sel_ord, const Order & new_order) InsertOrder(VehicleID veh, VehicleOrderID sel_ord, const Order &new_order)
:veh{veh}, sel_ord{sel_ord}, new_order{new_order} {} :veh{veh}, sel_ord{sel_ord}, new_order{new_order} {}
~InsertOrder() override {} ~InsertOrder() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class OrderRefit: public Command { class OrderRefit: public Command {
@@ -149,11 +166,12 @@ public:
VehicleOrderID order_number; VehicleOrderID order_number;
CargoID cargo; CargoID cargo;
OrderRefit(VehicleID veh, VehicleOrderID order_number, CargoID cargo) OrderRefit(VehicleID veh, VehicleOrderID order_number, CargoID cargo)
:veh{veh}, order_number{order_number}, cargo{cargo} {} :veh{veh}, order_number{order_number}, cargo{cargo} {}
~OrderRefit() override {} ~OrderRefit() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class CloneOrder: public Command { class CloneOrder: public Command {
@@ -162,11 +180,12 @@ public:
VehicleID veh_dst; VehicleID veh_dst;
VehicleID veh_src; VehicleID veh_src;
CloneOrder(CloneOptions action, VehicleID veh_dst, VehicleID veh_src) CloneOrder(CloneOptions action, VehicleID veh_dst, VehicleID veh_src)
:action{action}, veh_dst{veh_dst}, veh_src{veh_src} {} :action{action}, veh_dst{veh_dst}, veh_src{veh_src} {}
~CloneOrder() override {} ~CloneOrder() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class MoveOrder: public Command { class MoveOrder: public Command {
@@ -175,22 +194,410 @@ public:
VehicleOrderID moving_order; VehicleOrderID moving_order;
VehicleOrderID target_order; VehicleOrderID target_order;
MoveOrder(VehicleID veh, VehicleOrderID moving_order, VehicleOrderID target_order) MoveOrder(VehicleID veh, VehicleOrderID moving_order, VehicleOrderID target_order)
:veh{veh}, moving_order{moving_order}, target_order{target_order} {} :veh{veh}, moving_order{moving_order}, target_order{target_order} {}
~MoveOrder() override {} ~MoveOrder() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class ClearOrderBackup: public Command { class ClearOrderBackup: public Command {
public: public:
ClientID user_id; ClientID user_id;
ClearOrderBackup(ClientID user_id) ClearOrderBackup(ClientID user_id)
:user_id{user_id} {} :user_id{user_id} {}
ClearOrderBackup(TileIndex tile, ClientID user_id)
:Command{tile}, user_id{user_id} {}
~ClearOrderBackup() override {} ~ClearOrderBackup() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
};
class BuildRailroadTrack: public Command {
public:
TileIndex start_tile;
RailType railtype;
Track track;
bool auto_remove_signals;
bool fail_on_obstacle;
BuildRailroadTrack(TileIndex start_tile, RailType railtype, Track track, bool auto_remove_signals, bool fail_on_obstacle)
:start_tile{start_tile}, railtype{railtype}, track{track}, auto_remove_signals{auto_remove_signals}, fail_on_obstacle{fail_on_obstacle} {}
BuildRailroadTrack(TileIndex tile, TileIndex start_tile, RailType railtype, Track track, bool auto_remove_signals, bool fail_on_obstacle)
:Command{tile}, start_tile{start_tile}, railtype{railtype}, track{track}, auto_remove_signals{auto_remove_signals}, fail_on_obstacle{fail_on_obstacle} {}
~BuildRailroadTrack() override {}
bool DoPost() override;
bool DoTest() override;
};
class RemoveRailroadTrack: public Command {
public:
TileIndex start_tile;
Track track;
RemoveRailroadTrack(TileIndex start_tile, Track track)
:start_tile{start_tile}, track{track} {}
RemoveRailroadTrack(TileIndex tile, TileIndex start_tile, Track track)
:Command{tile}, start_tile{start_tile}, track{track} {}
~RemoveRailroadTrack() override {}
bool DoPost() override;
bool DoTest() override;
};
class BuildSingleRail: public Command {
public:
RailType railtype;
Track track;
bool auto_remove_signals;
BuildSingleRail(RailType railtype, Track track, bool auto_remove_signals)
:railtype{railtype}, track{track}, auto_remove_signals{auto_remove_signals} {}
BuildSingleRail(TileIndex tile, RailType railtype, Track track, bool auto_remove_signals)
:Command{tile}, railtype{railtype}, track{track}, auto_remove_signals{auto_remove_signals} {}
~BuildSingleRail() override {}
bool DoPost() override;
bool DoTest() override;
};
class RemoveSingleRail: public Command {
public:
Track track;
RemoveSingleRail(Track track)
:track{track} {}
RemoveSingleRail(TileIndex tile, Track track)
:Command{tile}, track{track} {}
~RemoveSingleRail() override {}
bool DoPost() override;
bool DoTest() override;
};
class BuildTrainDepot: public Command {
public:
RailType railtype;
DiagDirection dir;
BuildTrainDepot(RailType railtype, DiagDirection dir)
:railtype{railtype}, dir{dir} {}
BuildTrainDepot(TileIndex tile, RailType railtype, DiagDirection dir)
:Command{tile}, railtype{railtype}, dir{dir} {}
~BuildTrainDepot() override {}
bool DoPost() override;
bool DoTest() override;
};
class BuildSingleSignal: public Command {
public:
Track track;
SignalType sigtype;
SignalVariant sigvar;
bool convert_signal;
bool skip_existing_signals;
bool ctrl_pressed;
SignalType cycle_start;
SignalType cycle_stop;
uint8 num_dir_cycle;
byte signals_copy;
BuildSingleSignal(Track track, SignalType sigtype, SignalVariant sigvar, bool convert_signal, bool skip_existing_signals, bool ctrl_pressed, SignalType cycle_start, SignalType cycle_stop, uint8 num_dir_cycle, byte signals_copy)
:track{track}, sigtype{sigtype}, sigvar{sigvar}, convert_signal{convert_signal}, skip_existing_signals{skip_existing_signals}, ctrl_pressed{ctrl_pressed}, cycle_start{cycle_start}, cycle_stop{cycle_stop}, num_dir_cycle{num_dir_cycle}, signals_copy{signals_copy} {}
BuildSingleSignal(TileIndex tile, Track track, SignalType sigtype, SignalVariant sigvar, bool convert_signal, bool skip_existing_signals, bool ctrl_pressed, SignalType cycle_start, SignalType cycle_stop, uint8 num_dir_cycle, byte signals_copy)
:Command{tile}, track{track}, sigtype{sigtype}, sigvar{sigvar}, convert_signal{convert_signal}, skip_existing_signals{skip_existing_signals}, ctrl_pressed{ctrl_pressed}, cycle_start{cycle_start}, cycle_stop{cycle_stop}, num_dir_cycle{num_dir_cycle}, signals_copy{signals_copy} {}
~BuildSingleSignal() override {}
bool DoPost() override;
bool DoTest() override;
};
class RemoveSingleSignal: public Command {
public:
Track track;
RemoveSingleSignal(Track track)
:track{track} {}
RemoveSingleSignal(TileIndex tile, Track track)
:Command{tile}, track{track} {}
~RemoveSingleSignal() override {}
bool DoPost() override;
bool DoTest() override;
};
class ConvertRail: public Command {
public:
TileIndex area_start;
RailType totype;
bool diagonal;
ConvertRail(TileIndex area_start, RailType totype, bool diagonal)
:area_start{area_start}, totype{totype}, diagonal{diagonal} {}
ConvertRail(TileIndex tile, TileIndex area_start, RailType totype, bool diagonal)
:Command{tile}, area_start{area_start}, totype{totype}, diagonal{diagonal} {}
~ConvertRail() override {}
bool DoPost() override;
bool DoTest() override;
};
class BuildSignalTrack: public Command {
public:
TileIndex end_tile;
Track track;
SignalType sigtype;
SignalVariant sigvar;
bool mode;
bool autofill;
bool minimise_gaps;
byte signal_density;
BuildSignalTrack(TileIndex end_tile, Track track, SignalType sigtype, SignalVariant sigvar, bool mode, bool autofill, bool minimise_gaps, byte signal_density)
:end_tile{end_tile}, track{track}, sigtype{sigtype}, sigvar{sigvar}, mode{mode}, autofill{autofill}, minimise_gaps{minimise_gaps}, signal_density{signal_density} {}
BuildSignalTrack(TileIndex tile, TileIndex end_tile, Track track, SignalType sigtype, SignalVariant sigvar, bool mode, bool autofill, bool minimise_gaps, byte signal_density)
:Command{tile}, end_tile{end_tile}, track{track}, sigtype{sigtype}, sigvar{sigvar}, mode{mode}, autofill{autofill}, minimise_gaps{minimise_gaps}, signal_density{signal_density} {}
~BuildSignalTrack() override {}
bool DoPost() override;
bool DoTest() override;
};
class RemoveSignalTrack: public Command {
public:
TileIndex end_tile;
Track track;
bool autofill;
RemoveSignalTrack(TileIndex end_tile, Track track, bool autofill)
:end_tile{end_tile}, track{track}, autofill{autofill} {}
RemoveSignalTrack(TileIndex tile, TileIndex end_tile, Track track, bool autofill)
:Command{tile}, end_tile{end_tile}, track{track}, autofill{autofill} {}
~RemoveSignalTrack() override {}
bool DoPost() override;
bool DoTest() override;
};
class BuildLongRoad: public Command {
public:
TileIndex start_tile;
RoadType rt;
Axis axis;
DisallowedRoadDirections drd;
bool start_half;
bool end_half;
bool is_ai;
BuildLongRoad(TileIndex start_tile, RoadType rt, Axis axis, DisallowedRoadDirections drd, bool start_half, bool end_half, bool is_ai)
:start_tile{start_tile}, rt{rt}, axis{axis}, drd{drd}, start_half{start_half}, end_half{end_half}, is_ai{is_ai} {}
BuildLongRoad(TileIndex tile, TileIndex start_tile, RoadType rt, Axis axis, DisallowedRoadDirections drd, bool start_half, bool end_half, bool is_ai)
:Command{tile}, start_tile{start_tile}, rt{rt}, axis{axis}, drd{drd}, start_half{start_half}, end_half{end_half}, is_ai{is_ai} {}
~BuildLongRoad() override {}
bool DoPost() override;
bool DoTest() override;
};
class RemoveLongRoad: public Command {
public:
TileIndex start_tile;
RoadType rt;
Axis axis;
bool start_half;
bool end_half;
RemoveLongRoad(TileIndex start_tile, RoadType rt, Axis axis, bool start_half, bool end_half)
:start_tile{start_tile}, rt{rt}, axis{axis}, start_half{start_half}, end_half{end_half} {}
RemoveLongRoad(TileIndex tile, TileIndex start_tile, RoadType rt, Axis axis, bool start_half, bool end_half)
:Command{tile}, start_tile{start_tile}, rt{rt}, axis{axis}, start_half{start_half}, end_half{end_half} {}
~RemoveLongRoad() override {}
bool DoPost() override;
bool DoTest() override;
};
class BuildRoad: public Command {
public:
RoadBits pieces;
RoadType rt;
DisallowedRoadDirections toggle_drd;
TownID town_id;
BuildRoad(RoadBits pieces, RoadType rt, DisallowedRoadDirections toggle_drd, TownID town_id)
:pieces{pieces}, rt{rt}, toggle_drd{toggle_drd}, town_id{town_id} {}
BuildRoad(TileIndex tile, RoadBits pieces, RoadType rt, DisallowedRoadDirections toggle_drd, TownID town_id)
:Command{tile}, pieces{pieces}, rt{rt}, toggle_drd{toggle_drd}, town_id{town_id} {}
~BuildRoad() override {}
bool DoPost() override;
bool DoTest() override;
};
class BuildRoadDepot: public Command {
public:
RoadType rt;
DiagDirection dir;
BuildRoadDepot(RoadType rt, DiagDirection dir)
:rt{rt}, dir{dir} {}
BuildRoadDepot(TileIndex tile, RoadType rt, DiagDirection dir)
:Command{tile}, rt{rt}, dir{dir} {}
~BuildRoadDepot() override {}
bool DoPost() override;
bool DoTest() override;
};
class ConvertRoad: public Command {
public:
TileIndex area_start;
RoadType to_type;
ConvertRoad(TileIndex area_start, RoadType to_type)
:area_start{area_start}, to_type{to_type} {}
ConvertRoad(TileIndex tile, TileIndex area_start, RoadType to_type)
:Command{tile}, area_start{area_start}, to_type{to_type} {}
~ConvertRoad() override {}
bool DoPost() override;
bool DoTest() override;
};
class BuildAirport: public Command {
public:
byte airport_type;
byte layout;
StationID station_to_join;
bool allow_adjacent;
BuildAirport(byte airport_type, byte layout, StationID station_to_join, bool allow_adjacent)
:airport_type{airport_type}, layout{layout}, station_to_join{station_to_join}, allow_adjacent{allow_adjacent} {}
BuildAirport(TileIndex tile, byte airport_type, byte layout, StationID station_to_join, bool allow_adjacent)
:Command{tile}, airport_type{airport_type}, layout{layout}, station_to_join{station_to_join}, allow_adjacent{allow_adjacent} {}
~BuildAirport() override {}
bool DoPost() override;
bool DoTest() override;
};
class BuildDock: public Command {
public:
StationID station_to_join;
bool adjacent;
BuildDock(StationID station_to_join, bool adjacent)
:station_to_join{station_to_join}, adjacent{adjacent} {}
BuildDock(TileIndex tile, StationID station_to_join, bool adjacent)
:Command{tile}, station_to_join{station_to_join}, adjacent{adjacent} {}
~BuildDock() override {}
bool DoPost() override;
bool DoTest() override;
};
class BuildRailStation: public Command {
public:
RailType rt;
Axis axis;
byte numtracks;
byte plat_len;
StationClassID spec_class;
byte spec_index;
StationID station_to_join;
bool adjacent;
BuildRailStation(RailType rt, Axis axis, byte numtracks, byte plat_len, StationClassID spec_class, byte spec_index, StationID station_to_join, bool adjacent)
:rt{rt}, axis{axis}, numtracks{numtracks}, plat_len{plat_len}, spec_class{spec_class}, spec_index{spec_index}, station_to_join{station_to_join}, adjacent{adjacent} {}
BuildRailStation(TileIndex tile, RailType rt, Axis axis, byte numtracks, byte plat_len, StationClassID spec_class, byte spec_index, StationID station_to_join, bool adjacent)
:Command{tile}, rt{rt}, axis{axis}, numtracks{numtracks}, plat_len{plat_len}, spec_class{spec_class}, spec_index{spec_index}, station_to_join{station_to_join}, adjacent{adjacent} {}
~BuildRailStation() override {}
bool DoPost() override;
bool DoTest() override;
};
class RemoveFromRailStation: public Command {
public:
TileIndex end;
bool keep_rail;
RemoveFromRailStation(TileIndex end, bool keep_rail)
:end{end}, keep_rail{keep_rail} {}
RemoveFromRailStation(TileIndex tile, TileIndex end, bool keep_rail)
:Command{tile}, end{end}, keep_rail{keep_rail} {}
~RemoveFromRailStation() override {}
bool DoPost() override;
bool DoTest() override;
};
class BuildRoadStop: public Command {
public:
uint8 width;
uint8 length;
RoadStopType stop_type;
bool is_drive_through;
DiagDirection ddir;
RoadType rt;
StationID station_to_join;
bool adjacent;
BuildRoadStop(uint8 width, uint8 length, RoadStopType stop_type, bool is_drive_through, DiagDirection ddir, RoadType rt, StationID station_to_join, bool adjacent)
:width{width}, length{length}, stop_type{stop_type}, is_drive_through{is_drive_through}, ddir{ddir}, rt{rt}, station_to_join{station_to_join}, adjacent{adjacent} {}
BuildRoadStop(TileIndex tile, uint8 width, uint8 length, RoadStopType stop_type, bool is_drive_through, DiagDirection ddir, RoadType rt, StationID station_to_join, bool adjacent)
:Command{tile}, width{width}, length{length}, stop_type{stop_type}, is_drive_through{is_drive_through}, ddir{ddir}, rt{rt}, station_to_join{station_to_join}, adjacent{adjacent} {}
~BuildRoadStop() override {}
bool DoPost() override;
bool DoTest() override;
};
class RemoveRoadStop: public Command {
public:
uint8 width;
uint8 height;
RoadStopType stop_type;
bool remove_road;
RemoveRoadStop(uint8 width, uint8 height, RoadStopType stop_type, bool remove_road)
:width{width}, height{height}, stop_type{stop_type}, remove_road{remove_road} {}
RemoveRoadStop(TileIndex tile, uint8 width, uint8 height, RoadStopType stop_type, bool remove_road)
:Command{tile}, width{width}, height{height}, stop_type{stop_type}, remove_road{remove_road} {}
~RemoveRoadStop() override {}
bool DoPost() override;
bool DoTest() override;
};
class RenameStation: public Command {
public:
StationID station_id;
const std::string &text;
RenameStation(StationID station_id, const std::string &text)
:station_id{station_id}, text{text} {}
~RenameStation() override {}
bool DoPost() override;
bool DoTest() override;
};
class OpenCloseAirport: public Command {
public:
StationID station_id;
OpenCloseAirport(StationID station_id)
:station_id{station_id} {}
~OpenCloseAirport() override {}
bool DoPost() override;
bool DoTest() override;
}; };
class FoundTown: public Command { class FoundTown: public Command {
@@ -202,11 +609,14 @@ public:
uint32 townnameparts; uint32 townnameparts;
const std::string &text; const std::string &text;
FoundTown(TownSize size, bool city, TownLayout layout, bool random_location, uint32 townnameparts, const std::string & text) FoundTown(TownSize size, bool city, TownLayout layout, bool random_location, uint32 townnameparts, const std::string &text)
:size{size}, city{city}, layout{layout}, random_location{random_location}, townnameparts{townnameparts}, text{text} {} :size{size}, city{city}, layout{layout}, random_location{random_location}, townnameparts{townnameparts}, text{text} {}
FoundTown(TileIndex tile, TownSize size, bool city, TownLayout layout, bool random_location, uint32 townnameparts, const std::string &text)
:Command{tile}, size{size}, city{city}, layout{layout}, random_location{random_location}, townnameparts{townnameparts}, text{text} {}
~FoundTown() override {} ~FoundTown() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class RenameTown: public Command { class RenameTown: public Command {
@@ -214,11 +624,12 @@ public:
TownID town_id; TownID town_id;
const std::string &text; const std::string &text;
RenameTown(TownID town_id, const std::string & text) RenameTown(TownID town_id, const std::string &text)
:town_id{town_id}, text{text} {} :town_id{town_id}, text{text} {}
~RenameTown() override {} ~RenameTown() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class DoTownAction: public Command { class DoTownAction: public Command {
@@ -226,11 +637,12 @@ public:
TownID town_id; TownID town_id;
uint8 action; uint8 action;
DoTownAction(TownID town_id, uint8 action) DoTownAction(TownID town_id, uint8 action)
:town_id{town_id}, action{action} {} :town_id{town_id}, action{action} {}
~DoTownAction() override {} ~DoTownAction() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class TownGrowthRate: public Command { class TownGrowthRate: public Command {
@@ -238,11 +650,12 @@ public:
TownID town_id; TownID town_id;
uint16 growth_rate; uint16 growth_rate;
TownGrowthRate(TownID town_id, uint16 growth_rate) TownGrowthRate(TownID town_id, uint16 growth_rate)
:town_id{town_id}, growth_rate{growth_rate} {} :town_id{town_id}, growth_rate{growth_rate} {}
~TownGrowthRate() override {} ~TownGrowthRate() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class TownRating: public Command { class TownRating: public Command {
@@ -251,11 +664,12 @@ public:
CompanyID company_id; CompanyID company_id;
int16 rating; int16 rating;
TownRating(TownID town_id, CompanyID company_id, int16 rating) TownRating(TownID town_id, CompanyID company_id, int16 rating)
:town_id{town_id}, company_id{company_id}, rating{rating} {} :town_id{town_id}, company_id{company_id}, rating{rating} {}
~TownRating() override {} ~TownRating() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class TownCargoGoal: public Command { class TownCargoGoal: public Command {
@@ -264,11 +678,12 @@ public:
TownEffect te; TownEffect te;
uint32 goal; uint32 goal;
TownCargoGoal(TownID town_id, TownEffect te, uint32 goal) TownCargoGoal(TownID town_id, TownEffect te, uint32 goal)
:town_id{town_id}, te{te}, goal{goal} {} :town_id{town_id}, te{te}, goal{goal} {}
~TownCargoGoal() override {} ~TownCargoGoal() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class TownSetText: public Command { class TownSetText: public Command {
@@ -276,11 +691,12 @@ public:
TownID town_id; TownID town_id;
const std::string &text; const std::string &text;
TownSetText(TownID town_id, const std::string & text) TownSetText(TownID town_id, const std::string &text)
:town_id{town_id}, text{text} {} :town_id{town_id}, text{text} {}
~TownSetText() override {} ~TownSetText() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class ExpandTown: public Command { class ExpandTown: public Command {
@@ -288,22 +704,56 @@ public:
TownID town_id; TownID town_id;
uint32 grow_amount; uint32 grow_amount;
ExpandTown(TownID town_id, uint32 grow_amount) ExpandTown(TownID town_id, uint32 grow_amount)
:town_id{town_id}, grow_amount{grow_amount} {} :town_id{town_id}, grow_amount{grow_amount} {}
~ExpandTown() override {} ~ExpandTown() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
}; };
class DeleteTown: public Command { class DeleteTown: public Command {
public: public:
TownID town_id; TownID town_id;
DeleteTown(TownID town_id) DeleteTown(TownID town_id)
:town_id{town_id} {} :town_id{town_id} {}
~DeleteTown() override {} ~DeleteTown() override {}
bool DoPost() override; bool DoPost() override;
bool DoTest() override;
};
class BuildBridge: public Command {
public:
TileIndex tile_start;
TransportType transport_type;
BridgeType bridge_type;
byte road_rail_type;
BuildBridge(TileIndex tile_start, TransportType transport_type, BridgeType bridge_type, byte road_rail_type)
:tile_start{tile_start}, transport_type{transport_type}, bridge_type{bridge_type}, road_rail_type{road_rail_type} {}
BuildBridge(TileIndex tile, TileIndex tile_start, TransportType transport_type, BridgeType bridge_type, byte road_rail_type)
:Command{tile}, tile_start{tile_start}, transport_type{transport_type}, bridge_type{bridge_type}, road_rail_type{road_rail_type} {}
~BuildBridge() override {}
bool DoPost() override;
bool DoTest() override;
};
class BuildTunnel: public Command {
public:
TransportType transport_type;
byte road_rail_type;
BuildTunnel(TransportType transport_type, byte road_rail_type)
:transport_type{transport_type}, road_rail_type{road_rail_type} {}
BuildTunnel(TileIndex tile, TransportType transport_type, byte road_rail_type)
:Command{tile}, transport_type{transport_type}, road_rail_type{road_rail_type} {}
~BuildTunnel() override {}
bool DoPost() override;
bool DoTest() override;
}; };
} // namespace cmd } // namespace cmd

View File

@@ -279,11 +279,11 @@ void CommandHelperBase::InternalPostResult(const CommandCost &res, TileIndex til
ShowCostOrIncomeAnimation(x, y, GetSlopePixelZ(x, y), res.GetCost()); ShowCostOrIncomeAnimation(x, y, GetSlopePixelZ(x, y), res.GetCost());
} }
FIXME mode to callback /* FIXME mode to callback
if (!estimate_only && !only_sending) if (!estimate_only && !only_sending)
citymania::HandleCommandExecution(res.Succeeded(), tile, p1, p2, cmd, text); citymania::HandleCommandExecution(res.Succeeded(), tile, p1, p2, cmd, text);
return res.Succeeded(); return res.Succeeded();
*/
} }
/** Helper to make a desync log for a command. */ /** Helper to make a desync log for a command. */

View File

@@ -48,6 +48,8 @@
#include "table/strings.h" #include "table/strings.h"
#include "debug.h" #include "debug.h"
#include "citymania/cm_commands.hpp"
#include "safeguards.h" #include "safeguards.h"
/** /**

View File

@@ -169,7 +169,7 @@ CommandCost CmdPause(DoCommandFlag flags, PauseMode mode, bool pause)
if (pause) { if (pause) {
_pause_mode |= mode; _pause_mode |= mode;
FIXME //_pause_countdown = (p2 >> 1); // FIXME //_pause_countdown = (p2 >> 1);
} else { } else {
_pause_mode &= ~mode; _pause_mode &= ~mode;
} }

View File

@@ -1179,7 +1179,7 @@ void NetworkGameLoop()
} }
NetworkExecuteLocalCommandQueue(); NetworkExecuteLocalCommandQueue();
if (_pause_countdown > 0 && --_pause_countdown == 0) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE); if (_pause_countdown > 0 && --_pause_countdown == 0) Command<CMD_PAUSE>::Post(PM_PAUSED_NORMAL, 1);
citymania::ExecuteFakeCommands(_date, _date_fract); citymania::ExecuteFakeCommands(_date, _date_fract);

View File

@@ -292,8 +292,8 @@ void NetworkSendCommand(Commands cmd, StringID err_message, CommandCallback *cal
c.frame = 0; // The client can't tell which frame, so just make it 0 c.frame = 0; // The client can't tell which frame, so just make it 0
/* Clients send their command to the server and forget all about the packet */ /* Clients send their command to the server and forget all about the packet */
// MyClient::SendCommand(&c); MyClient::SendCommand(&c);
citymania::SendClientCommand(&c); // FIXME citymania::SendClientCommand(&c);
} }
/** /**
@@ -332,7 +332,8 @@ void NetworkExecuteLocalCommandQueue()
if (_frame_counter > cp->frame) { if (_frame_counter > cp->frame) {
/* If we reach here, it means for whatever reason, we've already executed /* If we reach here, it means for whatever reason, we've already executed
* past the command we need to execute. */ * past the command we need to execute. */
error("[net] Trying to execute a packet in the past! (frame=%u cmd_frame=%u tile=%u p1=%u p2=%u cmd=%u)", (uint)_frame_counter, (uint)cp->frame, (uint)cp->tile, (uint)cp->p1, (uint)cp->p2, (uint)cp->cmd); error("[net] Trying to execute a packet in the past! (frame=%u cmd_frame=%u)", (uint)_frame_counter, (uint)cp->frame);
// FIXME error("[net] Trying to execute a packet in the past! (frame=%u cmd_frame=%u tile=%u p1=%u p2=%u cmd=%u)", (uint)_frame_counter, (uint)cp->frame, (uint)cp->tile, (uint)cp->p1, (uint)cp->p2, (uint)cp->cmd);
} }
/* We can execute this command */ /* We can execute this command */

View File

@@ -458,7 +458,7 @@ public:
} }
if (_selected_object_index != -1) { if (_selected_object_index != -1) {
SetObjectToPlaceWnd(SPR_CURSOR_TRANSMITTER, PAL_NONE, HT_RECT | HT_DIAGONAL, this, CM_DDSP_PLACE_OBJECT); SetObjectToPlaceWnd(SPR_CURSOR_TRANSMITTER, PAL_NONE, HT_RECT | HT_DIAGONAL, this, DDSP_BUILD_OBJECT);
} }
this->UpdateButtons(_selected_object_class, _selected_object_index, _selected_object_view); this->UpdateButtons(_selected_object_class, _selected_object_index, _selected_object_view);

View File

@@ -1570,18 +1570,20 @@ public:
void OnPlaceObject(Point pt, TileIndex tile) override void OnPlaceObject(Point pt, TileIndex tile) override
{ {
if (this->goto_type == OPOS_GOTO) { if (this->goto_type == OPOS_GOTO) {
const Order cmd = GetOrderCmdFromTile(this->vehicle, tile); auto res = GetOrderCmdFromTile(this->vehicle, tile);
const Order cmd = res.first;
auto feeder_mod = res.second;
if (cmd.IsType(OT_NOTHING)) return; if (cmd.IsType(OT_NOTHING)) return;
if (feeder_mod != FeederOrderMod::NONE) { if (feeder_mod != FeederOrderMod::NONE) {
if (feeder_mod == FeederOrderMod::LOAD) { if (feeder_mod == FeederOrderMod::LOAD) {
if (Command<CMD_INSERT_ORDER>::Post(STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index, 1, cmd)) { if (Command<CMD_INSERT_ORDER>::Post(STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index, 1, cmd)) {
Command<CMD_DELETE_ORDER>::Post(STR_ERROR_CAN_T_DELETE_THIS_ORDER, this->vehicle->tile, this->vehicle->index, 0) Command<CMD_DELETE_ORDER>::Post(STR_ERROR_CAN_T_DELETE_THIS_ORDER, this->vehicle->tile, this->vehicle->index, 0);
} }
} else if (feeder_mod == FeederOrderMod::UNLOAD) { // still flushes the whole order table } else if (feeder_mod == FeederOrderMod::UNLOAD) { // still flushes the whole order table
if (Command<CMD_INSERT_ORDER>::Post(STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index, this->vehicle->GetNumOrders(), cmd)) { if (Command<CMD_INSERT_ORDER>::Post(STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index, this->vehicle->GetNumOrders(), cmd)) {
Command<CMD_DELETE_ORDER>::Post(STR_ERROR_CAN_T_DELETE_THIS_ORDER, this->vehicle->tile, this->vehicle->index, this->vehicle->GetNumOrders() + (int)_networking - 2) Command<CMD_DELETE_ORDER>::Post(STR_ERROR_CAN_T_DELETE_THIS_ORDER, this->vehicle->tile, this->vehicle->index, this->vehicle->GetNumOrders() + (int)_networking - 2);
} }
} }
} else if (Command<CMD_INSERT_ORDER>::Post(STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), cmd)) { } else if (Command<CMD_INSERT_ORDER>::Post(STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), cmd)) {

View File

@@ -373,7 +373,7 @@ static void BuildRailClick_Remove(Window *w)
} }
} }
static CommandContainer DoRailroadTrackCmd(TileIndex start_tile, TileIndex end_tile, Track track) /* FIXME static CommandContainer DoRailroadTrackCmd(TileIndex start_tile, TileIndex end_tile, Track track)
{ {
CommandContainer ret = { CommandContainer ret = {
start_tile, // tile start_tile, // tile
@@ -388,9 +388,9 @@ static CommandContainer DoRailroadTrackCmd(TileIndex start_tile, TileIndex end_t
return ret; return ret;
} }
*/
namespace citymania { namespace citymania {
/*
static bool DoAutodirTerraform(bool diagonal, TileIndex start_tile, TileIndex end_tile, Track track, CommandContainer &rail_cmd, TileIndex s1, TileIndex e1, TileIndex s2, TileIndex e2) { static bool DoAutodirTerraform(bool diagonal, TileIndex start_tile, TileIndex end_tile, Track track, CommandContainer &rail_cmd, TileIndex s1, TileIndex e1, TileIndex s2, TileIndex e2) {
auto rail_callback = [rail_cmd, start_tile, end_tile, track, estimate=citymania::_estimate_mod](bool res) -> bool { auto rail_callback = [rail_cmd, start_tile, end_tile, track, estimate=citymania::_estimate_mod](bool res) -> bool {
if (DoCommand(&rail_cmd, DC_AUTO | DC_NO_WATER).GetErrorMessage() != STR_ERROR_ALREADY_BUILT || if (DoCommand(&rail_cmd, DC_AUTO | DC_NO_WATER).GetErrorMessage() != STR_ERROR_ALREADY_BUILT ||
@@ -492,11 +492,11 @@ static bool HandleAutodirTerraform(TileIndex start_tile, TileIndex end_tile, Tra
break; break;
} }
return true; return true;
} }*/
} // namespace citymania } // namespace citymania
FIXME //FIXME
static void DoRailroadTrack(Track track) static void DoRailroadTrack(Track track)
{ {
if (_remove_button_clicked) { if (_remove_button_clicked) {
@@ -521,12 +521,13 @@ static void HandleAutodirPlacement()
} }
// end FIXME // end FIXME
/*
static void HandleAutodirPlacement() static void HandleAutodirPlacement()
{ {
Track track = (Track)(_thd.drawstyle & HT_DIR_MASK); // 0..5 Track track = (Track)(_thd.drawstyle & HT_DIR_MASK); // 0..5
TileIndex start_tile = TileVirtXY(_thd.selstart.x, _thd.selstart.y); TileIndex start_tile = TileVirtXY(_thd.selstart.x, _thd.selstart.y);
TileIndex end_tile = TileVirtXY(_thd.selend.x, _thd.selend.y); TileIndex end_tile = TileVirtXY(_thd.selend.x, _thd.selend.y);
/* FIXME
CommandContainer cmd = (_thd.drawstyle & HT_RAIL) ? CommandContainer cmd = (_thd.drawstyle & HT_RAIL) ?
GenericPlaceRailCmd(end_tile, track) : // one tile case GenericPlaceRailCmd(end_tile, track) : // one tile case
DoRailroadTrackCmd(start_tile, end_tile, track); // multitile selection DoRailroadTrackCmd(start_tile, end_tile, track); // multitile selection
@@ -535,7 +536,7 @@ static void HandleAutodirPlacement()
* snap point over the last overbuilt track piece. In such case we don't * snap point over the last overbuilt track piece. In such case we don't
* wan't to show any errors to the user. Don't execute the command right * wan't to show any errors to the user. Don't execute the command right
* away, first check if overbuilding. */ * away, first check if overbuilding. */
if (citymania::_estimate_mod || !(_thd.place_mode & HT_POLY) || _remove_button_clicked) { /* if (citymania::_estimate_mod || !(_thd.place_mode & HT_POLY) || _remove_button_clicked) {
if (!DoCommandP(&cmd)) return; if (!DoCommandP(&cmd)) return;
} else if (_thd.cm_poly_terra) { } else if (_thd.cm_poly_terra) {
citymania::HandleAutodirTerraform(start_tile, end_tile, track, cmd); citymania::HandleAutodirTerraform(start_tile, end_tile, track, cmd);
@@ -543,13 +544,13 @@ static void HandleAutodirPlacement()
} else if (DoCommand(&cmd, DC_AUTO | DC_NO_WATER).GetErrorMessage() != STR_ERROR_ALREADY_BUILT || } else if (DoCommand(&cmd, DC_AUTO | DC_NO_WATER).GetErrorMessage() != STR_ERROR_ALREADY_BUILT ||
_rail_track_endtile == INVALID_TILE) { _rail_track_endtile == INVALID_TILE) {
if (!DoCommandP(&cmd)) return; if (!DoCommandP(&cmd)) return;
} } */
/* Save new snap points for the polyline tool, no matter if the command /* Save new snap points for the polyline tool, no matter if the command
* succeeded, the snapping will be extended over overbuilt track pieces. */ * succeeded, the snapping will be extended over overbuilt track pieces. */
if (!citymania::_estimate_mod && _rail_track_endtile != INVALID_TILE) { /*if (!citymania::_estimate_mod && _rail_track_endtile != INVALID_TILE) {
StoreRailPlacementEndpoints(start_tile, _rail_track_endtile, track, true); StoreRailPlacementEndpoints(start_tile, _rail_track_endtile, track, true);
} }
} }*/
/** /**
* Build new signals or remove signals or (if only one tile marked) edit a signal. * Build new signals or remove signals or (if only one tile marked) edit a signal.

View File

@@ -9,7 +9,6 @@
#include "stdafx.h" #include "stdafx.h"
#include "gui.h" #include "gui.h"
#include "cmd_helper.h"
#include "window_gui.h" #include "window_gui.h"
#include "station_func.h" #include "station_func.h"
#include "station_gui.h" #include "station_gui.h"
@@ -171,7 +170,8 @@ void CcRoadStop(Commands cmd, const CommandCost &result, TileIndex tile, uint8 w
static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType stop_type, bool adjacent, RoadType rt, StringID err_msg) static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType stop_type, bool adjacent, RoadType rt, StringID err_msg)
{ {
if (citymania::UseImprovedStationJoin()) { if (citymania::UseImprovedStationJoin()) {
citymania::PlaceRoadStop(start_tile, end_tile, p2, cmd); // FIXME
// citymania::PlaceRoadStop(start_tile, end_tile, stop_type, adjacent, rt, err_msg);
return; return;
} }

View File

@@ -1464,7 +1464,7 @@ CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailTyp
st->MarkTilesDirty(false); st->MarkTilesDirty(false);
st->AfterStationTileSetChange(true, STATION_RAIL); st->AfterStationTileSetChange(true, STATION_RAIL);
citymania::OnStationPartBuilt(st, tile_org, p1, p2); // FIXME citymania::OnStationPartBuilt(st, tile_org, p1, p2);
} }
return cost; return cost;
@@ -1932,7 +1932,7 @@ CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, u
} }
if (st != nullptr) { if (st != nullptr) {
FIXME citymania::OnStationPartBuilt(st, tile, p1, p2); // FIXME citymania::OnStationPartBuilt(st, tile, p1, p2);
st->AfterStationTileSetChange(true, is_truck_stop ? STATION_TRUCK: STATION_BUS); st->AfterStationTileSetChange(true, is_truck_stop ? STATION_TRUCK: STATION_BUS);
} }
} }
@@ -2328,7 +2328,7 @@ CommandCost CmdBuildAirport(DoCommandFlag flags, TileIndex tile, byte airport_ty
Company::Get(st->owner)->infrastructure.airport++; Company::Get(st->owner)->infrastructure.airport++;
st->AfterStationTileSetChange(true, STATION_AIRPORT); st->AfterStationTileSetChange(true, STATION_AIRPORT);
citymania::OnStationPartBuilt(st, tile, p1, p2); // FIXME citymania::OnStationPartBuilt(st, tile, p1, p2);
InvalidateWindowData(WC_STATION_VIEW, st->index, -1); InvalidateWindowData(WC_STATION_VIEW, st->index, -1);
if (_settings_game.economy.station_noise_level) { if (_settings_game.economy.station_noise_level) {
@@ -2558,7 +2558,7 @@ CommandCost CmdBuildDock(DoCommandFlag flags, TileIndex tile, StationID station_
UpdateStationDockingTiles(st); UpdateStationDockingTiles(st);
st->AfterStationTileSetChange(true, STATION_DOCK); st->AfterStationTileSetChange(true, STATION_DOCK);
citymania::OnStationPartBuilt(st, tile, p1, p2); // FIXME citymania::OnStationPartBuilt(st, tile, p1, p2);
} }
return cost; return cost;

View File

@@ -123,7 +123,7 @@ bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_t
case DDSP_DEMOLISH_AREA: case DDSP_DEMOLISH_AREA:
Command<CMD_CLEAR_AREA>::Post(STR_ERROR_CAN_T_CLEAR_THIS_AREA, CcPlaySound_EXPLOSION, end_tile, start_tile, citymania::_fn_mod); Command<CMD_CLEAR_AREA>::Post(STR_ERROR_CAN_T_CLEAR_THIS_AREA, CcPlaySound_EXPLOSION, end_tile, start_tile, citymania::_fn_mod);
break; break;
case DDSP_DEMOLISH_TREES: case DDSP_DEMOLISH_TREES: {
// loop through every tile and send a demolish command for each tree // loop through every tile and send a demolish command for each tree
// orthogonal area // orthogonal area
TileIndex tree_start_tile, tree_recent_tile, prev_tile; TileIndex tree_start_tile, tree_recent_tile, prev_tile;
@@ -179,6 +179,7 @@ bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_t
} }
} }
break; break;
}
case DDSP_RAISE_AND_LEVEL_AREA: case DDSP_RAISE_AND_LEVEL_AREA:
Command<CMD_LEVEL_LAND>::Post(STR_ERROR_CAN_T_RAISE_LAND_HERE, CcTerraform, end_tile, start_tile, citymania::_fn_mod, LM_RAISE); Command<CMD_LEVEL_LAND>::Post(STR_ERROR_CAN_T_RAISE_LAND_HERE, CcTerraform, end_tile, start_tile, citymania::_fn_mod, LM_RAISE);
break; break;

View File

@@ -58,6 +58,7 @@
#include "network/network_func.h" #include "network/network_func.h"
#include "object_type.h" #include "object_type.h"
#include "company_cmd.h"
#include "citymania/cm_cargo_table_gui.hpp" #include "citymania/cm_cargo_table_gui.hpp"
#include "citymania/cm_commands.hpp" #include "citymania/cm_commands.hpp"
#include "citymania/cm_commands_gui.hpp" #include "citymania/cm_commands_gui.hpp"
@@ -2164,7 +2165,7 @@ struct MainToolbarWindow : Window {
break; break;
case CBF_PLACE_LANDINFO: case CBF_PLACE_LANDINFO:
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_MEASURE); VpStartPlaceSizing(tile, VPM_X_AND_Y, CM_DDSP_MEASURE);
break; break;
case CM_CBF_BUILD_HQ: case CM_CBF_BUILD_HQ:
@@ -2573,7 +2574,7 @@ struct ScenarioEditorToolbarWindow : Window {
break; break;
case CBF_PLACE_LANDINFO: case CBF_PLACE_LANDINFO:
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_MEASURE); VpStartPlaceSizing(tile, VPM_X_AND_Y, CM_DDSP_MEASURE);
break; break;
default: NOT_REACHED(); default: NOT_REACHED();

View File

@@ -3198,7 +3198,7 @@ CommandCost CmdTownGrowthRate(DoCommandFlag flags, TownID town_id, uint16 growth
} }
UpdateTownGrowth(t); UpdateTownGrowth(t);
InvalidateWindowData(WC_TOWN_VIEW, town_id); InvalidateWindowData(WC_TOWN_VIEW, town_id);
InvalidateWindowData(WC_CB_TOWN, p1); InvalidateWindowData(WC_CB_TOWN, town_id);
} }
return CommandCost(); return CommandCost();

View File

@@ -45,6 +45,7 @@
#include <list> #include <list>
#include "console_func.h" #include "console_func.h"
#include "citymania/cm_commands.hpp"
#include "citymania/cm_hotkeys.hpp" #include "citymania/cm_hotkeys.hpp"
/* CityMania end */ /* CityMania end */

View File

@@ -2640,7 +2640,7 @@ static bool IsVehicleRefitable(const Vehicle *v)
return false; return false;
} }
void CcCloneVehicleWithOrderIndex(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd) /* FIXME void CcCloneVehicleWithOrderIndex(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
{ {
if (result.Failed()) return; if (result.Failed()) return;
if (p2 != 1) CcCloneVehicle(result, tile, p1, p2, cmd); if (p2 != 1) CcCloneVehicle(result, tile, p1, p2, cmd);
@@ -2651,7 +2651,7 @@ void CcCloneVehicleWithOrderIndex(const CommandCost &result, TileIndex tile, uin
citymania::cmd::SkipToOrder(v->index, cloned->cur_implicit_order_index) citymania::cmd::SkipToOrder(v->index, cloned->cur_implicit_order_index)
.WithTile(v->tile) .WithTile(v->tile)
.Post(); .Post();
} }*/
/** Window manager class for viewing a vehicle. */ /** Window manager class for viewing a vehicle. */
struct VehicleViewWindow : Window { struct VehicleViewWindow : Window {

View File

@@ -3642,7 +3642,7 @@ calc_heightdiff_single_direction:;
FALLTHROUGH; FALLTHROUGH;
case VPM_X_AND_Y: // drag an X by Y area case VPM_X_AND_Y: // drag an X by Y area
if (_settings_client.gui.measure_tooltip || _thd.select_proc == DDSP_MEASURE) { if (_settings_client.gui.measure_tooltip || _thd.select_proc == CM_DDSP_MEASURE) {
static const StringID measure_strings_area[] = { static const StringID measure_strings_area[] = {
STR_NULL, STR_NULL, STR_MEASURE_AREA, STR_MEASURE_AREA_HEIGHTDIFF, STR_NULL, STR_NULL, STR_MEASURE_AREA, STR_MEASURE_AREA_HEIGHTDIFF,
STR_MEASURE_DIST_HEIGHTDIFF, STR_MEASURE_DIST_HEIGHTDIFF,
@@ -3701,7 +3701,7 @@ calc_heightdiff_single_direction:;
params[index++] = dx - (style & HT_POINT ? 1 : 0); params[index++] = dx - (style & HT_POINT ? 1 : 0);
params[index++] = dy - (style & HT_POINT ? 1 : 0); params[index++] = dy - (style & HT_POINT ? 1 : 0);
if (_thd.select_proc == DDSP_MEASURE) { if (_thd.select_proc == CM_DDSP_MEASURE) {
params[index++] = sqrtl(dx * dx + dy * dy); params[index++] = sqrtl(dx * dx + dy * dy);
} }