Introduce doCommand template (#1082)

* Introduce doCommand template

* Continue using template

* Swap around arguments

* Add remaining structs

* Start next batch

* Fix rebase issues and mistake
This commit is contained in:
Duncan 2021-08-12 22:00:35 +01:00 committed by GitHub
parent f2f9719b75
commit 22cf266773
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 105 additions and 203 deletions

View File

@ -130,6 +130,14 @@ namespace OpenLoco::GameCommands
uint32_t doCommand(GameCommand command, const registers& registers);
bool sub_431E6A(const CompanyId_t company, Map::TileElement* const tile = nullptr);
template<typename T>
uint32_t doCommand(const T& args, uint8_t flags)
{
registers regs = registers(args);
regs.bl = flags;
return doCommand(T::command, regs);
}
inline void do_0(EntityId_t source, EntityId_t dest)
{
registers regs;
@ -141,8 +149,10 @@ namespace OpenLoco::GameCommands
struct VehiclePlacementArgs
{
static constexpr auto command = GameCommand::vehiclePlace;
VehiclePlacementArgs() = default;
explicit VehiclePlacementArgs(const registers regs)
explicit VehiclePlacementArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.dx * 4)
, trackAndDirection(regs.bp)
, trackProgress(regs.ebx >> 16)
@ -170,13 +180,6 @@ namespace OpenLoco::GameCommands
}
};
inline bool do_1(uint8_t flags, const VehiclePlacementArgs& args)
{
registers regs = registers(args);
regs.bl = flags;
return doCommand(GameCommand::vehiclePlace, regs) != FAILURE;
}
inline bool do_2(EntityId_t head)
{
registers regs;
@ -283,6 +286,8 @@ namespace OpenLoco::GameCommands
struct SignalPlacementArgs
{
static constexpr auto command = GameCommand::createSignal;
SignalPlacementArgs() = default;
explicit SignalPlacementArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.di)
@ -317,17 +322,12 @@ namespace OpenLoco::GameCommands
}
};
inline uint32_t do_13(uint8_t flags, const SignalPlacementArgs& args)
{
registers regs = registers(args);
regs.bl = flags;
return doCommand(GameCommand::createSignal, regs);
}
struct SignalRemovalArgs
{
static constexpr auto command = GameCommand::removeSignal;
SignalRemovalArgs() = default;
explicit SignalRemovalArgs(const registers regs)
explicit SignalRemovalArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.di)
, rotation(regs.bh & 0x3)
, trackId(regs.dl & 0x3F)
@ -358,17 +358,12 @@ namespace OpenLoco::GameCommands
}
};
inline bool do_14(uint8_t flags, const SignalRemovalArgs& args)
{
registers regs = registers(args);
regs.bl = flags;
return doCommand(GameCommand::removeSignal, regs) != FAILURE;
}
struct TrackStationRemovalArgs
{
static constexpr auto command = GameCommand::removeTrackStation;
TrackStationRemovalArgs() = default;
explicit TrackStationRemovalArgs(const registers regs)
explicit TrackStationRemovalArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.di)
, rotation(regs.bh & 0x3)
, trackId(regs.dl & 0x3F)
@ -397,15 +392,10 @@ namespace OpenLoco::GameCommands
}
};
inline bool do_16(uint8_t flags, const TrackStationRemovalArgs& args)
{
registers regs = registers(args);
regs.bl = flags;
return doCommand(GameCommand::removeTrackStation, regs) != FAILURE;
}
struct TrackModsPlacementArgs
{
static constexpr auto command = GameCommand::createTrackMod;
TrackModsPlacementArgs() = default;
explicit TrackModsPlacementArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.di)
@ -440,13 +430,6 @@ namespace OpenLoco::GameCommands
}
};
inline uint32_t do_17(uint8_t flags, const TrackModsPlacementArgs& args)
{
registers regs = registers(args);
regs.bl = flags;
return doCommand(GameCommand::createTrackMod, regs);
}
// Change company colour scheme
inline void do_19(int8_t isPrimary, int8_t value, int8_t colourType, int8_t setColourMode, uint8_t companyId)
{
@ -490,8 +473,10 @@ namespace OpenLoco::GameCommands
struct TreeRemovalArgs
{
static constexpr auto command = GameCommand::removeTree;
TreeRemovalArgs() = default;
explicit TreeRemovalArgs(const registers regs)
explicit TreeRemovalArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.dl * 4)
, type(regs.dh)
, elementType(regs.bh)
@ -514,15 +499,10 @@ namespace OpenLoco::GameCommands
}
};
inline void do_22(uint8_t flags, const TreeRemovalArgs& args)
{
registers regs = registers(args);
regs.bl = flags;
doCommand(GameCommand::removeTree, regs);
}
struct TreePlacementArgs
{
static constexpr auto command = GameCommand::createTree;
TreePlacementArgs() = default;
explicit TreePlacementArgs(const registers& regs)
: pos(regs.ax, regs.cx)
@ -556,13 +536,6 @@ namespace OpenLoco::GameCommands
}
};
inline uint32_t do_23(uint8_t flags, const TreePlacementArgs& args)
{
registers regs = registers(args);
regs.bl = flags;
return doCommand(GameCommand::createTree, regs);
}
// Change Land Material
inline void do_24(Map::Pos2 pointA, Map::Pos2 pointB, uint8_t landType, uint8_t flags)
{
@ -667,6 +640,8 @@ namespace OpenLoco::GameCommands
struct WallPlacementArgs
{
static constexpr auto command = GameCommand::createWall;
WallPlacementArgs() = default;
explicit WallPlacementArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.di)
@ -699,15 +674,10 @@ namespace OpenLoco::GameCommands
}
};
inline bool do_32(uint8_t flags, const WallPlacementArgs& args)
{
registers regs = registers(args);
regs.bl = flags;
return doCommand(GameCommand::createWall, regs) != FAILURE;
}
struct WallRemovalArgs
{
static constexpr auto command = GameCommand::removeWall;
WallRemovalArgs() = default;
explicit WallRemovalArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.dh * 4)
@ -729,13 +699,6 @@ namespace OpenLoco::GameCommands
}
};
inline void do_33(uint8_t flags, const WallRemovalArgs& args)
{
registers regs = registers(args);
regs.bl = flags;
doCommand(GameCommand::removeWall, regs);
}
inline bool do_35(EntityId_t head, uint64_t rawOrder, uint32_t orderOffset)
{
registers regs;
@ -766,6 +729,8 @@ namespace OpenLoco::GameCommands
struct RoadModsPlacementArgs
{
static constexpr auto command = GameCommand::createRoadMod;
RoadModsPlacementArgs() = default;
explicit RoadModsPlacementArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.di)
@ -800,17 +765,12 @@ namespace OpenLoco::GameCommands
}
};
inline uint32_t do_40(uint8_t flags, const RoadModsPlacementArgs& args)
{
registers regs = registers(args);
regs.bl = flags;
return doCommand(GameCommand::createRoadMod, regs);
}
struct RoadStationRemovalArgs
{
static constexpr auto command = GameCommand::removeRoadStation;
RoadStationRemovalArgs() = default;
explicit RoadStationRemovalArgs(const registers regs)
explicit RoadStationRemovalArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.di)
, rotation(regs.bh & 0x3)
, roadId(regs.dl & 0xF)
@ -839,17 +799,12 @@ namespace OpenLoco::GameCommands
}
};
inline bool do_43(uint8_t flags, const RoadStationRemovalArgs& args)
{
registers regs = registers(args);
regs.bl = flags;
return doCommand(GameCommand::removeRoadStation, regs) != FAILURE;
}
struct BuildingPlacementArgs
{
static constexpr auto command = GameCommand::createBuilding;
BuildingPlacementArgs() = default;
explicit BuildingPlacementArgs(const registers regs)
explicit BuildingPlacementArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.di)
, rotation(regs.bh & 0x3)
, type(regs.dl)
@ -878,17 +833,12 @@ namespace OpenLoco::GameCommands
}
};
inline uint32_t do_44(const BuildingPlacementArgs& placementArgs, uint8_t flags)
{
registers regs = registers(placementArgs);
regs.bl = flags;
return doCommand(GameCommand::createBuilding, regs);
}
struct BuildingRemovalArgs
{
static constexpr auto command = GameCommand::removeBuilding;
BuildingRemovalArgs() = default;
explicit BuildingRemovalArgs(const registers regs)
explicit BuildingRemovalArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.di)
{
}
@ -909,13 +859,6 @@ namespace OpenLoco::GameCommands
}
};
inline void do_45(uint8_t flags, const BuildingRemovalArgs& args)
{
registers regs = registers(args);
regs.bl = flags;
doCommand(GameCommand::removeBuilding, regs);
}
// Rename town
inline void do_46(uint16_t cx, uint16_t ax, uint32_t edx, uint32_t ebp, uint32_t edi)
{
@ -931,8 +874,10 @@ namespace OpenLoco::GameCommands
struct IndustryPlacementArgs
{
static constexpr auto command = GameCommand::createIndustry;
IndustryPlacementArgs() = default;
explicit IndustryPlacementArgs(const registers regs)
explicit IndustryPlacementArgs(const registers& regs)
: pos(regs.ax, regs.cx)
, type(regs.dl)
, buildImmediately(regs.bh & 0x80)
@ -959,13 +904,6 @@ namespace OpenLoco::GameCommands
}
};
inline uint32_t do_47(uint8_t flags, const IndustryPlacementArgs& placementArgs)
{
registers regs = registers(placementArgs);
regs.bl = flags;
return doCommand(GameCommand::createIndustry, regs);
}
// Remove industry
inline bool do_48(uint8_t flags, uint8_t industryId)
{
@ -977,8 +915,10 @@ namespace OpenLoco::GameCommands
struct TownPlacementArgs
{
static constexpr auto command = GameCommand::createTown;
TownPlacementArgs() = default;
explicit TownPlacementArgs(const registers regs)
explicit TownPlacementArgs(const registers& regs)
: pos(regs.ax, regs.cx)
, size(regs.dl)
{
@ -997,13 +937,6 @@ namespace OpenLoco::GameCommands
}
};
inline uint32_t do_49(const TownPlacementArgs& args, uint8_t flags)
{
registers regs = registers(args);
regs.bl = flags;
return doCommand(GameCommand::createTown, regs);
}
// Remove town
inline bool do_50(uint8_t townId)
{
@ -1015,8 +948,10 @@ namespace OpenLoco::GameCommands
struct HeadquarterPlacementArgs
{
static constexpr auto command = GameCommand::buildCompanyHeadquarters;
HeadquarterPlacementArgs() = default;
explicit HeadquarterPlacementArgs(const registers regs)
explicit HeadquarterPlacementArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.di)
, rotation(regs.bh & 0x3)
, type(regs.dl)
@ -1043,12 +978,14 @@ namespace OpenLoco::GameCommands
struct HeadquarterRemovalArgs
{
static constexpr auto command = GameCommand::removeCompanyHeadquarters;
HeadquarterRemovalArgs() = default;
explicit HeadquarterRemovalArgs(const HeadquarterPlacementArgs& place)
: pos(place.pos)
{
}
explicit HeadquarterRemovalArgs(const registers regs)
explicit HeadquarterRemovalArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.di)
{
}
@ -1064,26 +1001,12 @@ namespace OpenLoco::GameCommands
}
};
// Build company headquarters
inline uint32_t do_54(uint8_t bl, const HeadquarterPlacementArgs& args)
{
registers regs = registers(args);
regs.bl = bl; // flags
return doCommand(GameCommand::buildCompanyHeadquarters, regs);
}
// Remove company headquarters
inline void do_55(uint8_t bl, const HeadquarterRemovalArgs& args)
{
registers regs = registers(args);
regs.bl = bl; // flags
doCommand(GameCommand::removeCompanyHeadquarters, regs);
}
struct AirportRemovalArgs
{
static constexpr auto command = GameCommand::removeAirport;
AirportRemovalArgs() = default;
explicit AirportRemovalArgs(const registers regs)
explicit AirportRemovalArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.di)
{
}
@ -1100,17 +1023,12 @@ namespace OpenLoco::GameCommands
}
};
inline bool do_57(uint8_t flags, const AirportRemovalArgs& args)
{
registers regs = registers(args);
regs.bl = flags;
return doCommand(GameCommand::removeAirport, regs) != FAILURE;
}
struct VehicleAirPlacementArgs
{
static constexpr auto command = GameCommand::vehiclePlaceAir;
VehicleAirPlacementArgs() = default;
explicit VehicleAirPlacementArgs(const registers regs)
explicit VehicleAirPlacementArgs(const registers& regs)
: stationId(regs.bp)
, airportNode(regs.dl)
, head(regs.di)
@ -1134,13 +1052,6 @@ namespace OpenLoco::GameCommands
}
};
inline bool do_58(uint8_t flags, const VehicleAirPlacementArgs& args)
{
registers regs = registers(args);
regs.bl = flags;
return doCommand(GameCommand::vehiclePlaceAir, regs) != FAILURE;
}
inline bool do_59(EntityId_t head)
{
registers regs;
@ -1151,8 +1062,10 @@ namespace OpenLoco::GameCommands
struct PortRemovalArgs
{
static constexpr auto command = GameCommand::removePort;
PortRemovalArgs() = default;
explicit PortRemovalArgs(const registers regs)
explicit PortRemovalArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.di)
{
}
@ -1169,17 +1082,12 @@ namespace OpenLoco::GameCommands
}
};
inline bool do_61(uint8_t flags, const PortRemovalArgs& args)
{
registers regs = registers(args);
regs.bl = flags;
return doCommand(GameCommand::removePort, regs) != FAILURE;
}
struct VehicleWaterPlacementArgs
{
static constexpr auto command = GameCommand::vehiclePlaceWater;
VehicleWaterPlacementArgs() = default;
explicit VehicleWaterPlacementArgs(const registers regs)
explicit VehicleWaterPlacementArgs(const registers& regs)
: pos(regs.ax, regs.cx, regs.dx)
, head(regs.di)
, convertGhost((regs.ebx >> 16) == 0xFFFF)
@ -1202,13 +1110,6 @@ namespace OpenLoco::GameCommands
}
};
inline bool do_62(uint8_t flags, const VehicleWaterPlacementArgs& args)
{
registers regs = registers(args);
regs.bl = flags;
return doCommand(GameCommand::vehiclePlaceWater, regs) != FAILURE;
}
inline bool do_63(EntityId_t head)
{
registers regs;

View File

@ -625,7 +625,7 @@ namespace OpenLoco::Input
}
GameCommands::setErrorTitle(StringIds::cant_remove_signal);
if (GameCommands::do_14(GameCommands::Flags::apply, args))
if (GameCommands::doCommand(args, GameCommands::Flags::apply) != GameCommands::FAILURE)
{
Audio::playSound(Audio::SoundId::demolish, GameCommands::getPosition());
}
@ -647,7 +647,7 @@ namespace OpenLoco::Input
args.trackId = track->trackId();
args.index = track->sequenceIndex();
args.type = track->trackObjectId();
if (GameCommands::do_16(GameCommands::Flags::apply, args))
if (GameCommands::doCommand(args, GameCommands::Flags::apply) != GameCommands::FAILURE)
{
Audio::playSound(Audio::SoundId::demolish, GameCommands::getPosition());
}
@ -669,7 +669,7 @@ namespace OpenLoco::Input
args.roadId = road->roadId();
args.index = road->sequenceIndex();
args.type = road->roadObjectId();
if (GameCommands::do_43(GameCommands::Flags::apply, args))
if (GameCommands::doCommand(args, GameCommands::Flags::apply) != GameCommands::FAILURE)
{
Audio::playSound(Audio::SoundId::demolish, GameCommands::getPosition());
}
@ -686,7 +686,7 @@ namespace OpenLoco::Input
GameCommands::setErrorTitle(StringIds::cant_remove_airport);
GameCommands::AirportRemovalArgs args;
args.pos = Pos3(pos.x, pos.y, station->baseZ() * 4);
if (GameCommands::do_57(GameCommands::Flags::apply, args))
if (GameCommands::doCommand(args, GameCommands::Flags::apply) != GameCommands::FAILURE)
{
Audio::playSound(Audio::SoundId::demolish, GameCommands::getPosition());
}
@ -704,7 +704,7 @@ namespace OpenLoco::Input
GameCommands::PortRemovalArgs args;
Pos2 firstTile = pos - Map::offsets[station->multiTileIndex()];
args.pos = Pos3(firstTile.x, firstTile.y, station->baseZ() * 4);
if (GameCommands::do_61(GameCommands::Flags::apply, args))
if (GameCommands::doCommand(args, GameCommands::Flags::apply) != GameCommands::FAILURE)
{
Audio::playSound(Audio::SoundId::demolish, GameCommands::getPosition());
}
@ -718,7 +718,7 @@ namespace OpenLoco::Input
args.pos = Pos3(pos.x, pos.y, tree->baseZ() * 4);
args.elementType = tree->rawData()[0];
args.type = tree->treeObjectId();
GameCommands::do_22(GameCommands::Flags::apply, args);
GameCommands::doCommand(args, GameCommands::Flags::apply);
}
// 0x0042D9BF TODO: Move to a better file
@ -728,7 +728,7 @@ namespace OpenLoco::Input
GameCommands::BuildingRemovalArgs args;
Pos2 firstTile = pos - Map::offsets[building->multiTileIndex()];
args.pos = Pos3(firstTile.x, firstTile.y, building->baseZ() * 4);
GameCommands::do_45(GameCommands::Flags::apply, args);
GameCommands::doCommand(args, GameCommands::Flags::apply);
}
// 0x004C4809 TODO: Move to a better file
@ -738,7 +738,7 @@ namespace OpenLoco::Input
GameCommands::WallRemovalArgs args;
args.pos = Pos3(pos.x, pos.y, wall->baseZ() * 4);
args.rotation = wall->rotation();
GameCommands::do_33(GameCommands::Flags::apply, args);
GameCommands::doCommand(args, GameCommands::Flags::apply);
}
// 0x0042F007 TODO: Move to a better file
@ -748,7 +748,7 @@ namespace OpenLoco::Input
GameCommands::HeadquarterRemovalArgs args;
Pos2 firstTile = pos - Map::offsets[building->multiTileIndex()];
args.pos = Pos3(firstTile.x, firstTile.y, building->baseZ() * 4);
GameCommands::do_55(GameCommands::Flags::apply, args);
GameCommands::doCommand(args, GameCommands::Flags::apply);
}
// 0x004C74BB

View File

@ -178,7 +178,7 @@ namespace OpenLoco::Map
{
GameCommands::BuildingRemovalArgs args;
args.pos = Map::Pos3(loc.x, loc.y, baseZ() * 4);
GameCommands::do_45(GameCommands::Flags::apply, args);
GameCommands::doCommand(args, GameCommands::Flags::apply);
return false;
}
}

View File

@ -901,7 +901,7 @@ namespace OpenLoco::Ui::Windows::CompanyWindow
auto flags = GameCommands::Flags::apply | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6;
GameCommands::HeadquarterRemovalArgs args;
args.pos = _headquarterGhostPos;
GameCommands::do_55(flags, args);
GameCommands::doCommand(args, flags);
}
}
@ -910,7 +910,7 @@ namespace OpenLoco::Ui::Windows::CompanyWindow
{
removeHeadquarterGhost();
auto flags = GameCommands::Flags::apply | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6;
if (GameCommands::do_54(flags, args) != GameCommands::FAILURE)
if (GameCommands::doCommand(args, flags) != GameCommands::FAILURE)
{
_headquarterGhostPlaced = true;
_headquarterGhostPos = args.pos;
@ -1030,7 +1030,7 @@ namespace OpenLoco::Ui::Windows::CompanyWindow
GameCommands::setErrorTitle(StringIds::error_cant_build_this_here);
uint8_t flags = GameCommands::Flags::apply | GameCommands::Flags::flag_1;
auto commandResult = GameCommands::do_54(flags, *placementArgs);
auto commandResult = GameCommands::doCommand(*placementArgs, flags);
if (commandResult != GameCommands::FAILURE)
{
Input::toolCancel();

View File

@ -189,7 +189,7 @@ namespace OpenLoco::Ui::Windows::Construction::Overhead
static uint32_t placeRoadModGhost(const GameCommands::RoadModsPlacementArgs& args)
{
auto res = GameCommands::do_40(GameCommands::Flags::apply | GameCommands::Flags::flag_1 | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6, args);
auto res = GameCommands::doCommand(args, GameCommands::Flags::apply | GameCommands::Flags::flag_1 | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6);
if (res != GameCommands::FAILURE)
{
_byte_522096 = _byte_522096 | (1 << 4);
@ -204,7 +204,7 @@ namespace OpenLoco::Ui::Windows::Construction::Overhead
static uint32_t placeTrackModGhost(const GameCommands::TrackModsPlacementArgs& args)
{
auto res = GameCommands::do_17(GameCommands::Flags::apply | GameCommands::Flags::flag_1 | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6, args);
auto res = GameCommands::doCommand(args, GameCommands::Flags::apply | GameCommands::Flags::flag_1 | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6);
if (res != GameCommands::FAILURE)
{
_byte_522096 = _byte_522096 | (1 << 4);
@ -321,7 +321,7 @@ namespace OpenLoco::Ui::Windows::Construction::Overhead
return;
}
GameCommands::setErrorTitle(StringIds::error_cant_build_this_here);
auto res = GameCommands::do_40(GameCommands::Flags::apply, *args);
auto res = GameCommands::doCommand(*args, GameCommands::Flags::apply);
if (res == GameCommands::FAILURE || res == 0)
{
return;
@ -342,7 +342,7 @@ namespace OpenLoco::Ui::Windows::Construction::Overhead
return;
}
GameCommands::setErrorTitle(StringIds::error_cant_build_this_here);
auto res = GameCommands::do_17(GameCommands::Flags::apply, *args);
auto res = GameCommands::doCommand(*args, GameCommands::Flags::apply);
if (res == GameCommands::FAILURE || res == 0)
{
return;

View File

@ -173,7 +173,7 @@ namespace OpenLoco::Ui::Windows::Construction::Signal
static uint32_t placeSignalGhost(const GameCommands::SignalPlacementArgs& args)
{
auto res = GameCommands::do_13(GameCommands::Flags::apply | GameCommands::Flags::flag_1 | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6, args);
auto res = GameCommands::doCommand(args, GameCommands::Flags::apply | GameCommands::Flags::flag_1 | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6);
if (res != GameCommands::FAILURE)
{
_byte_522096 = _byte_522096 | (1 << 2);
@ -256,7 +256,7 @@ namespace OpenLoco::Ui::Windows::Construction::Signal
}
GameCommands::setErrorTitle(isBothDirections ? StringIds::cant_build_signals_here : StringIds::cant_build_signal_here);
auto res = GameCommands::do_13(GameCommands::Flags::apply, *args);
auto res = GameCommands::doCommand(*args, GameCommands::Flags::apply);
if (res == GameCommands::FAILURE)
{
return;

View File

@ -932,7 +932,7 @@ namespace OpenLoco::Ui::Windows::IndustryList
// 0x00458BB5
static currency32_t placeIndustryGhost(const GameCommands::IndustryPlacementArgs& placementArgs)
{
auto res = GameCommands::do_47(GameCommands::Flags::apply | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6, placementArgs);
auto res = GameCommands::doCommand(placementArgs, GameCommands::Flags::apply | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6);
if (res == GameCommands::FAILURE)
{
return res;
@ -1023,7 +1023,7 @@ namespace OpenLoco::Ui::Windows::IndustryList
if (placementArgs)
{
GameCommands::setErrorTitle(StringIds::error_cant_build_this_here);
if (GameCommands::do_47(GameCommands::Flags::apply, *placementArgs) != GameCommands::FAILURE)
if (GameCommands::doCommand(*placementArgs, GameCommands::Flags::apply) != GameCommands::FAILURE)
{
Audio::playSound(Audio::SoundId::construct, GameCommands::getPosition());
}

View File

@ -417,7 +417,7 @@ namespace OpenLoco::Ui::Windows::Terraform
args.pos = Map::Pos3((*_terraformGhostPos).x, (*_terraformGhostPos).y, _terraformGhostBaseZ * 4);
args.type = _terraformGhostType;
args.elementType = _terraformGhostTreeElementType;
GameCommands::do_22(GameCommands::Flags::apply | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6, args);
GameCommands::doCommand(args, GameCommands::Flags::apply | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6);
}
}
@ -426,7 +426,7 @@ namespace OpenLoco::Ui::Windows::Terraform
{
removeTreeGhost();
auto res = GameCommands::do_23(GameCommands::Flags::apply | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6, placementArgs);
auto res = GameCommands::doCommand(placementArgs, GameCommands::Flags::apply | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6);
if (res != GameCommands::FAILURE)
{
_terraformGhostPos = placementArgs.pos;
@ -632,7 +632,7 @@ namespace OpenLoco::Ui::Windows::Terraform
args.requiresFullClearance = true;
// First query if we can place a tree at this location; skip if we can't.
auto queryRes = do_23(0, args);
auto queryRes = doCommand(args, 0);
if (queryRes == GameCommands::FAILURE)
{
numErrors++;
@ -640,7 +640,7 @@ namespace OpenLoco::Ui::Windows::Terraform
}
// Actually place the tree
do_23(GameCommands::Flags::apply, args);
doCommand(args, GameCommands::Flags::apply);
}
// Have we placed any trees?
@ -666,7 +666,7 @@ namespace OpenLoco::Ui::Windows::Terraform
switch (_treeClusterType)
{
case treeCluster::none:
if (GameCommands::do_23(GameCommands::Flags::apply, *placementArgs) != GameCommands::FAILURE)
if (GameCommands::doCommand(*placementArgs, GameCommands::Flags::apply) != GameCommands::FAILURE)
{
Audio::playSound(Audio::SoundId::construct, GameCommands::getPosition());
}
@ -2121,7 +2121,7 @@ namespace OpenLoco::Ui::Windows::Terraform
GameCommands::WallRemovalArgs args;
args.pos = Map::Pos3((*_terraformGhostPos).x, (*_terraformGhostPos).y, _terraformGhostBaseZ * 4);
args.rotation = _terraformGhostRotation;
GameCommands::do_33(GameCommands::Flags::apply | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6, args);
GameCommands::doCommand(args, GameCommands::Flags::apply | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6);
}
}
@ -2130,7 +2130,7 @@ namespace OpenLoco::Ui::Windows::Terraform
{
removeWallGhost();
if (GameCommands::do_32(GameCommands::Flags::apply | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6, placementArgs))
if (GameCommands::doCommand(placementArgs, GameCommands::Flags::apply | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6) != GameCommands::FAILURE)
{
_terraformGhostPos = placementArgs.pos;
_terraformGhostRotation = placementArgs.rotation;
@ -2218,7 +2218,7 @@ namespace OpenLoco::Ui::Windows::Terraform
if (placementArgs)
{
GameCommands::setErrorTitle(StringIds::error_cant_build_this_here);
if (GameCommands::do_32(GameCommands::Flags::apply, *placementArgs))
if (GameCommands::doCommand(*placementArgs, GameCommands::Flags::apply) != GameCommands::FAILURE)
{
Audio::playSound(Audio::SoundId::construct, GameCommands::getPosition());
}

View File

@ -717,7 +717,7 @@ namespace OpenLoco::Ui::Windows::TownList
GameCommands::TownPlacementArgs placementArgs;
placementArgs.pos = *mapPos;
placementArgs.size = _townSize;
if (GameCommands::do_49(placementArgs, GameCommands::Flags::apply) != GameCommands::FAILURE)
if (GameCommands::doCommand(placementArgs, GameCommands::Flags::apply) != GameCommands::FAILURE)
{
Audio::playSound(Audio::SoundId::construct, GameCommands::getPosition());
}
@ -980,7 +980,7 @@ namespace OpenLoco::Ui::Windows::TownList
{
GameCommands::BuildingRemovalArgs args;
args.pos = _buildingGhostPos;
GameCommands::do_45(GameCommands::Flags::apply | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6, args);
GameCommands::doCommand(args, GameCommands::Flags::apply | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6);
_buildingGhostPlaced = false;
}
}
@ -996,7 +996,7 @@ namespace OpenLoco::Ui::Windows::TownList
static currency32_t placeBuildingGhost(const GameCommands::BuildingPlacementArgs& placementArgs)
{
removeBuildingGhost();
auto res = GameCommands::do_44(placementArgs, GameCommands::Flags::apply | GameCommands::Flags::flag_1 | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6);
auto res = GameCommands::doCommand(placementArgs, GameCommands::Flags::apply | GameCommands::Flags::flag_1 | GameCommands::Flags::flag_3 | GameCommands::Flags::flag_5 | GameCommands::Flags::flag_6);
if (res != GameCommands::FAILURE)
{
_buildingGhostPos = placementArgs.pos;
@ -1104,7 +1104,8 @@ namespace OpenLoco::Ui::Windows::TownList
if (placementArgs)
{
GameCommands::setErrorTitle(StringIds::error_cant_build_this_here);
if (GameCommands::do_44(*placementArgs, GameCommands::Flags::apply | GameCommands::Flags::flag_1) != GameCommands::FAILURE)
if (GameCommands::doCommand(*placementArgs, GameCommands::Flags::apply | GameCommands::Flags::flag_1) != GameCommands::FAILURE)
{
Audio::playSound(Audio::SoundId::construct, GameCommands::getPosition());
}

View File

@ -3391,7 +3391,7 @@ namespace OpenLoco::Ui::Windows::Vehicle
}
_ghostVehiclePos = placementArgs->pos;
removeBoatGhost(head);
if (GameCommands::do_62(GameCommands::Flags::apply | GameCommands::Flags::flag_6 | GameCommands::Flags::flag_3, *placementArgs))
if (GameCommands::doCommand(*placementArgs, GameCommands::Flags::apply | GameCommands::Flags::flag_6 | GameCommands::Flags::flag_3) != GameCommands::FAILURE)
{
_1136264 = 0;
}
@ -3582,7 +3582,7 @@ namespace OpenLoco::Ui::Windows::Vehicle
}
removeAirplaneGhost(head);
if (GameCommands::do_58(GameCommands::Flags::apply | GameCommands::Flags::flag_6 | GameCommands::Flags::flag_3, *placementArgs))
if (GameCommands::doCommand(*placementArgs, GameCommands::Flags::apply | GameCommands::Flags::flag_6 | GameCommands::Flags::flag_3) != GameCommands::FAILURE)
{
_ghostAirportNode = placementArgs->airportNode;
_ghostAirportStationId = placementArgs->stationId;
@ -3829,7 +3829,7 @@ namespace OpenLoco::Ui::Windows::Vehicle
}
removeLandGhost(head);
if (GameCommands::do_1(GameCommands::Flags::apply | GameCommands::Flags::flag_6 | GameCommands::Flags::flag_3, *placementArgs))
if (GameCommands::doCommand(*placementArgs, GameCommands::Flags::apply | GameCommands::Flags::flag_6 | GameCommands::Flags::flag_3) != GameCommands::FAILURE)
{
_ghostLandTrackAndDirection = placementArgs->trackAndDirection;
_ghostVehiclePos = placementArgs->pos;
@ -3897,7 +3897,7 @@ namespace OpenLoco::Ui::Windows::Vehicle
args.push(head.name);
args.push(head.ordinalNumber);
GameCommands::setErrorTitle(StringIds::cant_place_string_id_here);
if (GameCommands::do_58(GameCommands::Flags::apply, *placementArgs))
if (GameCommands::doCommand(*placementArgs, GameCommands::Flags::apply) != GameCommands::FAILURE)
{
Input::toolCancel();
self.callOnMouseUp(Common::widx::tabMain);
@ -3931,7 +3931,7 @@ namespace OpenLoco::Ui::Windows::Vehicle
args.push(head.name);
args.push(head.ordinalNumber);
GameCommands::setErrorTitle(StringIds::cant_place_string_id_here);
if (GameCommands::do_62(GameCommands::Flags::apply, *placementArgs))
if (GameCommands::doCommand(*placementArgs, GameCommands::Flags::apply) != GameCommands::FAILURE)
{
Input::toolCancel();
self.callOnMouseUp(Common::widx::tabMain);
@ -3966,7 +3966,7 @@ namespace OpenLoco::Ui::Windows::Vehicle
args.push(head.name);
args.push(head.ordinalNumber);
GameCommands::setErrorTitle(StringIds::cant_place_string_id_here);
if (GameCommands::do_1(GameCommands::Flags::apply, *placementArgs))
if (GameCommands::doCommand(*placementArgs, GameCommands::Flags::apply) != GameCommands::FAILURE)
{
Input::toolCancel();
self.callOnMouseUp(Common::widx::tabMain);