mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use EnumBitSet for DoCommandFlags
parent
f309b90a1d
commit
c3d5e6d2a0
|
@ -268,7 +268,7 @@ void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height, int &xoff
|
|||
* @param[out] ret the vehicle that has been built.
|
||||
* @return the cost of this operation or an error.
|
||||
*/
|
||||
CommandCost CmdBuildAircraft(DoCommandFlag flags, TileIndex tile, const Engine *e, Vehicle **ret)
|
||||
CommandCost CmdBuildAircraft(DoCommandFlags flags, TileIndex tile, const Engine *e, Vehicle **ret)
|
||||
{
|
||||
const AircraftVehicleInfo *avi = &e->u.air;
|
||||
const Station *st = Station::GetByTile(tile);
|
||||
|
@ -279,7 +279,7 @@ CommandCost CmdBuildAircraft(DoCommandFlag flags, TileIndex tile, const Engine *
|
|||
/* Make sure all aircraft end up in the first tile of the hangar. */
|
||||
tile = st->airport.GetHangarTile(st->airport.GetHangarNum(tile));
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Aircraft *v = new Aircraft(); // aircraft
|
||||
Aircraft *u = new Aircraft(); // shadow
|
||||
*ret = v;
|
||||
|
@ -1287,7 +1287,7 @@ void HandleMissingAircraftOrders(Aircraft *v)
|
|||
const Station *st = GetTargetAirportIfValid(v);
|
||||
if (st == nullptr) {
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner);
|
||||
CommandCost ret = Command<CMD_SEND_VEHICLE_TO_DEPOT>::Do(DC_EXEC, v->index, DepotCommandFlag{}, {});
|
||||
CommandCost ret = Command<CMD_SEND_VEHICLE_TO_DEPOT>::Do(DoCommandFlag::Execute, v->index, DepotCommandFlag{}, {});
|
||||
cur_company.Restore();
|
||||
|
||||
if (ret.Failed()) CrashAirplane(v);
|
||||
|
@ -1653,7 +1653,7 @@ static void AircraftEventHandler_HeliTakeOff(Aircraft *v, const AirportFTAClass
|
|||
/* Send the helicopter to a hangar if needed for replacement */
|
||||
if (v->NeedsAutomaticServicing()) {
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner);
|
||||
Command<CMD_SEND_VEHICLE_TO_DEPOT>::Do(DC_EXEC, v->index, DepotCommandFlags{DepotCommandFlag::Service, DepotCommandFlag::LocateHangar}, {});
|
||||
Command<CMD_SEND_VEHICLE_TO_DEPOT>::Do(DoCommandFlag::Execute, v->index, DepotCommandFlags{DepotCommandFlag::Service, DepotCommandFlag::LocateHangar}, {});
|
||||
cur_company.Restore();
|
||||
}
|
||||
}
|
||||
|
@ -1704,7 +1704,7 @@ static void AircraftEventHandler_Landing(Aircraft *v, const AirportFTAClass *)
|
|||
/* check if the aircraft needs to be replaced or renewed and send it to a hangar if needed */
|
||||
if (v->NeedsAutomaticServicing()) {
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner);
|
||||
Command<CMD_SEND_VEHICLE_TO_DEPOT>::Do(DC_EXEC, v->index, DepotCommandFlag::Service, {});
|
||||
Command<CMD_SEND_VEHICLE_TO_DEPOT>::Do(DoCommandFlag::Execute, v->index, DepotCommandFlag::Service, {});
|
||||
cur_company.Restore();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,6 @@
|
|||
#include "engine_type.h"
|
||||
#include "vehicle_type.h"
|
||||
|
||||
CommandCost CmdBuildAircraft(DoCommandFlag flags, TileIndex tile, const Engine *e, Vehicle **v);
|
||||
CommandCost CmdBuildAircraft(DoCommandFlags flags, TileIndex tile, const Engine *e, Vehicle **v);
|
||||
|
||||
#endif /* AIRCRAFT_CMD_H */
|
||||
|
|
|
@ -94,12 +94,12 @@ EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group,
|
|||
* @param flags The calling command flags.
|
||||
* @return 0 on success, CMD_ERROR on failure.
|
||||
*/
|
||||
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags)
|
||||
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlags flags)
|
||||
{
|
||||
/* Check if the old vehicle is already in the list */
|
||||
EngineRenew *er = GetEngineReplacement(*erl, old_engine, group);
|
||||
if (er != nullptr) {
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
er->to = new_engine;
|
||||
er->replace_when_old = replace_when_old;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, Engi
|
|||
|
||||
if (!EngineRenew::CanAllocateItem()) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
er = new EngineRenew(old_engine, new_engine);
|
||||
er->group_id = group;
|
||||
er->replace_when_old = replace_when_old;
|
||||
|
@ -129,14 +129,14 @@ CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, Engi
|
|||
* @param flags The calling command flags.
|
||||
* @return 0 on success, CMD_ERROR on failure.
|
||||
*/
|
||||
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, DoCommandFlag flags)
|
||||
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, DoCommandFlags flags)
|
||||
{
|
||||
EngineRenew *er = (EngineRenew *)(*erl);
|
||||
EngineRenew *prev = nullptr;
|
||||
|
||||
while (er != nullptr) {
|
||||
if (er->from == engine && er->group_id == group) {
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (prev == nullptr) { // First element
|
||||
/* The second becomes the new first element */
|
||||
*erl = (EngineRenewList)er->next;
|
||||
|
|
|
@ -318,7 +318,7 @@ static CommandCost GetNewEngineType(const Vehicle *v, const Company *c, bool alw
|
|||
* @param flags The calling command flags.
|
||||
* @return cost or error
|
||||
*/
|
||||
static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehicle, bool part_of_chain, DoCommandFlag flags)
|
||||
static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehicle, bool part_of_chain, DoCommandFlags flags)
|
||||
{
|
||||
*new_vehicle = nullptr;
|
||||
|
||||
|
@ -332,7 +332,7 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic
|
|||
/* Does it need to be refitted */
|
||||
CargoType refit_cargo = GetNewCargoTypeForReplace(old_veh, e, part_of_chain);
|
||||
if (!IsValidCargoType(refit_cargo)) {
|
||||
if (!IsLocalCompany() || (flags & DC_EXEC) == 0) return CommandCost();
|
||||
if (!IsLocalCompany() || !flags.Test(DoCommandFlag::Execute)) return CommandCost();
|
||||
|
||||
VehicleID old_veh_id = (old_veh->type == VEH_TRAIN) ? Train::From(old_veh)->First()->index : old_veh->index;
|
||||
SetDParam(0, old_veh_id);
|
||||
|
@ -354,7 +354,7 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic
|
|||
|
||||
/* Build the new vehicle */
|
||||
VehicleID new_veh_id;
|
||||
std::tie(cost, new_veh_id, std::ignore, std::ignore, std::ignore) = Command<CMD_BUILD_VEHICLE>::Do(DC_EXEC | DC_AUTOREPLACE, old_veh->tile, e, true, INVALID_CARGO, INVALID_CLIENT_ID);
|
||||
std::tie(cost, new_veh_id, std::ignore, std::ignore, std::ignore) = Command<CMD_BUILD_VEHICLE>::Do({DoCommandFlag::Execute, DoCommandFlag::AutoReplace}, old_veh->tile, e, true, INVALID_CARGO, INVALID_CLIENT_ID);
|
||||
if (cost.Failed()) return cost;
|
||||
|
||||
Vehicle *new_veh = Vehicle::Get(new_veh_id);
|
||||
|
@ -364,13 +364,13 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic
|
|||
if (refit_cargo != CARGO_NO_REFIT) {
|
||||
uint8_t subtype = GetBestFittingSubType(old_veh, new_veh, refit_cargo);
|
||||
|
||||
cost.AddCost(std::get<0>(Command<CMD_REFIT_VEHICLE>::Do(DC_EXEC, new_veh->index, refit_cargo, subtype, false, false, 0)));
|
||||
cost.AddCost(std::get<0>(Command<CMD_REFIT_VEHICLE>::Do(DoCommandFlag::Execute, new_veh->index, refit_cargo, subtype, false, false, 0)));
|
||||
assert(cost.Succeeded()); // This should be ensured by GetNewCargoTypeForReplace()
|
||||
}
|
||||
|
||||
/* Try to reverse the vehicle, but do not care if it fails as the new type might not be reversible */
|
||||
if (new_veh->type == VEH_TRAIN && HasBit(Train::From(old_veh)->flags, VRF_REVERSE_DIRECTION)) {
|
||||
Command<CMD_REVERSE_TRAIN_DIRECTION>::Do(DC_EXEC, new_veh->index, true);
|
||||
Command<CMD_REVERSE_TRAIN_DIRECTION>::Do(DoCommandFlag::Execute, new_veh->index, true);
|
||||
}
|
||||
|
||||
return cost;
|
||||
|
@ -384,7 +384,7 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic
|
|||
*/
|
||||
static inline CommandCost DoCmdStartStopVehicle(const Vehicle *v, bool evaluate_callback)
|
||||
{
|
||||
return Command<CMD_START_STOP_VEHICLE>::Do(DC_EXEC | DC_AUTOREPLACE, v->index, evaluate_callback);
|
||||
return Command<CMD_START_STOP_VEHICLE>::Do({DoCommandFlag::Execute, DoCommandFlag::AutoReplace}, v->index, evaluate_callback);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -395,9 +395,9 @@ static inline CommandCost DoCmdStartStopVehicle(const Vehicle *v, bool evaluate_
|
|||
* @param whole_chain move all vehicles following 'v' (true), or only 'v' (false)
|
||||
* @return success or error
|
||||
*/
|
||||
static inline CommandCost CmdMoveVehicle(const Vehicle *v, const Vehicle *after, DoCommandFlag flags, bool whole_chain)
|
||||
static inline CommandCost CmdMoveVehicle(const Vehicle *v, const Vehicle *after, DoCommandFlags flags, bool whole_chain)
|
||||
{
|
||||
return Command<CMD_MOVE_RAIL_VEHICLE>::Do(flags | DC_NO_CARGO_CAP_CHECK, v->index, after != nullptr ? after->index : INVALID_VEHICLE, whole_chain);
|
||||
return Command<CMD_MOVE_RAIL_VEHICLE>::Do(flags.Set(DoCommandFlag::NoCargoCapacityCheck), v->index, after != nullptr ? after->index : INVALID_VEHICLE, whole_chain);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -406,15 +406,15 @@ static inline CommandCost CmdMoveVehicle(const Vehicle *v, const Vehicle *after,
|
|||
* @param new_head The new head of the completely replaced vehicle chain
|
||||
* @param flags the command flags to use
|
||||
*/
|
||||
static CommandCost CopyHeadSpecificThings(Vehicle *old_head, Vehicle *new_head, DoCommandFlag flags)
|
||||
static CommandCost CopyHeadSpecificThings(Vehicle *old_head, Vehicle *new_head, DoCommandFlags flags)
|
||||
{
|
||||
CommandCost cost = CommandCost();
|
||||
|
||||
/* Share orders */
|
||||
if (cost.Succeeded() && old_head != new_head) cost.AddCost(Command<CMD_CLONE_ORDER>::Do(DC_EXEC, CO_SHARE, new_head->index, old_head->index));
|
||||
if (cost.Succeeded() && old_head != new_head) cost.AddCost(Command<CMD_CLONE_ORDER>::Do(DoCommandFlag::Execute, CO_SHARE, new_head->index, old_head->index));
|
||||
|
||||
/* Copy group membership */
|
||||
if (cost.Succeeded() && old_head != new_head) cost.AddCost(std::get<0>(Command<CMD_ADD_VEHICLE_GROUP>::Do(DC_EXEC, old_head->group_id, new_head->index, false, VehicleListIdentifier{})));
|
||||
if (cost.Succeeded() && old_head != new_head) cost.AddCost(std::get<0>(Command<CMD_ADD_VEHICLE_GROUP>::Do(DoCommandFlag::Execute, old_head->group_id, new_head->index, false, VehicleListIdentifier{})));
|
||||
|
||||
/* Perform start/stop check whether the new vehicle suits newgrf restrictions etc. */
|
||||
if (cost.Succeeded()) {
|
||||
|
@ -427,7 +427,7 @@ static CommandCost CopyHeadSpecificThings(Vehicle *old_head, Vehicle *new_head,
|
|||
}
|
||||
|
||||
/* Last do those things which do never fail (resp. we do not care about), but which are not undo-able */
|
||||
if (cost.Succeeded() && old_head != new_head && (flags & DC_EXEC) != 0) {
|
||||
if (cost.Succeeded() && old_head != new_head && flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Copy other things which cannot be copied by a command and which shall not stay resetted from the build vehicle command */
|
||||
new_head->CopyVehicleConfigAndStatistics(old_head);
|
||||
GroupStatistics::AddProfitLastYear(new_head);
|
||||
|
@ -448,7 +448,7 @@ static CommandCost CopyHeadSpecificThings(Vehicle *old_head, Vehicle *new_head,
|
|||
* @param nothing_to_do is set to 'false' when something was done (only valid when not failed)
|
||||
* @return cost or error
|
||||
*/
|
||||
static CommandCost ReplaceFreeUnit(Vehicle **single_unit, DoCommandFlag flags, bool *nothing_to_do)
|
||||
static CommandCost ReplaceFreeUnit(Vehicle **single_unit, DoCommandFlags flags, bool *nothing_to_do)
|
||||
{
|
||||
Train *old_v = Train::From(*single_unit);
|
||||
assert(!old_v->IsArticulatedPart() && !old_v->IsRearDualheaded());
|
||||
|
@ -463,9 +463,9 @@ static CommandCost ReplaceFreeUnit(Vehicle **single_unit, DoCommandFlag flags, b
|
|||
if (cost.Succeeded() && new_v != nullptr) {
|
||||
*nothing_to_do = false;
|
||||
|
||||
if ((flags & DC_EXEC) != 0) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Move the new vehicle behind the old */
|
||||
CmdMoveVehicle(new_v, old_v, DC_EXEC, false);
|
||||
CmdMoveVehicle(new_v, old_v, DoCommandFlag::Execute, false);
|
||||
|
||||
/* Take over cargo
|
||||
* Note: We do only transfer cargo from the old to the new vehicle.
|
||||
|
@ -483,9 +483,9 @@ static CommandCost ReplaceFreeUnit(Vehicle **single_unit, DoCommandFlag flags, b
|
|||
/* Sell the old vehicle */
|
||||
cost.AddCost(Command<CMD_SELL_VEHICLE>::Do(flags, old_v->index, false, false, INVALID_CLIENT_ID));
|
||||
|
||||
/* If we are not in DC_EXEC undo everything */
|
||||
if ((flags & DC_EXEC) == 0) {
|
||||
Command<CMD_SELL_VEHICLE>::Do(DC_EXEC, new_v->index, false, false, INVALID_CLIENT_ID);
|
||||
/* If we are not in DoCommandFlag::Execute undo everything */
|
||||
if (!flags.Test(DoCommandFlag::Execute)) {
|
||||
Command<CMD_SELL_VEHICLE>::Do(DoCommandFlag::Execute, new_v->index, false, false, INVALID_CLIENT_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,7 @@ struct ReplaceChainItem {
|
|||
* @param nothing_to_do is set to 'false' when something was done (only valid when not failed)
|
||||
* @return cost or error
|
||||
*/
|
||||
static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon_removal, bool *nothing_to_do)
|
||||
static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlags flags, bool wagon_removal, bool *nothing_to_do)
|
||||
{
|
||||
Vehicle *old_head = *chain;
|
||||
assert(old_head->IsPrimaryVehicle());
|
||||
|
@ -546,7 +546,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
if (cost.Succeeded()) {
|
||||
/* Separate the head, so we can start constructing the new chain */
|
||||
Train *second = Train::From(old_head)->GetNextUnit();
|
||||
if (second != nullptr) cost.AddCost(CmdMoveVehicle(second, nullptr, DC_EXEC | DC_AUTOREPLACE, true));
|
||||
if (second != nullptr) cost.AddCost(CmdMoveVehicle(second, nullptr, {DoCommandFlag::Execute, DoCommandFlag::AutoReplace}, true));
|
||||
|
||||
assert(Train::From(new_head)->GetNextUnit() == nullptr);
|
||||
|
||||
|
@ -562,14 +562,14 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
if (RailVehInfo(append->engine_type)->railveh_type == RAILVEH_WAGON) continue;
|
||||
|
||||
if (it->new_veh != nullptr) {
|
||||
/* Move the old engine to a separate row with DC_AUTOREPLACE. Else
|
||||
/* Move the old engine to a separate row with DoCommandFlag::AutoReplace. Else
|
||||
* moving the wagon in front may fail later due to unitnumber limit.
|
||||
* (We have to attach wagons without DC_AUTOREPLACE.) */
|
||||
CmdMoveVehicle(it->old_veh, nullptr, DC_EXEC | DC_AUTOREPLACE, false);
|
||||
* (We have to attach wagons without DoCommandFlag::AutoReplace.) */
|
||||
CmdMoveVehicle(it->old_veh, nullptr, {DoCommandFlag::Execute, DoCommandFlag::AutoReplace}, false);
|
||||
}
|
||||
|
||||
if (last_engine == nullptr) last_engine = append;
|
||||
cost.AddCost(CmdMoveVehicle(append, new_head, DC_EXEC, false));
|
||||
cost.AddCost(CmdMoveVehicle(append, new_head, DoCommandFlag::Execute, false));
|
||||
if (cost.Failed()) break;
|
||||
}
|
||||
if (last_engine == nullptr) last_engine = new_head;
|
||||
|
@ -588,13 +588,13 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
|
||||
if (RailVehInfo(append->engine_type)->railveh_type == RAILVEH_WAGON) {
|
||||
/* Insert wagon after 'last_engine' */
|
||||
CommandCost res = CmdMoveVehicle(append, last_engine, DC_EXEC, false);
|
||||
CommandCost res = CmdMoveVehicle(append, last_engine, DoCommandFlag::Execute, false);
|
||||
|
||||
/* When we allow removal of wagons, either the move failing due
|
||||
* to the train becoming too long, or the train becoming longer
|
||||
* would move the vehicle to the empty vehicle chain. */
|
||||
if (wagon_removal && (res.Failed() ? res.GetErrorMessage() == STR_ERROR_TRAIN_TOO_LONG : Train::From(new_head)->gcache.cached_total_length > old_total_length)) {
|
||||
CmdMoveVehicle(append, nullptr, DC_EXEC | DC_AUTOREPLACE, false);
|
||||
CmdMoveVehicle(append, nullptr, {DoCommandFlag::Execute, DoCommandFlag::AutoReplace}, false);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -619,7 +619,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
assert(RailVehInfo(wagon->engine_type)->railveh_type == RAILVEH_WAGON);
|
||||
|
||||
/* Sell wagon */
|
||||
[[maybe_unused]] CommandCost ret = Command<CMD_SELL_VEHICLE>::Do(DC_EXEC, wagon->index, false, false, INVALID_CLIENT_ID);
|
||||
[[maybe_unused]] CommandCost ret = Command<CMD_SELL_VEHICLE>::Do(DoCommandFlag::Execute, wagon->index, false, false, INVALID_CLIENT_ID);
|
||||
assert(ret.Succeeded());
|
||||
it->new_veh = nullptr;
|
||||
|
||||
|
@ -634,7 +634,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
|
||||
if (cost.Succeeded()) {
|
||||
/* Success ! */
|
||||
if ((flags & DC_EXEC) != 0 && new_head != old_head) {
|
||||
if (flags.Test(DoCommandFlag::Execute) && new_head != old_head) {
|
||||
*chain = new_head;
|
||||
AI::NewEvent(old_head->owner, new ScriptEventVehicleAutoReplaced(old_head->index, new_head->index));
|
||||
}
|
||||
|
@ -646,43 +646,43 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
* Note: We cannot test 'new_vehs[i] != nullptr' as wagon removal might cause to remove both */
|
||||
if (w->First() == new_head) continue;
|
||||
|
||||
if ((flags & DC_EXEC) != 0) TransferCargo(w, new_head, true);
|
||||
if (flags.Test(DoCommandFlag::Execute)) TransferCargo(w, new_head, true);
|
||||
|
||||
/* Sell the vehicle.
|
||||
* Note: This might temporarily construct new trains, so use DC_AUTOREPLACE to prevent
|
||||
* Note: This might temporarily construct new trains, so use DoCommandFlag::AutoReplace to prevent
|
||||
* it from failing due to engine limits. */
|
||||
cost.AddCost(Command<CMD_SELL_VEHICLE>::Do(flags | DC_AUTOREPLACE, w->index, false, false, INVALID_CLIENT_ID));
|
||||
if ((flags & DC_EXEC) != 0) {
|
||||
cost.AddCost(Command<CMD_SELL_VEHICLE>::Do(DoCommandFlags{flags}.Set(DoCommandFlag::AutoReplace), w->index, false, false, INVALID_CLIENT_ID));
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
it->old_veh = nullptr;
|
||||
if (it == std::begin(replacements)) old_head = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if ((flags & DC_EXEC) != 0) CheckCargoCapacity(new_head);
|
||||
if (flags.Test(DoCommandFlag::Execute)) CheckCargoCapacity(new_head);
|
||||
}
|
||||
|
||||
/* If we are not in DC_EXEC undo everything, i.e. rearrange old vehicles.
|
||||
/* If we are not in DoCommandFlag::Execute undo everything, i.e. rearrange old vehicles.
|
||||
* We do this from back to front, so that the head of the temporary vehicle chain does not change all the time.
|
||||
* Note: The vehicle attach callback is disabled here :) */
|
||||
if ((flags & DC_EXEC) == 0) {
|
||||
if (!flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Separate the head, so we can reattach the old vehicles */
|
||||
Train *second = Train::From(old_head)->GetNextUnit();
|
||||
if (second != nullptr) CmdMoveVehicle(second, nullptr, DC_EXEC | DC_AUTOREPLACE, true);
|
||||
if (second != nullptr) CmdMoveVehicle(second, nullptr, {DoCommandFlag::Execute, DoCommandFlag::AutoReplace}, true);
|
||||
|
||||
assert(Train::From(old_head)->GetNextUnit() == nullptr);
|
||||
|
||||
for (auto it = std::rbegin(replacements); it != std::rend(replacements); ++it) {
|
||||
[[maybe_unused]] CommandCost ret = CmdMoveVehicle(it->old_veh, old_head, DC_EXEC | DC_AUTOREPLACE, false);
|
||||
[[maybe_unused]] CommandCost ret = CmdMoveVehicle(it->old_veh, old_head, {DoCommandFlag::Execute, DoCommandFlag::AutoReplace}, false);
|
||||
assert(ret.Succeeded());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Finally undo buying of new vehicles */
|
||||
if ((flags & DC_EXEC) == 0) {
|
||||
if (!flags.Test(DoCommandFlag::Execute)) {
|
||||
for (auto it = std::rbegin(replacements); it != std::rend(replacements); ++it) {
|
||||
if (it->new_veh != nullptr) {
|
||||
Command<CMD_SELL_VEHICLE>::Do(DC_EXEC, it->new_veh->index, false, false, INVALID_CLIENT_ID);
|
||||
Command<CMD_SELL_VEHICLE>::Do(DoCommandFlag::Execute, it->new_veh->index, false, false, INVALID_CLIENT_ID);
|
||||
it->new_veh = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -701,7 +701,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
|
||||
if (cost.Succeeded()) {
|
||||
/* The new vehicle is constructed, now take over cargo */
|
||||
if ((flags & DC_EXEC) != 0) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
TransferCargo(old_head, new_head, true);
|
||||
*chain = new_head;
|
||||
|
||||
|
@ -712,9 +712,9 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
cost.AddCost(Command<CMD_SELL_VEHICLE>::Do(flags, old_head->index, false, false, INVALID_CLIENT_ID));
|
||||
}
|
||||
|
||||
/* If we are not in DC_EXEC undo everything */
|
||||
if ((flags & DC_EXEC) == 0) {
|
||||
Command<CMD_SELL_VEHICLE>::Do(DC_EXEC, new_head->index, false, false, INVALID_CLIENT_ID);
|
||||
/* If we are not in DoCommandFlag::Execute undo everything */
|
||||
if (!flags.Test(DoCommandFlag::Execute)) {
|
||||
Command<CMD_SELL_VEHICLE>::Do(DoCommandFlag::Execute, new_head->index, false, false, INVALID_CLIENT_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -729,7 +729,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
* @param veh_id Index of vehicle
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdAutoreplaceVehicle(DoCommandFlag flags, VehicleID veh_id)
|
||||
CommandCost CmdAutoreplaceVehicle(DoCommandFlags flags, VehicleID veh_id)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(veh_id);
|
||||
if (v == nullptr) return CMD_ERROR;
|
||||
|
@ -781,17 +781,17 @@ CommandCost CmdAutoreplaceVehicle(DoCommandFlag flags, VehicleID veh_id)
|
|||
|
||||
/* We have to construct the new vehicle chain to test whether it is valid.
|
||||
* Vehicle construction needs random bits, so we have to save the random seeds
|
||||
* to prevent desyncs and to replay newgrf callbacks during DC_EXEC */
|
||||
* to prevent desyncs and to replay newgrf callbacks during DoCommandFlag::Execute */
|
||||
SavedRandomSeeds saved_seeds;
|
||||
SaveRandomSeeds(&saved_seeds);
|
||||
if (free_wagon) {
|
||||
cost.AddCost(ReplaceFreeUnit(&v, flags & ~DC_EXEC, ¬hing_to_do));
|
||||
cost.AddCost(ReplaceFreeUnit(&v, DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), ¬hing_to_do));
|
||||
} else {
|
||||
cost.AddCost(ReplaceChain(&v, flags & ~DC_EXEC, wagon_removal, ¬hing_to_do));
|
||||
cost.AddCost(ReplaceChain(&v, DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), wagon_removal, ¬hing_to_do));
|
||||
}
|
||||
RestoreRandomSeeds(saved_seeds);
|
||||
|
||||
if (cost.Succeeded() && (flags & DC_EXEC) != 0) {
|
||||
if (cost.Succeeded() && flags.Test(DoCommandFlag::Execute)) {
|
||||
if (free_wagon) {
|
||||
ret = ReplaceFreeUnit(&v, flags, ¬hing_to_do);
|
||||
} else {
|
||||
|
@ -817,7 +817,7 @@ CommandCost CmdAutoreplaceVehicle(DoCommandFlag flags, VehicleID veh_id)
|
|||
* @param when_old replace when engine gets old?
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetAutoReplace(DoCommandFlag flags, GroupID id_g, EngineID old_engine_type, EngineID new_engine_type, bool when_old)
|
||||
CommandCost CmdSetAutoReplace(DoCommandFlags flags, GroupID id_g, EngineID old_engine_type, EngineID new_engine_type, bool when_old)
|
||||
{
|
||||
Company *c = Company::GetIfValid(_current_company);
|
||||
if (c == nullptr) return CMD_ERROR;
|
||||
|
@ -837,14 +837,14 @@ CommandCost CmdSetAutoReplace(DoCommandFlag flags, GroupID id_g, EngineID old_en
|
|||
cost = RemoveEngineReplacementForCompany(c, old_engine_type, id_g, flags);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
GroupStatistics::UpdateAutoreplace(_current_company);
|
||||
if (IsLocalCompany()) SetWindowDirty(WC_REPLACE_VEHICLE, Engine::Get(old_engine_type)->type);
|
||||
|
||||
const VehicleType vt = Engine::Get(old_engine_type)->type;
|
||||
SetWindowDirty(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_GROUP_LIST, vt, _current_company).ToWindowNumber());
|
||||
}
|
||||
if ((flags & DC_EXEC) && IsLocalCompany()) InvalidateAutoreplaceWindow(old_engine_type, id_g);
|
||||
if (flags.Test(DoCommandFlag::Execute) && IsLocalCompany()) InvalidateAutoreplaceWindow(old_engine_type, id_g);
|
||||
|
||||
return cost;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
#include "engine_type.h"
|
||||
#include "group_type.h"
|
||||
|
||||
CommandCost CmdAutoreplaceVehicle(DoCommandFlag flags, VehicleID veh_id);
|
||||
CommandCost CmdSetAutoReplace(DoCommandFlag flags, GroupID id_g, EngineID old_engine_type, EngineID new_engine_type, bool when_old);
|
||||
CommandCost CmdAutoreplaceVehicle(DoCommandFlags flags, VehicleID veh_id);
|
||||
CommandCost CmdSetAutoReplace(DoCommandFlags flags, GroupID id_g, EngineID old_engine_type, EngineID new_engine_type, bool when_old);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_AUTOREPLACE_VEHICLE, CmdAutoreplaceVehicle, 0, CMDT_VEHICLE_MANAGEMENT)
|
||||
DEF_CMD_TRAIT(CMD_SET_AUTOREPLACE, CmdSetAutoReplace, 0, CMDT_VEHICLE_MANAGEMENT)
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
void RemoveAllEngineReplacement(EngineRenewList *erl);
|
||||
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group, bool *replace_when_old = nullptr);
|
||||
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags);
|
||||
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, DoCommandFlag flags);
|
||||
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlags flags);
|
||||
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, DoCommandFlags flags);
|
||||
|
||||
/**
|
||||
* Remove all engine replacement settings for the given company.
|
||||
|
@ -77,7 +77,7 @@ inline bool EngineHasReplacementWhenOldForCompany(const Company *c, EngineID eng
|
|||
* @param flags The calling command flags.
|
||||
* @return 0 on success, CMD_ERROR on failure.
|
||||
*/
|
||||
inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags)
|
||||
inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlags flags)
|
||||
{
|
||||
return AddEngineReplacement(&c->engine_renew_list, old_engine, new_engine, group, replace_when_old, flags);
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engin
|
|||
* @param flags The calling command flags.
|
||||
* @return 0 on success, CMD_ERROR on failure.
|
||||
*/
|
||||
inline CommandCost RemoveEngineReplacementForCompany(Company *c, EngineID engine, GroupID group, DoCommandFlag flags)
|
||||
inline CommandCost RemoveEngineReplacementForCompany(Company *c, EngineID engine, GroupID group, DoCommandFlags flags)
|
||||
{
|
||||
return RemoveEngineReplacement(&c->engine_renew_list, engine, group, flags);
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ inline const BridgeSpec *GetBridgeSpec(BridgeType i)
|
|||
|
||||
void DrawBridgeMiddle(const TileInfo *ti);
|
||||
|
||||
CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags = DC_NONE);
|
||||
CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlags flags = {});
|
||||
int CalcBridgeLenCostFactor(int x);
|
||||
|
||||
void ResetBridges();
|
||||
|
|
|
@ -377,7 +377,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
|
|||
/* only query bridge building possibility once, result is the same for all bridges!
|
||||
* returns CMD_ERROR on failure, and price on success */
|
||||
StringID errmsg = INVALID_STRING_ID;
|
||||
CommandCost ret = Command<CMD_BUILD_BRIDGE>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_BRIDGE>()) | DC_QUERY_COST, end, start, transport_type, 0, road_rail_type);
|
||||
CommandCost ret = Command<CMD_BUILD_BRIDGE>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_BRIDGE>()) | DoCommandFlag::QueryCost, end, start, transport_type, 0, road_rail_type);
|
||||
|
||||
GUIBridgeList bl;
|
||||
if (ret.Failed()) {
|
||||
|
@ -422,7 +422,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
|
|||
item.index = brd_type;
|
||||
item.spec = GetBridgeSpec(brd_type);
|
||||
/* Add to terraforming & bulldozing costs the cost of the
|
||||
* bridge itself (not computed with DC_QUERY_COST) */
|
||||
* bridge itself (not computed with DoCommandFlag::QueryCost) */
|
||||
item.cost = ret.GetCost() + (((int64_t)tot_bridgedata_len * _price[PR_BUILD_BRIDGE] * item.spec->price) >> 8) + infra_cost;
|
||||
any_available = true;
|
||||
}
|
||||
|
|
|
@ -1322,7 +1322,7 @@ struct BuildVehicleWindow : Window {
|
|||
|
||||
if (!this->listview_mode) {
|
||||
/* Query for cost and refitted capacity */
|
||||
auto [ret, veh_id, refit_capacity, refit_mail, cargo_capacities] = Command<CMD_BUILD_VEHICLE>::Do(DC_QUERY_COST, TileIndex(this->window_number), this->sel_engine, true, cargo, INVALID_CLIENT_ID);
|
||||
auto [ret, veh_id, refit_capacity, refit_mail, cargo_capacities] = Command<CMD_BUILD_VEHICLE>::Do(DoCommandFlag::QueryCost, TileIndex(this->window_number), this->sel_engine, true, cargo, INVALID_CLIENT_ID);
|
||||
if (ret.Succeeded()) {
|
||||
this->te.cost = ret.GetCost() - e->GetCost();
|
||||
this->te.capacity = refit_capacity;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "safeguards.h"
|
||||
|
||||
static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
static const Price clear_price_table[] = {
|
||||
PR_CLEAR_GRASS,
|
||||
|
@ -39,7 +39,7 @@ static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlag flags)
|
|||
price.AddCost(_price[clear_price_table[GetClearGround(tile)]]);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) DoClearSquare(tile);
|
||||
if (flags.Test(DoCommandFlag::Execute)) DoClearSquare(tile);
|
||||
|
||||
return price;
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ static void ChangeTileOwner_Clear(TileIndex, Owner, Owner)
|
|||
return;
|
||||
}
|
||||
|
||||
static CommandCost TerraformTile_Clear(TileIndex tile, DoCommandFlag flags, int, Slope)
|
||||
static CommandCost TerraformTile_Clear(TileIndex tile, DoCommandFlags flags, int, Slope)
|
||||
{
|
||||
return Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile);
|
||||
}
|
||||
|
|
|
@ -179,17 +179,17 @@ void CommandHelperBase::InternalDoBefore(bool top_level, bool test)
|
|||
* @param top_level Top level of command execution, i.e. command from a command.
|
||||
* @param test Test run of command?
|
||||
*/
|
||||
void CommandHelperBase::InternalDoAfter(CommandCost &res, DoCommandFlag flags, bool top_level, bool test)
|
||||
void CommandHelperBase::InternalDoAfter(CommandCost &res, DoCommandFlags flags, bool top_level, bool test)
|
||||
{
|
||||
if (test) {
|
||||
SetTownRatingTestMode(false);
|
||||
|
||||
if (res.Succeeded() && top_level && !(flags & DC_QUERY_COST) && !(flags & DC_BANKRUPT)) {
|
||||
if (res.Succeeded() && top_level && !flags.Test(DoCommandFlag::QueryCost) && !flags.Test(DoCommandFlag::Bankrupt)) {
|
||||
CheckCompanyHasMoney(res); // CheckCompanyHasMoney() modifies 'res' to an error if it fails.
|
||||
}
|
||||
} else {
|
||||
/* If top-level, subtract the money. */
|
||||
if (res.Succeeded() && top_level && !(flags & DC_BANKRUPT)) {
|
||||
if (res.Succeeded() && top_level && !flags.Test(DoCommandFlag::Bankrupt)) {
|
||||
SubtractMoneyFromCompany(res);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,12 +45,12 @@ constexpr CommandFlags GetCommandFlags()
|
|||
* @param cmd_flags Flags from GetCommandFlags
|
||||
* @return flags for DoCommand
|
||||
*/
|
||||
static constexpr inline DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
|
||||
static constexpr inline DoCommandFlags CommandFlagsToDCFlags(CommandFlags cmd_flags)
|
||||
{
|
||||
DoCommandFlag flags = DC_NONE;
|
||||
if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER;
|
||||
if (cmd_flags & CMD_AUTO) flags |= DC_AUTO;
|
||||
if (cmd_flags & CMD_ALL_TILES) flags |= DC_ALL_TILES;
|
||||
DoCommandFlags flags = {};
|
||||
if (cmd_flags & CMD_NO_WATER) flags.Set(DoCommandFlag::NoWater);
|
||||
if (cmd_flags & CMD_AUTO) flags.Set(DoCommandFlag::Auto);
|
||||
if (cmd_flags & CMD_ALL_TILES) flags.Set(DoCommandFlag::AllTiles);
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ template <Commands TCmd, typename T, bool THasTile> struct CommandHelper;
|
|||
class CommandHelperBase {
|
||||
protected:
|
||||
static void InternalDoBefore(bool top_level, bool test);
|
||||
static void InternalDoAfter(CommandCost &res, DoCommandFlag flags, bool top_level, bool test);
|
||||
static void InternalDoAfter(CommandCost &res, DoCommandFlags flags, bool top_level, bool test);
|
||||
static std::tuple<bool, bool, bool> InternalPostBefore(Commands cmd, CommandFlags flags, TileIndex tile, StringID err_message, bool network_command);
|
||||
static void InternalPostResult(const CommandCost &res, TileIndex tile, bool estimate_only, bool only_sending, StringID err_message, bool my_cmd);
|
||||
static bool InternalExecutePrepTest(CommandFlags cmd_flags, TileIndex tile, Backup<CompanyID> &cur_company);
|
||||
|
@ -102,7 +102,7 @@ protected:
|
|||
* @tparam Targs The command parameter types.
|
||||
*/
|
||||
template <Commands Tcmd, typename Tret, typename... Targs>
|
||||
struct CommandHelper<Tcmd, Tret(*)(DoCommandFlag, Targs...), true> : protected CommandHelperBase {
|
||||
struct CommandHelper<Tcmd, Tret(*)(DoCommandFlags, Targs...), true> : protected CommandHelperBase {
|
||||
private:
|
||||
/** Extract the \c CommandCost from a command proc result. */
|
||||
static inline CommandCost &ExtractCommandCost(Tret &ret)
|
||||
|
@ -136,23 +136,23 @@ public:
|
|||
* @see CommandProc
|
||||
* @return the cost
|
||||
*/
|
||||
static Tret Do(DoCommandFlag flags, Targs... args)
|
||||
static Tret Do(DoCommandFlags flags, Targs... args)
|
||||
{
|
||||
if constexpr (std::is_same_v<TileIndex, std::tuple_element_t<0, std::tuple<Targs...>>>) {
|
||||
/* Do not even think about executing out-of-bounds tile-commands. */
|
||||
TileIndex tile = std::get<0>(std::make_tuple(args...));
|
||||
if (tile != 0 && (tile >= Map::Size() || (!IsValidTile(tile) && (flags & DC_ALL_TILES) == 0))) return MakeResult(CMD_ERROR);
|
||||
if (tile != 0 && (tile >= Map::Size() || (!IsValidTile(tile) && !flags.Test(DoCommandFlag::AllTiles)))) return MakeResult(CMD_ERROR);
|
||||
}
|
||||
|
||||
RecursiveCommandCounter counter{};
|
||||
|
||||
/* Only execute the test call if it's toplevel, or we're not execing. */
|
||||
if (counter.IsTopLevel() || !(flags & DC_EXEC)) {
|
||||
if (counter.IsTopLevel() || !flags.Test(DoCommandFlag::Execute)) {
|
||||
InternalDoBefore(counter.IsTopLevel(), true);
|
||||
Tret res = CommandTraits<Tcmd>::proc(flags & ~DC_EXEC, args...);
|
||||
Tret res = CommandTraits<Tcmd>::proc(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), args...);
|
||||
InternalDoAfter(ExtractCommandCost(res), flags, counter.IsTopLevel(), true); // Can modify res.
|
||||
|
||||
if (ExtractCommandCost(res).Failed() || !(flags & DC_EXEC)) return res;
|
||||
if (ExtractCommandCost(res).Failed() || !flags.Test(DoCommandFlag::Execute)) return res;
|
||||
}
|
||||
|
||||
/* Execute the command here. All cost-relevant functions set the expenses type
|
||||
|
@ -369,7 +369,7 @@ protected:
|
|||
}
|
||||
|
||||
/* Test the command. */
|
||||
DoCommandFlag flags = CommandFlagsToDCFlags(cmd_flags);
|
||||
DoCommandFlags flags = CommandFlagsToDCFlags(cmd_flags);
|
||||
Tret res = std::apply(CommandTraits<Tcmd>::proc, std::tuple_cat(std::make_tuple(flags), args));
|
||||
|
||||
auto [exit_test, desync_log, send_net] = InternalExecuteValidateTestAndPrepExec(ExtractCommandCost(res), cmd_flags, estimate_only, network_command, cur_company);
|
||||
|
@ -395,7 +395,7 @@ protected:
|
|||
if (desync_log) LogCommandExecution(Tcmd, err_message, EndianBufferWriter<CommandDataBuffer>::FromValue(args), false);
|
||||
|
||||
/* Actually try and execute the command. */
|
||||
Tret res2 = std::apply(CommandTraits<Tcmd>::proc, std::tuple_cat(std::make_tuple(flags | DC_EXEC), args));
|
||||
Tret res2 = std::apply(CommandTraits<Tcmd>::proc, std::tuple_cat(std::make_tuple(flags | DoCommandFlag::Execute), args));
|
||||
|
||||
/* Convention: If the second result element is of type Money,
|
||||
* this is the additional cash required for the command. */
|
||||
|
@ -421,7 +421,7 @@ protected:
|
|||
* @tparam Targs The command parameter types.
|
||||
*/
|
||||
template <Commands Tcmd, typename Tret, typename... Targs>
|
||||
struct CommandHelper<Tcmd, Tret(*)(DoCommandFlag, Targs...), false> : CommandHelper<Tcmd, Tret(*)(DoCommandFlag, Targs...), true>
|
||||
struct CommandHelper<Tcmd, Tret(*)(DoCommandFlags, Targs...), false> : CommandHelper<Tcmd, Tret(*)(DoCommandFlags, Targs...), true>
|
||||
{
|
||||
/* Do not allow Post without explicit location. */
|
||||
static inline bool Post(StringID err_message, Targs... args) = delete;
|
||||
|
@ -464,7 +464,7 @@ struct CommandHelper<Tcmd, Tret(*)(DoCommandFlag, Targs...), false> : CommandHel
|
|||
template <typename Tcallback>
|
||||
static inline bool Post(StringID err_message, Tcallback *callback, TileIndex location, Targs... args)
|
||||
{
|
||||
return CommandHelper<Tcmd, Tret(*)(DoCommandFlag, Targs...), true>::InternalPost(err_message, callback, true, false, location, std::forward_as_tuple(args...));
|
||||
return CommandHelper<Tcmd, Tret(*)(DoCommandFlags, Targs...), true>::InternalPost(err_message, callback, true, false, location, std::forward_as_tuple(args...));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -371,22 +371,20 @@ enum Commands : uint8_t {
|
|||
*
|
||||
* This enums defines some flags which can be used for the commands.
|
||||
*/
|
||||
enum DoCommandFlag : uint16_t {
|
||||
DC_NONE = 0x000, ///< no flag is set
|
||||
DC_EXEC = 0x001, ///< execute the given command
|
||||
DC_AUTO = 0x002, ///< don't allow building on structures
|
||||
DC_QUERY_COST = 0x004, ///< query cost only, don't build.
|
||||
DC_NO_WATER = 0x008, ///< don't allow building on water
|
||||
// 0x010 is unused
|
||||
DC_NO_TEST_TOWN_RATING = 0x020, ///< town rating does not disallow you from building
|
||||
DC_BANKRUPT = 0x040, ///< company bankrupts, skip money check, skip vehicle on tile check in some cases
|
||||
DC_AUTOREPLACE = 0x080, ///< autoreplace/autorenew is in progress, this shall disable vehicle limits when building, and ignore certain restrictions when undoing things (like vehicle attach callback)
|
||||
DC_NO_CARGO_CAP_CHECK = 0x100, ///< when autoreplace/autorenew is in progress, this shall prevent truncating the amount of cargo in the vehicle to prevent testing the command to remove cargo
|
||||
DC_ALL_TILES = 0x200, ///< allow this command also on MP_VOID tiles
|
||||
DC_NO_MODIFY_TOWN_RATING = 0x400, ///< do not change town rating
|
||||
DC_FORCE_CLEAR_TILE = 0x800, ///< do not only remove the object on the tile, but also clear any water left on it
|
||||
enum DoCommandFlag : uint8_t {
|
||||
Execute, ///< execute the given command
|
||||
Auto, ///< don't allow building on structures
|
||||
QueryCost, ///< query cost only, don't build.
|
||||
NoWater, ///< don't allow building on water
|
||||
NoTestTownRating, ///< town rating does not disallow you from building
|
||||
Bankrupt, ///< company bankrupts, skip money check, skip vehicle on tile check in some cases
|
||||
AutoReplace, ///< autoreplace/autorenew is in progress, this shall disable vehicle limits when building, and ignore certain restrictions when undoing things (like vehicle attach callback)
|
||||
NoCargoCapacityCheck, ///< when autoreplace/autorenew is in progress, this shall prevent truncating the amount of cargo in the vehicle to prevent testing the command to remove cargo
|
||||
AllTiles, ///< allow this command also on MP_VOID tiles
|
||||
NoModifyTownRating, ///< do not change town rating
|
||||
ForceClearTile, ///< do not only remove the object on the tile, but also clear any water left on it
|
||||
};
|
||||
DECLARE_ENUM_AS_BIT_SET(DoCommandFlag)
|
||||
using DoCommandFlags = EnumBitSet<DoCommandFlag, uint16_t>;
|
||||
|
||||
/**
|
||||
* Command flags for the command table _command_proc_table.
|
||||
|
@ -397,10 +395,10 @@ enum CommandFlags : uint16_t {
|
|||
CMD_SERVER = 0x001, ///< the command can only be initiated by the server
|
||||
CMD_SPECTATOR = 0x002, ///< the command may be initiated by a spectator
|
||||
CMD_OFFLINE = 0x004, ///< the command cannot be executed in a multiplayer game; single-player only
|
||||
CMD_AUTO = 0x008, ///< set the DC_AUTO flag on this command
|
||||
CMD_AUTO = 0x008, ///< set the DoCommandFlag::Auto flag on this command
|
||||
CMD_ALL_TILES = 0x010, ///< allow this command also on MP_VOID tiles
|
||||
CMD_NO_TEST = 0x020, ///< the command's output may differ between test and execute due to town rating changes etc.
|
||||
CMD_NO_WATER = 0x040, ///< set the DC_NO_WATER flag on this command
|
||||
CMD_NO_WATER = 0x040, ///< set the DoCommandFlag::NoWater flag on this command
|
||||
CMD_CLIENT_ID = 0x080, ///< set p2 with the ClientID of the sending client.
|
||||
CMD_DEITY = 0x100, ///< the command may be executed by COMPANY_DEITY
|
||||
CMD_STR_CTRL = 0x200, ///< the command's string may contain control strings
|
||||
|
@ -435,14 +433,14 @@ enum CommandPauseLevel : uint8_t {
|
|||
|
||||
template <typename T> struct CommandFunctionTraitHelper;
|
||||
template <typename... Targs>
|
||||
struct CommandFunctionTraitHelper<CommandCost(*)(DoCommandFlag, Targs...)> {
|
||||
struct CommandFunctionTraitHelper<CommandCost(*)(DoCommandFlags, Targs...)> {
|
||||
using Args = std::tuple<std::decay_t<Targs>...>;
|
||||
using RetTypes = void;
|
||||
using CbArgs = Args;
|
||||
using CbProcType = void(*)(Commands, const CommandCost &);
|
||||
};
|
||||
template <template <typename...> typename Tret, typename... Tretargs, typename... Targs>
|
||||
struct CommandFunctionTraitHelper<Tret<CommandCost, Tretargs...>(*)(DoCommandFlag, Targs...)> {
|
||||
struct CommandFunctionTraitHelper<Tret<CommandCost, Tretargs...>(*)(DoCommandFlags, Targs...)> {
|
||||
using Args = std::tuple<std::decay_t<Targs>...>;
|
||||
using RetTypes = std::tuple<std::decay_t<Tretargs>...>;
|
||||
using CbArgs = std::tuple<std::decay_t<Tretargs>..., std::decay_t<Targs>...>;
|
||||
|
|
|
@ -863,7 +863,7 @@ void CompanyAdminRemove(CompanyID company_id, CompanyRemoveReason reason)
|
|||
* @param client_id ClientID
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID company_id, CompanyRemoveReason reason, ClientID client_id)
|
||||
CommandCost CmdCompanyCtrl(DoCommandFlags flags, CompanyCtrlAction cca, CompanyID company_id, CompanyRemoveReason reason, ClientID client_id)
|
||||
{
|
||||
InvalidateWindowData(WC_COMPANY_LEAGUE, 0, 0);
|
||||
|
||||
|
@ -873,7 +873,7 @@ CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID
|
|||
if (!_networking) return CMD_ERROR;
|
||||
|
||||
/* Has the network client a correct ClientID? */
|
||||
if (!(flags & DC_EXEC)) return CommandCost();
|
||||
if (!flags.Test(DoCommandFlag::Execute)) return CommandCost();
|
||||
|
||||
NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(client_id);
|
||||
|
||||
|
@ -924,7 +924,7 @@ CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID
|
|||
/* For network games, company deletion is delayed. */
|
||||
if (!_networking && company_id != INVALID_COMPANY && Company::IsValidID(company_id)) return CMD_ERROR;
|
||||
|
||||
if (!(flags & DC_EXEC)) return CommandCost();
|
||||
if (!flags.Test(DoCommandFlag::Execute)) return CommandCost();
|
||||
|
||||
/* For network game, just assume deletion happened. */
|
||||
assert(company_id == INVALID_COMPANY || !Company::IsValidID(company_id));
|
||||
|
@ -946,7 +946,7 @@ CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID
|
|||
Company *c = Company::GetIfValid(company_id);
|
||||
if (c == nullptr) return CMD_ERROR;
|
||||
|
||||
if (!(flags & DC_EXEC)) return CommandCost();
|
||||
if (!flags.Test(DoCommandFlag::Execute)) return CommandCost();
|
||||
|
||||
auto cni = std::make_unique<CompanyNewsInformation>(c);
|
||||
|
||||
|
@ -1003,7 +1003,7 @@ static bool ExecuteAllowListCtrlAction(CompanyAllowListCtrlAction action, Compan
|
|||
* @param public_key The public key of the client to add or remove.
|
||||
* @return The cost of this operation or an error.
|
||||
*/
|
||||
CommandCost CmdCompanyAllowListCtrl(DoCommandFlag flags, CompanyAllowListCtrlAction action, const std::string &public_key)
|
||||
CommandCost CmdCompanyAllowListCtrl(DoCommandFlags flags, CompanyAllowListCtrlAction action, const std::string &public_key)
|
||||
{
|
||||
Company *c = Company::GetIfValid(_current_company);
|
||||
if (c == nullptr) return CMD_ERROR;
|
||||
|
@ -1020,7 +1020,7 @@ CommandCost CmdCompanyAllowListCtrl(DoCommandFlag flags, CompanyAllowListCtrlAct
|
|||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (ExecuteAllowListCtrlAction(action, c, public_key)) {
|
||||
InvalidateWindowData(WC_CLIENT_LIST, 0);
|
||||
SetWindowDirty(WC_COMPANY, _current_company);
|
||||
|
@ -1036,11 +1036,11 @@ CommandCost CmdCompanyAllowListCtrl(DoCommandFlag flags, CompanyAllowListCtrlAct
|
|||
* @param cmf face bitmasked
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetCompanyManagerFace(DoCommandFlag flags, CompanyManagerFace cmf)
|
||||
CommandCost CmdSetCompanyManagerFace(DoCommandFlags flags, CompanyManagerFace cmf)
|
||||
{
|
||||
if (!IsValidCompanyManagerFace(cmf)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Company::Get(_current_company)->face = cmf;
|
||||
MarkWholeScreenDirty();
|
||||
}
|
||||
|
@ -1069,7 +1069,7 @@ void UpdateCompanyLiveries(Company *c)
|
|||
* @param colour new colour for vehicles, property, etc.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetCompanyColour(DoCommandFlag flags, LiveryScheme scheme, bool primary, Colours colour)
|
||||
CommandCost CmdSetCompanyColour(DoCommandFlags flags, LiveryScheme scheme, bool primary, Colours colour)
|
||||
{
|
||||
if (scheme >= LS_END || (colour >= COLOUR_END && colour != INVALID_COLOUR)) return CMD_ERROR;
|
||||
|
||||
|
@ -1085,7 +1085,7 @@ CommandCost CmdSetCompanyColour(DoCommandFlag flags, LiveryScheme scheme, bool p
|
|||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (primary) {
|
||||
if (scheme != LS_DEFAULT) AssignBit(c->livery[scheme].in_use, 0, colour != INVALID_COLOUR);
|
||||
if (colour == INVALID_COLOUR) colour = c->livery[LS_DEFAULT].colour1;
|
||||
|
@ -1168,7 +1168,7 @@ static bool IsUniqueCompanyName(const std::string &name)
|
|||
* @param text the new name or an empty string when resetting to the default
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRenameCompany(DoCommandFlag flags, const std::string &text)
|
||||
CommandCost CmdRenameCompany(DoCommandFlags flags, const std::string &text)
|
||||
{
|
||||
bool reset = text.empty();
|
||||
|
||||
|
@ -1177,7 +1177,7 @@ CommandCost CmdRenameCompany(DoCommandFlag flags, const std::string &text)
|
|||
if (!IsUniqueCompanyName(text)) return CommandCost(STR_ERROR_NAME_MUST_BE_UNIQUE);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Company *c = Company::Get(_current_company);
|
||||
if (reset) {
|
||||
c->name.clear();
|
||||
|
@ -1216,7 +1216,7 @@ static bool IsUniquePresidentName(const std::string &name)
|
|||
* @param text the new name or an empty string when resetting to the default
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRenamePresident(DoCommandFlag flags, const std::string &text)
|
||||
CommandCost CmdRenamePresident(DoCommandFlags flags, const std::string &text)
|
||||
{
|
||||
bool reset = text.empty();
|
||||
|
||||
|
@ -1225,7 +1225,7 @@ CommandCost CmdRenamePresident(DoCommandFlag flags, const std::string &text)
|
|||
if (!IsUniquePresidentName(text)) return CommandCost(STR_ERROR_NAME_MUST_BE_UNIQUE);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Company *c = Company::Get(_current_company);
|
||||
|
||||
if (reset) {
|
||||
|
@ -1234,7 +1234,7 @@ CommandCost CmdRenamePresident(DoCommandFlag flags, const std::string &text)
|
|||
c->president_name = text;
|
||||
|
||||
if (c->name_1 == STR_SV_UNNAMED && c->name.empty()) {
|
||||
Command<CMD_RENAME_COMPANY>::Do(DC_EXEC, text + " Transport");
|
||||
Command<CMD_RENAME_COMPANY>::Do(DoCommandFlag::Execute, text + " Transport");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1305,7 +1305,7 @@ uint32_t CompanyInfrastructure::GetTramTotal() const
|
|||
* @param dest_company the company to transfer the money to
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdGiveMoney(DoCommandFlag flags, Money money, CompanyID dest_company)
|
||||
CommandCost CmdGiveMoney(DoCommandFlags flags, Money money, CompanyID dest_company)
|
||||
{
|
||||
if (!_settings_game.economy.give_money) return CMD_ERROR;
|
||||
|
||||
|
@ -1316,7 +1316,7 @@ CommandCost CmdGiveMoney(DoCommandFlag flags, Money money, CompanyID dest_compan
|
|||
if (c->money - c->current_loan < amount.GetCost() || amount.GetCost() < 0) return CommandCost(STR_ERROR_INSUFFICIENT_FUNDS);
|
||||
if (!Company::IsValidID(dest_company)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Add money to company */
|
||||
Backup<CompanyID> cur_company(_current_company, dest_company);
|
||||
SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, -amount.GetCost()));
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
enum ClientID : uint32_t;
|
||||
enum Colours : uint8_t;
|
||||
|
||||
CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID company_id, CompanyRemoveReason reason, ClientID client_id);
|
||||
CommandCost CmdCompanyAllowListCtrl(DoCommandFlag flags, CompanyAllowListCtrlAction action, const std::string &public_key);
|
||||
CommandCost CmdGiveMoney(DoCommandFlag flags, Money money, CompanyID dest_company);
|
||||
CommandCost CmdRenameCompany(DoCommandFlag flags, const std::string &text);
|
||||
CommandCost CmdRenamePresident(DoCommandFlag flags, const std::string &text);
|
||||
CommandCost CmdSetCompanyManagerFace(DoCommandFlag flags, CompanyManagerFace cmf);
|
||||
CommandCost CmdSetCompanyColour(DoCommandFlag flags, LiveryScheme scheme, bool primary, Colours colour);
|
||||
CommandCost CmdCompanyCtrl(DoCommandFlags flags, CompanyCtrlAction cca, CompanyID company_id, CompanyRemoveReason reason, ClientID client_id);
|
||||
CommandCost CmdCompanyAllowListCtrl(DoCommandFlags flags, CompanyAllowListCtrlAction action, const std::string &public_key);
|
||||
CommandCost CmdGiveMoney(DoCommandFlags flags, Money money, CompanyID dest_company);
|
||||
CommandCost CmdRenameCompany(DoCommandFlags flags, const std::string &text);
|
||||
CommandCost CmdRenamePresident(DoCommandFlags flags, const std::string &text);
|
||||
CommandCost CmdSetCompanyManagerFace(DoCommandFlags flags, CompanyManagerFace cmf);
|
||||
CommandCost CmdSetCompanyColour(DoCommandFlags flags, LiveryScheme scheme, bool primary, Colours colour);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_COMPANY_CTRL, CmdCompanyCtrl, CMD_SPECTATOR | CMD_CLIENT_ID | CMD_NO_EST, CMDT_SERVER_SETTING)
|
||||
DEF_CMD_TRAIT(CMD_COMPANY_ALLOW_LIST_CTRL, CmdCompanyAllowListCtrl, CMD_NO_EST, CMDT_SERVER_SETTING)
|
||||
|
|
|
@ -43,7 +43,7 @@ static bool IsUniqueDepotName(const std::string &name)
|
|||
* @param text the new name or an empty string when resetting to the default
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRenameDepot(DoCommandFlag flags, DepotID depot_id, const std::string &text)
|
||||
CommandCost CmdRenameDepot(DoCommandFlags flags, DepotID depot_id, const std::string &text)
|
||||
{
|
||||
Depot *d = Depot::GetIfValid(depot_id);
|
||||
if (d == nullptr) return CMD_ERROR;
|
||||
|
@ -58,7 +58,7 @@ CommandCost CmdRenameDepot(DoCommandFlag flags, DepotID depot_id, const std::str
|
|||
if (!IsUniqueDepotName(text)) return CommandCost(STR_ERROR_NAME_MUST_BE_UNIQUE);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (reset) {
|
||||
d->name.clear();
|
||||
MakeDefaultName(d);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "command_type.h"
|
||||
#include "depot_type.h"
|
||||
|
||||
CommandCost CmdRenameDepot(DoCommandFlag flags, DepotID depot_id, const std::string &text);
|
||||
CommandCost CmdRenameDepot(DoCommandFlags flags, DepotID depot_id, const std::string &text);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_RENAME_DEPOT, CmdRenameDepot, 0, CMDT_OTHER_MANAGEMENT)
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ static void DisasterClearSquare(TileIndex tile)
|
|||
case MP_RAILWAY:
|
||||
if (Company::IsHumanID(GetTileOwner(tile)) && !IsRailDepot(tile)) {
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_WATER);
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC, tile);
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DoCommandFlag::Execute, tile);
|
||||
cur_company.Restore();
|
||||
|
||||
/* update signals in buffer */
|
||||
|
@ -74,7 +74,7 @@ static void DisasterClearSquare(TileIndex tile)
|
|||
|
||||
case MP_HOUSE: {
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE);
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC, tile);
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DoCommandFlag::Execute, tile);
|
||||
cur_company.Restore();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -461,7 +461,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
|
|||
* However, do not rely on that behaviour.
|
||||
*/
|
||||
int interval = CompanyServiceInterval(new_company, v->type);
|
||||
Command<CMD_CHANGE_SERVICE_INT>::Do(DC_EXEC | DC_BANKRUPT, v->index, interval, false, new_company->settings.vehicle.servint_ispercent);
|
||||
Command<CMD_CHANGE_SERVICE_INT>::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, v->index, interval, false, new_company->settings.vehicle.servint_ispercent);
|
||||
}
|
||||
|
||||
v->owner = new_owner;
|
||||
|
@ -1513,7 +1513,7 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
|
|||
if (st->goods[cargo_type].HasData() && st->goods[cargo_type].GetData().cargo.HasCargoFor(next_station)) {
|
||||
/* Try to find out if auto-refitting would succeed. In case the refit is allowed,
|
||||
* the returned refit capacity will be greater than zero. */
|
||||
auto [cc, refit_capacity, mail_capacity, cargo_capacities] = Command<CMD_REFIT_VEHICLE>::Do(DC_QUERY_COST, v_start->index, cargo_type, 0xFF, true, false, 1); // Auto-refit and only this vehicle including artic parts.
|
||||
auto [cc, refit_capacity, mail_capacity, cargo_capacities] = Command<CMD_REFIT_VEHICLE>::Do(DoCommandFlag::QueryCost, v_start->index, cargo_type, 0xFF, true, false, 1); // Auto-refit and only this vehicle including artic parts.
|
||||
/* Try to balance different loadable cargoes between parts of the consist, so that
|
||||
* all of them can be loaded. Avoid a situation where all vehicles suddenly switch
|
||||
* to the first loadable cargo for which there is only one packet. If the capacities
|
||||
|
@ -1536,7 +1536,7 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
|
|||
* "via any station" before reserving. We rather produce some more "any station" cargo than
|
||||
* misrouting it. */
|
||||
IterateVehicleParts(v_start, ReturnCargoAction(st, INVALID_STATION));
|
||||
CommandCost cost = std::get<0>(Command<CMD_REFIT_VEHICLE>::Do(DC_EXEC, v_start->index, new_cargo_type, 0xFF, true, false, 1)); // Auto-refit and only this vehicle including artic parts.
|
||||
CommandCost cost = std::get<0>(Command<CMD_REFIT_VEHICLE>::Do(DoCommandFlag::Execute, v_start->index, new_cargo_type, 0xFF, true, false, 1)); // Auto-refit and only this vehicle including artic parts.
|
||||
if (cost.Succeeded()) v->First()->profit_this_year -= cost.GetCost() << 8;
|
||||
}
|
||||
|
||||
|
@ -2041,7 +2041,7 @@ static void DoAcquireCompany(Company *c, bool hostile_takeover)
|
|||
* @param hostile_takeover whether to buy up the company even if it is not bankrupt
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuyCompany(DoCommandFlag flags, CompanyID target_company, bool hostile_takeover)
|
||||
CommandCost CmdBuyCompany(DoCommandFlags flags, CompanyID target_company, bool hostile_takeover)
|
||||
{
|
||||
Company *c = Company::GetIfValid(target_company);
|
||||
if (c == nullptr) return CMD_ERROR;
|
||||
|
@ -2070,7 +2070,7 @@ CommandCost CmdBuyCompany(DoCommandFlag flags, CompanyID target_company, bool ho
|
|||
* for hostile takeover you pay the current price. */
|
||||
CommandCost cost(EXPENSES_OTHER, hostile_takeover ? CalculateHostileTakeoverValue(c) : c->bankrupt_value);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
DoAcquireCompany(c, hostile_takeover);
|
||||
}
|
||||
return cost;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "command_type.h"
|
||||
#include "company_type.h"
|
||||
|
||||
CommandCost CmdBuyCompany(DoCommandFlag flags, CompanyID target_company, bool hostile_takeover);
|
||||
CommandCost CmdBuyCompany(DoCommandFlags flags, CompanyID target_company, bool hostile_takeover);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_BUY_COMPANY, CmdBuyCompany, 0, CMDT_MONEY_MANAGEMENT)
|
||||
|
||||
|
|
|
@ -1016,13 +1016,13 @@ void ClearEnginesHiddenFlagOfCompany(CompanyID cid)
|
|||
* @param hide Set for hidden, unset for visible.
|
||||
* @return The cost of this operation or an error.
|
||||
*/
|
||||
CommandCost CmdSetVehicleVisibility(DoCommandFlag flags, EngineID engine_id, bool hide)
|
||||
CommandCost CmdSetVehicleVisibility(DoCommandFlags flags, EngineID engine_id, bool hide)
|
||||
{
|
||||
Engine *e = Engine::GetIfValid(engine_id);
|
||||
if (e == nullptr || _current_company >= MAX_COMPANIES) return CMD_ERROR;
|
||||
if (!IsEngineBuildable(e->index, e->type, _current_company)) return CMD_ERROR;
|
||||
|
||||
if ((flags & DC_EXEC) != 0) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
e->company_hidden.Set(_current_company, hide);
|
||||
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
|
||||
}
|
||||
|
@ -1037,12 +1037,12 @@ CommandCost CmdSetVehicleVisibility(DoCommandFlag flags, EngineID engine_id, boo
|
|||
* @param engine_id engine-prototype offered
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdWantEnginePreview(DoCommandFlag flags, EngineID engine_id)
|
||||
CommandCost CmdWantEnginePreview(DoCommandFlags flags, EngineID engine_id)
|
||||
{
|
||||
Engine *e = Engine::GetIfValid(engine_id);
|
||||
if (e == nullptr || !e->flags.Test(EngineFlag::ExclusivePreview) || e->preview_company != _current_company) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) AcceptEnginePreview(engine_id, _current_company);
|
||||
if (flags.Test(DoCommandFlag::Execute)) AcceptEnginePreview(engine_id, _current_company);
|
||||
|
||||
return CommandCost();
|
||||
}
|
||||
|
@ -1055,13 +1055,13 @@ CommandCost CmdWantEnginePreview(DoCommandFlag flags, EngineID engine_id)
|
|||
* @param allow false to forbid, true to allow.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdEngineCtrl(DoCommandFlag flags, EngineID engine_id, CompanyID company_id, bool allow)
|
||||
CommandCost CmdEngineCtrl(DoCommandFlags flags, EngineID engine_id, CompanyID company_id, bool allow)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
|
||||
if (!Engine::IsValidID(engine_id) || !Company::IsValidID(company_id)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (allow) {
|
||||
EnableEngineForCompany(engine_id, company_id);
|
||||
} else {
|
||||
|
@ -1217,7 +1217,7 @@ static bool IsUniqueEngineName(const std::string &name)
|
|||
* @param text the new name or an empty string when resetting to the default
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRenameEngine(DoCommandFlag flags, EngineID engine_id, const std::string &text)
|
||||
CommandCost CmdRenameEngine(DoCommandFlags flags, EngineID engine_id, const std::string &text)
|
||||
{
|
||||
Engine *e = Engine::GetIfValid(engine_id);
|
||||
if (e == nullptr) return CMD_ERROR;
|
||||
|
@ -1229,7 +1229,7 @@ CommandCost CmdRenameEngine(DoCommandFlag flags, EngineID engine_id, const std::
|
|||
if (!IsUniqueEngineName(text)) return CommandCost(STR_ERROR_NAME_MUST_BE_UNIQUE);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (reset) {
|
||||
e->name.clear();
|
||||
} else {
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
|
||||
#include "command_type.h"
|
||||
|
||||
CommandCost CmdWantEnginePreview(DoCommandFlag flags, EngineID engine_id);
|
||||
CommandCost CmdEngineCtrl(DoCommandFlag flags, EngineID engine_id, CompanyID company_id, bool allow);
|
||||
CommandCost CmdRenameEngine(DoCommandFlag flags, EngineID engine_id, const std::string &text);
|
||||
CommandCost CmdSetVehicleVisibility(DoCommandFlag flags, EngineID engine_id, bool hide);
|
||||
CommandCost CmdWantEnginePreview(DoCommandFlags flags, EngineID engine_id);
|
||||
CommandCost CmdEngineCtrl(DoCommandFlags flags, EngineID engine_id, CompanyID company_id, bool allow);
|
||||
CommandCost CmdRenameEngine(DoCommandFlags flags, EngineID engine_id, const std::string &text);
|
||||
CommandCost CmdSetVehicleVisibility(DoCommandFlags flags, EngineID engine_id, bool hide);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_WANT_ENGINE_PREVIEW, CmdWantEnginePreview, 0, CMDT_VEHICLE_MANAGEMENT)
|
||||
DEF_CMD_TRAIT(CMD_ENGINE_CTRL, CmdEngineCtrl, CMD_DEITY, CMDT_VEHICLE_MANAGEMENT)
|
||||
|
|
|
@ -365,7 +365,7 @@ struct ExternalTownData {
|
|||
static bool TryFoundTownNearby(TileIndex tile, void *user_data)
|
||||
{
|
||||
ExternalTownData &town = *static_cast<ExternalTownData *>(user_data);
|
||||
std::tuple<CommandCost, Money, TownID> result = Command<CMD_FOUND_TOWN>::Do(DC_EXEC, tile, TSZ_SMALL, town.is_city, _settings_game.economy.town_layout, false, 0, town.name);
|
||||
std::tuple<CommandCost, Money, TownID> result = Command<CMD_FOUND_TOWN>::Do(DoCommandFlag::Execute, tile, TSZ_SMALL, town.is_city, _settings_game.economy.town_layout, false, 0, town.name);
|
||||
|
||||
TownID id = std::get<TownID>(result);
|
||||
|
||||
|
|
38
src/goal.cpp
38
src/goal.cpp
|
@ -75,7 +75,7 @@ INSTANTIATE_POOL_METHODS(Goal)
|
|||
* @param text Text of the goal.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
std::tuple<CommandCost, GoalID> CmdCreateGoal(DoCommandFlag flags, CompanyID company, GoalType type, GoalTypeID dest, const std::string &text)
|
||||
std::tuple<CommandCost, GoalID> CmdCreateGoal(DoCommandFlags flags, CompanyID company, GoalType type, GoalTypeID dest, const std::string &text)
|
||||
{
|
||||
if (!Goal::CanAllocateItem()) return { CMD_ERROR, INVALID_GOAL };
|
||||
|
||||
|
@ -84,7 +84,7 @@ std::tuple<CommandCost, GoalID> CmdCreateGoal(DoCommandFlag flags, CompanyID com
|
|||
if (company != INVALID_COMPANY && !Company::IsValidID(company)) return { CMD_ERROR, INVALID_GOAL };
|
||||
if (!Goal::IsValidGoalDestination(company, type, dest)) return { CMD_ERROR, INVALID_GOAL };
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Goal *g = new Goal();
|
||||
g->type = type;
|
||||
g->dst = dest;
|
||||
|
@ -111,12 +111,12 @@ std::tuple<CommandCost, GoalID> CmdCreateGoal(DoCommandFlag flags, CompanyID com
|
|||
* @param goal GoalID to remove.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRemoveGoal(DoCommandFlag flags, GoalID goal)
|
||||
CommandCost CmdRemoveGoal(DoCommandFlags flags, GoalID goal)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
if (!Goal::IsValidID(goal)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Goal *g = Goal::Get(goal);
|
||||
CompanyID c = g->company;
|
||||
delete g;
|
||||
|
@ -140,14 +140,14 @@ CommandCost CmdRemoveGoal(DoCommandFlag flags, GoalID goal)
|
|||
* @param dest GoalTypeID of destination.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetGoalDestination(DoCommandFlag flags, GoalID goal, GoalType type, GoalTypeID dest)
|
||||
CommandCost CmdSetGoalDestination(DoCommandFlags flags, GoalID goal, GoalType type, GoalTypeID dest)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
if (!Goal::IsValidID(goal)) return CMD_ERROR;
|
||||
Goal *g = Goal::Get(goal);
|
||||
if (!Goal::IsValidGoalDestination(g->company, type, dest)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
g->type = type;
|
||||
g->dst = dest;
|
||||
}
|
||||
|
@ -162,13 +162,13 @@ CommandCost CmdSetGoalDestination(DoCommandFlag flags, GoalID goal, GoalType typ
|
|||
* @param text Text of the goal.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetGoalText(DoCommandFlag flags, GoalID goal, const std::string &text)
|
||||
CommandCost CmdSetGoalText(DoCommandFlags flags, GoalID goal, const std::string &text)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
if (!Goal::IsValidID(goal)) return CMD_ERROR;
|
||||
if (text.empty()) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Goal *g = Goal::Get(goal);
|
||||
g->text = text;
|
||||
|
||||
|
@ -189,12 +189,12 @@ CommandCost CmdSetGoalText(DoCommandFlag flags, GoalID goal, const std::string &
|
|||
* @param text Progress text of the goal.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetGoalProgress(DoCommandFlag flags, GoalID goal, const std::string &text)
|
||||
CommandCost CmdSetGoalProgress(DoCommandFlags flags, GoalID goal, const std::string &text)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
if (!Goal::IsValidID(goal)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Goal *g = Goal::Get(goal);
|
||||
g->progress = text;
|
||||
|
||||
|
@ -215,12 +215,12 @@ CommandCost CmdSetGoalProgress(DoCommandFlag flags, GoalID goal, const std::stri
|
|||
* @param completed completed state of goal.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetGoalCompleted(DoCommandFlag flags, GoalID goal, bool completed)
|
||||
CommandCost CmdSetGoalCompleted(DoCommandFlags flags, GoalID goal, bool completed)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
if (!Goal::IsValidID(goal)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Goal *g = Goal::Get(goal);
|
||||
g->completed = completed;
|
||||
|
||||
|
@ -245,7 +245,7 @@ CommandCost CmdSetGoalCompleted(DoCommandFlag flags, GoalID goal, bool completed
|
|||
* @param text Text of the question.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdGoalQuestion(DoCommandFlag flags, uint16_t uniqueid, uint32_t target, bool is_client, uint32_t button_mask, GoalQuestionType type, const std::string &text)
|
||||
CommandCost CmdGoalQuestion(DoCommandFlags flags, uint16_t uniqueid, uint32_t target, bool is_client, uint32_t button_mask, GoalQuestionType type, const std::string &text)
|
||||
{
|
||||
static_assert(sizeof(uint32_t) >= sizeof(CompanyID));
|
||||
CompanyID company = (CompanyID)target;
|
||||
|
@ -261,7 +261,7 @@ CommandCost CmdGoalQuestion(DoCommandFlag flags, uint16_t uniqueid, uint32_t tar
|
|||
/* Only check during pre-flight; the client might have left between
|
||||
* testing and executing. In that case it is fine to just ignore the
|
||||
* fact the client is no longer here. */
|
||||
if (!(flags & DC_EXEC) && _network_server && NetworkClientInfo::GetByClientID(client) == nullptr) return CMD_ERROR;
|
||||
if (!flags.Test(DoCommandFlag::Execute) && _network_server && NetworkClientInfo::GetByClientID(client) == nullptr) return CMD_ERROR;
|
||||
} else {
|
||||
if (company != INVALID_COMPANY && !Company::IsValidID(company)) return CMD_ERROR;
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ CommandCost CmdGoalQuestion(DoCommandFlag flags, uint16_t uniqueid, uint32_t tar
|
|||
if (CountBits(button_mask) < min_buttons || CountBits(button_mask) > 3) return CMD_ERROR;
|
||||
if (type >= GQT_END) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (is_client) {
|
||||
if (client != _network_own_client_id) return CommandCost();
|
||||
} else {
|
||||
|
@ -289,23 +289,23 @@ CommandCost CmdGoalQuestion(DoCommandFlag flags, uint16_t uniqueid, uint32_t tar
|
|||
* @param button Button the company pressed
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdGoalQuestionAnswer(DoCommandFlag flags, uint16_t uniqueid, uint8_t button)
|
||||
CommandCost CmdGoalQuestionAnswer(DoCommandFlags flags, uint16_t uniqueid, uint8_t button)
|
||||
{
|
||||
if (button >= GOAL_QUESTION_BUTTON_COUNT) return CMD_ERROR;
|
||||
|
||||
if (_current_company == OWNER_DEITY) {
|
||||
/* It has been requested to close this specific question on all clients */
|
||||
if (flags & DC_EXEC) CloseWindowById(WC_GOAL_QUESTION, uniqueid);
|
||||
if (flags.Test(DoCommandFlag::Execute)) CloseWindowById(WC_GOAL_QUESTION, uniqueid);
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
if (_networking && _local_company == _current_company) {
|
||||
/* Somebody in the same company answered the question. Close the window */
|
||||
if (flags & DC_EXEC) CloseWindowById(WC_GOAL_QUESTION, uniqueid);
|
||||
if (flags.Test(DoCommandFlag::Execute)) CloseWindowById(WC_GOAL_QUESTION, uniqueid);
|
||||
if (!_network_server) return CommandCost();
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Game::NewEvent(new ScriptEventGoalQuestionAnswer(uniqueid, _current_company, (ScriptGoal::QuestionButton)(1 << button)));
|
||||
}
|
||||
|
||||
|
|
|
@ -13,14 +13,14 @@
|
|||
#include "command_type.h"
|
||||
#include "goal_type.h"
|
||||
|
||||
std::tuple<CommandCost, GoalID> CmdCreateGoal(DoCommandFlag flags, CompanyID company, GoalType type, GoalTypeID dest, const std::string &text);
|
||||
CommandCost CmdRemoveGoal(DoCommandFlag flags, GoalID goal);
|
||||
CommandCost CmdSetGoalDestination(DoCommandFlag flags, GoalID goal, GoalType type, GoalTypeID dest);
|
||||
CommandCost CmdSetGoalText(DoCommandFlag flags, GoalID goal, const std::string &text);
|
||||
CommandCost CmdSetGoalProgress(DoCommandFlag flags, GoalID goal, const std::string &text);
|
||||
CommandCost CmdSetGoalCompleted(DoCommandFlag flags, GoalID goal, bool completed);
|
||||
CommandCost CmdGoalQuestion(DoCommandFlag flags, uint16_t uniqueid, uint32_t target, bool is_client, uint32_t button_mask, GoalQuestionType type, const std::string &text);
|
||||
CommandCost CmdGoalQuestionAnswer(DoCommandFlag flags, uint16_t uniqueid, uint8_t button);
|
||||
std::tuple<CommandCost, GoalID> CmdCreateGoal(DoCommandFlags flags, CompanyID company, GoalType type, GoalTypeID dest, const std::string &text);
|
||||
CommandCost CmdRemoveGoal(DoCommandFlags flags, GoalID goal);
|
||||
CommandCost CmdSetGoalDestination(DoCommandFlags flags, GoalID goal, GoalType type, GoalTypeID dest);
|
||||
CommandCost CmdSetGoalText(DoCommandFlags flags, GoalID goal, const std::string &text);
|
||||
CommandCost CmdSetGoalProgress(DoCommandFlags flags, GoalID goal, const std::string &text);
|
||||
CommandCost CmdSetGoalCompleted(DoCommandFlags flags, GoalID goal, bool completed);
|
||||
CommandCost CmdGoalQuestion(DoCommandFlags flags, uint16_t uniqueid, uint32_t target, bool is_client, uint32_t button_mask, GoalQuestionType type, const std::string &text);
|
||||
CommandCost CmdGoalQuestionAnswer(DoCommandFlags flags, uint16_t uniqueid, uint8_t button);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_CREATE_GOAL, CmdCreateGoal, CMD_DEITY | CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT)
|
||||
DEF_CMD_TRAIT(CMD_REMOVE_GOAL, CmdRemoveGoal, CMD_DEITY, CMDT_OTHER_MANAGEMENT)
|
||||
|
|
|
@ -333,7 +333,7 @@ Group::Group(Owner owner)
|
|||
* @param parent_group parent groupid
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
std::tuple<CommandCost, GroupID> CmdCreateGroup(DoCommandFlag flags, VehicleType vt, GroupID parent_group)
|
||||
std::tuple<CommandCost, GroupID> CmdCreateGroup(DoCommandFlags flags, VehicleType vt, GroupID parent_group)
|
||||
{
|
||||
if (!IsCompanyBuildableVehicleType(vt)) return { CMD_ERROR, INVALID_GROUP };
|
||||
|
||||
|
@ -345,7 +345,7 @@ std::tuple<CommandCost, GroupID> CmdCreateGroup(DoCommandFlag flags, VehicleType
|
|||
if (pg->vehicle_type != vt) return { CMD_ERROR, INVALID_GROUP };
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Group *g = new Group(_current_company);
|
||||
g->vehicle_type = vt;
|
||||
g->parent = INVALID_GROUP;
|
||||
|
@ -379,7 +379,7 @@ std::tuple<CommandCost, GroupID> CmdCreateGroup(DoCommandFlag flags, VehicleType
|
|||
* @param group_id index of group
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdDeleteGroup(DoCommandFlag flags, GroupID group_id)
|
||||
CommandCost CmdDeleteGroup(DoCommandFlags flags, GroupID group_id)
|
||||
{
|
||||
Group *g = Group::GetIfValid(group_id);
|
||||
if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
|
||||
|
@ -394,7 +394,7 @@ CommandCost CmdDeleteGroup(DoCommandFlag flags, GroupID group_id)
|
|||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Update backupped orders if needed */
|
||||
OrderBackup::ClearGroup(g->index);
|
||||
|
||||
|
@ -431,7 +431,7 @@ CommandCost CmdDeleteGroup(DoCommandFlag flags, GroupID group_id)
|
|||
* @param text the new name or an empty string when resetting to the default
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdAlterGroup(DoCommandFlag flags, AlterGroupMode mode, GroupID group_id, GroupID parent_id, const std::string &text)
|
||||
CommandCost CmdAlterGroup(DoCommandFlags flags, AlterGroupMode mode, GroupID group_id, GroupID parent_id, const std::string &text)
|
||||
{
|
||||
Group *g = Group::GetIfValid(group_id);
|
||||
if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
|
||||
|
@ -444,7 +444,7 @@ CommandCost CmdAlterGroup(DoCommandFlag flags, AlterGroupMode mode, GroupID grou
|
|||
if (Utf8StringLength(text) >= MAX_LENGTH_GROUP_NAME_CHARS) return CMD_ERROR;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Assign the new one */
|
||||
if (reset) {
|
||||
g->name.clear();
|
||||
|
@ -465,7 +465,7 @@ CommandCost CmdAlterGroup(DoCommandFlag flags, AlterGroupMode mode, GroupID grou
|
|||
if (GroupIsInGroup(pg->index, g->index)) return CommandCost(STR_ERROR_GROUP_CAN_T_SET_PARENT_RECURSION);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
g->parent = (pg == nullptr) ? INVALID_GROUP : pg->index;
|
||||
GroupStatistics::UpdateAutoreplace(g->owner);
|
||||
|
||||
|
@ -483,7 +483,7 @@ CommandCost CmdAlterGroup(DoCommandFlag flags, AlterGroupMode mode, GroupID grou
|
|||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
InvalidateWindowData(WC_REPLACE_VEHICLE, g->vehicle_type, 1);
|
||||
InvalidateWindowData(GetWindowClassForVehicleType(g->vehicle_type), VehicleListIdentifier(VL_GROUP_LIST, g->vehicle_type, _current_company).ToWindowNumber());
|
||||
InvalidateWindowData(WC_COMPANY_COLOUR, g->owner, g->vehicle_type);
|
||||
|
@ -534,7 +534,7 @@ static void AddVehicleToGroup(Vehicle *v, GroupID new_g)
|
|||
* @param add_shared Add shared vehicles as well.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
std::tuple<CommandCost, GroupID> CmdAddVehicleGroup(DoCommandFlag flags, GroupID group_id, VehicleID veh_id, bool add_shared, const VehicleListIdentifier &vli)
|
||||
std::tuple<CommandCost, GroupID> CmdAddVehicleGroup(DoCommandFlags flags, GroupID group_id, VehicleID veh_id, bool add_shared, const VehicleListIdentifier &vli)
|
||||
{
|
||||
GroupID new_g = group_id;
|
||||
if (!Group::IsValidID(new_g) && !IsDefaultGroupID(new_g) && new_g != NEW_GROUP) return { CMD_ERROR, INVALID_GROUP };
|
||||
|
@ -566,7 +566,7 @@ std::tuple<CommandCost, GroupID> CmdAddVehicleGroup(DoCommandFlag flags, GroupID
|
|||
new_g = new_group_id;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
for (const Vehicle *vc : list) {
|
||||
/* VehicleList is const but we need to modify the vehicle. */
|
||||
Vehicle *v = Vehicle::Get(vc->index);
|
||||
|
@ -603,11 +603,11 @@ std::tuple<CommandCost, GroupID> CmdAddVehicleGroup(DoCommandFlag flags, GroupID
|
|||
* @param type type of vehicles
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdAddSharedVehicleGroup(DoCommandFlag flags, GroupID id_g, VehicleType type)
|
||||
CommandCost CmdAddSharedVehicleGroup(DoCommandFlags flags, GroupID id_g, VehicleType type)
|
||||
{
|
||||
if (!Group::IsValidID(id_g) || !IsCompanyBuildableVehicleType(type)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Find the first front engine which belong to the group id_g
|
||||
* then add all shared vehicles of this front engine to the group id_g */
|
||||
for (const Vehicle *v : Vehicle::Iterate()) {
|
||||
|
@ -634,13 +634,13 @@ CommandCost CmdAddSharedVehicleGroup(DoCommandFlag flags, GroupID id_g, VehicleT
|
|||
* @param group_id index of group
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRemoveAllVehiclesGroup(DoCommandFlag flags, GroupID group_id)
|
||||
CommandCost CmdRemoveAllVehiclesGroup(DoCommandFlags flags, GroupID group_id)
|
||||
{
|
||||
Group *g = Group::GetIfValid(group_id);
|
||||
|
||||
if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Find each Vehicle that belongs to the group old_g and add it to the default group */
|
||||
for (const Vehicle *v : Vehicle::Iterate()) {
|
||||
if (v->IsPrimaryVehicle()) {
|
||||
|
@ -664,7 +664,7 @@ CommandCost CmdRemoveAllVehiclesGroup(DoCommandFlag flags, GroupID group_id)
|
|||
* @param primary Set primary instead of secondary colour
|
||||
* @param colour Colour.
|
||||
*/
|
||||
CommandCost CmdSetGroupLivery(DoCommandFlag flags, GroupID group_id, bool primary, Colours colour)
|
||||
CommandCost CmdSetGroupLivery(DoCommandFlags flags, GroupID group_id, bool primary, Colours colour)
|
||||
{
|
||||
Group *g = Group::GetIfValid(group_id);
|
||||
|
||||
|
@ -672,7 +672,7 @@ CommandCost CmdSetGroupLivery(DoCommandFlag flags, GroupID group_id, bool primar
|
|||
|
||||
if (colour >= COLOUR_END && colour != INVALID_COLOUR) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (primary) {
|
||||
AssignBit(g->livery.in_use, 0, colour != INVALID_COLOUR);
|
||||
if (colour == INVALID_COLOUR) colour = GetParentLivery(g)->colour1;
|
||||
|
@ -719,14 +719,14 @@ static void SetGroupFlag(Group *g, GroupFlag flag, bool set, bool children)
|
|||
* @param recursive to apply to sub-groups.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetGroupFlag(DoCommandFlag flags, GroupID group_id, GroupFlag flag, bool value, bool recursive)
|
||||
CommandCost CmdSetGroupFlag(DoCommandFlags flags, GroupID group_id, GroupFlag flag, bool value, bool recursive)
|
||||
{
|
||||
Group *g = Group::GetIfValid(group_id);
|
||||
if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
|
||||
|
||||
if (flag != GroupFlag::ReplaceProtection && flag != GroupFlag::ReplaceWagonRemoval) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
SetGroupFlag(g, flag, value, recursive);
|
||||
|
||||
SetWindowDirty(GetWindowClassForVehicleType(g->vehicle_type), VehicleListIdentifier(VL_GROUP_LIST, g->vehicle_type, _current_company).ToWindowNumber());
|
||||
|
|
|
@ -25,14 +25,14 @@ enum class AlterGroupMode : uint8_t {
|
|||
SetParent, ///< Change group parent.
|
||||
};
|
||||
|
||||
std::tuple<CommandCost, GroupID> CmdCreateGroup(DoCommandFlag flags, VehicleType vt, GroupID parent_group);
|
||||
CommandCost CmdAlterGroup(DoCommandFlag flags, AlterGroupMode mode, GroupID group_id, GroupID parent_id, const std::string &text);
|
||||
CommandCost CmdDeleteGroup(DoCommandFlag flags, GroupID group_id);
|
||||
std::tuple<CommandCost, GroupID> CmdAddVehicleGroup(DoCommandFlag flags, GroupID group_id, VehicleID veh_id, bool add_shared, const VehicleListIdentifier &vli);
|
||||
CommandCost CmdAddSharedVehicleGroup(DoCommandFlag flags, GroupID id_g, VehicleType type);
|
||||
CommandCost CmdRemoveAllVehiclesGroup(DoCommandFlag flags, GroupID group_id);
|
||||
CommandCost CmdSetGroupFlag(DoCommandFlag flags, GroupID group_id, GroupFlag flag, bool value, bool recursive);
|
||||
CommandCost CmdSetGroupLivery(DoCommandFlag flags, GroupID group_id, bool primary, Colours colour);
|
||||
std::tuple<CommandCost, GroupID> CmdCreateGroup(DoCommandFlags flags, VehicleType vt, GroupID parent_group);
|
||||
CommandCost CmdAlterGroup(DoCommandFlags flags, AlterGroupMode mode, GroupID group_id, GroupID parent_id, const std::string &text);
|
||||
CommandCost CmdDeleteGroup(DoCommandFlags flags, GroupID group_id);
|
||||
std::tuple<CommandCost, GroupID> CmdAddVehicleGroup(DoCommandFlags flags, GroupID group_id, VehicleID veh_id, bool add_shared, const VehicleListIdentifier &vli);
|
||||
CommandCost CmdAddSharedVehicleGroup(DoCommandFlags flags, GroupID id_g, VehicleType type);
|
||||
CommandCost CmdRemoveAllVehiclesGroup(DoCommandFlags flags, GroupID group_id);
|
||||
CommandCost CmdSetGroupFlag(DoCommandFlags flags, GroupID group_id, GroupFlag flag, bool value, bool recursive);
|
||||
CommandCost CmdSetGroupLivery(DoCommandFlags flags, GroupID group_id, bool primary, Colours colour);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_CREATE_GROUP, CmdCreateGroup, 0, CMDT_ROUTE_MANAGEMENT)
|
||||
DEF_CMD_TRAIT(CMD_DELETE_GROUP, CmdDeleteGroup, 0, CMDT_ROUTE_MANAGEMENT)
|
||||
|
|
|
@ -489,7 +489,7 @@ static void GetTileDesc_Industry(TileIndex tile, TileDesc *td)
|
|||
}
|
||||
}
|
||||
|
||||
static CommandCost ClearTile_Industry(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost ClearTile_Industry(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
Industry *i = Industry::GetByTile(tile);
|
||||
const IndustrySpec *indspec = GetIndustrySpec(i->type);
|
||||
|
@ -501,15 +501,15 @@ static CommandCost ClearTile_Industry(TileIndex tile, DoCommandFlag flags)
|
|||
*/
|
||||
if ((_current_company != OWNER_WATER && _game_mode != GM_EDITOR &&
|
||||
!_cheats.magic_bulldozer.value) ||
|
||||
((flags & DC_AUTO) != 0) ||
|
||||
flags.Test(DoCommandFlag::Auto) ||
|
||||
(_current_company == OWNER_WATER &&
|
||||
(indspec->behaviour.Test(IndustryBehaviour::BuiltOnWater) ||
|
||||
HasBit(GetIndustryTileSpec(GetIndustryGfx(tile))->slopes_refused, 5)))) {
|
||||
SetDParam(1, indspec->name);
|
||||
return CommandCost(flags & DC_AUTO ? STR_ERROR_GENERIC_OBJECT_IN_THE_WAY : INVALID_STRING_ID);
|
||||
return CommandCost(flags.Test(DoCommandFlag::Auto) ? STR_ERROR_GENERIC_OBJECT_IN_THE_WAY : INVALID_STRING_ID);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
AI::BroadcastNewEvent(new ScriptEventIndustryClose(i->index));
|
||||
Game::NewEvent(new ScriptEventIndustryClose(i->index));
|
||||
delete i;
|
||||
|
@ -1115,7 +1115,7 @@ static bool SearchLumberMillTrees(TileIndex tile, void *)
|
|||
_industry_sound_tile = tile;
|
||||
if (_settings_client.sound.ambient) SndPlayTileFx(SND_38_LUMBER_MILL_1, tile);
|
||||
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC, tile);
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DoCommandFlag::Execute, tile);
|
||||
|
||||
cur_company.Restore();
|
||||
return true;
|
||||
|
@ -1506,13 +1506,13 @@ static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTil
|
|||
|
||||
/* Clear the tiles as OWNER_TOWN to not affect town rating, and to not clear protected buildings */
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN);
|
||||
ret = Command<CMD_LANDSCAPE_CLEAR>::Do(DC_NONE, cur_tile);
|
||||
ret = Command<CMD_LANDSCAPE_CLEAR>::Do({}, cur_tile);
|
||||
cur_company.Restore();
|
||||
|
||||
if (ret.Failed()) return ret;
|
||||
} else {
|
||||
/* Clear the tiles, but do not affect town ratings */
|
||||
ret = Command<CMD_LANDSCAPE_CLEAR>::Do(DC_AUTO | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, cur_tile);
|
||||
ret = Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Auto, DoCommandFlag::NoTestTownRating, DoCommandFlag::NoModifyTownRating}, cur_tile);
|
||||
if (ret.Failed()) return ret;
|
||||
}
|
||||
}
|
||||
|
@ -1619,7 +1619,7 @@ static bool CheckCanTerraformSurroundingTiles(TileIndex tile, uint height, int i
|
|||
* This function tries to flatten out the land below an industry, without
|
||||
* damaging the surroundings too much.
|
||||
*/
|
||||
static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlag flags, const IndustryTileLayout &layout)
|
||||
static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlags flags, const IndustryTileLayout &layout)
|
||||
{
|
||||
int max_x = 0;
|
||||
int max_y = 0;
|
||||
|
@ -1660,14 +1660,14 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlag flags,
|
|||
}
|
||||
/* This is not 100% correct check, but the best we can do without modifying the map.
|
||||
* What is missing, is if the difference in height is more than 1.. */
|
||||
if (std::get<0>(Command<CMD_TERRAFORM_LAND>::Do(flags & ~DC_EXEC, tile_walk, SLOPE_N, curh <= h)).Failed()) {
|
||||
if (std::get<0>(Command<CMD_TERRAFORM_LAND>::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), tile_walk, SLOPE_N, curh <= h)).Failed()) {
|
||||
cur_company.Restore();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Terraform the land under the industry */
|
||||
for (TileIndex tile_walk : ta) {
|
||||
uint curh = TileHeight(tile_walk);
|
||||
|
@ -1941,7 +1941,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
|
|||
|
||||
WaterClass wc = (IsWaterTile(cur_tile) ? GetWaterClass(cur_tile) : WATER_CLASS_INVALID);
|
||||
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, cur_tile);
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Execute, DoCommandFlag::NoTestTownRating, DoCommandFlag::NoModifyTownRating}, cur_tile);
|
||||
|
||||
MakeIndustry(cur_tile, i->index, it.gfx, Random(), wc);
|
||||
|
||||
|
@ -1982,7 +1982,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
|
|||
*
|
||||
* @post \c *ip contains the newly created industry if all checks are successful and the \a flags request actual creation, else it contains \c nullptr afterwards.
|
||||
*/
|
||||
static CommandCost CreateNewIndustryHelper(TileIndex tile, IndustryType type, DoCommandFlag flags, const IndustrySpec *indspec, size_t layout_index, uint32_t random_var8f, uint16_t random_initial_bits, Owner founder, IndustryAvailabilityCallType creation_type, Industry **ip)
|
||||
static CommandCost CreateNewIndustryHelper(TileIndex tile, IndustryType type, DoCommandFlags flags, const IndustrySpec *indspec, size_t layout_index, uint32_t random_var8f, uint16_t random_initial_bits, Owner founder, IndustryAvailabilityCallType creation_type, Industry **ip)
|
||||
{
|
||||
assert(layout_index < indspec->layouts.size());
|
||||
const IndustryTileLayout &layout = indspec->layouts[layout_index];
|
||||
|
@ -2021,15 +2021,15 @@ static CommandCost CreateNewIndustryHelper(TileIndex tile, IndustryType type, Do
|
|||
if (ret.Failed()) return ret;
|
||||
|
||||
if (!custom_shape_check && _settings_game.game_creation.land_generator == LG_TERRAGENESIS && _generating_world &&
|
||||
!_ignore_restrictions && !CheckIfCanLevelIndustryPlatform(tile, DC_NO_WATER, layout)) {
|
||||
!_ignore_restrictions && !CheckIfCanLevelIndustryPlatform(tile, DoCommandFlag::NoWater, layout)) {
|
||||
return CommandCost(STR_ERROR_SITE_UNSUITABLE);
|
||||
}
|
||||
|
||||
if (!Industry::CanAllocateItem()) return CommandCost(STR_ERROR_TOO_MANY_INDUSTRIES);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
*ip = new Industry(tile);
|
||||
if (!custom_shape_check) CheckIfCanLevelIndustryPlatform(tile, DC_NO_WATER | DC_EXEC, layout);
|
||||
if (!custom_shape_check) CheckIfCanLevelIndustryPlatform(tile, {DoCommandFlag::NoWater, DoCommandFlag::Execute}, layout);
|
||||
DoCreateNewIndustry(*ip, tile, type, layout, layout_index, t, founder, random_initial_bits);
|
||||
}
|
||||
|
||||
|
@ -2046,7 +2046,7 @@ static CommandCost CreateNewIndustryHelper(TileIndex tile, IndustryType type, Do
|
|||
* @param seed seed to use for desyncfree randomisations
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildIndustry(DoCommandFlag flags, TileIndex tile, IndustryType it, uint32_t first_layout, bool fund, uint32_t seed)
|
||||
CommandCost CmdBuildIndustry(DoCommandFlags flags, TileIndex tile, IndustryType it, uint32_t first_layout, bool fund, uint32_t seed)
|
||||
{
|
||||
if (it >= NUM_INDUSTRYTYPES) return CMD_ERROR;
|
||||
|
||||
|
@ -2075,7 +2075,7 @@ CommandCost CmdBuildIndustry(DoCommandFlag flags, TileIndex tile, IndustryType i
|
|||
|
||||
Industry *ind = nullptr;
|
||||
if (deity_prospect || (_game_mode != GM_EDITOR && _current_company != OWNER_DEITY && _settings_game.construction.raw_industry_construction == 2 && indspec->IsRawIndustry())) {
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Prospecting has a chance to fail, however we cannot guarantee that something can
|
||||
* be built on the map, so the chance gets lower when the map is fuller, but there
|
||||
* is nothing we can really do about that. */
|
||||
|
@ -2124,7 +2124,7 @@ CommandCost CmdBuildIndustry(DoCommandFlag flags, TileIndex tile, IndustryType i
|
|||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
if ((flags & DC_EXEC) && ind != nullptr && _game_mode != GM_EDITOR) {
|
||||
if (flags.Test(DoCommandFlag::Execute) && ind != nullptr && _game_mode != GM_EDITOR) {
|
||||
AdvertiseIndustryOpening(ind);
|
||||
}
|
||||
|
||||
|
@ -2138,7 +2138,7 @@ CommandCost CmdBuildIndustry(DoCommandFlag flags, TileIndex tile, IndustryType i
|
|||
* @param ctlflags IndustryControlFlags
|
||||
* @return Empty cost or an error.
|
||||
*/
|
||||
CommandCost CmdIndustrySetFlags(DoCommandFlag flags, IndustryID ind_id, IndustryControlFlags ctlflags)
|
||||
CommandCost CmdIndustrySetFlags(DoCommandFlags flags, IndustryID ind_id, IndustryControlFlags ctlflags)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
|
||||
|
@ -2146,7 +2146,7 @@ CommandCost CmdIndustrySetFlags(DoCommandFlag flags, IndustryID ind_id, Industry
|
|||
if (ind == nullptr) return CMD_ERROR;
|
||||
if (!ctlflags.IsValid()) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) ind->ctlflags = ctlflags;
|
||||
if (flags.Test(DoCommandFlag::Execute)) ind->ctlflags = ctlflags;
|
||||
|
||||
return CommandCost();
|
||||
}
|
||||
|
@ -2160,7 +2160,7 @@ CommandCost CmdIndustrySetFlags(DoCommandFlag flags, IndustryID ind_id, Industry
|
|||
* @param custom_news Custom news message text.
|
||||
* @return Empty cost or an error.
|
||||
*/
|
||||
CommandCost CmdIndustrySetProduction(DoCommandFlag flags, IndustryID ind_id, uint8_t prod_level, bool show_news, const std::string &custom_news)
|
||||
CommandCost CmdIndustrySetProduction(DoCommandFlags flags, IndustryID ind_id, uint8_t prod_level, bool show_news, const std::string &custom_news)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
if (prod_level < PRODLEVEL_MINIMUM || prod_level > PRODLEVEL_MAXIMUM) return CMD_ERROR;
|
||||
|
@ -2168,7 +2168,7 @@ CommandCost CmdIndustrySetProduction(DoCommandFlag flags, IndustryID ind_id, uin
|
|||
Industry *ind = Industry::GetIfValid(ind_id);
|
||||
if (ind == nullptr) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
StringID str = STR_NULL;
|
||||
if (prod_level > ind->prod_level) {
|
||||
str = GetIndustrySpec(ind->type)->production_up_text;
|
||||
|
@ -2217,7 +2217,7 @@ CommandCost CmdIndustrySetProduction(DoCommandFlag flags, IndustryID ind_id, uin
|
|||
* @param consumer Set exclusive consumer if true, supplier if false.
|
||||
* @return Empty cost or an error.
|
||||
*/
|
||||
CommandCost CmdIndustrySetExclusivity(DoCommandFlag flags, IndustryID ind_id, Owner company_id, bool consumer)
|
||||
CommandCost CmdIndustrySetExclusivity(DoCommandFlags flags, IndustryID ind_id, Owner company_id, bool consumer)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
|
||||
|
@ -2227,7 +2227,7 @@ CommandCost CmdIndustrySetExclusivity(DoCommandFlag flags, IndustryID ind_id, Ow
|
|||
if (company_id != OWNER_NONE && company_id != INVALID_OWNER && company_id != OWNER_DEITY
|
||||
&& !Company::IsValidID(company_id)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (consumer) {
|
||||
ind->exclusive_consumer = company_id;
|
||||
} else {
|
||||
|
@ -2246,14 +2246,14 @@ CommandCost CmdIndustrySetExclusivity(DoCommandFlag flags, IndustryID ind_id, Ow
|
|||
* @param text - Additional industry text.
|
||||
* @return Empty cost or an error.
|
||||
*/
|
||||
CommandCost CmdIndustrySetText(DoCommandFlag flags, IndustryID ind_id, const std::string &text)
|
||||
CommandCost CmdIndustrySetText(DoCommandFlags flags, IndustryID ind_id, const std::string &text)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
|
||||
Industry *ind = Industry::GetIfValid(ind_id);
|
||||
if (ind == nullptr) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
ind->text.clear();
|
||||
if (!text.empty()) ind->text = text;
|
||||
InvalidateWindowData(WC_INDUSTRY_VIEW, ind->index);
|
||||
|
@ -2277,7 +2277,7 @@ static Industry *CreateNewIndustry(TileIndex tile, IndustryType type, IndustryAv
|
|||
uint32_t seed2 = Random();
|
||||
Industry *i = nullptr;
|
||||
size_t layout_index = RandomRange((uint32_t)indspec->layouts.size());
|
||||
[[maybe_unused]] CommandCost ret = CreateNewIndustryHelper(tile, type, DC_EXEC, indspec, layout_index, seed, GB(seed2, 0, 16), OWNER_NONE, creation_type, &i);
|
||||
[[maybe_unused]] CommandCost ret = CreateNewIndustryHelper(tile, type, DoCommandFlag::Execute, indspec, layout_index, seed, GB(seed2, 0, 16), OWNER_NONE, creation_type, &i);
|
||||
assert(i != nullptr || ret.Failed());
|
||||
return i;
|
||||
}
|
||||
|
@ -3160,7 +3160,7 @@ bool IndustrySpec::UsesOriginalEconomy() const
|
|||
IndustryCallbackMask::ProdChangeBuild}); // production change callbacks
|
||||
}
|
||||
|
||||
static CommandCost TerraformTile_Industry(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
|
||||
static CommandCost TerraformTile_Industry(TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new)
|
||||
{
|
||||
if (AutoslopeEnabled()) {
|
||||
/* We imitate here TTDP's behaviour:
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
#include "industry_type.h"
|
||||
#include "industry.h"
|
||||
|
||||
CommandCost CmdBuildIndustry(DoCommandFlag flags, TileIndex tile, IndustryType it, uint32_t first_layout, bool fund, uint32_t seed);
|
||||
CommandCost CmdIndustrySetFlags(DoCommandFlag flags, IndustryID ind_id, IndustryControlFlags ctlflags);
|
||||
CommandCost CmdIndustrySetExclusivity(DoCommandFlag flags, IndustryID ind_id, Owner company_id, bool consumer);
|
||||
CommandCost CmdIndustrySetText(DoCommandFlag flags, IndustryID ind_id, const std::string &text);
|
||||
CommandCost CmdIndustrySetProduction(DoCommandFlag flags, IndustryID ind_id, uint8_t prod_level, bool show_news, const std::string &text);
|
||||
CommandCost CmdBuildIndustry(DoCommandFlags flags, TileIndex tile, IndustryType it, uint32_t first_layout, bool fund, uint32_t seed);
|
||||
CommandCost CmdIndustrySetFlags(DoCommandFlags flags, IndustryID ind_id, IndustryControlFlags ctlflags);
|
||||
CommandCost CmdIndustrySetExclusivity(DoCommandFlags flags, IndustryID ind_id, Owner company_id, bool consumer);
|
||||
CommandCost CmdIndustrySetText(DoCommandFlags flags, IndustryID ind_id, const std::string &text);
|
||||
CommandCost CmdIndustrySetProduction(DoCommandFlags flags, IndustryID ind_id, uint8_t prod_level, bool show_news, const std::string &text);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_BUILD_INDUSTRY, CmdBuildIndustry, CMD_DEITY, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
DEF_CMD_TRAIT(CMD_INDUSTRY_SET_FLAGS, CmdIndustrySetFlags, CMD_DEITY, CMDT_OTHER_MANAGEMENT)
|
||||
|
|
|
@ -640,18 +640,18 @@ void ClearSnowLine()
|
|||
* @param tile tile to clear
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdLandscapeClear(DoCommandFlag flags, TileIndex tile)
|
||||
CommandCost CmdLandscapeClear(DoCommandFlags flags, TileIndex tile)
|
||||
{
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
bool do_clear = false;
|
||||
/* Test for stuff which results in water when cleared. Then add the cost to also clear the water. */
|
||||
if ((flags & DC_FORCE_CLEAR_TILE) && HasTileWaterClass(tile) && IsTileOnWater(tile) && !IsWaterTile(tile) && !IsCoastTile(tile)) {
|
||||
if ((flags & DC_AUTO) && GetWaterClass(tile) == WATER_CLASS_CANAL) return CommandCost(STR_ERROR_MUST_DEMOLISH_CANAL_FIRST);
|
||||
if (flags.Test(DoCommandFlag::ForceClearTile) && HasTileWaterClass(tile) && IsTileOnWater(tile) && !IsWaterTile(tile) && !IsCoastTile(tile)) {
|
||||
if (flags.Test(DoCommandFlag::Auto) && GetWaterClass(tile) == WATER_CLASS_CANAL) return CommandCost(STR_ERROR_MUST_DEMOLISH_CANAL_FIRST);
|
||||
do_clear = true;
|
||||
cost.AddCost(GetWaterClass(tile) == WATER_CLASS_CANAL ? _price[PR_CLEAR_CANAL] : _price[PR_CLEAR_WATER]);
|
||||
}
|
||||
|
||||
Company *c = (flags & (DC_AUTO | DC_BANKRUPT)) ? nullptr : Company::GetIfValid(_current_company);
|
||||
Company *c = flags.Any({DoCommandFlag::Auto, DoCommandFlag::Bankrupt}) ? nullptr : Company::GetIfValid(_current_company);
|
||||
if (c != nullptr && (int)GB(c->clear_limit, 16, 16) < 1) {
|
||||
return CommandCost(STR_ERROR_CLEARING_LIMIT_REACHED);
|
||||
}
|
||||
|
@ -666,14 +666,14 @@ CommandCost CmdLandscapeClear(DoCommandFlag flags, TileIndex tile)
|
|||
* However, we need to check stuff, which is not the same for all object tiles. (e.g. being on water or not) */
|
||||
|
||||
/* If a object is removed, it leaves either bare land or water. */
|
||||
if ((flags & DC_NO_WATER) && HasTileWaterClass(tile) && IsTileOnWater(tile)) {
|
||||
if (flags.Test(DoCommandFlag::NoWater) && HasTileWaterClass(tile) && IsTileOnWater(tile)) {
|
||||
return CommandCost(STR_ERROR_CAN_T_BUILD_ON_WATER);
|
||||
}
|
||||
} else {
|
||||
cost.AddCost(_tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags));
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (c != nullptr) c->clear_limit -= 1 << 16;
|
||||
if (do_clear) {
|
||||
if (IsWaterTile(tile) && IsCanal(tile)) {
|
||||
|
@ -698,7 +698,7 @@ CommandCost CmdLandscapeClear(DoCommandFlag flags, TileIndex tile)
|
|||
* @param diagonal Whether to use the Orthogonal (false) or Diagonal (true) iterator.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
std::tuple<CommandCost, Money> CmdClearArea(DoCommandFlag flags, TileIndex tile, TileIndex start_tile, bool diagonal)
|
||||
std::tuple<CommandCost, Money> CmdClearArea(DoCommandFlags flags, TileIndex tile, TileIndex start_tile, bool diagonal)
|
||||
{
|
||||
if (start_tile >= Map::Size()) return { CMD_ERROR, 0 };
|
||||
|
||||
|
@ -707,15 +707,15 @@ std::tuple<CommandCost, Money> CmdClearArea(DoCommandFlag flags, TileIndex tile,
|
|||
CommandCost last_error = CMD_ERROR;
|
||||
bool had_success = false;
|
||||
|
||||
const Company *c = (flags & (DC_AUTO | DC_BANKRUPT)) ? nullptr : Company::GetIfValid(_current_company);
|
||||
const Company *c = flags.Any({DoCommandFlag::Auto, DoCommandFlag::Bankrupt}) ? nullptr : Company::GetIfValid(_current_company);
|
||||
int limit = (c == nullptr ? INT32_MAX : GB(c->clear_limit, 16, 16));
|
||||
|
||||
if (tile != start_tile) flags |= DC_FORCE_CLEAR_TILE;
|
||||
if (tile != start_tile) flags.Set(DoCommandFlag::ForceClearTile);
|
||||
|
||||
std::unique_ptr<TileIterator> iter = TileIterator::Create(tile, start_tile, diagonal);
|
||||
for (; *iter != INVALID_TILE; ++(*iter)) {
|
||||
TileIndex t = *iter;
|
||||
CommandCost ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags & ~DC_EXEC, t);
|
||||
CommandCost ret = Command<CMD_LANDSCAPE_CLEAR>::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), t);
|
||||
if (ret.Failed()) {
|
||||
last_error = ret;
|
||||
|
||||
|
@ -725,7 +725,7 @@ std::tuple<CommandCost, Money> CmdClearArea(DoCommandFlag flags, TileIndex tile,
|
|||
}
|
||||
|
||||
had_success = true;
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
money -= ret.GetCost();
|
||||
if (ret.GetCost() > 0 && money < 0) {
|
||||
return { cost, ret.GetCost() };
|
||||
|
@ -1106,7 +1106,7 @@ static bool RiverMakeWider(TileIndex tile, void *user_data)
|
|||
TileIndex other_tile = TileAddByDiagDir(tile, d);
|
||||
if (IsInclinedSlope(GetTileSlope(other_tile)) && IsWaterTile(other_tile)) return false;
|
||||
}
|
||||
Command<CMD_TERRAFORM_LAND>::Do(DC_EXEC | DC_AUTO, tile, ComplementSlope(cur_slope), true);
|
||||
Command<CMD_TERRAFORM_LAND>::Do({DoCommandFlag::Execute, DoCommandFlag::Auto}, tile, ComplementSlope(cur_slope), true);
|
||||
|
||||
/* If the river is descending and the adjacent tile has either one or three corners raised, we want to make it match the slope. */
|
||||
} else if (IsInclinedSlope(desired_slope)) {
|
||||
|
@ -1127,14 +1127,14 @@ static bool RiverMakeWider(TileIndex tile, void *user_data)
|
|||
/* Lower unwanted corners first. If only one corner is raised, no corners need lowering. */
|
||||
if (!IsSlopeWithOneCornerRaised(cur_slope)) {
|
||||
to_change = to_change & ComplementSlope(desired_slope);
|
||||
Command<CMD_TERRAFORM_LAND>::Do(DC_EXEC | DC_AUTO, tile, to_change, false);
|
||||
Command<CMD_TERRAFORM_LAND>::Do({DoCommandFlag::Execute, DoCommandFlag::Auto}, tile, to_change, false);
|
||||
}
|
||||
|
||||
/* Now check the match and raise any corners needed. */
|
||||
cur_slope = GetTileSlope(tile);
|
||||
if (cur_slope != desired_slope && IsSlopeWithOneCornerRaised(cur_slope)) {
|
||||
to_change = cur_slope ^ desired_slope;
|
||||
Command<CMD_TERRAFORM_LAND>::Do(DC_EXEC | DC_AUTO, tile, to_change, true);
|
||||
Command<CMD_TERRAFORM_LAND>::Do({DoCommandFlag::Execute, DoCommandFlag::Auto}, tile, to_change, true);
|
||||
}
|
||||
}
|
||||
/* Update cur_slope after possibly terraforming. */
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
|
||||
#include "command_type.h"
|
||||
|
||||
CommandCost CmdLandscapeClear(DoCommandFlag flags, TileIndex tile);
|
||||
std::tuple<CommandCost, Money> CmdClearArea(DoCommandFlag flags, TileIndex tile, TileIndex start_tile, bool diagonal);
|
||||
CommandCost CmdLandscapeClear(DoCommandFlags flags, TileIndex tile);
|
||||
std::tuple<CommandCost, Money> CmdClearArea(DoCommandFlags flags, TileIndex tile, TileIndex start_tile, bool diagonal);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_LANDSCAPE_CLEAR, CmdLandscapeClear, CMD_DEITY, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
DEF_CMD_TRAIT(CMD_CLEAR_AREA, CmdClearArea, CMD_NO_TEST, CMDT_LANDSCAPE_CONSTRUCTION) // destroying multi-tile houses makes town rating differ between test and execution
|
||||
|
|
|
@ -53,13 +53,13 @@ bool IsValidLink(Link link)
|
|||
* @param footer Text to show below the table
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
std::tuple<CommandCost, LeagueTableID> CmdCreateLeagueTable(DoCommandFlag flags, const std::string &title, const std::string &header, const std::string &footer)
|
||||
std::tuple<CommandCost, LeagueTableID> CmdCreateLeagueTable(DoCommandFlags flags, const std::string &title, const std::string &header, const std::string &footer)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return { CMD_ERROR, INVALID_LEAGUE_TABLE };
|
||||
if (!LeagueTable::CanAllocateItem()) return { CMD_ERROR, INVALID_LEAGUE_TABLE };
|
||||
if (title.empty()) return { CMD_ERROR, INVALID_LEAGUE_TABLE };
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
LeagueTable *lt = new LeagueTable();
|
||||
lt->title = title;
|
||||
lt->header = header;
|
||||
|
@ -83,7 +83,7 @@ std::tuple<CommandCost, LeagueTableID> CmdCreateLeagueTable(DoCommandFlag flags,
|
|||
* @param link_target Id of the referenced object
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
std::tuple<CommandCost, LeagueTableElementID> CmdCreateLeagueTableElement(DoCommandFlag flags, LeagueTableID table, int64_t rating, CompanyID company, const std::string &text, const std::string &score, LinkType link_type, LinkTargetID link_target)
|
||||
std::tuple<CommandCost, LeagueTableElementID> CmdCreateLeagueTableElement(DoCommandFlags flags, LeagueTableID table, int64_t rating, CompanyID company, const std::string &text, const std::string &score, LinkType link_type, LinkTargetID link_target)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return { CMD_ERROR, INVALID_LEAGUE_TABLE_ELEMENT };
|
||||
if (!LeagueTableElement::CanAllocateItem()) return { CMD_ERROR, INVALID_LEAGUE_TABLE_ELEMENT };
|
||||
|
@ -91,7 +91,7 @@ std::tuple<CommandCost, LeagueTableElementID> CmdCreateLeagueTableElement(DoComm
|
|||
if (!IsValidLink(link)) return { CMD_ERROR, INVALID_LEAGUE_TABLE_ELEMENT };
|
||||
if (company != INVALID_COMPANY && !Company::IsValidID(company)) return { CMD_ERROR, INVALID_LEAGUE_TABLE_ELEMENT };
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
LeagueTableElement *lte = new LeagueTableElement();
|
||||
lte->table = table;
|
||||
lte->rating = rating;
|
||||
|
@ -115,7 +115,7 @@ std::tuple<CommandCost, LeagueTableElementID> CmdCreateLeagueTableElement(DoComm
|
|||
* @param link_target Id of the referenced object
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdUpdateLeagueTableElementData(DoCommandFlag flags, LeagueTableElementID element, CompanyID company, const std::string &text, LinkType link_type, LinkTargetID link_target)
|
||||
CommandCost CmdUpdateLeagueTableElementData(DoCommandFlags flags, LeagueTableElementID element, CompanyID company, const std::string &text, LinkType link_type, LinkTargetID link_target)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
auto lte = LeagueTableElement::GetIfValid(element);
|
||||
|
@ -124,7 +124,7 @@ CommandCost CmdUpdateLeagueTableElementData(DoCommandFlag flags, LeagueTableElem
|
|||
Link link{link_type, link_target};
|
||||
if (!IsValidLink(link)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
lte->company = company;
|
||||
lte->text = text;
|
||||
lte->link = link;
|
||||
|
@ -141,13 +141,13 @@ CommandCost CmdUpdateLeagueTableElementData(DoCommandFlag flags, LeagueTableElem
|
|||
* @param score String representation of the score associated with the element
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdUpdateLeagueTableElementScore(DoCommandFlag flags, LeagueTableElementID element, int64_t rating, const std::string &score)
|
||||
CommandCost CmdUpdateLeagueTableElementScore(DoCommandFlags flags, LeagueTableElementID element, int64_t rating, const std::string &score)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
auto lte = LeagueTableElement::GetIfValid(element);
|
||||
if (lte == nullptr) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
lte->rating = rating;
|
||||
lte->score = score;
|
||||
InvalidateWindowData(WC_COMPANY_LEAGUE, lte->table);
|
||||
|
@ -161,13 +161,13 @@ CommandCost CmdUpdateLeagueTableElementScore(DoCommandFlag flags, LeagueTableEle
|
|||
* @param element Id of the element to update
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRemoveLeagueTableElement(DoCommandFlag flags, LeagueTableElementID element)
|
||||
CommandCost CmdRemoveLeagueTableElement(DoCommandFlags flags, LeagueTableElementID element)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
auto lte = LeagueTableElement::GetIfValid(element);
|
||||
if (lte == nullptr) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
auto table = lte->table;
|
||||
delete lte;
|
||||
InvalidateWindowData(WC_COMPANY_LEAGUE, table);
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
#include "command_type.h"
|
||||
#include "company_type.h"
|
||||
|
||||
std::tuple<CommandCost, LeagueTableID> CmdCreateLeagueTable(DoCommandFlag flags, const std::string &title, const std::string &header, const std::string &footer);
|
||||
std::tuple<CommandCost, LeagueTableElementID> CmdCreateLeagueTableElement(DoCommandFlag flags, LeagueTableID table, int64_t rating, CompanyID company, const std::string &text, const std::string &score, LinkType link_type, LinkTargetID link_target);
|
||||
CommandCost CmdUpdateLeagueTableElementData(DoCommandFlag flags, LeagueTableElementID element, CompanyID company, const std::string &text, LinkType link_type, LinkTargetID link_target);
|
||||
CommandCost CmdUpdateLeagueTableElementScore(DoCommandFlag flags, LeagueTableElementID element, int64_t rating, const std::string &score);
|
||||
CommandCost CmdRemoveLeagueTableElement(DoCommandFlag flags, LeagueTableElementID element);
|
||||
std::tuple<CommandCost, LeagueTableID> CmdCreateLeagueTable(DoCommandFlags flags, const std::string &title, const std::string &header, const std::string &footer);
|
||||
std::tuple<CommandCost, LeagueTableElementID> CmdCreateLeagueTableElement(DoCommandFlags flags, LeagueTableID table, int64_t rating, CompanyID company, const std::string &text, const std::string &score, LinkType link_type, LinkTargetID link_target);
|
||||
CommandCost CmdUpdateLeagueTableElementData(DoCommandFlags flags, LeagueTableElementID element, CompanyID company, const std::string &text, LinkType link_type, LinkTargetID link_target);
|
||||
CommandCost CmdUpdateLeagueTableElementScore(DoCommandFlags flags, LeagueTableElementID element, int64_t rating, const std::string &score);
|
||||
CommandCost CmdRemoveLeagueTableElement(DoCommandFlags flags, LeagueTableElementID element);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_CREATE_LEAGUE_TABLE, CmdCreateLeagueTable, CMD_DEITY | CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT)
|
||||
DEF_CMD_TRAIT(CMD_CREATE_LEAGUE_TABLE_ELEMENT, CmdCreateLeagueTableElement, CMD_DEITY | CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT)
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
* @param amount amount to increase the loan with, multitude of LOAN_INTERVAL. Only used when cmd == LoanCommand::Amount.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdIncreaseLoan(DoCommandFlag flags, LoanCommand cmd, Money amount)
|
||||
CommandCost CmdIncreaseLoan(DoCommandFlags flags, LoanCommand cmd, Money amount)
|
||||
{
|
||||
Company *c = Company::Get(_current_company);
|
||||
Money max_loan = c->GetMaxLoan();
|
||||
|
@ -65,7 +65,7 @@ CommandCost CmdIncreaseLoan(DoCommandFlag flags, LoanCommand cmd, Money amount)
|
|||
* immediately would not get us back to the same bank balance anymore. */
|
||||
if (c->money > Money::max() - loan) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
c->money += loan;
|
||||
c->current_loan += loan;
|
||||
InvalidateCompanyWindows(c);
|
||||
|
@ -83,7 +83,7 @@ CommandCost CmdIncreaseLoan(DoCommandFlag flags, LoanCommand cmd, Money amount)
|
|||
* @param amount amount to decrease the loan with, multitude of LOAN_INTERVAL. Only used when cmd == LoanCommand::Amount.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdDecreaseLoan(DoCommandFlag flags, LoanCommand cmd, Money amount)
|
||||
CommandCost CmdDecreaseLoan(DoCommandFlags flags, LoanCommand cmd, Money amount)
|
||||
{
|
||||
Company *c = Company::Get(_current_company);
|
||||
|
||||
|
@ -110,7 +110,7 @@ CommandCost CmdDecreaseLoan(DoCommandFlag flags, LoanCommand cmd, Money amount)
|
|||
return CommandCost(STR_ERROR_CURRENCY_REQUIRED);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
c->money -= loan;
|
||||
c->current_loan -= loan;
|
||||
InvalidateCompanyWindows(c);
|
||||
|
@ -124,7 +124,7 @@ CommandCost CmdDecreaseLoan(DoCommandFlag flags, LoanCommand cmd, Money amount)
|
|||
* @param amount the new max loan amount, will be rounded down to the multitude of LOAN_INTERVAL. If set to COMPANY_MAX_LOAN_DEFAULT reset the max loan to default(global) value.
|
||||
* @return zero cost or an error
|
||||
*/
|
||||
CommandCost CmdSetCompanyMaxLoan(DoCommandFlag flags, CompanyID company, Money amount)
|
||||
CommandCost CmdSetCompanyMaxLoan(DoCommandFlags flags, CompanyID company, Money amount)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
if (amount != COMPANY_MAX_LOAN_DEFAULT) {
|
||||
|
@ -134,7 +134,7 @@ CommandCost CmdSetCompanyMaxLoan(DoCommandFlag flags, CompanyID company, Money a
|
|||
Company *c = Company::GetIfValid(company);
|
||||
if (c == nullptr) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Round the amount down to a multiple of LOAN_INTERVAL. */
|
||||
if (amount != COMPANY_MAX_LOAN_DEFAULT) amount -= (int64_t)amount % LOAN_INTERVAL;
|
||||
|
||||
|
@ -166,7 +166,7 @@ static void AskUnsafeUnpauseCallback(Window *, bool confirmed)
|
|||
* @param pause true pauses, false unpauses this mode
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdPause(DoCommandFlag flags, PauseMode mode, bool pause)
|
||||
CommandCost CmdPause(DoCommandFlags flags, PauseMode mode, bool pause)
|
||||
{
|
||||
switch (mode) {
|
||||
case PM_PAUSED_SAVELOAD:
|
||||
|
@ -183,7 +183,7 @@ CommandCost CmdPause(DoCommandFlag flags, PauseMode mode, bool pause)
|
|||
|
||||
default: return CMD_ERROR;
|
||||
}
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (mode == PM_PAUSED_NORMAL && _pause_mode & PM_PAUSED_ERROR) {
|
||||
ShowQuery(
|
||||
GetEncodedString(STR_NEWGRF_UNPAUSE_WARNING_TITLE),
|
||||
|
@ -219,7 +219,7 @@ CommandCost CmdPause(DoCommandFlag flags, PauseMode mode, bool pause)
|
|||
* @param amount the amount of money to receive (if positive), or spend (if negative)
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdMoneyCheat(DoCommandFlag, Money amount)
|
||||
CommandCost CmdMoneyCheat(DoCommandFlags, Money amount)
|
||||
{
|
||||
return CommandCost(EXPENSES_OTHER, -amount);
|
||||
}
|
||||
|
@ -233,13 +233,13 @@ CommandCost CmdMoneyCheat(DoCommandFlag, Money amount)
|
|||
* @param expenses_type the expenses type which should register the cost/income @see ExpensesType.
|
||||
* @return zero cost or an error
|
||||
*/
|
||||
CommandCost CmdChangeBankBalance(DoCommandFlag flags, TileIndex tile, Money delta, CompanyID company, ExpensesType expenses_type)
|
||||
CommandCost CmdChangeBankBalance(DoCommandFlags flags, TileIndex tile, Money delta, CompanyID company, ExpensesType expenses_type)
|
||||
{
|
||||
if (!Company::IsValidID(company)) return CMD_ERROR;
|
||||
if (expenses_type >= EXPENSES_END) return CMD_ERROR;
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Change company bank balance of company. */
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
SubtractMoneyFromCompany(CommandCost(expenses_type, -delta));
|
||||
|
|
|
@ -21,12 +21,12 @@ enum class LoanCommand : uint8_t {
|
|||
Amount,
|
||||
};
|
||||
|
||||
CommandCost CmdMoneyCheat(DoCommandFlag flags, Money amount);
|
||||
CommandCost CmdChangeBankBalance(DoCommandFlag flags, TileIndex tile, Money delta, CompanyID company, ExpensesType expenses_type);
|
||||
CommandCost CmdIncreaseLoan(DoCommandFlag flags, LoanCommand cmd, Money amount);
|
||||
CommandCost CmdDecreaseLoan(DoCommandFlag flags, LoanCommand cmd, Money amount);
|
||||
CommandCost CmdSetCompanyMaxLoan(DoCommandFlag flags, CompanyID company, Money amount);
|
||||
CommandCost CmdPause(DoCommandFlag flags, PauseMode mode, bool pause);
|
||||
CommandCost CmdMoneyCheat(DoCommandFlags flags, Money amount);
|
||||
CommandCost CmdChangeBankBalance(DoCommandFlags flags, TileIndex tile, Money delta, CompanyID company, ExpensesType expenses_type);
|
||||
CommandCost CmdIncreaseLoan(DoCommandFlags flags, LoanCommand cmd, Money amount);
|
||||
CommandCost CmdDecreaseLoan(DoCommandFlags flags, LoanCommand cmd, Money amount);
|
||||
CommandCost CmdSetCompanyMaxLoan(DoCommandFlags flags, CompanyID company, Money amount);
|
||||
CommandCost CmdPause(DoCommandFlags flags, PauseMode mode, bool pause);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_MONEY_CHEAT, CmdMoneyCheat, CMD_OFFLINE, CMDT_CHEAT)
|
||||
DEF_CMD_TRAIT(CMD_CHANGE_BANK_BALANCE, CmdChangeBankBalance, CMD_DEITY, CMDT_MONEY_MANAGEMENT)
|
||||
|
|
|
@ -196,7 +196,7 @@ public:
|
|||
Company *c = Company::GetIfValid(_local_company);
|
||||
if (c != nullptr) {
|
||||
assert(_current_company == _local_company);
|
||||
CommandCost costclear = Command<CMD_LANDSCAPE_CLEAR>::Do(DC_QUERY_COST, tile);
|
||||
CommandCost costclear = Command<CMD_LANDSCAPE_CLEAR>::Do(DoCommandFlag::QueryCost, tile);
|
||||
if (costclear.Succeeded()) {
|
||||
Money cost = costclear.GetCost();
|
||||
if (cost < 0) {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "company_type.h"
|
||||
#include "news_type.h"
|
||||
|
||||
CommandCost CmdCustomNewsItem(DoCommandFlag flags, NewsType type, NewsReferenceType reftype1, CompanyID company, uint32_t reference, const std::string &text);
|
||||
CommandCost CmdCustomNewsItem(DoCommandFlags flags, NewsType type, NewsReferenceType reftype1, CompanyID company, uint32_t reference, const std::string &text);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_CUSTOM_NEWS_ITEM, CmdCustomNewsItem, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT)
|
||||
|
||||
|
|
|
@ -921,7 +921,7 @@ void AddNewsItem(StringID string, NewsType type, NewsStyle style, NewsFlags flag
|
|||
* @param text The text of the news message.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdCustomNewsItem(DoCommandFlag flags, NewsType type, NewsReferenceType reftype1, CompanyID company, uint32_t reference, const std::string &text)
|
||||
CommandCost CmdCustomNewsItem(DoCommandFlags flags, NewsType type, NewsReferenceType reftype1, CompanyID company, uint32_t reference, const std::string &text)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
|
||||
|
@ -960,7 +960,7 @@ CommandCost CmdCustomNewsItem(DoCommandFlag flags, NewsType type, NewsReferenceT
|
|||
|
||||
if (company != INVALID_OWNER && company != _local_company) return CommandCost();
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
SetDParamStr(0, text);
|
||||
AddNewsItem(STR_NEWS_CUSTOM_ITEM, type, NewsStyle::Normal, {}, reftype1, reference, NewsReferenceType::None, UINT32_MAX);
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ void UpdateObjectColours(const Company *c)
|
|||
}
|
||||
|
||||
extern CommandCost CheckBuildableTile(TileIndex tile, uint invalid_dirs, int &allowed_z, bool allow_steep, bool check_bridge);
|
||||
static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags);
|
||||
static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlags flags);
|
||||
|
||||
/**
|
||||
* Build an object object
|
||||
|
@ -207,7 +207,7 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags);
|
|||
* @param view the view for the object
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildObject(DoCommandFlag flags, TileIndex tile, ObjectType type, uint8_t view)
|
||||
CommandCost CmdBuildObject(DoCommandFlags flags, TileIndex tile, ObjectType type, uint8_t view)
|
||||
{
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
|
||||
|
@ -245,7 +245,7 @@ CommandCost CmdBuildObject(DoCommandFlag flags, TileIndex tile, ObjectType type,
|
|||
if (!IsWaterTile(t)) {
|
||||
/* Normal water tiles don't have to be cleared. For all other tile types clear
|
||||
* the tile but leave the water. */
|
||||
cost.AddCost(Command<CMD_LANDSCAPE_CLEAR>::Do(flags & ~DC_NO_WATER & ~DC_EXEC, t));
|
||||
cost.AddCost(Command<CMD_LANDSCAPE_CLEAR>::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::NoWater).Reset(DoCommandFlag::Execute), t));
|
||||
} else {
|
||||
/* Can't build on water owned by another company. */
|
||||
Owner o = GetTileOwner(t);
|
||||
|
@ -263,7 +263,7 @@ CommandCost CmdBuildObject(DoCommandFlag flags, TileIndex tile, ObjectType type,
|
|||
IsTileType(t, MP_OBJECT) &&
|
||||
IsTileOwner(t, _current_company) &&
|
||||
IsObjectType(t, OBJECT_HQ))) {
|
||||
cost.AddCost(Command<CMD_LANDSCAPE_CLEAR>::Do(flags & ~DC_EXEC, t));
|
||||
cost.AddCost(Command<CMD_LANDSCAPE_CLEAR>::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), t));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -289,16 +289,16 @@ CommandCost CmdBuildObject(DoCommandFlag flags, TileIndex tile, ObjectType type,
|
|||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* This is basically a copy of the loop above with the exception that we now
|
||||
* execute the commands and don't check for errors, since that's already done. */
|
||||
for (TileIndex t : ta) {
|
||||
if (HasTileWaterGround(t)) {
|
||||
if (!IsWaterTile(t)) {
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do((flags & ~DC_NO_WATER) | DC_NO_MODIFY_TOWN_RATING, t);
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::NoWater).Set(DoCommandFlag::NoModifyTownRating), t);
|
||||
}
|
||||
} else {
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(flags | DC_NO_MODIFY_TOWN_RATING, t);
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(flags | DoCommandFlag::NoModifyTownRating, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ CommandCost CmdBuildObject(DoCommandFlag flags, TileIndex tile, ObjectType type,
|
|||
_current_company = c->index;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
hq_score = UpdateCompanyRatingAndValue(c, false);
|
||||
c->location_of_HQ = tile;
|
||||
SetWindowDirty(WC_COMPANY, c->index);
|
||||
|
@ -364,7 +364,7 @@ CommandCost CmdBuildObject(DoCommandFlag flags, TileIndex tile, ObjectType type,
|
|||
return CommandCost(STR_ERROR_BUILD_OBJECT_LIMIT_REACHED);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
BuildObject(type, tile, _current_company == OWNER_DEITY ? OWNER_NONE : _current_company, nullptr, view);
|
||||
|
||||
/* Make sure the HQ starts at the right size. */
|
||||
|
@ -388,7 +388,7 @@ CommandCost CmdBuildObject(DoCommandFlag flags, TileIndex tile, ObjectType type,
|
|||
* @param diagonal Whether to use the Orthogonal (0) or Diagonal (1) iterator.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildObjectArea(DoCommandFlag flags, TileIndex tile, TileIndex start_tile, ObjectType type, uint8_t view, bool diagonal)
|
||||
CommandCost CmdBuildObjectArea(DoCommandFlags flags, TileIndex tile, TileIndex start_tile, ObjectType type, uint8_t view, bool diagonal)
|
||||
{
|
||||
if (start_tile >= Map::Size()) return CMD_ERROR;
|
||||
|
||||
|
@ -409,7 +409,7 @@ CommandCost CmdBuildObjectArea(DoCommandFlag flags, TileIndex tile, TileIndex st
|
|||
std::unique_ptr<TileIterator> iter = TileIterator::Create(tile, start_tile, diagonal);
|
||||
for (; *iter != INVALID_TILE; ++(*iter)) {
|
||||
TileIndex t = *iter;
|
||||
CommandCost ret = Command<CMD_BUILD_OBJECT>::Do(flags & ~DC_EXEC, t, type, view);
|
||||
CommandCost ret = Command<CMD_BUILD_OBJECT>::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), t, type, view);
|
||||
|
||||
/* If we've reached the limit, stop building (or testing). */
|
||||
if (c != nullptr && limit-- <= 0) break;
|
||||
|
@ -420,7 +420,7 @@ CommandCost CmdBuildObjectArea(DoCommandFlag flags, TileIndex tile, TileIndex st
|
|||
}
|
||||
|
||||
had_success = true;
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
money -= ret.GetCost();
|
||||
|
||||
/* If we run out of money, stop building. */
|
||||
|
@ -539,7 +539,7 @@ ClearedObjectArea *FindClearedObject(TileIndex tile)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
/* Get to the northern most tile. */
|
||||
Object *o = Object::GetByTile(tile);
|
||||
|
@ -556,10 +556,10 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags)
|
|||
|
||||
/* Water can remove everything! */
|
||||
if (_current_company != OWNER_WATER) {
|
||||
if ((flags & DC_NO_WATER) && IsTileOnWater(tile)) {
|
||||
if (flags.Test(DoCommandFlag::NoWater) && IsTileOnWater(tile)) {
|
||||
/* There is water under the object, treat it as water tile. */
|
||||
return CommandCost(STR_ERROR_CAN_T_BUILD_ON_WATER);
|
||||
} else if (!spec->flags.Test(ObjectFlag::Autoremove) && (flags & DC_AUTO)) {
|
||||
} else if (!spec->flags.Test(ObjectFlag::Autoremove) && flags.Test(DoCommandFlag::Auto)) {
|
||||
/* No automatic removal by overbuilding stuff. */
|
||||
return CommandCost(type == OBJECT_HQ ? STR_ERROR_COMPANY_HEADQUARTERS_IN : STR_ERROR_OBJECT_IN_THE_WAY);
|
||||
} else if (_game_mode == GM_EDITOR) {
|
||||
|
@ -588,7 +588,7 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags)
|
|||
switch (type) {
|
||||
case OBJECT_HQ: {
|
||||
Company *c = Company::Get(GetTileOwner(tile));
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
c->location_of_HQ = INVALID_TILE; // reset HQ position
|
||||
SetWindowDirty(WC_COMPANY, c->index);
|
||||
CargoPacket::InvalidateAllFrom({c->index, SourceType::Headquarters});
|
||||
|
@ -600,7 +600,7 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags)
|
|||
}
|
||||
|
||||
case OBJECT_STATUE:
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Town *town = o->town;
|
||||
town->statues.Reset(GetTileOwner(tile));
|
||||
SetWindowDirty(WC_TOWN_AUTHORITY, town->index);
|
||||
|
@ -613,7 +613,7 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags)
|
|||
|
||||
_cleared_object_areas.push_back({tile, ta});
|
||||
|
||||
if (flags & DC_EXEC) ReallyClearObjectTile(o);
|
||||
if (flags.Test(DoCommandFlag::Execute)) ReallyClearObjectTile(o);
|
||||
|
||||
return cost;
|
||||
}
|
||||
|
@ -864,7 +864,7 @@ void GenerateObjects()
|
|||
|
||||
default:
|
||||
uint8_t view = RandomRange(spec.views);
|
||||
if (CmdBuildObject(DC_EXEC | DC_AUTO | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, RandomTile(), spec.Index(), view).Succeeded()) amount--;
|
||||
if (CmdBuildObject({DoCommandFlag::Execute, DoCommandFlag::Auto, DoCommandFlag::NoTestTownRating, DoCommandFlag::NoModifyTownRating}, RandomTile(), spec.Index(), view).Succeeded()) amount--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -908,7 +908,7 @@ static void ChangeTileOwner_Object(TileIndex tile, Owner old_owner, Owner new_ow
|
|||
}
|
||||
}
|
||||
|
||||
static CommandCost TerraformTile_Object(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
|
||||
static CommandCost TerraformTile_Object(TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new)
|
||||
{
|
||||
ObjectType type = GetObjectType(tile);
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#include "command_type.h"
|
||||
#include "object_type.h"
|
||||
|
||||
CommandCost CmdBuildObject(DoCommandFlag flags, TileIndex tile, ObjectType type, uint8_t view);
|
||||
CommandCost CmdBuildObjectArea(DoCommandFlag flags, TileIndex tile, TileIndex start_tile, ObjectType type, uint8_t view, bool diagonal);
|
||||
CommandCost CmdBuildObject(DoCommandFlags flags, TileIndex tile, ObjectType type, uint8_t view);
|
||||
CommandCost CmdBuildObjectArea(DoCommandFlags flags, TileIndex tile, TileIndex start_tile, ObjectType type, uint8_t view, bool diagonal);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_BUILD_OBJECT, CmdBuildObject, CMD_DEITY | CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
DEF_CMD_TRAIT(CMD_BUILD_OBJECT_AREA, CmdBuildObjectArea, CMD_DEITY | CMD_NO_WATER | CMD_NO_TEST | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
|
|
|
@ -76,7 +76,7 @@ void OrderBackup::DoRestore(Vehicle *v)
|
|||
{
|
||||
/* If we had shared orders, recover that */
|
||||
if (this->clone != nullptr) {
|
||||
Command<CMD_CLONE_ORDER>::Do(DC_EXEC, CO_SHARE, v->index, this->clone->index);
|
||||
Command<CMD_CLONE_ORDER>::Do(DoCommandFlag::Execute, CO_SHARE, v->index, this->clone->index);
|
||||
} else if (this->orders != nullptr && OrderList::CanAllocateItem()) {
|
||||
v->orders = new OrderList(this->orders, v);
|
||||
this->orders = nullptr;
|
||||
|
@ -94,7 +94,7 @@ void OrderBackup::DoRestore(Vehicle *v)
|
|||
if (v->cur_implicit_order_index >= v->GetNumOrders()) v->cur_implicit_order_index = v->cur_real_order_index;
|
||||
|
||||
/* Restore vehicle group */
|
||||
Command<CMD_ADD_VEHICLE_GROUP>::Do(DC_EXEC, this->group, v->index, false, VehicleListIdentifier{});
|
||||
Command<CMD_ADD_VEHICLE_GROUP>::Do(DoCommandFlag::Execute, this->group, v->index, false, VehicleListIdentifier{});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -151,10 +151,10 @@ void OrderBackup::DoRestore(Vehicle *v)
|
|||
* @param user_id User that had the OrderBackup.
|
||||
* @return The cost of this operation or an error.
|
||||
*/
|
||||
CommandCost CmdClearOrderBackup(DoCommandFlag flags, TileIndex tile, ClientID user_id)
|
||||
CommandCost CmdClearOrderBackup(DoCommandFlags flags, TileIndex tile, ClientID user_id)
|
||||
{
|
||||
/* No need to check anything. If the tile or user don't exist we just ignore it. */
|
||||
if (flags & DC_EXEC) OrderBackup::ResetOfUser(tile == 0 ? INVALID_TILE : tile, user_id);
|
||||
if (flags.Test(DoCommandFlag::Execute)) OrderBackup::ResetOfUser(tile == 0 ? INVALID_TILE : tile, user_id);
|
||||
|
||||
return CommandCost();
|
||||
}
|
||||
|
|
|
@ -679,7 +679,7 @@ uint GetOrderDistance(const Order *prev, const Order *cur, const Vehicle *v, int
|
|||
* @param new_order order to insert
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdInsertOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, const Order &new_order)
|
||||
CommandCost CmdInsertOrder(DoCommandFlags flags, VehicleID veh, VehicleOrderID sel_ord, const Order &new_order)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(veh);
|
||||
if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
||||
|
@ -879,7 +879,7 @@ CommandCost CmdInsertOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID se
|
|||
if (!Order::CanAllocateItem()) return CommandCost(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS);
|
||||
if (v->orders == nullptr && !OrderList::CanAllocateItem()) return CommandCost(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Order *new_o = new Order();
|
||||
new_o->AssignOrder(new_order);
|
||||
InsertOrder(v, new_o, sel_ord);
|
||||
|
@ -964,9 +964,9 @@ void InsertOrder(Vehicle *v, Order *new_o, VehicleOrderID sel_ord)
|
|||
* @param *dst delete the orders of this vehicle
|
||||
* @param flags execution flags
|
||||
*/
|
||||
static CommandCost DecloneOrder(Vehicle *dst, DoCommandFlag flags)
|
||||
static CommandCost DecloneOrder(Vehicle *dst, DoCommandFlags flags)
|
||||
{
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
DeleteVehicleOrders(dst);
|
||||
InvalidateVehicleOrder(dst, VIWD_REMOVE_ALL_ORDERS);
|
||||
InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0);
|
||||
|
@ -981,7 +981,7 @@ static CommandCost DecloneOrder(Vehicle *dst, DoCommandFlag flags)
|
|||
* @param sel_ord the order to delete (max 255)
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdDeleteOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID sel_ord)
|
||||
CommandCost CmdDeleteOrder(DoCommandFlags flags, VehicleID veh_id, VehicleOrderID sel_ord)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(veh_id);
|
||||
|
||||
|
@ -995,7 +995,7 @@ CommandCost CmdDeleteOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID
|
|||
|
||||
if (v->GetOrder(sel_ord) == nullptr) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) DeleteOrder(v, sel_ord);
|
||||
if (flags.Test(DoCommandFlag::Execute)) DeleteOrder(v, sel_ord);
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
|
@ -1083,7 +1083,7 @@ void DeleteOrder(Vehicle *v, VehicleOrderID sel_ord)
|
|||
* @param sel_ord the selected order to which we want to skip
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSkipToOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID sel_ord)
|
||||
CommandCost CmdSkipToOrder(DoCommandFlags flags, VehicleID veh_id, VehicleOrderID sel_ord)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(veh_id);
|
||||
|
||||
|
@ -1092,7 +1092,7 @@ CommandCost CmdSkipToOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID
|
|||
CommandCost ret = CheckOwnership(v->owner);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (v->current_order.IsType(OT_LOADING)) v->LeaveStation();
|
||||
|
||||
v->cur_implicit_order_index = v->cur_real_order_index = sel_ord;
|
||||
|
@ -1121,7 +1121,7 @@ CommandCost CmdSkipToOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID
|
|||
* @note The target order will move one place down in the orderlist
|
||||
* if you move the order upwards else it'll move it one place down
|
||||
*/
|
||||
CommandCost CmdMoveOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID moving_order, VehicleOrderID target_order)
|
||||
CommandCost CmdMoveOrder(DoCommandFlags flags, VehicleID veh, VehicleOrderID moving_order, VehicleOrderID target_order)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(veh);
|
||||
if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
||||
|
@ -1137,7 +1137,7 @@ CommandCost CmdMoveOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID movi
|
|||
/* Don't move an empty order */
|
||||
if (moving_one == nullptr) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
v->orders->MoveOrder(moving_order, target_order);
|
||||
|
||||
/* Update shared list */
|
||||
|
@ -1219,7 +1219,7 @@ CommandCost CmdMoveOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID movi
|
|||
* @param data the data to modify
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdModifyOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, ModifyOrderFlags mof, uint16_t data)
|
||||
CommandCost CmdModifyOrder(DoCommandFlags flags, VehicleID veh, VehicleOrderID sel_ord, ModifyOrderFlags mof, uint16_t data)
|
||||
{
|
||||
if (mof >= MOF_END) return CMD_ERROR;
|
||||
|
||||
|
@ -1338,7 +1338,7 @@ CommandCost CmdModifyOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID se
|
|||
break;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
switch (mof) {
|
||||
case MOF_NON_STOP:
|
||||
order->SetNonStopType((OrderNonStopFlags)data);
|
||||
|
@ -1504,7 +1504,7 @@ static bool CheckAircraftOrderDistance(const Aircraft *v_new, const Vehicle *v_o
|
|||
* @param veh_src source vehicle to clone orders from, if any (none for CO_UNSHARE)
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdCloneOrder(DoCommandFlag flags, CloneOptions action, VehicleID veh_dst, VehicleID veh_src)
|
||||
CommandCost CmdCloneOrder(DoCommandFlags flags, CloneOptions action, VehicleID veh_dst, VehicleID veh_src)
|
||||
{
|
||||
Vehicle *dst = Vehicle::GetIfValid(veh_dst);
|
||||
if (dst == nullptr || !dst->IsPrimaryVehicle()) return CMD_ERROR;
|
||||
|
@ -1551,7 +1551,7 @@ CommandCost CmdCloneOrder(DoCommandFlag flags, CloneOptions action, VehicleID ve
|
|||
return CommandCost(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* If the destination vehicle had a OrderList, destroy it.
|
||||
* We only reset the order indices, if the new orders are obviously different.
|
||||
* (We mainly do this to keep the order indices valid and in range.) */
|
||||
|
@ -1599,7 +1599,7 @@ CommandCost CmdCloneOrder(DoCommandFlag flags, CloneOptions action, VehicleID ve
|
|||
return CommandCost(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Order *first = nullptr;
|
||||
Order **order_dst;
|
||||
|
||||
|
@ -1646,7 +1646,7 @@ CommandCost CmdCloneOrder(DoCommandFlag flags, CloneOptions action, VehicleID ve
|
|||
* @param cargo CargoType
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdOrderRefit(DoCommandFlag flags, VehicleID veh, VehicleOrderID order_number, CargoType cargo)
|
||||
CommandCost CmdOrderRefit(DoCommandFlags flags, VehicleID veh, VehicleOrderID order_number, CargoType cargo)
|
||||
{
|
||||
if (cargo >= NUM_CARGO && cargo != CARGO_NO_REFIT && cargo != CARGO_AUTO_REFIT) return CMD_ERROR;
|
||||
|
||||
|
@ -1664,7 +1664,7 @@ CommandCost CmdOrderRefit(DoCommandFlag flags, VehicleID veh, VehicleOrderID ord
|
|||
|
||||
if (order->GetLoadType() & OLFB_NO_LOAD) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
order->SetRefit(cargo);
|
||||
|
||||
/* Make the depot order an 'always go' order. */
|
||||
|
@ -2016,7 +2016,7 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool
|
|||
v->current_order.SetDestination(closestDepot.destination);
|
||||
|
||||
/* If there is no depot in front, reverse automatically (trains only) */
|
||||
if (v->type == VEH_TRAIN && closestDepot.reverse) Command<CMD_REVERSE_TRAIN_DIRECTION>::Do(DC_EXEC, v->index, false);
|
||||
if (v->type == VEH_TRAIN && closestDepot.reverse) Command<CMD_REVERSE_TRAIN_DIRECTION>::Do(DoCommandFlag::Execute, v->index, false);
|
||||
|
||||
if (v->type == VEH_AIRCRAFT) {
|
||||
Aircraft *a = Aircraft::From(v);
|
||||
|
|
|
@ -14,14 +14,14 @@
|
|||
#include "order_base.h"
|
||||
#include "misc/endian_buffer.hpp"
|
||||
|
||||
CommandCost CmdModifyOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, ModifyOrderFlags mof, uint16_t data);
|
||||
CommandCost CmdSkipToOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID sel_ord);
|
||||
CommandCost CmdDeleteOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID sel_ord);
|
||||
CommandCost CmdInsertOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, const Order &new_order);
|
||||
CommandCost CmdOrderRefit(DoCommandFlag flags, VehicleID veh, VehicleOrderID order_number, CargoType cargo);
|
||||
CommandCost CmdCloneOrder(DoCommandFlag flags, CloneOptions action, VehicleID veh_dst, VehicleID veh_src);
|
||||
CommandCost CmdMoveOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID moving_order, VehicleOrderID target_order);
|
||||
CommandCost CmdClearOrderBackup(DoCommandFlag flags, TileIndex tile, ClientID user_id);
|
||||
CommandCost CmdModifyOrder(DoCommandFlags flags, VehicleID veh, VehicleOrderID sel_ord, ModifyOrderFlags mof, uint16_t data);
|
||||
CommandCost CmdSkipToOrder(DoCommandFlags flags, VehicleID veh_id, VehicleOrderID sel_ord);
|
||||
CommandCost CmdDeleteOrder(DoCommandFlags flags, VehicleID veh_id, VehicleOrderID sel_ord);
|
||||
CommandCost CmdInsertOrder(DoCommandFlags flags, VehicleID veh, VehicleOrderID sel_ord, const Order &new_order);
|
||||
CommandCost CmdOrderRefit(DoCommandFlags flags, VehicleID veh, VehicleOrderID order_number, CargoType cargo);
|
||||
CommandCost CmdCloneOrder(DoCommandFlags flags, CloneOptions action, VehicleID veh_dst, VehicleID veh_src);
|
||||
CommandCost CmdMoveOrder(DoCommandFlags flags, VehicleID veh, VehicleOrderID moving_order, VehicleOrderID target_order);
|
||||
CommandCost CmdClearOrderBackup(DoCommandFlags flags, TileIndex tile, ClientID user_id);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_MODIFY_ORDER, CmdModifyOrder, CMD_LOCATION, CMDT_ROUTE_MANAGEMENT)
|
||||
DEF_CMD_TRAIT(CMD_SKIP_TO_ORDER, CmdSkipToOrder, CMD_LOCATION, CMDT_ROUTE_MANAGEMENT)
|
||||
|
|
|
@ -423,7 +423,7 @@ static inline bool ValParamTrackOrientation(Track track)
|
|||
* @param auto_remove_signals false = error on signal in the way, true = auto remove signals when in the way
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildSingleRail(DoCommandFlag flags, TileIndex tile, RailType railtype, Track track, bool auto_remove_signals)
|
||||
CommandCost CmdBuildSingleRail(DoCommandFlags flags, TileIndex tile, RailType railtype, Track track, bool auto_remove_signals)
|
||||
{
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
|
||||
|
@ -475,7 +475,7 @@ CommandCost CmdBuildSingleRail(DoCommandFlag flags, TileIndex tile, RailType rai
|
|||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
SetRailGroundType(tile, RAIL_GROUND_BARREN);
|
||||
TrackBits bits = GetTrackBits(tile);
|
||||
SetTrackBits(tile, bits | trackbit);
|
||||
|
@ -540,7 +540,7 @@ CommandCost CmdBuildSingleRail(DoCommandFlag flags, TileIndex tile, RailType rai
|
|||
cost.AddCost(num_new_tram_pieces * RoadBuildCost(roadtype_tram));
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
MakeRoadCrossing(tile, road_owner, tram_owner, _current_company, (track == TRACK_X ? AXIS_Y : AXIS_X), railtype, roadtype_road, roadtype_tram, GetTownIndex(tile));
|
||||
UpdateLevelCrossing(tile, false);
|
||||
MarkDirtyAdjacentLevelCrossingTiles(tile, GetCrossingRoadAxis(tile));
|
||||
|
@ -582,7 +582,7 @@ CommandCost CmdBuildSingleRail(DoCommandFlag flags, TileIndex tile, RailType rai
|
|||
cost.AddCost(_price[PR_CLEAR_ROUGH]);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
MakeRailNormal(tile, _current_company, trackbit, railtype);
|
||||
if (water_ground) {
|
||||
SetRailGroundType(tile, RAIL_GROUND_WATER);
|
||||
|
@ -595,7 +595,7 @@ CommandCost CmdBuildSingleRail(DoCommandFlag flags, TileIndex tile, RailType rai
|
|||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
MarkTileDirtyByTile(tile);
|
||||
AddTrackToSignalBuffer(tile, track, _current_company);
|
||||
YapfNotifyTrackLayoutChange(tile, track);
|
||||
|
@ -612,7 +612,7 @@ CommandCost CmdBuildSingleRail(DoCommandFlag flags, TileIndex tile, RailType rai
|
|||
* @param track rail orientation
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRemoveSingleRail(DoCommandFlag flags, TileIndex tile, Track track)
|
||||
CommandCost CmdRemoveSingleRail(DoCommandFlags flags, TileIndex tile, Track track)
|
||||
{
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
bool crossing = false;
|
||||
|
@ -637,14 +637,14 @@ CommandCost CmdRemoveSingleRail(DoCommandFlag flags, TileIndex tile, Track track
|
|||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
if (!(flags & DC_BANKRUPT)) {
|
||||
if (!flags.Test(DoCommandFlag::Bankrupt)) {
|
||||
CommandCost ret = EnsureNoVehicleOnGround(tile);
|
||||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
cost.AddCost(RailClearCost(GetRailType(tile)));
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(tile, GetCrossingRoadAxis(tile));
|
||||
|
||||
if (HasReservedTracks(tile, trackbit)) {
|
||||
|
@ -685,7 +685,7 @@ CommandCost CmdRemoveSingleRail(DoCommandFlag flags, TileIndex tile, Track track
|
|||
cost.AddCost(Command<CMD_REMOVE_SINGLE_SIGNAL>::Do(flags, tile, track));
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (HasReservedTracks(tile, trackbit)) {
|
||||
v = GetTrainForReservation(tile, track);
|
||||
if (v != nullptr) FreeTrainTrackReservation(v);
|
||||
|
@ -726,7 +726,7 @@ CommandCost CmdRemoveSingleRail(DoCommandFlag flags, TileIndex tile, Track track
|
|||
default: return CommandCost(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* if we got that far, 'owner' variable is set correctly */
|
||||
assert(Company::IsValidID(owner));
|
||||
|
||||
|
@ -775,7 +775,7 @@ bool FloodHalftile(TileIndex t)
|
|||
TrackBits to_remove = lower_track & rail_bits;
|
||||
if (to_remove != TRACK_BIT_NONE) {
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_WATER);
|
||||
flooded = Command<CMD_REMOVE_SINGLE_RAIL>::Do(DC_EXEC, t, FindFirstTrack(to_remove)).Succeeded();
|
||||
flooded = Command<CMD_REMOVE_SINGLE_RAIL>::Do(DoCommandFlag::Execute, t, FindFirstTrack(to_remove)).Succeeded();
|
||||
cur_company.Restore();
|
||||
if (!flooded) return flooded; // not yet floodable
|
||||
rail_bits = rail_bits & ~to_remove;
|
||||
|
@ -873,7 +873,7 @@ static CommandCost ValidateAutoDrag(Trackdir *trackdir, TileIndex start, TileInd
|
|||
* @param fail_on_obstacle false = build starting from and up to an obstacle, true = fail if an obstacle is found (used for AIs)
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
static CommandCost CmdRailTrackHelper(DoCommandFlag flags, TileIndex tile, TileIndex end_tile, RailType railtype, Track track, bool remove, bool auto_remove_signals, bool fail_on_obstacle)
|
||||
static CommandCost CmdRailTrackHelper(DoCommandFlags flags, TileIndex tile, TileIndex end_tile, RailType railtype, Track track, bool remove, bool auto_remove_signals, bool fail_on_obstacle)
|
||||
{
|
||||
CommandCost total_cost(EXPENSES_CONSTRUCTION);
|
||||
|
||||
|
@ -929,7 +929,7 @@ static CommandCost CmdRailTrackHelper(DoCommandFlag flags, TileIndex tile, TileI
|
|||
|
||||
* @see CmdRailTrackHelper
|
||||
*/
|
||||
CommandCost CmdBuildRailroadTrack(DoCommandFlag flags, TileIndex end_tile, TileIndex start_tile, RailType railtype, Track track, bool auto_remove_signals, bool fail_on_obstacle)
|
||||
CommandCost CmdBuildRailroadTrack(DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, RailType railtype, Track track, bool auto_remove_signals, bool fail_on_obstacle)
|
||||
{
|
||||
return CmdRailTrackHelper(flags, start_tile, end_tile, railtype, track, false, auto_remove_signals, fail_on_obstacle);
|
||||
}
|
||||
|
@ -944,7 +944,7 @@ CommandCost CmdBuildRailroadTrack(DoCommandFlag flags, TileIndex end_tile, TileI
|
|||
* @return the cost of this operation or an error
|
||||
* @see CmdRailTrackHelper
|
||||
*/
|
||||
CommandCost CmdRemoveRailroadTrack(DoCommandFlag flags, TileIndex end_tile, TileIndex start_tile, Track track)
|
||||
CommandCost CmdRemoveRailroadTrack(DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, Track track)
|
||||
{
|
||||
return CmdRailTrackHelper(flags, start_tile, end_tile, INVALID_RAILTYPE, track, true, false, false);
|
||||
}
|
||||
|
@ -960,7 +960,7 @@ CommandCost CmdRemoveRailroadTrack(DoCommandFlag flags, TileIndex end_tile, Tile
|
|||
* @todo When checking for the tile slope,
|
||||
* distinguish between "Flat land required" and "land sloped in wrong direction"
|
||||
*/
|
||||
CommandCost CmdBuildTrainDepot(DoCommandFlag flags, TileIndex tile, RailType railtype, DiagDirection dir)
|
||||
CommandCost CmdBuildTrainDepot(DoCommandFlags flags, TileIndex tile, RailType railtype, DiagDirection dir)
|
||||
{
|
||||
/* check railtype and valid direction for depot (0 through 3), 4 in total */
|
||||
if (!ValParamRailType(railtype) || !IsValidDiagDirection(dir)) return CMD_ERROR;
|
||||
|
@ -1006,7 +1006,7 @@ CommandCost CmdBuildTrainDepot(DoCommandFlag flags, TileIndex tile, RailType rai
|
|||
if (!Depot::CanAllocateItem()) return CMD_ERROR;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (rotate_existing_depot) {
|
||||
SetRailDepotExitDirection(tile, dir);
|
||||
} else {
|
||||
|
@ -1049,7 +1049,7 @@ CommandCost CmdBuildTrainDepot(DoCommandFlag flags, TileIndex tile, RailType rai
|
|||
* @return the cost of this operation or an error
|
||||
* @todo p2 should be replaced by two bits for "along" and "against" the track.
|
||||
*/
|
||||
CommandCost CmdBuildSingleSignal(DoCommandFlag flags, 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_t num_dir_cycle, uint8_t signals_copy)
|
||||
CommandCost CmdBuildSingleSignal(DoCommandFlags flags, 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_t num_dir_cycle, uint8_t signals_copy)
|
||||
{
|
||||
if (sigtype > SIGTYPE_LAST || sigvar > SIG_SEMAPHORE) return CMD_ERROR;
|
||||
if (cycle_start > cycle_stop || cycle_stop > SIGTYPE_LAST) return CMD_ERROR;
|
||||
|
@ -1101,7 +1101,7 @@ CommandCost CmdBuildSingleSignal(DoCommandFlag flags, TileIndex tile, Track trac
|
|||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Train *v = nullptr;
|
||||
/* The new/changed signal could block our path. As this can lead to
|
||||
* stale reservations, we clear the path reservation here and try
|
||||
|
@ -1255,7 +1255,7 @@ static bool AdvanceSignalAutoFill(TileIndex &tile, Trackdir &trackdir, bool remo
|
|||
* @param signal_density user defined signals_density
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
static CommandCost CmdSignalTrackHelper(DoCommandFlag flags, TileIndex tile, TileIndex end_tile, Track track, SignalType sigtype, SignalVariant sigvar, bool mode, bool remove, bool autofill, bool minimise_gaps, int signal_density)
|
||||
static CommandCost CmdSignalTrackHelper(DoCommandFlags flags, TileIndex tile, TileIndex end_tile, Track track, SignalType sigtype, SignalVariant sigvar, bool mode, bool remove, bool autofill, bool minimise_gaps, int signal_density)
|
||||
{
|
||||
CommandCost total_cost(EXPENSES_CONSTRUCTION);
|
||||
|
||||
|
@ -1324,7 +1324,7 @@ static CommandCost CmdSignalTrackHelper(DoCommandFlag flags, TileIndex tile, Til
|
|||
if (HasBit(signal_dir, 0)) signals |= SignalAlongTrackdir(trackdir);
|
||||
if (HasBit(signal_dir, 1)) signals |= SignalAgainstTrackdir(trackdir);
|
||||
|
||||
DoCommandFlag do_flags = test_only ? flags & ~DC_EXEC : flags;
|
||||
DoCommandFlags do_flags = test_only ? DoCommandFlags{flags}.Reset(DoCommandFlag::Execute) : flags;
|
||||
CommandCost ret = remove ? Command<CMD_REMOVE_SINGLE_SIGNAL>::Do(do_flags, tile, TrackdirToTrack(trackdir)) : Command<CMD_BUILD_SINGLE_SIGNAL>::Do(do_flags, tile, TrackdirToTrack(trackdir), sigtype, sigvar, false, signal_ctr == 0, mode, SIGTYPE_BLOCK, SIGTYPE_BLOCK, 0, signals);
|
||||
|
||||
if (test_only) return ret.Succeeded();
|
||||
|
@ -1446,7 +1446,7 @@ static CommandCost CmdSignalTrackHelper(DoCommandFlag flags, TileIndex tile, Til
|
|||
* @return the cost of this operation or an error
|
||||
* @see CmdSignalTrackHelper
|
||||
*/
|
||||
CommandCost CmdBuildSignalTrack(DoCommandFlag flags, TileIndex tile, TileIndex end_tile, Track track, SignalType sigtype, SignalVariant sigvar, bool mode, bool autofill, bool minimise_gaps, uint8_t signal_density)
|
||||
CommandCost CmdBuildSignalTrack(DoCommandFlags flags, TileIndex tile, TileIndex end_tile, Track track, SignalType sigtype, SignalVariant sigvar, bool mode, bool autofill, bool minimise_gaps, uint8_t signal_density)
|
||||
{
|
||||
return CmdSignalTrackHelper(flags, tile, end_tile, track, sigtype, sigvar, mode, false, autofill, minimise_gaps, signal_density);
|
||||
}
|
||||
|
@ -1458,7 +1458,7 @@ CommandCost CmdBuildSignalTrack(DoCommandFlag flags, TileIndex tile, TileIndex e
|
|||
* @param track track-orientation
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRemoveSingleSignal(DoCommandFlag flags, TileIndex tile, Track track)
|
||||
CommandCost CmdRemoveSingleSignal(DoCommandFlags flags, TileIndex tile, Track track)
|
||||
{
|
||||
if (!ValParamTrackOrientation(track) || !IsPlainRailTile(tile) || !HasTrack(tile, track)) {
|
||||
return CommandCost(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
|
||||
|
@ -1474,7 +1474,7 @@ CommandCost CmdRemoveSingleSignal(DoCommandFlag flags, TileIndex tile, Track tra
|
|||
}
|
||||
|
||||
/* Do it? */
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Train *v = nullptr;
|
||||
if (HasReservedTracks(tile, TrackToTrackBits(track))) {
|
||||
v = GetTrainForReservation(tile, track);
|
||||
|
@ -1524,7 +1524,7 @@ CommandCost CmdRemoveSingleSignal(DoCommandFlag flags, TileIndex tile, Track tra
|
|||
* @return the cost of this operation or an error
|
||||
* @see CmdSignalTrackHelper
|
||||
*/
|
||||
CommandCost CmdRemoveSignalTrack(DoCommandFlag flags, TileIndex tile, TileIndex end_tile, Track track, bool autofill)
|
||||
CommandCost CmdRemoveSignalTrack(DoCommandFlags flags, TileIndex tile, TileIndex end_tile, Track track, bool autofill)
|
||||
{
|
||||
return CmdSignalTrackHelper(flags, tile, end_tile, track, SIGTYPE_BLOCK, SIG_ELECTRIC, false, true, autofill, false, 1); // bit 5 is remove bit
|
||||
}
|
||||
|
@ -1550,7 +1550,7 @@ static Vehicle *UpdateTrainPowerProc(Vehicle *v, void *data)
|
|||
* @param diagonal build diagonally or not.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_start, RailType totype, bool diagonal)
|
||||
CommandCost CmdConvertRail(DoCommandFlags flags, TileIndex tile, TileIndex area_start, RailType totype, bool diagonal)
|
||||
{
|
||||
TileIndex area_end = tile;
|
||||
|
||||
|
@ -1612,7 +1612,7 @@ CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if (flags & DC_EXEC) { // we can safely convert, too
|
||||
if (flags.Test(DoCommandFlag::Execute)) { // we can safely convert, too
|
||||
TrackBits reserved = GetReservedTrackbits(tile);
|
||||
Track track;
|
||||
while ((track = RemoveFirstTrack(&reserved)) != INVALID_TRACK) {
|
||||
|
@ -1649,7 +1649,7 @@ CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
|||
case MP_RAILWAY:
|
||||
switch (GetRailTileType(tile)) {
|
||||
case RAIL_TILE_DEPOT:
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* notify YAPF about the track layout change */
|
||||
YapfNotifyTrackLayoutChange(tile, GetRailDepotTrack(tile));
|
||||
|
||||
|
@ -1662,7 +1662,7 @@ CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
|||
break;
|
||||
|
||||
default: // RAIL_TILE_NORMAL, RAIL_TILE_SIGNALS
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* notify YAPF about the track layout change */
|
||||
TrackBits tracks = GetTrackBits(tile);
|
||||
while (tracks != TRACK_BIT_NONE) {
|
||||
|
@ -1697,7 +1697,7 @@ CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
|||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Track track = DiagDirToDiagTrack(GetTunnelBridgeDirection(tile));
|
||||
if (HasTunnelBridgeReservation(tile)) {
|
||||
Train *v = GetTrainForReservation(tile, track);
|
||||
|
@ -1738,7 +1738,7 @@ CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
|||
}
|
||||
|
||||
default: // MP_STATION, MP_ROAD
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Track track = ((tt == MP_STATION) ? GetRailStationTrack(tile) : GetCrossingRailTrack(tile));
|
||||
YapfNotifyTrackLayoutChange(tile, track);
|
||||
}
|
||||
|
@ -1753,7 +1753,7 @@ CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
|||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Railtype changed, update trains as when entering different track */
|
||||
for (Train *v : affected_trains) {
|
||||
v->ConsistChanged(CCF_TRACK);
|
||||
|
@ -1763,7 +1763,7 @@ CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
|||
return found_convertible_track ? cost : error;
|
||||
}
|
||||
|
||||
static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
if (_current_company != OWNER_WATER) {
|
||||
CommandCost ret = CheckTileOwnership(tile);
|
||||
|
@ -1773,7 +1773,7 @@ static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlag flags)
|
|||
CommandCost ret = EnsureNoVehicleOnGround(tile);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* read variables before the depot is removed */
|
||||
DiagDirection dir = GetRailDepotDirection(tile);
|
||||
Owner owner = GetTileOwner(tile);
|
||||
|
@ -1797,11 +1797,11 @@ static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlag flags)
|
|||
return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_DEPOT_TRAIN]);
|
||||
}
|
||||
|
||||
static CommandCost ClearTile_Track(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost ClearTile_Track(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
|
||||
if (flags & DC_AUTO) {
|
||||
if (flags.Test(DoCommandFlag::Auto)) {
|
||||
if (!IsTileOwner(tile, _current_company)) {
|
||||
return CommandCost(STR_ERROR_AREA_IS_OWNED_BY_ANOTHER);
|
||||
}
|
||||
|
@ -1830,12 +1830,12 @@ static CommandCost ClearTile_Track(TileIndex tile, DoCommandFlag flags)
|
|||
|
||||
/* When bankrupting, don't make water dirty, there could be a ship on lower halftile.
|
||||
* Same holds for non-companies clearing the tile, e.g. disasters. */
|
||||
if (water_ground && !(flags & DC_BANKRUPT) && Company::IsValidID(_current_company)) {
|
||||
if (water_ground && !flags.Test(DoCommandFlag::Bankrupt) && Company::IsValidID(_current_company)) {
|
||||
CommandCost ret = EnsureNoVehicleOnGround(tile);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
/* The track was removed, and left a coast tile. Now also clear the water. */
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
DoClearSquare(tile);
|
||||
}
|
||||
cost.AddCost(_price[PR_CLEAR_WATER]);
|
||||
|
@ -2898,7 +2898,7 @@ static void ChangeTileOwner_Track(TileIndex tile, Owner old_owner, Owner new_own
|
|||
|
||||
SetTileOwner(tile, new_owner);
|
||||
} else {
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC | DC_BANKRUPT, tile);
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2994,7 +2994,7 @@ static VehicleEnterTileStatus VehicleEnter_Track(Vehicle *u, TileIndex tile, int
|
|||
* @param tileh_new New TileSlope.
|
||||
* @param rail_bits Trackbits.
|
||||
*/
|
||||
static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, int z_old, Slope tileh_old, int z_new, Slope tileh_new, TrackBits rail_bits)
|
||||
static CommandCost TestAutoslopeOnRailTile(TileIndex tile, DoCommandFlags flags, int z_old, Slope tileh_old, int z_new, Slope tileh_new, TrackBits rail_bits)
|
||||
{
|
||||
if (!_settings_game.construction.build_on_slopes || !AutoslopeEnabled()) return CommandCost(STR_ERROR_MUST_REMOVE_RAILROAD_TRACK);
|
||||
|
||||
|
@ -3028,7 +3028,7 @@ static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, int z_old
|
|||
if (tileh_old != tileh_new) {
|
||||
/* If there is flat water on the lower halftile add the cost for clearing it */
|
||||
if (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh_old)) cost.AddCost(_price[PR_CLEAR_WATER]);
|
||||
if ((flags & DC_EXEC) != 0) SetRailGroundType(tile, RAIL_GROUND_BARREN);
|
||||
if (flags.Test(DoCommandFlag::Execute)) SetRailGroundType(tile, RAIL_GROUND_BARREN);
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
@ -3041,7 +3041,7 @@ static Vehicle *EnsureNoShipProc(Vehicle *v, void *)
|
|||
return v->type == VEH_SHIP ? v : nullptr;
|
||||
}
|
||||
|
||||
static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
|
||||
static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new)
|
||||
{
|
||||
auto [tileh_old, z_old] = GetTileSlopeZ(tile);
|
||||
if (IsPlainRail(tile)) {
|
||||
|
@ -3077,7 +3077,7 @@ static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlag flags, int
|
|||
}
|
||||
|
||||
/* Make the ground dirty */
|
||||
if ((flags & DC_EXEC) != 0) SetRailGroundType(tile, RAIL_GROUND_BARREN);
|
||||
if (flags.Test(DoCommandFlag::Execute)) SetRailGroundType(tile, RAIL_GROUND_BARREN);
|
||||
|
||||
/* allow terraforming */
|
||||
return CommandCost(EXPENSES_CONSTRUCTION, was_water ? _price[PR_CLEAR_WATER] : (Money)0);
|
||||
|
|
|
@ -15,16 +15,16 @@
|
|||
#include "rail_type.h"
|
||||
#include "signal_type.h"
|
||||
|
||||
CommandCost CmdBuildRailroadTrack(DoCommandFlag flags, TileIndex end_tile, TileIndex start_tile, RailType railtype, Track track, bool auto_remove_signals, bool fail_on_obstacle);
|
||||
CommandCost CmdRemoveRailroadTrack(DoCommandFlag flags, TileIndex end_tile, TileIndex start_tile, Track track);
|
||||
CommandCost CmdBuildSingleRail(DoCommandFlag flags, TileIndex tile, RailType railtype, Track track, bool auto_remove_signals);
|
||||
CommandCost CmdRemoveSingleRail(DoCommandFlag flags, TileIndex tile, Track track);
|
||||
CommandCost CmdBuildTrainDepot(DoCommandFlag flags, TileIndex tile, RailType railtype, DiagDirection dir);
|
||||
CommandCost CmdBuildSingleSignal(DoCommandFlag flags, 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_t num_dir_cycle, uint8_t signals_copy);
|
||||
CommandCost CmdRemoveSingleSignal(DoCommandFlag flags, TileIndex tile, Track track);
|
||||
CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_start, RailType totype, bool diagonal);
|
||||
CommandCost CmdBuildSignalTrack(DoCommandFlag flags, TileIndex tile, TileIndex end_tile, Track track, SignalType sigtype, SignalVariant sigvar, bool mode, bool autofill, bool minimise_gaps, uint8_t signal_density);
|
||||
CommandCost CmdRemoveSignalTrack(DoCommandFlag flags, TileIndex tile, TileIndex end_tile, Track track, bool autofill);
|
||||
CommandCost CmdBuildRailroadTrack(DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, RailType railtype, Track track, bool auto_remove_signals, bool fail_on_obstacle);
|
||||
CommandCost CmdRemoveRailroadTrack(DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, Track track);
|
||||
CommandCost CmdBuildSingleRail(DoCommandFlags flags, TileIndex tile, RailType railtype, Track track, bool auto_remove_signals);
|
||||
CommandCost CmdRemoveSingleRail(DoCommandFlags flags, TileIndex tile, Track track);
|
||||
CommandCost CmdBuildTrainDepot(DoCommandFlags flags, TileIndex tile, RailType railtype, DiagDirection dir);
|
||||
CommandCost CmdBuildSingleSignal(DoCommandFlags flags, 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_t num_dir_cycle, uint8_t signals_copy);
|
||||
CommandCost CmdRemoveSingleSignal(DoCommandFlags flags, TileIndex tile, Track track);
|
||||
CommandCost CmdConvertRail(DoCommandFlags flags, TileIndex tile, TileIndex area_start, RailType totype, bool diagonal);
|
||||
CommandCost CmdBuildSignalTrack(DoCommandFlags flags, TileIndex tile, TileIndex end_tile, Track track, SignalType sigtype, SignalVariant sigvar, bool mode, bool autofill, bool minimise_gaps, uint8_t signal_density);
|
||||
CommandCost CmdRemoveSignalTrack(DoCommandFlags flags, TileIndex tile, TileIndex end_tile, Track track, bool autofill);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_BUILD_RAILROAD_TRACK, CmdBuildRailroadTrack, CMD_AUTO | CMD_NO_WATER, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
DEF_CMD_TRAIT(CMD_REMOVE_RAILROAD_TRACK, CmdRemoveRailroadTrack, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
|
|
|
@ -809,7 +809,7 @@ struct BuildRailToolbarWindow : Window {
|
|||
|
||||
void OnPlacePresize([[maybe_unused]] Point pt, TileIndex tile) override
|
||||
{
|
||||
Command<CMD_BUILD_TUNNEL>::Do(DC_AUTO, tile, TRANSPORT_RAIL, _cur_railtype);
|
||||
Command<CMD_BUILD_TUNNEL>::Do(DoCommandFlag::Auto, tile, TRANSPORT_RAIL, _cur_railtype);
|
||||
VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
|
||||
}
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ static Foundation GetRoadFoundation(Slope tileh, RoadBits bits);
|
|||
* @param town_check Shall the town rating checked/affected
|
||||
* @return A succeeded command when it is allowed to remove the road bits, a failed command otherwise.
|
||||
*/
|
||||
CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadTramType rtt, DoCommandFlag flags, bool town_check)
|
||||
CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadTramType rtt, DoCommandFlags flags, bool town_check)
|
||||
{
|
||||
if (_game_mode == GM_EDITOR || remove == ROAD_NONE) return CommandCost();
|
||||
|
||||
|
@ -322,7 +322,7 @@ CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, R
|
|||
* @param rt roadtype to remove
|
||||
* @param town_check should we check if the town allows removal?
|
||||
*/
|
||||
static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits pieces, RoadTramType rtt, bool town_check)
|
||||
static CommandCost RemoveRoad(TileIndex tile, DoCommandFlags flags, RoadBits pieces, RoadTramType rtt, bool town_check)
|
||||
{
|
||||
assert(pieces != ROAD_NONE);
|
||||
|
||||
|
@ -372,7 +372,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
|
|||
/* Pay for *every* tile of the bridge or tunnel */
|
||||
uint len = GetTunnelBridgeLength(other_end, tile) + 2;
|
||||
cost.AddCost(len * 2 * RoadClearCost(existing_rt));
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* A full diagonal road tile has two road bits. */
|
||||
UpdateCompanyRoadInfrastructure(existing_rt, GetRoadOwner(tile, rtt), -(int)(len * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR));
|
||||
|
||||
|
@ -398,7 +398,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
|
|||
} else {
|
||||
assert(IsDriveThroughStopTile(tile));
|
||||
cost.AddCost(RoadClearCost(existing_rt) * 2);
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* A full diagonal road tile has two road bits. */
|
||||
UpdateCompanyRoadInfrastructure(existing_rt, GetRoadOwner(tile, rtt), -2);
|
||||
SetRoadType(tile, rtt, INVALID_ROADTYPE);
|
||||
|
@ -444,7 +444,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
|
|||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (HasRoadWorks(tile)) {
|
||||
/* flooding tile with road works, don't forget to remove the effect vehicle too */
|
||||
assert(_current_company == OWNER_WATER);
|
||||
|
@ -495,7 +495,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
|
|||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(tile, GetCrossingRoadAxis(tile));
|
||||
|
||||
/* A full diagonal road tile has two road bits. */
|
||||
|
@ -607,7 +607,7 @@ static CommandCost CheckRoadSlope(Slope tileh, RoadBits *pieces, RoadBits existi
|
|||
* @param town_id the town that is building the road (INVALID_TOWN if not applicable)
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildRoad(DoCommandFlag flags, TileIndex tile, RoadBits pieces, RoadType rt, DisallowedRoadDirections toggle_drd, TownID town_id)
|
||||
CommandCost CmdBuildRoad(DoCommandFlags flags, TileIndex tile, RoadBits pieces, RoadType rt, DisallowedRoadDirections toggle_drd, TownID town_id)
|
||||
{
|
||||
CompanyID company = _current_company;
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
|
@ -679,7 +679,7 @@ CommandCost CmdBuildRoad(DoCommandFlag flags, TileIndex tile, RoadBits pieces, R
|
|||
}
|
||||
|
||||
/* Ignore half built tiles */
|
||||
if ((flags & DC_EXEC) && IsStraightRoad(existing)) {
|
||||
if (flags.Test(DoCommandFlag::Execute) && IsStraightRoad(existing)) {
|
||||
SetDisallowedRoadDirections(tile, dis_new);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
|
@ -762,7 +762,7 @@ CommandCost CmdBuildRoad(DoCommandFlag flags, TileIndex tile, RoadBits pieces, R
|
|||
CommandCost ret = EnsureNoVehicleOnGround(tile);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Track railtrack = AxisToTrack(OtherAxis(roaddir));
|
||||
YapfNotifyTrackLayoutChange(tile, railtrack);
|
||||
/* Update company infrastructure counts. A level crossing has two road bits. */
|
||||
|
@ -882,7 +882,7 @@ do_clear:;
|
|||
|
||||
cost.AddCost(num_pieces * RoadBuildCost(rt));
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
switch (GetTileType(tile)) {
|
||||
case MP_ROAD: {
|
||||
RoadTileType rttype = GetRoadTileType(tile);
|
||||
|
@ -976,7 +976,7 @@ static bool CanConnectToRoad(TileIndex tile, RoadType rt, DiagDirection dir)
|
|||
* - true = Fail if an obstacle is found. Always take into account start_half and end_half. This behavior is used for scripts
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, DisallowedRoadDirections drd, bool start_half, bool end_half, bool is_ai)
|
||||
CommandCost CmdBuildLongRoad(DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, DisallowedRoadDirections drd, bool start_half, bool end_half, bool is_ai)
|
||||
{
|
||||
if (start_tile >= Map::Size()) return CMD_ERROR;
|
||||
|
||||
|
@ -1072,7 +1072,7 @@ CommandCost CmdBuildLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex
|
|||
* @param end_half end tile starts in the 2nd half of tile (p2 & 2)
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
std::tuple<CommandCost, Money> CmdRemoveLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, bool start_half, bool end_half)
|
||||
std::tuple<CommandCost, Money> CmdRemoveLongRoad(DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, bool start_half, bool end_half)
|
||||
{
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
|
||||
|
@ -1104,12 +1104,12 @@ std::tuple<CommandCost, Money> CmdRemoveLongRoad(DoCommandFlag flags, TileIndex
|
|||
/* try to remove the halves. */
|
||||
if (bits != 0) {
|
||||
RoadTramType rtt = GetRoadTramType(rt);
|
||||
CommandCost ret = RemoveRoad(tile, flags & ~DC_EXEC, bits, rtt, true);
|
||||
CommandCost ret = RemoveRoad(tile, DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), bits, rtt, true);
|
||||
if (ret.Succeeded()) {
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
money_spent += ret.GetCost();
|
||||
if (money_spent > 0 && money_spent > money_available) {
|
||||
return { cost, std::get<0>(Command<CMD_REMOVE_LONG_ROAD>::Do(flags & ~DC_EXEC, end_tile, start_tile, rt, axis, start_half, end_half)).GetCost() };
|
||||
return { cost, std::get<0>(Command<CMD_REMOVE_LONG_ROAD>::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), end_tile, start_tile, rt, axis, start_half, end_half)).GetCost() };
|
||||
}
|
||||
RemoveRoad(tile, flags, bits, rtt, false);
|
||||
}
|
||||
|
@ -1146,7 +1146,7 @@ std::tuple<CommandCost, Money> CmdRemoveLongRoad(DoCommandFlag flags, TileIndex
|
|||
* @todo When checking for the tile slope,
|
||||
* distinguish between "Flat land required" and "land sloped in wrong direction"
|
||||
*/
|
||||
CommandCost CmdBuildRoadDepot(DoCommandFlag flags, TileIndex tile, RoadType rt, DiagDirection dir)
|
||||
CommandCost CmdBuildRoadDepot(DoCommandFlags flags, TileIndex tile, RoadType rt, DiagDirection dir)
|
||||
{
|
||||
if (!ValParamRoadType(rt) || !IsValidDiagDirection(dir)) return CMD_ERROR;
|
||||
|
||||
|
@ -1184,7 +1184,7 @@ CommandCost CmdBuildRoadDepot(DoCommandFlag flags, TileIndex tile, RoadType rt,
|
|||
if (!Depot::CanAllocateItem()) return CMD_ERROR;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (rotate_existing_depot) {
|
||||
SetRoadDepotExitDirection(tile, dir);
|
||||
} else {
|
||||
|
@ -1204,7 +1204,7 @@ CommandCost CmdBuildRoadDepot(DoCommandFlag flags, TileIndex tile, RoadType rt,
|
|||
return cost;
|
||||
}
|
||||
|
||||
static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
if (_current_company != OWNER_WATER) {
|
||||
CommandCost ret = CheckTileOwnership(tile);
|
||||
|
@ -1214,7 +1214,7 @@ static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags)
|
|||
CommandCost ret = EnsureNoVehicleOnGround(tile);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Company *c = Company::GetIfValid(GetTileOwner(tile));
|
||||
if (c != nullptr) {
|
||||
/* A road depot has two road bits. */
|
||||
|
@ -1231,14 +1231,14 @@ static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags)
|
|||
return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_DEPOT_ROAD]);
|
||||
}
|
||||
|
||||
static CommandCost ClearTile_Road(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost ClearTile_Road(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
switch (GetRoadTileType(tile)) {
|
||||
case ROAD_TILE_NORMAL: {
|
||||
RoadBits b = GetAllRoadBits(tile);
|
||||
|
||||
/* Clear the road if only one piece is on the tile OR we are not using the DC_AUTO flag */
|
||||
if ((HasExactlyOneBit(b) && GetRoadBits(tile, RTT_TRAM) == ROAD_NONE) || !(flags & DC_AUTO)) {
|
||||
/* Clear the road if only one piece is on the tile OR we are not using the DoCommandFlag::Auto flag */
|
||||
if ((HasExactlyOneBit(b) && GetRoadBits(tile, RTT_TRAM) == ROAD_NONE) || !flags.Test(DoCommandFlag::Auto)) {
|
||||
CommandCost ret(EXPENSES_CONSTRUCTION);
|
||||
for (RoadTramType rtt : _roadtramtypes) {
|
||||
if (!MayHaveRoad(tile) || GetRoadType(tile, rtt) == INVALID_ROADTYPE) continue;
|
||||
|
@ -1255,7 +1255,7 @@ static CommandCost ClearTile_Road(TileIndex tile, DoCommandFlag flags)
|
|||
case ROAD_TILE_CROSSING: {
|
||||
CommandCost ret(EXPENSES_CONSTRUCTION);
|
||||
|
||||
if (flags & DC_AUTO) return CommandCost(STR_ERROR_MUST_REMOVE_ROAD_FIRST);
|
||||
if (flags.Test(DoCommandFlag::Auto)) return CommandCost(STR_ERROR_MUST_REMOVE_ROAD_FIRST);
|
||||
|
||||
/* Must iterate over the roadtypes in a reverse manner because
|
||||
* tram tracks must be removed before the road bits. */
|
||||
|
@ -1267,7 +1267,7 @@ static CommandCost ClearTile_Road(TileIndex tile, DoCommandFlag flags)
|
|||
ret.AddCost(tmp_ret);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile);
|
||||
}
|
||||
return ret;
|
||||
|
@ -1275,7 +1275,7 @@ static CommandCost ClearTile_Road(TileIndex tile, DoCommandFlag flags)
|
|||
|
||||
default:
|
||||
case ROAD_TILE_DEPOT:
|
||||
if (flags & DC_AUTO) {
|
||||
if (flags.Test(DoCommandFlag::Auto)) {
|
||||
return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
|
||||
}
|
||||
return RemoveRoadDepot(tile, flags);
|
||||
|
@ -2058,7 +2058,7 @@ static void TileLoop_Road(TileIndex tile)
|
|||
const RoadBits new_rb = CleanUpRoadBits(tile, old_rb);
|
||||
|
||||
if (old_rb != new_rb) {
|
||||
RemoveRoad(tile, DC_EXEC | DC_AUTO | DC_NO_WATER, (old_rb ^ new_rb), RTT_ROAD, true);
|
||||
RemoveRoad(tile, {DoCommandFlag::Execute, DoCommandFlag::Auto, DoCommandFlag::NoWater}, (old_rb ^ new_rb), RTT_ROAD, true);
|
||||
|
||||
/* If new_rb is 0, there are now no road pieces left and the tile is no longer a road tile */
|
||||
if (new_rb == 0) {
|
||||
|
@ -2289,7 +2289,7 @@ static void ChangeTileOwner_Road(TileIndex tile, Owner old_owner, Owner new_owne
|
|||
if (IsRoadDepot(tile)) {
|
||||
if (GetTileOwner(tile) == old_owner) {
|
||||
if (new_owner == INVALID_OWNER) {
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC | DC_BANKRUPT, tile);
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile);
|
||||
} else {
|
||||
/* A road depot has two road bits. No need to dirty windows here, we'll redraw the whole screen anyway. */
|
||||
RoadType rt = GetRoadTypeRoad(tile);
|
||||
|
@ -2326,7 +2326,7 @@ static void ChangeTileOwner_Road(TileIndex tile, Owner old_owner, Owner new_owne
|
|||
if (IsLevelCrossing(tile)) {
|
||||
if (GetTileOwner(tile) == old_owner) {
|
||||
if (new_owner == INVALID_OWNER) {
|
||||
Command<CMD_REMOVE_SINGLE_RAIL>::Do(DC_EXEC | DC_BANKRUPT, tile, GetCrossingRailTrack(tile));
|
||||
Command<CMD_REMOVE_SINGLE_RAIL>::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile, GetCrossingRailTrack(tile));
|
||||
} else {
|
||||
/* Update infrastructure counts. No need to dirty windows here, we'll redraw the whole screen anyway. */
|
||||
Company::Get(old_owner)->infrastructure.rail[GetRailType(tile)] -= LEVELCROSSING_TRACKBIT_FACTOR;
|
||||
|
@ -2338,7 +2338,7 @@ static void ChangeTileOwner_Road(TileIndex tile, Owner old_owner, Owner new_owne
|
|||
}
|
||||
}
|
||||
|
||||
static CommandCost TerraformTile_Road(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
|
||||
static CommandCost TerraformTile_Road(TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new)
|
||||
{
|
||||
if (_settings_game.construction.build_on_slopes && AutoslopeEnabled()) {
|
||||
switch (GetRoadTileType(tile)) {
|
||||
|
@ -2442,7 +2442,7 @@ static void ConvertRoadTypeOwner(TileIndex tile, uint num_pieces, Owner owner, R
|
|||
* @param to_type new roadtype to convert to.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdConvertRoad(DoCommandFlag flags, TileIndex tile, TileIndex area_start, RoadType to_type)
|
||||
CommandCost CmdConvertRoad(DoCommandFlags flags, TileIndex tile, TileIndex area_start, RoadType to_type)
|
||||
{
|
||||
TileIndex area_end = tile;
|
||||
|
||||
|
@ -2497,7 +2497,7 @@ CommandCost CmdConvertRoad(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
|||
* acceptance of destructive actions. */
|
||||
if (owner == OWNER_TOWN) {
|
||||
Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
|
||||
CommandCost ret = CheckforTownRating(DC_NONE, t, tt == MP_TUNNELBRIDGE ? TUNNELBRIDGE_REMOVE : ROAD_REMOVE);
|
||||
CommandCost ret = CheckforTownRating({}, t, tt == MP_TUNNELBRIDGE ? TUNNELBRIDGE_REMOVE : ROAD_REMOVE);
|
||||
if (ret.Failed()) {
|
||||
error = ret;
|
||||
continue;
|
||||
|
@ -2531,7 +2531,7 @@ CommandCost CmdConvertRoad(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
|||
found_convertible_road = true;
|
||||
cost.AddCost(num_pieces * RoadConvertCost(from_type, to_type));
|
||||
|
||||
if (flags & DC_EXEC) { // we can safely convert, too
|
||||
if (flags.Test(DoCommandFlag::Execute)) { // we can safely convert, too
|
||||
/* Call ConvertRoadTypeOwner() to update the company infrastructure counters. */
|
||||
if (owner == _current_company) {
|
||||
ConvertRoadTypeOwner(tile, num_pieces, owner, from_type, to_type);
|
||||
|
@ -2579,7 +2579,7 @@ CommandCost CmdConvertRoad(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
|||
found_convertible_road = true;
|
||||
cost.AddCost(num_pieces * RoadConvertCost(from_type, to_type));
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Update the company infrastructure counters. */
|
||||
if (owner == _current_company) {
|
||||
/* Each piece should be counted TUNNELBRIDGE_TRACKBIT_FACTOR times
|
||||
|
@ -2605,7 +2605,7 @@ CommandCost CmdConvertRoad(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
|||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Roadtype changed, update roadvehicles as when entering different track */
|
||||
for (RoadVehicle *v : affected_rvs) {
|
||||
v->CargoChanged();
|
||||
|
|
|
@ -19,11 +19,11 @@ enum RoadStopClassID : uint16_t;
|
|||
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt);
|
||||
void UpdateNearestTownForRoadTiles(bool invalidate);
|
||||
|
||||
CommandCost CmdBuildLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, DisallowedRoadDirections drd, bool start_half, bool end_half, bool is_ai);
|
||||
std::tuple<CommandCost, Money> CmdRemoveLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, bool start_half, bool end_half);
|
||||
CommandCost CmdBuildRoad(DoCommandFlag flags, TileIndex tile, RoadBits pieces, RoadType rt, DisallowedRoadDirections toggle_drd, TownID town_id);
|
||||
CommandCost CmdBuildRoadDepot(DoCommandFlag flags, TileIndex tile, RoadType rt, DiagDirection dir);
|
||||
CommandCost CmdConvertRoad(DoCommandFlag flags, TileIndex tile, TileIndex area_start, RoadType to_type);
|
||||
CommandCost CmdBuildLongRoad(DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, DisallowedRoadDirections drd, bool start_half, bool end_half, bool is_ai);
|
||||
std::tuple<CommandCost, Money> CmdRemoveLongRoad(DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, bool start_half, bool end_half);
|
||||
CommandCost CmdBuildRoad(DoCommandFlags flags, TileIndex tile, RoadBits pieces, RoadType rt, DisallowedRoadDirections toggle_drd, TownID town_id);
|
||||
CommandCost CmdBuildRoadDepot(DoCommandFlags flags, TileIndex tile, RoadType rt, DiagDirection dir);
|
||||
CommandCost CmdConvertRoad(DoCommandFlags flags, TileIndex tile, TileIndex area_start, RoadType to_type);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_BUILD_LONG_ROAD, CmdBuildLongRoad, CMD_AUTO | CMD_NO_WATER | CMD_DEITY, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
DEF_CMD_TRAIT(CMD_REMOVE_LONG_ROAD, CmdRemoveLongRoad, CMD_AUTO | CMD_NO_TEST, CMDT_LANDSCAPE_CONSTRUCTION) // towns may disallow removing road bits (as they are connected) in test, but in exec they're removed and thus removing is allowed.
|
||||
|
|
|
@ -814,7 +814,7 @@ struct BuildRoadToolbarWindow : Window {
|
|||
|
||||
void OnPlacePresize([[maybe_unused]] Point pt, TileIndex tile) override
|
||||
{
|
||||
Command<CMD_BUILD_TUNNEL>::Do(DC_AUTO, tile, TRANSPORT_ROAD, _cur_roadtype);
|
||||
Command<CMD_BUILD_TUNNEL>::Do(DoCommandFlag::Auto, tile, TRANSPORT_ROAD, _cur_roadtype);
|
||||
VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
RoadBits CleanUpRoadBits(const TileIndex tile, RoadBits org_rb);
|
||||
|
||||
CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadTramType rtt, DoCommandFlag flags, bool town_check = true);
|
||||
CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadTramType rtt, DoCommandFlags flags, bool town_check = true);
|
||||
|
||||
void DrawRoadCatenary(const TileInfo *ti);
|
||||
|
||||
|
|
|
@ -258,14 +258,14 @@ void RoadVehUpdateCache(RoadVehicle *v, bool same_length)
|
|||
* @param[out] ret the vehicle that has been built.
|
||||
* @return the cost of this operation or an error.
|
||||
*/
|
||||
CommandCost CmdBuildRoadVehicle(DoCommandFlag flags, TileIndex tile, const Engine *e, Vehicle **ret)
|
||||
CommandCost CmdBuildRoadVehicle(DoCommandFlags flags, TileIndex tile, const Engine *e, Vehicle **ret)
|
||||
{
|
||||
/* Check that the vehicle can drive on the road in question */
|
||||
RoadType rt = e->u.road.roadtype;
|
||||
const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
|
||||
if (!HasTileAnyRoadType(tile, rti->powered_roadtypes)) return CommandCost(STR_ERROR_DEPOT_WRONG_DEPOT_TYPE);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
const RoadVehicleInfo *rvi = &e->u.road;
|
||||
|
||||
RoadVehicle *v = new RoadVehicle();
|
||||
|
@ -358,7 +358,7 @@ ClosestDepot RoadVehicle::FindClosestDepot()
|
|||
* @param veh_id vehicle ID to turn
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdTurnRoadVeh(DoCommandFlag flags, VehicleID veh_id)
|
||||
CommandCost CmdTurnRoadVeh(DoCommandFlags flags, VehicleID veh_id)
|
||||
{
|
||||
RoadVehicle *v = RoadVehicle::GetIfValid(veh_id);
|
||||
if (v == nullptr) return CMD_ERROR;
|
||||
|
@ -382,7 +382,7 @@ CommandCost CmdTurnRoadVeh(DoCommandFlag flags, VehicleID veh_id)
|
|||
|
||||
if (IsTileType(v->tile, MP_TUNNELBRIDGE) && DirToDiagDir(v->direction) == GetTunnelBridgeDirection(v->tile)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
v->reverse_ctr = 180;
|
||||
|
||||
/* Unbunching data is no longer valid. */
|
||||
|
@ -1126,7 +1126,7 @@ static bool CanBuildTramTrackOnTile(CompanyID c, TileIndex t, RoadType rt, RoadB
|
|||
/* The 'current' company is not necessarily the owner of the vehicle. */
|
||||
Backup<CompanyID> cur_company(_current_company, c);
|
||||
|
||||
CommandCost ret = Command<CMD_BUILD_ROAD>::Do(DC_NO_WATER, t, r, rt, DRD_NONE, INVALID_TOWN);
|
||||
CommandCost ret = Command<CMD_BUILD_ROAD>::Do(DoCommandFlag::NoWater, t, r, rt, DRD_NONE, INVALID_TOWN);
|
||||
|
||||
cur_company.Restore();
|
||||
return ret.Succeeded();
|
||||
|
|
|
@ -18,9 +18,9 @@ bool RoadVehLeaveDepot(RoadVehicle *v, bool first);
|
|||
bool IndividualRoadVehicleController(RoadVehicle *v, const RoadVehicle *prev);
|
||||
bool RoadVehiclesAreBuilt();
|
||||
|
||||
CommandCost CmdBuildRoadVehicle(DoCommandFlag flags, TileIndex tile, const Engine *e, Vehicle **v);
|
||||
CommandCost CmdBuildRoadVehicle(DoCommandFlags flags, TileIndex tile, const Engine *e, Vehicle **v);
|
||||
|
||||
CommandCost CmdTurnRoadVeh(DoCommandFlag flags, VehicleID veh_id);
|
||||
CommandCost CmdTurnRoadVeh(DoCommandFlags flags, VehicleID veh_id);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_TURN_ROADVEH, CmdTurnRoadVeh, CMD_LOCATION, CMDT_VEHICLE_MANAGEMENT)
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ protected:
|
|||
* @tparam Targs The command parameter types.
|
||||
*/
|
||||
template <Commands Tcmd, typename Tret, typename... Targs>
|
||||
struct ScriptDoCommandHelper<Tcmd, Tret(*)(DoCommandFlag, Targs...)> {
|
||||
struct ScriptDoCommandHelper<Tcmd, Tret(*)(DoCommandFlags, Targs...)> {
|
||||
static bool Do(Script_SuspendCallbackProc *callback, Targs... args)
|
||||
{
|
||||
return Execute(callback, std::forward_as_tuple(args...));
|
||||
|
@ -377,7 +377,7 @@ namespace ScriptObjectInternal {
|
|||
}
|
||||
|
||||
template <Commands Tcmd, typename Tret, typename... Targs>
|
||||
bool ScriptObject::ScriptDoCommandHelper<Tcmd, Tret(*)(DoCommandFlag, Targs...)>::Execute(Script_SuspendCallbackProc *callback, std::tuple<Targs...> args)
|
||||
bool ScriptObject::ScriptDoCommandHelper<Tcmd, Tret(*)(DoCommandFlags, Targs...)>::Execute(Script_SuspendCallbackProc *callback, std::tuple<Targs...> args)
|
||||
{
|
||||
auto [err, estimate_only, asynchronous, networking] = ScriptObject::DoCommandPrep();
|
||||
if (err) return false;
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
if (!ScriptEngine::IsBuildable(engine_id)) return -1;
|
||||
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
||||
|
||||
auto [res, veh_id, refit_capacity, refit_mail, cargo_capacities] = ::Command<CMD_BUILD_VEHICLE>::Do(DC_QUERY_COST, depot, engine_id, true, cargo, INVALID_CLIENT_ID);
|
||||
auto [res, veh_id, refit_capacity, refit_mail, cargo_capacities] = ::Command<CMD_BUILD_VEHICLE>::Do(DoCommandFlag::QueryCost, depot, engine_id, true, cargo, INVALID_CLIENT_ID);
|
||||
return res.Succeeded() ? refit_capacity : -1;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@
|
|||
if (!IsValidVehicle(vehicle_id)) return -1;
|
||||
if (!ScriptCargo::IsValidCargo(cargo)) return -1;
|
||||
|
||||
auto [res, refit_capacity, refit_mail, cargo_capacities] = ::Command<CMD_REFIT_VEHICLE>::Do(DC_QUERY_COST, vehicle_id, cargo, 0, false, false, 0);
|
||||
auto [res, refit_capacity, refit_mail, cargo_capacities] = ::Command<CMD_REFIT_VEHICLE>::Do(DoCommandFlag::QueryCost, vehicle_id, cargo, 0, false, false, 0);
|
||||
return res.Succeeded() ? refit_capacity : -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1724,7 +1724,7 @@ std::vector<const SettingDesc *> GetFilteredSettingCollection(std::function<bool
|
|||
* @return the cost of this operation or an error
|
||||
* @see _settings
|
||||
*/
|
||||
CommandCost CmdChangeSetting(DoCommandFlag flags, const std::string &name, int32_t value)
|
||||
CommandCost CmdChangeSetting(DoCommandFlags flags, const std::string &name, int32_t value)
|
||||
{
|
||||
if (name.empty()) return CMD_ERROR;
|
||||
const SettingDesc *sd = GetSettingFromName(name);
|
||||
|
@ -1735,7 +1735,7 @@ CommandCost CmdChangeSetting(DoCommandFlag flags, const std::string &name, int32
|
|||
|
||||
if (!sd->IsEditable(true)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
sd->AsIntSetting()->ChangeValue(&GetGameSettings(), value);
|
||||
}
|
||||
|
||||
|
@ -1750,7 +1750,7 @@ CommandCost CmdChangeSetting(DoCommandFlag flags, const std::string &name, int32
|
|||
* The new value is properly clamped to its minimum/maximum when setting
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdChangeCompanySetting(DoCommandFlag flags, const std::string &name, int32_t value)
|
||||
CommandCost CmdChangeCompanySetting(DoCommandFlags flags, const std::string &name, int32_t value)
|
||||
{
|
||||
if (name.empty()) return CMD_ERROR;
|
||||
const SettingDesc *sd = GetCompanySettingFromName(name);
|
||||
|
@ -1758,7 +1758,7 @@ CommandCost CmdChangeCompanySetting(DoCommandFlag flags, const std::string &name
|
|||
if (sd == nullptr) return CMD_ERROR;
|
||||
if (!sd->IsIntSetting()) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
sd->AsIntSetting()->ChangeValue(&Company::Get(_current_company)->settings, value);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
|
||||
#include "command_type.h"
|
||||
|
||||
CommandCost CmdChangeSetting(DoCommandFlag flags, const std::string &name, int32_t value);
|
||||
CommandCost CmdChangeCompanySetting(DoCommandFlag flags, const std::string &name, int32_t value);
|
||||
CommandCost CmdChangeSetting(DoCommandFlags flags, const std::string &name, int32_t value);
|
||||
CommandCost CmdChangeCompanySetting(DoCommandFlags flags, const std::string &name, int32_t value);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_CHANGE_SETTING, CmdChangeSetting, CMD_SERVER, CMDT_SERVER_SETTING)
|
||||
DEF_CMD_TRAIT(CMD_CHANGE_COMPANY_SETTING, CmdChangeCompanySetting, 0, CMDT_COMPANY_SETTING)
|
||||
|
|
|
@ -892,10 +892,10 @@ void Ship::SetDestTile(TileIndex tile)
|
|||
* @param[out] ret the vehicle that has been built.
|
||||
* @return the cost of this operation or an error.
|
||||
*/
|
||||
CommandCost CmdBuildShip(DoCommandFlag flags, TileIndex tile, const Engine *e, Vehicle **ret)
|
||||
CommandCost CmdBuildShip(DoCommandFlags flags, TileIndex tile, const Engine *e, Vehicle **ret)
|
||||
{
|
||||
tile = GetShipDepotNorthTile(tile);
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
int x;
|
||||
int y;
|
||||
|
||||
|
|
|
@ -14,6 +14,6 @@
|
|||
#include "engine_type.h"
|
||||
#include "vehicle_type.h"
|
||||
|
||||
CommandCost CmdBuildShip(DoCommandFlag flags, TileIndex tile, const Engine *e, Vehicle **v);
|
||||
CommandCost CmdBuildShip(DoCommandFlags flags, TileIndex tile, const Engine *e, Vehicle **v);
|
||||
|
||||
#endif /* SHIP_CMD_H */
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
* @param text contents of the sign
|
||||
* @return the cost of this operation + the ID of the new sign or an error
|
||||
*/
|
||||
std::tuple<CommandCost, SignID> CmdPlaceSign(DoCommandFlag flags, TileIndex tile, const std::string &text)
|
||||
std::tuple<CommandCost, SignID> CmdPlaceSign(DoCommandFlags flags, TileIndex tile, const std::string &text)
|
||||
{
|
||||
/* Try to locate a new sign */
|
||||
if (!Sign::CanAllocateItem()) return { CommandCost(STR_ERROR_TOO_MANY_SIGNS), INVALID_SIGN };
|
||||
|
@ -41,7 +41,7 @@ std::tuple<CommandCost, SignID> CmdPlaceSign(DoCommandFlag flags, TileIndex tile
|
|||
if (Utf8StringLength(text) >= MAX_LENGTH_SIGN_NAME_CHARS) return { CMD_ERROR, INVALID_SIGN };
|
||||
|
||||
/* When we execute, really make the sign */
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Sign *si = new Sign(_game_mode == GM_EDITOR ? OWNER_DEITY : _current_company);
|
||||
int x = TileX(tile) * TILE_SIZE;
|
||||
int y = TileY(tile) * TILE_SIZE;
|
||||
|
@ -69,7 +69,7 @@ std::tuple<CommandCost, SignID> CmdPlaceSign(DoCommandFlag flags, TileIndex tile
|
|||
* @param text the new name or an empty string when resetting to the default
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRenameSign(DoCommandFlag flags, SignID sign_id, const std::string &text)
|
||||
CommandCost CmdRenameSign(DoCommandFlags flags, SignID sign_id, const std::string &text)
|
||||
{
|
||||
Sign *si = Sign::GetIfValid(sign_id);
|
||||
if (si == nullptr) return CMD_ERROR;
|
||||
|
@ -79,7 +79,7 @@ CommandCost CmdRenameSign(DoCommandFlag flags, SignID sign_id, const std::string
|
|||
if (!text.empty()) {
|
||||
if (Utf8StringLength(text) >= MAX_LENGTH_SIGN_NAME_CHARS) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Assign the new one */
|
||||
si->name = text;
|
||||
if (_game_mode != GM_EDITOR) si->owner = _current_company;
|
||||
|
@ -88,7 +88,7 @@ CommandCost CmdRenameSign(DoCommandFlag flags, SignID sign_id, const std::string
|
|||
InvalidateWindowData(WC_SIGN_LIST, 0, 1);
|
||||
}
|
||||
} else { // Delete sign
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
si->sign.MarkDirty();
|
||||
if (si->sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeSign(si->index));
|
||||
delete si;
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#include "command_type.h"
|
||||
#include "signs_type.h"
|
||||
|
||||
std::tuple<CommandCost, SignID> CmdPlaceSign(DoCommandFlag flags, TileIndex tile, const std::string &text);
|
||||
CommandCost CmdRenameSign(DoCommandFlag flags, SignID sign_id, const std::string &text);
|
||||
std::tuple<CommandCost, SignID> CmdPlaceSign(DoCommandFlags flags, TileIndex tile, const std::string &text);
|
||||
CommandCost CmdRenameSign(DoCommandFlags flags, SignID sign_id, const std::string &text);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_PLACE_SIGN, CmdPlaceSign, CMD_DEITY, CMDT_OTHER_MANAGEMENT)
|
||||
DEF_CMD_TRAIT(CMD_RENAME_SIGN, CmdRenameSign, CMD_DEITY, CMDT_OTHER_MANAGEMENT)
|
||||
|
|
|
@ -696,7 +696,7 @@ static void UpdateStationSignCoord(BaseStation *st)
|
|||
* @param name_class Station naming class to use to generate the new station's name
|
||||
* @return Command error that occurred, if any
|
||||
*/
|
||||
static CommandCost BuildStationPart(Station **st, DoCommandFlag flags, bool reuse, TileArea area, StationNaming name_class)
|
||||
static CommandCost BuildStationPart(Station **st, DoCommandFlags flags, bool reuse, TileArea area, StationNaming name_class)
|
||||
{
|
||||
/* Find a deleted station close to us */
|
||||
if (*st == nullptr && reuse) *st = GetClosestDeletedStation(area.tile);
|
||||
|
@ -712,7 +712,7 @@ static CommandCost BuildStationPart(Station **st, DoCommandFlag flags, bool reus
|
|||
/* allocate and initialize new station */
|
||||
if (!Station::CanAllocateItem()) return CommandCost(STR_ERROR_TOO_MANY_STATIONS_LOADING);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
*st = new Station(area.tile);
|
||||
_station_kdtree.Insert((*st)->index);
|
||||
|
||||
|
@ -787,7 +787,7 @@ void Station::AfterStationTileSetChange(bool adding, StationType type)
|
|||
|
||||
}
|
||||
|
||||
CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags);
|
||||
CommandCost ClearTile_Station(TileIndex tile, DoCommandFlags flags);
|
||||
|
||||
/**
|
||||
* Checks if the given tile is buildable, flat and has a certain height.
|
||||
|
@ -847,7 +847,7 @@ CommandCost CheckBuildableTile(TileIndex tile, uint invalid_dirs, int &allowed_z
|
|||
* @param flags Operation to perform.
|
||||
* @return The cost in case of success, or an error code if it failed.
|
||||
*/
|
||||
static CommandCost CheckFlatLandAirport(AirportTileTableIterator tile_iter, DoCommandFlag flags)
|
||||
static CommandCost CheckFlatLandAirport(AirportTileTableIterator tile_iter, DoCommandFlags flags)
|
||||
{
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
int allowed_z = -1;
|
||||
|
@ -881,7 +881,7 @@ static CommandCost CheckFlatLandAirport(AirportTileTableIterator tile_iter, DoCo
|
|||
* @param numtracks Number of platforms.
|
||||
* @return The cost in case of success, or an error code if it failed.
|
||||
*/
|
||||
static CommandCost CheckFlatLandRailStation(TileIndex tile_cur, TileIndex north_tile, int &allowed_z, DoCommandFlag flags, Axis axis, StationID *station, RailType rt, std::vector<Train *> &affected_vehicles, StationClassID spec_class, uint16_t spec_index, uint8_t plat_len, uint8_t numtracks)
|
||||
static CommandCost CheckFlatLandRailStation(TileIndex tile_cur, TileIndex north_tile, int &allowed_z, DoCommandFlags flags, Axis axis, StationID *station, RailType rt, std::vector<Train *> &affected_vehicles, StationClassID spec_class, uint16_t spec_index, uint8_t plat_len, uint8_t numtracks)
|
||||
{
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
uint invalid_dirs = 5 << axis;
|
||||
|
@ -904,7 +904,7 @@ static CommandCost CheckFlatLandRailStation(TileIndex tile_cur, TileIndex north_
|
|||
* Or it points to a station if we're only allowed to build on exactly that station. */
|
||||
if (station != nullptr && IsTileType(tile_cur, MP_STATION)) {
|
||||
if (!IsRailStation(tile_cur)) {
|
||||
return ClearTile_Station(tile_cur, DC_AUTO); // get error message
|
||||
return ClearTile_Station(tile_cur, DoCommandFlag::Auto); // get error message
|
||||
} else {
|
||||
StationID st = GetStationIndex(tile_cur);
|
||||
if (*station == INVALID_STATION) {
|
||||
|
@ -937,7 +937,7 @@ static CommandCost CheckFlatLandRailStation(TileIndex tile_cur, TileIndex north_
|
|||
ret = Command<CMD_REMOVE_SINGLE_RAIL>::Do(flags, tile_cur, track);
|
||||
if (ret.Failed()) return ret;
|
||||
cost.AddCost(ret);
|
||||
/* With flags & ~DC_EXEC CmdLandscapeClear would fail since the rail still exists */
|
||||
/* With DoCommandFlags{flags}.Reset(DoCommandFlag::Execute) CmdLandscapeClear would fail since the rail still exists */
|
||||
return cost;
|
||||
}
|
||||
}
|
||||
|
@ -963,7 +963,7 @@ static CommandCost CheckFlatLandRailStation(TileIndex tile_cur, TileIndex north_
|
|||
* @param rt Road type to build, may be INVALID_ROADTYPE if an existing road is required.
|
||||
* @return The cost in case of success, or an error code if it failed.
|
||||
*/
|
||||
CommandCost CheckFlatLandRoadStop(TileIndex cur_tile, int &allowed_z, DoCommandFlag flags, uint invalid_dirs, bool is_drive_through, StationType station_type, Axis axis, StationID *station, RoadType rt)
|
||||
CommandCost CheckFlatLandRoadStop(TileIndex cur_tile, int &allowed_z, DoCommandFlags flags, uint invalid_dirs, bool is_drive_through, StationType station_type, Axis axis, StationID *station, RoadType rt)
|
||||
{
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
|
||||
|
@ -976,11 +976,11 @@ CommandCost CheckFlatLandRoadStop(TileIndex cur_tile, int &allowed_z, DoCommandF
|
|||
* Or it points to a station if we're only allowed to build on exactly that station. */
|
||||
if (station != nullptr && IsTileType(cur_tile, MP_STATION)) {
|
||||
if (!IsAnyRoadStop(cur_tile)) {
|
||||
return ClearTile_Station(cur_tile, DC_AUTO); // Get error message.
|
||||
return ClearTile_Station(cur_tile, DoCommandFlag::Auto); // Get error message.
|
||||
} else {
|
||||
if (station_type != GetStationType(cur_tile) ||
|
||||
is_drive_through != IsDriveThroughStopTile(cur_tile)) {
|
||||
return ClearTile_Station(cur_tile, DC_AUTO); // Get error message.
|
||||
return ClearTile_Station(cur_tile, DoCommandFlag::Auto); // Get error message.
|
||||
}
|
||||
/* Drive-through station in the wrong direction. */
|
||||
if (is_drive_through && IsDriveThroughStopTile(cur_tile) && GetDriveThroughStopAxis(cur_tile) != axis) {
|
||||
|
@ -1264,7 +1264,7 @@ static void RestoreTrainReservation(Train *v)
|
|||
* @param numtracks Number of platforms.
|
||||
* @return The cost in case of success, or an error code if it failed.
|
||||
*/
|
||||
static CommandCost CalculateRailStationCost(TileArea tile_area, DoCommandFlag flags, Axis axis, StationID *station, RailType rt, std::vector<Train *> &affected_vehicles, StationClassID spec_class, uint16_t spec_index, uint8_t plat_len, uint8_t numtracks)
|
||||
static CommandCost CalculateRailStationCost(TileArea tile_area, DoCommandFlags flags, Axis axis, StationID *station, RailType rt, std::vector<Train *> &affected_vehicles, StationClassID spec_class, uint16_t spec_index, uint8_t plat_len, uint8_t numtracks)
|
||||
{
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
bool length_price_ready = true;
|
||||
|
@ -1339,7 +1339,7 @@ void SetRailStationTileFlags(TileIndex tile, const StationSpec *statspec)
|
|||
* @param adjacent allow stations directly adjacent to other stations.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailType rt, Axis axis, uint8_t numtracks, uint8_t plat_len, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
|
||||
CommandCost CmdBuildRailStation(DoCommandFlags flags, TileIndex tile_org, RailType rt, Axis axis, uint8_t numtracks, uint8_t plat_len, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
|
||||
{
|
||||
/* Does the authority allow this? */
|
||||
CommandCost ret = CheckIfAuthorityAllowsNewStation(tile_org, flags);
|
||||
|
@ -1395,7 +1395,7 @@ CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailTyp
|
|||
|
||||
/* Check if we can allocate a custom stationspec to this station */
|
||||
const StationSpec *statspec = StationClass::Get(spec_class)->GetSpec(spec_index);
|
||||
int specindex = AllocateSpecToStation(statspec, st, (flags & DC_EXEC) != 0);
|
||||
int specindex = AllocateSpecToStation(statspec, st, flags.Test(DoCommandFlag::Execute));
|
||||
if (specindex == -1) return CommandCost(STR_ERROR_TOO_MANY_STATION_SPECS);
|
||||
|
||||
if (statspec != nullptr) {
|
||||
|
@ -1412,7 +1412,7 @@ CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailTyp
|
|||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
st->train_station = new_location;
|
||||
st->AddFacility(StationFacility::Train, new_location.tile);
|
||||
|
||||
|
@ -1637,7 +1637,7 @@ void MakeRoadWaypointStationAreaSmaller(BaseStation *st, TileArea &road_waypoint
|
|||
* @return the number of cleared tiles or an error.
|
||||
*/
|
||||
template <class T>
|
||||
CommandCost RemoveFromRailBaseStation(TileArea ta, std::vector<T *> &affected_stations, DoCommandFlag flags, Money removal_cost, bool keep_rail)
|
||||
CommandCost RemoveFromRailBaseStation(TileArea ta, std::vector<T *> &affected_stations, DoCommandFlags flags, Money removal_cost, bool keep_rail)
|
||||
{
|
||||
/* Count of the number of tiles removed */
|
||||
int quantity = 0;
|
||||
|
@ -1676,7 +1676,7 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, std::vector<T *> &affected_st
|
|||
total_cost.AddCost(-_price[PR_CLEAR_RAIL]);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* read variables before the station tile is removed */
|
||||
uint specindex = GetCustomStationSpecIndex(tile);
|
||||
Track track = GetRailStationTrack(tile);
|
||||
|
@ -1744,7 +1744,7 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, std::vector<T *> &affected_st
|
|||
* @param keep_rail if set keep the rail
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRemoveFromRailStation(DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail)
|
||||
CommandCost CmdRemoveFromRailStation(DoCommandFlags flags, TileIndex start, TileIndex end, bool keep_rail)
|
||||
{
|
||||
if (end == 0) end = start;
|
||||
if (start >= Map::Size() || end >= Map::Size()) return CMD_ERROR;
|
||||
|
@ -1777,7 +1777,7 @@ CommandCost CmdRemoveFromRailStation(DoCommandFlag flags, TileIndex start, TileI
|
|||
* @param keep_rail if set keep the rail
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRemoveFromRailWaypoint(DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail)
|
||||
CommandCost CmdRemoveFromRailWaypoint(DoCommandFlags flags, TileIndex start, TileIndex end, bool keep_rail)
|
||||
{
|
||||
if (end == 0) end = start;
|
||||
if (start >= Map::Size() || end >= Map::Size()) return CMD_ERROR;
|
||||
|
@ -1798,7 +1798,7 @@ CommandCost CmdRemoveFromRailWaypoint(DoCommandFlag flags, TileIndex start, Tile
|
|||
* @return cost or failure of operation
|
||||
*/
|
||||
template <class T>
|
||||
CommandCost RemoveRailStation(T *st, DoCommandFlag flags, Money removal_cost)
|
||||
CommandCost RemoveRailStation(T *st, DoCommandFlags flags, Money removal_cost)
|
||||
{
|
||||
/* Current company owns the station? */
|
||||
if (_current_company != OWNER_WATER) {
|
||||
|
@ -1832,17 +1832,17 @@ CommandCost RemoveRailStation(T *st, DoCommandFlag flags, Money removal_cost)
|
|||
* @param flags operation to perform
|
||||
* @return cost or failure of operation
|
||||
*/
|
||||
static CommandCost RemoveRailStation(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost RemoveRailStation(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
/* if there is flooding, remove platforms tile by tile */
|
||||
if (_current_company == OWNER_WATER) {
|
||||
return Command<CMD_REMOVE_FROM_RAIL_STATION>::Do(DC_EXEC, tile, TileIndex{}, false);
|
||||
return Command<CMD_REMOVE_FROM_RAIL_STATION>::Do(DoCommandFlag::Execute, tile, TileIndex{}, false);
|
||||
}
|
||||
|
||||
Station *st = Station::GetByTile(tile);
|
||||
CommandCost cost = RemoveRailStation(st, flags, _price[PR_CLEAR_STATION_RAIL]);
|
||||
|
||||
if (flags & DC_EXEC) st->RecomputeCatchment();
|
||||
if (flags.Test(DoCommandFlag::Execute)) st->RecomputeCatchment();
|
||||
|
||||
return cost;
|
||||
}
|
||||
|
@ -1853,11 +1853,11 @@ static CommandCost RemoveRailStation(TileIndex tile, DoCommandFlag flags)
|
|||
* @param flags operation to perform
|
||||
* @return cost or failure of operation
|
||||
*/
|
||||
static CommandCost RemoveRailWaypoint(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost RemoveRailWaypoint(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
/* if there is flooding, remove waypoints tile by tile */
|
||||
if (_current_company == OWNER_WATER) {
|
||||
return Command<CMD_REMOVE_FROM_RAIL_WAYPOINT>::Do(DC_EXEC, tile, TileIndex{}, false);
|
||||
return Command<CMD_REMOVE_FROM_RAIL_WAYPOINT>::Do(DoCommandFlag::Execute, tile, TileIndex{}, false);
|
||||
}
|
||||
|
||||
return RemoveRailStation(Waypoint::GetByTile(tile), flags, _price[PR_CLEAR_WAYPOINT_RAIL]);
|
||||
|
@ -1884,8 +1884,8 @@ static RoadStop **FindRoadStopSpot(bool truck_station, Station *st)
|
|||
}
|
||||
}
|
||||
|
||||
static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags, int replacement_spec_index = -1);
|
||||
CommandCost RemoveRoadWaypointStop(TileIndex tile, DoCommandFlag flags, int replacement_spec_index = -1);
|
||||
static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlags flags, int replacement_spec_index = -1);
|
||||
CommandCost RemoveRoadWaypointStop(TileIndex tile, DoCommandFlags flags, int replacement_spec_index = -1);
|
||||
|
||||
/**
|
||||
* Find a nearby station that joins this road stop.
|
||||
|
@ -1914,7 +1914,7 @@ static CommandCost FindJoiningRoadStop(StationID existing_stop, StationID statio
|
|||
* @param unit_cost The cost to build one road stop of the current type.
|
||||
* @return The cost in case of success, or an error code if it failed.
|
||||
*/
|
||||
CommandCost CalculateRoadStopCost(TileArea tile_area, DoCommandFlag flags, bool is_drive_through, StationType station_type, Axis axis, DiagDirection ddir, StationID *est, RoadType rt, Money unit_cost)
|
||||
CommandCost CalculateRoadStopCost(TileArea tile_area, DoCommandFlags flags, bool is_drive_through, StationType station_type, Axis axis, DiagDirection ddir, StationID *est, RoadType rt, Money unit_cost)
|
||||
{
|
||||
uint invalid_dirs = 0;
|
||||
if (is_drive_through) {
|
||||
|
@ -1959,7 +1959,7 @@ CommandCost CalculateRoadStopCost(TileArea tile_area, DoCommandFlag flags, bool
|
|||
* @param adjacent Allow stations directly adjacent to other stations.
|
||||
* @return The cost of this operation or an error.
|
||||
*/
|
||||
CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t length, RoadStopType stop_type, bool is_drive_through,
|
||||
CommandCost CmdBuildRoadStop(DoCommandFlags flags, TileIndex tile, uint8_t width, uint8_t length, RoadStopType stop_type, bool is_drive_through,
|
||||
DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
|
||||
{
|
||||
if (!ValParamRoadType(rt) || !IsValidDiagDirection(ddir) || stop_type >= RoadStopType::End) return CMD_ERROR;
|
||||
|
@ -2023,7 +2023,7 @@ CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width,
|
|||
if (ret.Failed()) return ret;
|
||||
|
||||
/* Check if we can allocate a custom stationspec to this station */
|
||||
int specindex = AllocateSpecToRoadStop(roadstopspec, st, (flags & DC_EXEC) != 0);
|
||||
int specindex = AllocateSpecToRoadStop(roadstopspec, st, flags.Test(DoCommandFlag::Execute));
|
||||
if (specindex == -1) return CommandCost(STR_ERROR_TOO_MANY_STATION_SPECS);
|
||||
|
||||
if (roadstopspec != nullptr) {
|
||||
|
@ -2036,7 +2036,7 @@ CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width,
|
|||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Check every tile in the area. */
|
||||
for (TileIndex cur_tile : roadstop_area) {
|
||||
/* Get existing road types and owners before any tile clearing */
|
||||
|
@ -2135,7 +2135,7 @@ static Vehicle *ClearRoadStopStatusEnum(Vehicle *v, void *)
|
|||
* @param replacement_spec_index replacement spec index to avoid deallocating, if < 0, tile is not being replaced
|
||||
* @return cost or failure of operation
|
||||
*/
|
||||
static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags, int replacement_spec_index)
|
||||
static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlags flags, int replacement_spec_index)
|
||||
{
|
||||
Station *st = Station::GetByTile(tile);
|
||||
|
||||
|
@ -2159,9 +2159,9 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags, int repla
|
|||
assert(cur_stop != nullptr);
|
||||
|
||||
/* don't do the check for drive-through road stops when company bankrupts */
|
||||
if (IsDriveThroughStopTile(tile) && (flags & DC_BANKRUPT)) {
|
||||
if (IsDriveThroughStopTile(tile) && flags.Test(DoCommandFlag::Bankrupt)) {
|
||||
/* remove the 'going through road stop' status from all vehicles on that tile */
|
||||
if (flags & DC_EXEC) FindVehicleOnPos(tile, nullptr, &ClearRoadStopStatusEnum);
|
||||
if (flags.Test(DoCommandFlag::Execute)) FindVehicleOnPos(tile, nullptr, &ClearRoadStopStatusEnum);
|
||||
} else {
|
||||
CommandCost ret = EnsureNoVehicleOnGround(tile);
|
||||
if (ret.Failed()) return ret;
|
||||
|
@ -2169,7 +2169,7 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags, int repla
|
|||
|
||||
const RoadStopSpec *spec = GetRoadStopSpec(tile);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (*primary_stop == cur_stop) {
|
||||
/* removed the first stop in the list */
|
||||
*primary_stop = cur_stop->next;
|
||||
|
@ -2249,7 +2249,7 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags, int repla
|
|||
* @param replacement_spec_index replacement spec index to avoid deallocating, if < 0, tile is not being replaced
|
||||
* @return cost or failure of operation
|
||||
*/
|
||||
CommandCost RemoveRoadWaypointStop(TileIndex tile, DoCommandFlag flags, int replacement_spec_index)
|
||||
CommandCost RemoveRoadWaypointStop(TileIndex tile, DoCommandFlags flags, int replacement_spec_index)
|
||||
{
|
||||
Waypoint *wp = Waypoint::GetByTile(tile);
|
||||
|
||||
|
@ -2259,14 +2259,14 @@ CommandCost RemoveRoadWaypointStop(TileIndex tile, DoCommandFlag flags, int repl
|
|||
}
|
||||
|
||||
/* Ignore vehicles when the company goes bankrupt. The road will remain, any vehicles going to the waypoint will be removed. */
|
||||
if (!(flags & DC_BANKRUPT)) {
|
||||
if (!flags.Test(DoCommandFlag::Bankrupt)) {
|
||||
CommandCost ret = EnsureNoVehicleOnGround(tile);
|
||||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
const RoadStopSpec *spec = GetRoadStopSpec(tile);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Update company infrastructure counts. */
|
||||
for (RoadTramType rtt : _roadtramtypes) {
|
||||
RoadType rt = GetRoadType(tile, rtt);
|
||||
|
@ -2313,7 +2313,7 @@ CommandCost RemoveRoadWaypointStop(TileIndex tile, DoCommandFlag flags, int repl
|
|||
* @param remove_road Remove roads of drive-through stops?
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
static CommandCost RemoveGenericRoadStop(DoCommandFlag flags, const TileArea &roadstop_area, bool road_waypoint, bool remove_road)
|
||||
static CommandCost RemoveGenericRoadStop(DoCommandFlags flags, const TileArea &roadstop_area, bool road_waypoint, bool remove_road)
|
||||
{
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
CommandCost last_error(STR_ERROR_THERE_IS_NO_STATION);
|
||||
|
@ -2352,7 +2352,7 @@ static CommandCost RemoveGenericRoadStop(DoCommandFlag flags, const TileArea &ro
|
|||
had_success = true;
|
||||
|
||||
/* Restore roads. */
|
||||
if ((flags & DC_EXEC) && (road_type[RTT_ROAD] != INVALID_ROADTYPE || road_type[RTT_TRAM] != INVALID_ROADTYPE)) {
|
||||
if (flags.Test(DoCommandFlag::Execute) && (road_type[RTT_ROAD] != INVALID_ROADTYPE || road_type[RTT_TRAM] != INVALID_ROADTYPE)) {
|
||||
MakeRoadNormal(cur_tile, road_bits, road_type[RTT_ROAD], road_type[RTT_TRAM], ClosestTownFromTile(cur_tile, UINT_MAX)->index,
|
||||
road_owner[RTT_ROAD], road_owner[RTT_TRAM]);
|
||||
|
||||
|
@ -2376,7 +2376,7 @@ static CommandCost RemoveGenericRoadStop(DoCommandFlag flags, const TileArea &ro
|
|||
* @param remove_road Remove roads of drive-through stops?
|
||||
* @return The cost of this operation or an error.
|
||||
*/
|
||||
CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t height, RoadStopType stop_type, bool remove_road)
|
||||
CommandCost CmdRemoveRoadStop(DoCommandFlags flags, TileIndex tile, uint8_t width, uint8_t height, RoadStopType stop_type, bool remove_road)
|
||||
{
|
||||
if (stop_type >= RoadStopType::End) return CMD_ERROR;
|
||||
/* Check for incorrect width / height. */
|
||||
|
@ -2384,7 +2384,7 @@ CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width
|
|||
/* Check if the first tile and the last tile are valid */
|
||||
if (!IsValidTile(tile) || TileAddWrap(tile, width - 1, height - 1) == INVALID_TILE) return CMD_ERROR;
|
||||
/* Bankrupting company is not supposed to remove roads, there may be road vehicles. */
|
||||
if (remove_road && (flags & DC_BANKRUPT)) return CMD_ERROR;
|
||||
if (remove_road && flags.Test(DoCommandFlag::Bankrupt)) return CMD_ERROR;
|
||||
|
||||
TileArea roadstop_area(tile, width, height);
|
||||
|
||||
|
@ -2398,7 +2398,7 @@ CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width
|
|||
* @param end other edge of the rect to remove
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRemoveFromRoadWaypoint(DoCommandFlag flags, TileIndex start, TileIndex end)
|
||||
CommandCost CmdRemoveFromRoadWaypoint(DoCommandFlags flags, TileIndex start, TileIndex end)
|
||||
{
|
||||
if (end == 0) end = start;
|
||||
if (start >= Map::Size() || end >= Map::Size()) return CMD_ERROR;
|
||||
|
@ -2520,7 +2520,7 @@ void UpdateAirportsNoise()
|
|||
* @param allow_adjacent allow airports directly adjacent to other airports.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildAirport(DoCommandFlag flags, TileIndex tile, uint8_t airport_type, uint8_t layout, StationID station_to_join, bool allow_adjacent)
|
||||
CommandCost CmdBuildAirport(DoCommandFlags flags, TileIndex tile, uint8_t airport_type, uint8_t layout, StationID station_to_join, bool allow_adjacent)
|
||||
{
|
||||
bool reuse = (station_to_join != NEW_STATION);
|
||||
if (!reuse) station_to_join = INVALID_STATION;
|
||||
|
@ -2602,7 +2602,7 @@ CommandCost CmdBuildAirport(DoCommandFlag flags, TileIndex tile, uint8_t airport
|
|||
cost.AddCost(_price[PR_BUILD_STATION_AIRPORT]);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Always add the noise, so there will be no need to recalculate when option toggles */
|
||||
nearest->noise_reached += newnoise_level;
|
||||
|
||||
|
@ -2649,7 +2649,7 @@ CommandCost CmdBuildAirport(DoCommandFlag flags, TileIndex tile, uint8_t airport
|
|||
* @param flags operation to perform
|
||||
* @return cost or failure of operation
|
||||
*/
|
||||
static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost RemoveAirport(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
Station *st = Station::GetByTile(tile);
|
||||
|
||||
|
@ -2669,7 +2669,7 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
|
|||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
for (uint i = 0; i < st->airport.GetNumHangars(); ++i) {
|
||||
TileIndex tile_cur = st->airport.GetHangarTile(i);
|
||||
OrderBackup::Reset(tile_cur, false);
|
||||
|
@ -2696,13 +2696,13 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
|
|||
|
||||
cost.AddCost(_price[PR_CLEAR_STATION_AIRPORT]);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
DoClearSquare(tile_cur);
|
||||
DeleteNewGRFInspectWindow(GSF_AIRPORTTILES, tile_cur.base());
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Clear the persistent storage. */
|
||||
delete st->airport.psa;
|
||||
|
||||
|
@ -2730,7 +2730,7 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
|
|||
* @param station_id Station ID of the airport.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdOpenCloseAirport(DoCommandFlag flags, StationID station_id)
|
||||
CommandCost CmdOpenCloseAirport(DoCommandFlags flags, StationID station_id)
|
||||
{
|
||||
if (!Station::IsValidID(station_id)) return CMD_ERROR;
|
||||
Station *st = Station::Get(station_id);
|
||||
|
@ -2740,7 +2740,7 @@ CommandCost CmdOpenCloseAirport(DoCommandFlag flags, StationID station_id)
|
|||
CommandCost ret = CheckOwnership(st->owner);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
st->airport.blocks.Flip(AirportBlock::AirportClosed);
|
||||
SetWindowWidgetDirty(WC_STATION_VIEW, st->index, WID_SV_CLOSE_AIRPORT);
|
||||
}
|
||||
|
@ -2786,7 +2786,7 @@ static const uint8_t _dock_h_chk[4] = { 1, 2, 1, 2 };
|
|||
* @param adjacent allow docks directly adjacent to other docks.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildDock(DoCommandFlag flags, TileIndex tile, StationID station_to_join, bool adjacent)
|
||||
CommandCost CmdBuildDock(DoCommandFlags flags, TileIndex tile, StationID station_to_join, bool adjacent)
|
||||
{
|
||||
bool reuse = (station_to_join != NEW_STATION);
|
||||
if (!reuse) station_to_join = INVALID_STATION;
|
||||
|
@ -2846,7 +2846,7 @@ CommandCost CmdBuildDock(DoCommandFlag flags, TileIndex tile, StationID station_
|
|||
ret = BuildStationPart(&st, flags, reuse, dock_area, STATIONNAMING_DOCK);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
st->ship_station.Add(tile);
|
||||
TileIndex flat_tile = tile + TileOffsByDiagDir(direction);
|
||||
st->ship_station.Add(flat_tile);
|
||||
|
@ -2937,7 +2937,7 @@ static TileIndex FindDockLandPart(TileIndex t)
|
|||
* @param flags operation to perform
|
||||
* @return cost or failure of operation
|
||||
*/
|
||||
static CommandCost RemoveDock(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost RemoveDock(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
Station *st = Station::GetByTile(tile);
|
||||
CommandCost ret = CheckOwnership(st->owner);
|
||||
|
@ -2953,7 +2953,7 @@ static CommandCost RemoveDock(TileIndex tile, DoCommandFlag flags)
|
|||
if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile2);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
DoClearSquare(tile1);
|
||||
MarkTileDirtyByTile(tile1);
|
||||
MakeWaterKeepingClass(tile2, st->owner);
|
||||
|
@ -4310,7 +4310,7 @@ static bool IsUniqueStationName(const std::string &name)
|
|||
* @param text the new name or an empty string when resetting to the default
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRenameStation(DoCommandFlag flags, StationID station_id, const std::string &text)
|
||||
CommandCost CmdRenameStation(DoCommandFlags flags, StationID station_id, const std::string &text)
|
||||
{
|
||||
Station *st = Station::GetIfValid(station_id);
|
||||
if (st == nullptr) return CMD_ERROR;
|
||||
|
@ -4325,7 +4325,7 @@ CommandCost CmdRenameStation(DoCommandFlag flags, StationID station_id, const st
|
|||
if (!IsUniqueStationName(text)) return CommandCost(STR_ERROR_NAME_MUST_BE_UNIQUE);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
st->cached_name.clear();
|
||||
if (reset) {
|
||||
st->name.clear();
|
||||
|
@ -4635,15 +4635,15 @@ static void ChangeTileOwner_Station(TileIndex tile, Owner old_owner, Owner new_o
|
|||
if (IsDriveThroughStopTile(tile)) {
|
||||
/* Remove the drive-through road stop */
|
||||
if (IsRoadWaypoint(tile)) {
|
||||
Command<CMD_REMOVE_FROM_ROAD_WAYPOINT>::Do(DC_EXEC | DC_BANKRUPT, tile, tile);
|
||||
Command<CMD_REMOVE_FROM_ROAD_WAYPOINT>::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile, tile);
|
||||
} else {
|
||||
Command<CMD_REMOVE_ROAD_STOP>::Do(DC_EXEC | DC_BANKRUPT, tile, 1, 1, (GetStationType(tile) == StationType::Truck) ? RoadStopType::Truck : RoadStopType::Bus, false);
|
||||
Command<CMD_REMOVE_ROAD_STOP>::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile, 1, 1, (GetStationType(tile) == StationType::Truck) ? RoadStopType::Truck : RoadStopType::Bus, false);
|
||||
}
|
||||
assert(IsTileType(tile, MP_ROAD));
|
||||
/* Change owner of tile and all roadtypes */
|
||||
ChangeTileOwner(tile, old_owner, new_owner);
|
||||
} else {
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC | DC_BANKRUPT, tile);
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile);
|
||||
/* Set tile owner of water under (now removed) buoy and dock to OWNER_NONE.
|
||||
* Update owner of buoy if it was not removed (was in orders).
|
||||
* Do not update when owned by OWNER_WATER (sea and rivers). */
|
||||
|
@ -4660,7 +4660,7 @@ static void ChangeTileOwner_Station(TileIndex tile, Owner old_owner, Owner new_o
|
|||
* @param flags Command flags.
|
||||
* @return A succeeded command if the road can be removed, a failed command with the relevant error message otherwise.
|
||||
*/
|
||||
static CommandCost CanRemoveRoadWithStop(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost CanRemoveRoadWithStop(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
/* Water flooding can always clear road stops. */
|
||||
if (_current_company == OWNER_WATER) return CommandCost();
|
||||
|
@ -4695,9 +4695,9 @@ static CommandCost CanRemoveRoadWithStop(TileIndex tile, DoCommandFlag flags)
|
|||
* @param flags The DoCommand flags related to the "command".
|
||||
* @return The cost, or error of clearing.
|
||||
*/
|
||||
CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags)
|
||||
CommandCost ClearTile_Station(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
if (flags & DC_AUTO) {
|
||||
if (flags.Test(DoCommandFlag::Auto)) {
|
||||
switch (GetStationType(tile)) {
|
||||
default: break;
|
||||
case StationType::Rail: return CommandCost(STR_ERROR_MUST_DEMOLISH_RAILROAD);
|
||||
|
@ -4738,7 +4738,7 @@ CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags)
|
|||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
static CommandCost TerraformTile_Station(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
|
||||
static CommandCost TerraformTile_Station(TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new)
|
||||
{
|
||||
if (_settings_game.construction.build_on_slopes && AutoslopeEnabled()) {
|
||||
/* TODO: If you implement newgrf callback 149 'land slope check', you have to decide what to do with it here.
|
||||
|
|
|
@ -19,14 +19,14 @@ enum RoadStopClassID : uint16_t;
|
|||
extern Town *AirportGetNearestTown(const struct AirportSpec *as, Direction rotation, TileIndex tile, TileIterator &&it, uint &mindist);
|
||||
extern uint8_t GetAirportNoiseLevelForDistance(const struct AirportSpec *as, uint distance);
|
||||
|
||||
CommandCost CmdBuildAirport(DoCommandFlag flags, TileIndex tile, uint8_t airport_type, uint8_t layout, StationID station_to_join, bool allow_adjacent);
|
||||
CommandCost CmdBuildDock(DoCommandFlag flags, TileIndex tile, StationID station_to_join, bool adjacent);
|
||||
CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailType rt, Axis axis, uint8_t numtracks, uint8_t plat_len, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent);
|
||||
CommandCost CmdRemoveFromRailStation(DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail);
|
||||
CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t length, RoadStopType stop_type, bool is_drive_through, DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent);
|
||||
CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t height, RoadStopType stop_type, bool remove_road);
|
||||
CommandCost CmdRenameStation(DoCommandFlag flags, StationID station_id, const std::string &text);
|
||||
CommandCost CmdOpenCloseAirport(DoCommandFlag flags, StationID station_id);
|
||||
CommandCost CmdBuildAirport(DoCommandFlags flags, TileIndex tile, uint8_t airport_type, uint8_t layout, StationID station_to_join, bool allow_adjacent);
|
||||
CommandCost CmdBuildDock(DoCommandFlags flags, TileIndex tile, StationID station_to_join, bool adjacent);
|
||||
CommandCost CmdBuildRailStation(DoCommandFlags flags, TileIndex tile_org, RailType rt, Axis axis, uint8_t numtracks, uint8_t plat_len, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent);
|
||||
CommandCost CmdRemoveFromRailStation(DoCommandFlags flags, TileIndex start, TileIndex end, bool keep_rail);
|
||||
CommandCost CmdBuildRoadStop(DoCommandFlags flags, TileIndex tile, uint8_t width, uint8_t length, RoadStopType stop_type, bool is_drive_through, DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent);
|
||||
CommandCost CmdRemoveRoadStop(DoCommandFlags flags, TileIndex tile, uint8_t width, uint8_t height, RoadStopType stop_type, bool remove_road);
|
||||
CommandCost CmdRenameStation(DoCommandFlags flags, StationID station_id, const std::string &text);
|
||||
CommandCost CmdOpenCloseAirport(DoCommandFlags flags, StationID station_id);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_BUILD_AIRPORT, CmdBuildAirport, CMD_AUTO | CMD_NO_WATER, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
DEF_CMD_TRAIT(CMD_BUILD_DOCK, CmdBuildDock, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
|
|
|
@ -206,14 +206,14 @@ bool StoryPageButtonData::ValidateVehicleType() const
|
|||
* @param text Title of the story page. Null is allowed in which case a generic page title is provided by OpenTTD.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
std::tuple<CommandCost, StoryPageID> CmdCreateStoryPage(DoCommandFlag flags, CompanyID company, const std::string &text)
|
||||
std::tuple<CommandCost, StoryPageID> CmdCreateStoryPage(DoCommandFlags flags, CompanyID company, const std::string &text)
|
||||
{
|
||||
if (!StoryPage::CanAllocateItem()) return { CMD_ERROR, INVALID_STORY_PAGE };
|
||||
|
||||
if (_current_company != OWNER_DEITY) return { CMD_ERROR, INVALID_STORY_PAGE };
|
||||
if (company != INVALID_COMPANY && !Company::IsValidID(company)) return { CMD_ERROR, INVALID_STORY_PAGE };
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (StoryPage::GetNumItems() == 0) {
|
||||
/* Initialize the next sort value variable. */
|
||||
_story_page_next_sort_value = 0;
|
||||
|
@ -245,7 +245,7 @@ std::tuple<CommandCost, StoryPageID> CmdCreateStoryPage(DoCommandFlag flags, Com
|
|||
* @param text Text content in case it is a text or location page element
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
std::tuple<CommandCost, StoryPageElementID> CmdCreateStoryPageElement(DoCommandFlag flags, TileIndex tile, StoryPageID page_id, StoryPageElementType type, uint32_t reference, const std::string &text)
|
||||
std::tuple<CommandCost, StoryPageElementID> CmdCreateStoryPageElement(DoCommandFlags flags, TileIndex tile, StoryPageID page_id, StoryPageElementType type, uint32_t reference, const std::string &text)
|
||||
{
|
||||
if (!StoryPageElement::CanAllocateItem()) return { CMD_ERROR, INVALID_STORY_PAGE_ELEMENT };
|
||||
|
||||
|
@ -261,7 +261,7 @@ std::tuple<CommandCost, StoryPageElementID> CmdCreateStoryPageElement(DoCommandF
|
|||
if (!VerifyElementContentParameters(page_id, type, tile, reference, text)) return { CMD_ERROR, INVALID_STORY_PAGE_ELEMENT };
|
||||
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (StoryPageElement::GetNumItems() == 0) {
|
||||
/* Initialize the next sort value variable. */
|
||||
_story_page_element_next_sort_value = 0;
|
||||
|
@ -291,7 +291,7 @@ std::tuple<CommandCost, StoryPageElementID> CmdCreateStoryPageElement(DoCommandF
|
|||
* @param text Text content in case it is a text or location page element
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdUpdateStoryPageElement(DoCommandFlag flags, TileIndex tile, StoryPageElementID page_element_id, uint32_t reference, const std::string &text)
|
||||
CommandCost CmdUpdateStoryPageElement(DoCommandFlags flags, TileIndex tile, StoryPageElementID page_element_id, uint32_t reference, const std::string &text)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR;
|
||||
|
@ -302,7 +302,7 @@ CommandCost CmdUpdateStoryPageElement(DoCommandFlag flags, TileIndex tile, Story
|
|||
|
||||
if (!VerifyElementContentParameters(page_id, type, tile, reference, text)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
UpdateElement(*pe, tile, reference, text);
|
||||
InvalidateWindowClassesData(WC_STORY_BOOK, pe->page);
|
||||
}
|
||||
|
@ -317,12 +317,12 @@ CommandCost CmdUpdateStoryPageElement(DoCommandFlag flags, TileIndex tile, Story
|
|||
* @param text title text of the story page.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetStoryPageTitle(DoCommandFlag flags, StoryPageID page_id, const std::string &text)
|
||||
CommandCost CmdSetStoryPageTitle(DoCommandFlags flags, StoryPageID page_id, const std::string &text)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
StoryPage *p = StoryPage::Get(page_id);
|
||||
p->title = text;
|
||||
|
||||
|
@ -339,12 +339,12 @@ CommandCost CmdSetStoryPageTitle(DoCommandFlag flags, StoryPageID page_id, const
|
|||
* @param date date
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetStoryPageDate(DoCommandFlag flags, StoryPageID page_id, TimerGameCalendar::Date date)
|
||||
CommandCost CmdSetStoryPageDate(DoCommandFlags flags, StoryPageID page_id, TimerGameCalendar::Date date)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
StoryPage *p = StoryPage::Get(page_id);
|
||||
p->date = date;
|
||||
|
||||
|
@ -361,12 +361,12 @@ CommandCost CmdSetStoryPageDate(DoCommandFlag flags, StoryPageID page_id, TimerG
|
|||
* @param page_id StoryPageID to show.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdShowStoryPage(DoCommandFlag flags, StoryPageID page_id)
|
||||
CommandCost CmdShowStoryPage(DoCommandFlags flags, StoryPageID page_id)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
StoryPage *g = StoryPage::Get(page_id);
|
||||
if ((g->company != INVALID_COMPANY && g->company == _local_company) || (g->company == INVALID_COMPANY && Company::IsValidID(_local_company))) ShowStoryBook(_local_company, page_id, true);
|
||||
}
|
||||
|
@ -379,12 +379,12 @@ CommandCost CmdShowStoryPage(DoCommandFlag flags, StoryPageID page_id)
|
|||
* @param page_id StoryPageID to remove.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRemoveStoryPage(DoCommandFlag flags, StoryPageID page_id)
|
||||
CommandCost CmdRemoveStoryPage(DoCommandFlags flags, StoryPageID page_id)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
StoryPage *p = StoryPage::Get(page_id);
|
||||
|
||||
for (StoryPageElement *pe : StoryPageElement::Iterate()) {
|
||||
|
@ -408,12 +408,12 @@ CommandCost CmdRemoveStoryPage(DoCommandFlag flags, StoryPageID page_id)
|
|||
* @param page_element_id StoryPageElementID to remove.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRemoveStoryPageElement(DoCommandFlag flags, StoryPageElementID page_element_id)
|
||||
CommandCost CmdRemoveStoryPageElement(DoCommandFlags flags, StoryPageElementID page_element_id)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
StoryPageElement *pe = StoryPageElement::Get(page_element_id);
|
||||
StoryPageID page_id = pe->page;
|
||||
|
||||
|
@ -433,7 +433,7 @@ CommandCost CmdRemoveStoryPageElement(DoCommandFlag flags, StoryPageElementID pa
|
|||
* @param reference ID of selected item for buttons that select an item (e.g. vehicle), otherwise unused.
|
||||
* @return The cost of the operation, or an error.
|
||||
*/
|
||||
CommandCost CmdStoryPageButton(DoCommandFlag flags, TileIndex tile, StoryPageElementID page_element_id, VehicleID reference)
|
||||
CommandCost CmdStoryPageButton(DoCommandFlags flags, TileIndex tile, StoryPageElementID page_element_id, VehicleID reference)
|
||||
{
|
||||
if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR;
|
||||
const StoryPageElement *const pe = StoryPageElement::Get(page_element_id);
|
||||
|
@ -445,15 +445,15 @@ CommandCost CmdStoryPageButton(DoCommandFlag flags, TileIndex tile, StoryPageEle
|
|||
switch (pe->type) {
|
||||
case SPET_BUTTON_PUSH:
|
||||
/* No validation required */
|
||||
if (flags & DC_EXEC) Game::NewEvent(new ScriptEventStoryPageButtonClick(_current_company, pe->page, page_element_id));
|
||||
if (flags.Test(DoCommandFlag::Execute)) Game::NewEvent(new ScriptEventStoryPageButtonClick(_current_company, pe->page, page_element_id));
|
||||
break;
|
||||
case SPET_BUTTON_TILE:
|
||||
if (!IsValidTile(tile)) return CMD_ERROR;
|
||||
if (flags & DC_EXEC) Game::NewEvent(new ScriptEventStoryPageTileSelect(_current_company, pe->page, page_element_id, tile));
|
||||
if (flags.Test(DoCommandFlag::Execute)) Game::NewEvent(new ScriptEventStoryPageTileSelect(_current_company, pe->page, page_element_id, tile));
|
||||
break;
|
||||
case SPET_BUTTON_VEHICLE:
|
||||
if (!Vehicle::IsValidID(reference)) return CMD_ERROR;
|
||||
if (flags & DC_EXEC) Game::NewEvent(new ScriptEventStoryPageVehicleSelect(_current_company, pe->page, page_element_id, reference));
|
||||
if (flags.Test(DoCommandFlag::Execute)) Game::NewEvent(new ScriptEventStoryPageVehicleSelect(_current_company, pe->page, page_element_id, reference));
|
||||
break;
|
||||
default:
|
||||
/* Invalid page element type, not a button. */
|
||||
|
|
|
@ -15,15 +15,15 @@
|
|||
#include "story_type.h"
|
||||
#include "vehicle_type.h"
|
||||
|
||||
std::tuple<CommandCost, StoryPageID> CmdCreateStoryPage(DoCommandFlag flags, CompanyID company, const std::string &text);
|
||||
std::tuple<CommandCost, StoryPageElementID> CmdCreateStoryPageElement(DoCommandFlag flags, TileIndex tile, StoryPageID page_id, StoryPageElementType type, uint32_t reference, const std::string &text);
|
||||
CommandCost CmdUpdateStoryPageElement(DoCommandFlag flags, TileIndex tile, StoryPageElementID page_element_id, uint32_t reference, const std::string &text);
|
||||
CommandCost CmdSetStoryPageTitle(DoCommandFlag flags, StoryPageID page_id, const std::string &text);
|
||||
CommandCost CmdSetStoryPageDate(DoCommandFlag flags, StoryPageID page_id, TimerGameCalendar::Date date);
|
||||
CommandCost CmdShowStoryPage(DoCommandFlag flags, StoryPageID page_id);
|
||||
CommandCost CmdRemoveStoryPage(DoCommandFlag flags, StoryPageID page_id);
|
||||
CommandCost CmdRemoveStoryPageElement(DoCommandFlag flags, StoryPageElementID page_element_id);
|
||||
CommandCost CmdStoryPageButton(DoCommandFlag flags, TileIndex tile, StoryPageElementID page_element_id, VehicleID reference);
|
||||
std::tuple<CommandCost, StoryPageID> CmdCreateStoryPage(DoCommandFlags flags, CompanyID company, const std::string &text);
|
||||
std::tuple<CommandCost, StoryPageElementID> CmdCreateStoryPageElement(DoCommandFlags flags, TileIndex tile, StoryPageID page_id, StoryPageElementType type, uint32_t reference, const std::string &text);
|
||||
CommandCost CmdUpdateStoryPageElement(DoCommandFlags flags, TileIndex tile, StoryPageElementID page_element_id, uint32_t reference, const std::string &text);
|
||||
CommandCost CmdSetStoryPageTitle(DoCommandFlags flags, StoryPageID page_id, const std::string &text);
|
||||
CommandCost CmdSetStoryPageDate(DoCommandFlags flags, StoryPageID page_id, TimerGameCalendar::Date date);
|
||||
CommandCost CmdShowStoryPage(DoCommandFlags flags, StoryPageID page_id);
|
||||
CommandCost CmdRemoveStoryPage(DoCommandFlags flags, StoryPageID page_id);
|
||||
CommandCost CmdRemoveStoryPageElement(DoCommandFlags flags, StoryPageElementID page_element_id);
|
||||
CommandCost CmdStoryPageButton(DoCommandFlags flags, TileIndex tile, StoryPageElementID page_element_id, VehicleID reference);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_CREATE_STORY_PAGE, CmdCreateStoryPage, CMD_DEITY | CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT)
|
||||
DEF_CMD_TRAIT(CMD_CREATE_STORY_PAGE_ELEMENT, CmdCreateStoryPageElement, CMD_DEITY | CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT)
|
||||
|
|
|
@ -227,7 +227,7 @@ void CreateSubsidy(CargoType cargo_type, Source src, Source dst)
|
|||
* @param dst Destination.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdCreateSubsidy(DoCommandFlag flags, CargoType cargo_type, Source src, Source dst)
|
||||
CommandCost CmdCreateSubsidy(DoCommandFlags flags, CargoType cargo_type, Source src, Source dst)
|
||||
{
|
||||
if (!Subsidy::CanAllocateItem()) return CMD_ERROR;
|
||||
|
||||
|
@ -256,7 +256,7 @@ CommandCost CmdCreateSubsidy(DoCommandFlag flags, CargoType cargo_type, Source s
|
|||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
CreateSubsidy(cargo_type, src, dst);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "source_type.h"
|
||||
#include "misc/endian_buffer.hpp"
|
||||
|
||||
CommandCost CmdCreateSubsidy(DoCommandFlag flags, CargoType cargo_type, Source src, Source dst);
|
||||
CommandCost CmdCreateSubsidy(DoCommandFlags flags, CargoType cargo_type, Source src, Source dst);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_CREATE_SUBSIDY, CmdCreateSubsidy, CMD_DEITY, CMDT_OTHER_MANAGEMENT)
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ static std::tuple<CommandCost, TileIndex> TerraformTileHeight(TerraformerState *
|
|||
* @param dir_up direction; eg up (true) or down (false)
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
std::tuple<CommandCost, Money, TileIndex> CmdTerraformLand(DoCommandFlag flags, TileIndex tile, Slope slope, bool dir_up)
|
||||
std::tuple<CommandCost, Money, TileIndex> CmdTerraformLand(DoCommandFlags flags, TileIndex tile, Slope slope, bool dir_up)
|
||||
{
|
||||
CommandCost total_cost(EXPENSES_CONSTRUCTION);
|
||||
int direction = (dir_up ? 1 : -1);
|
||||
|
@ -256,10 +256,10 @@ std::tuple<CommandCost, Money, TileIndex> CmdTerraformLand(DoCommandFlag flags,
|
|||
/* Check tiletype-specific things, and add extra-cost */
|
||||
Backup<bool> old_generating_world(_generating_world);
|
||||
if (_game_mode == GM_EDITOR) old_generating_world.Change(true); // used to create green terraformed land
|
||||
DoCommandFlag tile_flags = flags | DC_AUTO | DC_FORCE_CLEAR_TILE;
|
||||
DoCommandFlags tile_flags = flags | DoCommandFlag::Auto | DoCommandFlag::ForceClearTile;
|
||||
if (pass == 0) {
|
||||
tile_flags &= ~DC_EXEC;
|
||||
tile_flags |= DC_NO_MODIFY_TOWN_RATING;
|
||||
tile_flags.Reset(DoCommandFlag::Execute);
|
||||
tile_flags.Set(DoCommandFlag::NoModifyTownRating);
|
||||
}
|
||||
CommandCost cost;
|
||||
if (indirectly_cleared) {
|
||||
|
@ -280,7 +280,7 @@ std::tuple<CommandCost, Money, TileIndex> CmdTerraformLand(DoCommandFlag flags,
|
|||
return { CommandCost(STR_ERROR_TERRAFORM_LIMIT_REACHED), 0, INVALID_TILE };
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Mark affected areas dirty. */
|
||||
for (const auto &t : ts.dirty_tiles) {
|
||||
MarkTileDirtyByTile(t);
|
||||
|
@ -312,7 +312,7 @@ std::tuple<CommandCost, Money, TileIndex> CmdTerraformLand(DoCommandFlag flags,
|
|||
* @param LevelMode Mode of leveling \c LevelMode.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
std::tuple<CommandCost, Money, TileIndex> CmdLevelLand(DoCommandFlag flags, TileIndex tile, TileIndex start_tile, bool diagonal, LevelMode lm)
|
||||
std::tuple<CommandCost, Money, TileIndex> CmdLevelLand(DoCommandFlags flags, TileIndex tile, TileIndex start_tile, bool diagonal, LevelMode lm)
|
||||
{
|
||||
if (start_tile >= Map::Size()) return { CMD_ERROR, 0, INVALID_TILE };
|
||||
|
||||
|
@ -347,7 +347,7 @@ std::tuple<CommandCost, Money, TileIndex> CmdLevelLand(DoCommandFlag flags, Tile
|
|||
uint curh = TileHeight(t);
|
||||
while (curh != h) {
|
||||
CommandCost ret;
|
||||
std::tie(ret, std::ignore, error_tile) = Command<CMD_TERRAFORM_LAND>::Do(flags & ~DC_EXEC, t, SLOPE_N, curh <= h);
|
||||
std::tie(ret, std::ignore, error_tile) = Command<CMD_TERRAFORM_LAND>::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), t, SLOPE_N, curh <= h);
|
||||
if (ret.Failed()) {
|
||||
last_error = ret;
|
||||
|
||||
|
@ -356,7 +356,7 @@ std::tuple<CommandCost, Money, TileIndex> CmdLevelLand(DoCommandFlag flags, Tile
|
|||
break;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
money -= ret.GetCost();
|
||||
if (money < 0) {
|
||||
return { cost, ret.GetCost(), error_tile };
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
#include "map_type.h"
|
||||
#include "slope_type.h"
|
||||
|
||||
std::tuple<CommandCost, Money, TileIndex> CmdTerraformLand(DoCommandFlag flags, TileIndex tile, Slope slope, bool dir_up);
|
||||
std::tuple<CommandCost, Money, TileIndex> CmdLevelLand(DoCommandFlag flags, TileIndex tile, TileIndex start_tile, bool diagonal, LevelMode lm);
|
||||
std::tuple<CommandCost, Money, TileIndex> CmdTerraformLand(DoCommandFlags flags, TileIndex tile, Slope slope, bool dir_up);
|
||||
std::tuple<CommandCost, Money, TileIndex> CmdLevelLand(DoCommandFlags flags, TileIndex tile, TileIndex start_tile, bool diagonal, LevelMode lm);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_TERRAFORM_LAND, CmdTerraformLand, CMD_ALL_TILES | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
DEF_CMD_TRAIT(CMD_LEVEL_LAND, CmdLevelLand, CMD_ALL_TILES | CMD_AUTO | CMD_NO_TEST, CMDT_LANDSCAPE_CONSTRUCTION) // test run might clear tiles multiple times, in execution that only happens once
|
||||
|
|
|
@ -521,7 +521,7 @@ static void ResetLandscapeConfirmationCallback(Window *, bool confirmed)
|
|||
/* Delete all station signs */
|
||||
for (BaseStation *st : BaseStation::Iterate()) {
|
||||
/* There can be buoys, remove them */
|
||||
if (IsBuoyTile(st->xy)) Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC | DC_BANKRUPT, st->xy);
|
||||
if (IsBuoyTile(st->xy)) Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, st->xy);
|
||||
if (!st->IsInUse()) delete st;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ typedef void DrawTileProc(TileInfo *ti);
|
|||
* @see GetSlopePixelZ
|
||||
*/
|
||||
typedef int GetSlopeZProc(TileIndex tile, uint x, uint y, bool ground_vehicle);
|
||||
typedef CommandCost ClearTileProc(TileIndex tile, DoCommandFlag flags);
|
||||
typedef CommandCost ClearTileProc(TileIndex tile, DoCommandFlags flags);
|
||||
|
||||
/**
|
||||
* Tile callback function signature for obtaining cargo acceptance of a tile
|
||||
|
@ -140,17 +140,17 @@ typedef Foundation GetFoundationProc(TileIndex tile, Slope tileh);
|
|||
*
|
||||
* The function is called when a tile is affected by a terraforming operation.
|
||||
* It has to check if terraforming of the tile is allowed and return extra terraform-cost that depend on the tiletype.
|
||||
* With DC_EXEC in \a flags it has to perform tiletype-specific actions (like clearing land etc., but not the terraforming itself).
|
||||
* With DoCommandFlag::Execute in \a flags it has to perform tiletype-specific actions (like clearing land etc., but not the terraforming itself).
|
||||
*
|
||||
* @note The terraforming has not yet taken place. So GetTileZ() and GetTileSlope() refer to the landscape before the terraforming operation.
|
||||
*
|
||||
* @param tile The involved tile.
|
||||
* @param flags Command flags passed to the terraform command (DC_EXEC, DC_QUERY_COST, etc.).
|
||||
* @param flags Command flags passed to the terraform command (DoCommandFlag::Execute, DoCommandFlag::QueryCost, etc.).
|
||||
* @param z_new TileZ after terraforming.
|
||||
* @param tileh_new Slope after terraforming.
|
||||
* @return Error code or extra cost for terraforming (like clearing land, building foundations, etc., but not the terraforming itself.)
|
||||
*/
|
||||
typedef CommandCost TerraformTileProc(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new);
|
||||
typedef CommandCost TerraformTileProc(TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new);
|
||||
|
||||
/**
|
||||
* Set of callback functions for performing tile operations of a given tile type.
|
||||
|
|
|
@ -130,7 +130,7 @@ static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint16_t va
|
|||
* 0 to clear times, UINT16_MAX to clear speed limit.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdChangeTimetable(DoCommandFlag flags, VehicleID veh, VehicleOrderID order_number, ModifyTimetableFlags mtf, uint16_t data)
|
||||
CommandCost CmdChangeTimetable(DoCommandFlags flags, VehicleID veh, VehicleOrderID order_number, ModifyTimetableFlags mtf, uint16_t data)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(veh);
|
||||
if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
||||
|
@ -180,7 +180,7 @@ CommandCost CmdChangeTimetable(DoCommandFlag flags, VehicleID veh, VehicleOrderI
|
|||
if (travel_time != order->GetTravelTime() && order->IsType(OT_CONDITIONAL)) return CMD_ERROR;
|
||||
if (max_speed != order->GetMaxSpeed() && (order->IsType(OT_CONDITIONAL) || v->type == VEH_AIRCRAFT)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
switch (mtf) {
|
||||
case MTF_WAIT_TIME:
|
||||
/* Set time if changing the value or confirming an estimated time as timetabled. */
|
||||
|
@ -225,7 +225,7 @@ CommandCost CmdChangeTimetable(DoCommandFlag flags, VehicleID veh, VehicleOrderI
|
|||
* 0 to clear times, UINT16_MAX to clear speed limit.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBulkChangeTimetable(DoCommandFlag flags, VehicleID veh, ModifyTimetableFlags mtf, uint16_t data)
|
||||
CommandCost CmdBulkChangeTimetable(DoCommandFlags flags, VehicleID veh, ModifyTimetableFlags mtf, uint16_t data)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(veh);
|
||||
if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
||||
|
@ -237,12 +237,12 @@ CommandCost CmdBulkChangeTimetable(DoCommandFlag flags, VehicleID veh, ModifyTim
|
|||
|
||||
if (v->GetNumOrders() == 0) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
for (VehicleOrderID order_number = 0; order_number < v->GetNumOrders(); order_number++) {
|
||||
Order *order = v->GetOrder(order_number);
|
||||
if (order == nullptr || order->IsType(OT_IMPLICIT)) continue;
|
||||
|
||||
Command<CMD_CHANGE_TIMETABLE>::Do(DC_EXEC, v->index, order_number, mtf, data);
|
||||
Command<CMD_CHANGE_TIMETABLE>::Do(DoCommandFlag::Execute, v->index, order_number, mtf, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ CommandCost CmdBulkChangeTimetable(DoCommandFlag flags, VehicleID veh, ModifyTim
|
|||
* @param apply_to_group Set to reset the late counter for all vehicles sharing the orders.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetVehicleOnTime(DoCommandFlag flags, VehicleID veh, bool apply_to_group)
|
||||
CommandCost CmdSetVehicleOnTime(DoCommandFlags flags, VehicleID veh, bool apply_to_group)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(veh);
|
||||
if (v == nullptr || !v->IsPrimaryVehicle() || v->orders == nullptr) return CMD_ERROR;
|
||||
|
@ -268,7 +268,7 @@ CommandCost CmdSetVehicleOnTime(DoCommandFlag flags, VehicleID veh, bool apply_t
|
|||
CommandCost ret = CheckOwnership(v->owner);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (apply_to_group) {
|
||||
TimerGameTick::Ticks most_late = 0;
|
||||
for (Vehicle *u = v->FirstShared(); u != nullptr; u = u->NextShared()) {
|
||||
|
@ -348,7 +348,7 @@ static bool VehicleTimetableSorter(Vehicle * const &a, Vehicle * const &b)
|
|||
* @param start_tick The TimerGameTick::counter tick when the timetable starts.
|
||||
* @return The error or cost of the operation.
|
||||
*/
|
||||
CommandCost CmdSetTimetableStart(DoCommandFlag flags, VehicleID veh_id, bool timetable_all, TimerGameTick::TickCounter start_tick)
|
||||
CommandCost CmdSetTimetableStart(DoCommandFlags flags, VehicleID veh_id, bool timetable_all, TimerGameTick::TickCounter start_tick)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(veh_id);
|
||||
if (v == nullptr || !v->IsPrimaryVehicle() || v->orders == nullptr) return CMD_ERROR;
|
||||
|
@ -374,7 +374,7 @@ CommandCost CmdSetTimetableStart(DoCommandFlag flags, VehicleID veh_id, bool tim
|
|||
/* Don't allow invalid start dates for other vehicles in the shared order group. */
|
||||
if (timetable_all && start_date + (total_duration / Ticks::DAY_TICKS) > EconomyTime::MAX_DATE) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
std::vector<Vehicle *> vehs;
|
||||
|
||||
if (timetable_all) {
|
||||
|
@ -422,7 +422,7 @@ CommandCost CmdSetTimetableStart(DoCommandFlag flags, VehicleID veh_id, bool tim
|
|||
* @param preserve_wait_time Set to preserve waiting times in non-destructive mode
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdAutofillTimetable(DoCommandFlag flags, VehicleID veh, bool autofill, bool preserve_wait_time)
|
||||
CommandCost CmdAutofillTimetable(DoCommandFlags flags, VehicleID veh, bool autofill, bool preserve_wait_time)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(veh);
|
||||
if (v == nullptr || !v->IsPrimaryVehicle() || v->orders == nullptr) return CMD_ERROR;
|
||||
|
@ -430,7 +430,7 @@ CommandCost CmdAutofillTimetable(DoCommandFlag flags, VehicleID veh, bool autofi
|
|||
CommandCost ret = CheckOwnership(v->owner);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (autofill) {
|
||||
/* Start autofilling the timetable, which clears the
|
||||
* "timetable has started" bit. Times are not cleared anymore, but are
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
#include "command_type.h"
|
||||
#include "timer/timer_game_tick.h"
|
||||
|
||||
CommandCost CmdChangeTimetable(DoCommandFlag flags, VehicleID veh, VehicleOrderID order_number, ModifyTimetableFlags mtf, uint16_t data);
|
||||
CommandCost CmdBulkChangeTimetable(DoCommandFlag flags, VehicleID veh, ModifyTimetableFlags mtf, uint16_t data);
|
||||
CommandCost CmdSetVehicleOnTime(DoCommandFlag flags, VehicleID veh, bool apply_to_group);
|
||||
CommandCost CmdAutofillTimetable(DoCommandFlag flags, VehicleID veh, bool autofill, bool preserve_wait_time);
|
||||
CommandCost CmdSetTimetableStart(DoCommandFlag flags, VehicleID veh_id, bool timetable_all, TimerGameTick::TickCounter start_tick);
|
||||
CommandCost CmdChangeTimetable(DoCommandFlags flags, VehicleID veh, VehicleOrderID order_number, ModifyTimetableFlags mtf, uint16_t data);
|
||||
CommandCost CmdBulkChangeTimetable(DoCommandFlags flags, VehicleID veh, ModifyTimetableFlags mtf, uint16_t data);
|
||||
CommandCost CmdSetVehicleOnTime(DoCommandFlags flags, VehicleID veh, bool apply_to_group);
|
||||
CommandCost CmdAutofillTimetable(DoCommandFlags flags, VehicleID veh, bool autofill, bool preserve_wait_time);
|
||||
CommandCost CmdSetTimetableStart(DoCommandFlags flags, VehicleID veh_id, bool timetable_all, TimerGameTick::TickCounter start_tick);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_CHANGE_TIMETABLE, CmdChangeTimetable, 0, CMDT_ROUTE_MANAGEMENT)
|
||||
DEF_CMD_TRAIT(CMD_BULK_CHANGE_TIMETABLE, CmdBulkChangeTimetable, 0, CMDT_ROUTE_MANAGEMENT)
|
||||
|
|
|
@ -197,7 +197,7 @@ enum TownFlags {
|
|||
TOWN_CUSTOM_GROWTH = 3, ///< Growth rate is controlled by GS.
|
||||
};
|
||||
|
||||
CommandCost CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType type);
|
||||
CommandCost CheckforTownRating(DoCommandFlags flags, Town *t, TownRatingCheckType type);
|
||||
|
||||
|
||||
TileIndexDiff GetHouseNorthPart(HouseID &house);
|
||||
|
@ -225,9 +225,9 @@ DECLARE_INCREMENT_DECREMENT_OPERATORS(TownAction);
|
|||
void ClearTownHouse(Town *t, TileIndex tile);
|
||||
void UpdateTownMaxPass(Town *t);
|
||||
void UpdateTownRadius(Town *t);
|
||||
CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags);
|
||||
CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlags flags);
|
||||
Town *ClosestTownFromTile(TileIndex tile, uint threshold);
|
||||
void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags);
|
||||
void ChangeTownRating(Town *t, int add, int max, DoCommandFlags flags);
|
||||
HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile);
|
||||
void SetTownRatingTestMode(bool mode);
|
||||
TownActions GetMaskOfTownActions(CompanyID cid, const Town *t);
|
||||
|
|
142
src/town_cmd.cpp
142
src/town_cmd.cpp
|
@ -714,9 +714,9 @@ static void TileLoop_Town(TileIndex tile)
|
|||
* @param flags Type of operation.
|
||||
* @return The cost of this operation or an error.
|
||||
*/
|
||||
static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
if (flags & DC_AUTO) return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
|
||||
if (flags.Test(DoCommandFlag::Auto)) return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
|
||||
if (!CanDeleteHouse(tile)) return CMD_ERROR;
|
||||
|
||||
const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile));
|
||||
|
@ -728,7 +728,7 @@ static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlag flags)
|
|||
Town *t = Town::GetByTile(tile);
|
||||
|
||||
if (Company::IsValidID(_current_company)) {
|
||||
if (!_cheats.magic_bulldozer.value && !(flags & DC_NO_TEST_TOWN_RATING)) {
|
||||
if (!_cheats.magic_bulldozer.value && !flags.Test(DoCommandFlag::NoTestTownRating)) {
|
||||
/* NewGRFs can add indestructible houses. */
|
||||
if (rating > RATING_MAXIMUM) {
|
||||
SetDParam(0, t->index);
|
||||
|
@ -743,7 +743,7 @@ static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlag flags)
|
|||
}
|
||||
|
||||
ChangeTownRating(t, -rating, RATING_HOUSE_MINIMUM, flags);
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
ClearTownHouse(t, tile);
|
||||
}
|
||||
|
||||
|
@ -1085,8 +1085,8 @@ static bool IsRoadAllowedHere(Town *t, TileIndex tile, DiagDirection dir)
|
|||
* If that fails clear the land, and if that fails exit.
|
||||
* This is to make sure that we can build a road here later. */
|
||||
RoadType rt = GetTownRoadType();
|
||||
if (Command<CMD_BUILD_ROAD>::Do(DC_AUTO | DC_NO_WATER, tile, (dir == DIAGDIR_NW || dir == DIAGDIR_SE) ? ROAD_Y : ROAD_X, rt, DRD_NONE, t->index).Failed() &&
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DC_AUTO | DC_NO_WATER, tile).Failed()) {
|
||||
if (Command<CMD_BUILD_ROAD>::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile, (dir == DIAGDIR_NW || dir == DIAGDIR_SE) ? ROAD_Y : ROAD_X, rt, DRD_NONE, t->index).Failed() &&
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile).Failed()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1103,7 +1103,7 @@ static bool IsRoadAllowedHere(Town *t, TileIndex tile, DiagDirection dir)
|
|||
CommandCost res = CMD_ERROR;
|
||||
if (!_generating_world && Chance16(1, 10)) {
|
||||
/* Note: Do not replace "^ SLOPE_ELEVATED" with ComplementSlope(). The slope might be steep. */
|
||||
res = std::get<0>(Command<CMD_TERRAFORM_LAND>::Do(DC_EXEC | DC_AUTO | DC_NO_WATER,
|
||||
res = std::get<0>(Command<CMD_TERRAFORM_LAND>::Do({DoCommandFlag::Execute, DoCommandFlag::Auto, DoCommandFlag::NoWater},
|
||||
tile, Chance16(1, 16) ? cur_slope : cur_slope ^ SLOPE_ELEVATED, false));
|
||||
}
|
||||
if (res.Failed() && Chance16(1, 3)) {
|
||||
|
@ -1120,9 +1120,9 @@ static bool TerraformTownTile(TileIndex tile, Slope edges, bool dir)
|
|||
{
|
||||
assert(tile < Map::Size());
|
||||
|
||||
CommandCost r = std::get<0>(Command<CMD_TERRAFORM_LAND>::Do(DC_AUTO | DC_NO_WATER, tile, edges, dir));
|
||||
CommandCost r = std::get<0>(Command<CMD_TERRAFORM_LAND>::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile, edges, dir));
|
||||
if (r.Failed() || r.GetCost() >= (_price[PR_TERRAFORM] + 2) * 8) return false;
|
||||
Command<CMD_TERRAFORM_LAND>::Do(DC_AUTO | DC_NO_WATER | DC_EXEC, tile, edges, dir);
|
||||
Command<CMD_TERRAFORM_LAND>::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater, DoCommandFlag::Execute}, tile, edges, dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1253,7 +1253,7 @@ static bool GrowTownWithExtraHouse(Town *t, TileIndex tile)
|
|||
static bool GrowTownWithRoad(const Town *t, TileIndex tile, RoadBits rcmd)
|
||||
{
|
||||
RoadType rt = GetTownRoadType();
|
||||
if (Command<CMD_BUILD_ROAD>::Do(DC_EXEC | DC_AUTO | DC_NO_WATER, tile, rcmd, rt, DRD_NONE, t->index).Succeeded()) {
|
||||
if (Command<CMD_BUILD_ROAD>::Do({DoCommandFlag::Execute, DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile, rcmd, rt, DRD_NONE, t->index).Succeeded()) {
|
||||
_grow_town_result = GROWTH_SUCCEED;
|
||||
return true;
|
||||
}
|
||||
|
@ -1302,7 +1302,7 @@ static bool CanRoadContinueIntoNextTile(const Town *t, const TileIndex tile, con
|
|||
if (IsTileType(next_tile, MP_RAILWAY) && !_settings_game.economy.allow_town_level_crossings) return false;
|
||||
|
||||
/* If a road tile can be built, the construction is allowed. */
|
||||
return Command<CMD_BUILD_ROAD>::Do(DC_AUTO | DC_NO_WATER, next_tile, rcmd, rt, DRD_NONE, t->index).Succeeded();
|
||||
return Command<CMD_BUILD_ROAD>::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, next_tile, rcmd, rt, DRD_NONE, t->index).Succeeded();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1398,7 +1398,7 @@ static bool GrowTownWithBridge(const Town *t, const TileIndex tile, const DiagDi
|
|||
/* Can we actually build the bridge? */
|
||||
RoadType rt = GetTownRoadType();
|
||||
if (Command<CMD_BUILD_BRIDGE>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_BRIDGE>()), tile, bridge_tile, TRANSPORT_ROAD, bridge_type, rt).Succeeded()) {
|
||||
Command<CMD_BUILD_BRIDGE>::Do(DC_EXEC | CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_BRIDGE>()), tile, bridge_tile, TRANSPORT_ROAD, bridge_type, rt);
|
||||
Command<CMD_BUILD_BRIDGE>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_BRIDGE>()).Set(DoCommandFlag::Execute), tile, bridge_tile, TRANSPORT_ROAD, bridge_type, rt);
|
||||
_grow_town_result = GROWTH_SUCCEED;
|
||||
return true;
|
||||
}
|
||||
|
@ -1469,7 +1469,7 @@ static bool GrowTownWithTunnel(const Town *t, const TileIndex tile, const DiagDi
|
|||
/* Attempt to build the tunnel. Return false if it fails to let the town build a road instead. */
|
||||
RoadType rt = GetTownRoadType();
|
||||
if (Command<CMD_BUILD_TUNNEL>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_TUNNEL>()), tile, TRANSPORT_ROAD, rt).Succeeded()) {
|
||||
Command<CMD_BUILD_TUNNEL>::Do(DC_EXEC | CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_TUNNEL>()), tile, TRANSPORT_ROAD, rt);
|
||||
Command<CMD_BUILD_TUNNEL>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_TUNNEL>()).Set(DoCommandFlag::Execute), tile, TRANSPORT_ROAD, rt);
|
||||
_grow_town_result = GROWTH_SUCCEED;
|
||||
return true;
|
||||
}
|
||||
|
@ -1932,9 +1932,9 @@ static bool GrowTown(Town *t)
|
|||
for (const auto &ptr : _town_coord_mod) {
|
||||
/* Only work with plain land that not already has a house */
|
||||
if (!IsTileType(tile, MP_HOUSE) && IsTileFlat(tile)) {
|
||||
if (Command<CMD_LANDSCAPE_CLEAR>::Do(DC_AUTO | DC_NO_WATER, tile).Succeeded()) {
|
||||
if (Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile).Succeeded()) {
|
||||
RoadType rt = GetTownRoadType();
|
||||
Command<CMD_BUILD_ROAD>::Do(DC_EXEC | DC_AUTO, tile, GenRandomRoadBits(), rt, DRD_NONE, t->index);
|
||||
Command<CMD_BUILD_ROAD>::Do({DoCommandFlag::Execute, DoCommandFlag::Auto}, tile, GenRandomRoadBits(), rt, DRD_NONE, t->index);
|
||||
cur_company.Restore();
|
||||
return true;
|
||||
}
|
||||
|
@ -2150,7 +2150,7 @@ static bool IsUniqueTownName(const std::string &name)
|
|||
* @param text Custom name for the town. If empty, the town name parts will be used.
|
||||
* @return The cost of this operation or an error.
|
||||
*/
|
||||
std::tuple<CommandCost, Money, TownID> CmdFoundTown(DoCommandFlag flags, TileIndex tile, TownSize size, bool city, TownLayout layout, bool random_location, uint32_t townnameparts, const std::string &text)
|
||||
std::tuple<CommandCost, Money, TownID> CmdFoundTown(DoCommandFlags flags, TileIndex tile, TownSize size, bool city, TownLayout layout, bool random_location, uint32_t townnameparts, const std::string &text)
|
||||
{
|
||||
TownNameParams par(_settings_game.game_creation.town_name);
|
||||
|
||||
|
@ -2198,7 +2198,7 @@ std::tuple<CommandCost, Money, TownID> CmdFoundTown(DoCommandFlag flags, TileInd
|
|||
|
||||
/* Create the town */
|
||||
TownID new_town = INVALID_TOWN;
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (cost.GetCost() > GetAvailableMoneyForCommand()) {
|
||||
return { CommandCost(EXPENSES_OTHER), cost.GetCost(), INVALID_TOWN };
|
||||
}
|
||||
|
@ -2399,7 +2399,7 @@ static Town *CreateRandomTown(uint attempts, uint32_t townnameparts, TownSize si
|
|||
if (t->cache.population > 0) return t;
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN);
|
||||
[[maybe_unused]] CommandCost rc = Command<CMD_DELETE_TOWN>::Do(DC_EXEC, t->index);
|
||||
[[maybe_unused]] CommandCost rc = Command<CMD_DELETE_TOWN>::Do(DoCommandFlag::Execute, t->index);
|
||||
cur_company.Restore();
|
||||
assert(rc.Succeeded());
|
||||
|
||||
|
@ -2509,7 +2509,7 @@ HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile)
|
|||
*/
|
||||
static inline void ClearMakeHouseTile(TileIndex tile, Town *t, uint8_t counter, uint8_t stage, HouseID type, uint8_t random_bits, bool is_protected)
|
||||
{
|
||||
[[maybe_unused]] CommandCost cc = Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC | DC_AUTO | DC_NO_WATER, tile);
|
||||
[[maybe_unused]] CommandCost cc = Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Execute, DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile);
|
||||
assert(cc.Succeeded());
|
||||
|
||||
IncreaseBuildingCount(t, type);
|
||||
|
@ -2566,7 +2566,7 @@ static inline bool CanBuildHouseHere(TileIndex tile, bool noslope)
|
|||
if (IsBridgeAbove(tile)) return false;
|
||||
|
||||
/* can we clear the land? */
|
||||
return Command<CMD_LANDSCAPE_CLEAR>::Do(DC_AUTO | DC_NO_WATER, tile).Succeeded();
|
||||
return Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile).Succeeded();
|
||||
}
|
||||
|
||||
|
||||
|
@ -2900,7 +2900,7 @@ static bool TryBuildTownHouse(Town *t, TileIndex tile)
|
|||
* @param is_protected Whether the house is protected from the town upgrading it.
|
||||
* @return Empty cost or an error.
|
||||
*/
|
||||
CommandCost CmdPlaceHouse(DoCommandFlag flags, TileIndex tile, HouseID house, bool is_protected)
|
||||
CommandCost CmdPlaceHouse(DoCommandFlags flags, TileIndex tile, HouseID house, bool is_protected)
|
||||
{
|
||||
if (_game_mode != GM_EDITOR && _settings_game.economy.place_houses == PH_FORBIDDEN) return CMD_ERROR;
|
||||
|
||||
|
@ -2920,7 +2920,7 @@ CommandCost CmdPlaceHouse(DoCommandFlag flags, TileIndex tile, HouseID house, bo
|
|||
if (IsBridgeAbove(tile)) return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
|
||||
|
||||
/* can we clear the land? */
|
||||
CommandCost cost = Command<CMD_LANDSCAPE_CLEAR>::Do(DC_AUTO | DC_NO_WATER, tile);
|
||||
CommandCost cost = Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile);
|
||||
if (!cost.Succeeded()) return cost;
|
||||
|
||||
int maxz = GetTileMaxZ(tile);
|
||||
|
@ -2936,13 +2936,13 @@ CommandCost CmdPlaceHouse(DoCommandFlag flags, TileIndex tile, HouseID house, bo
|
|||
|
||||
/* Check additional tiles covered by this house. */
|
||||
for (const TileIndex &subtile : ta) {
|
||||
cost = Command<CMD_LANDSCAPE_CLEAR>::Do(DC_AUTO | DC_NO_WATER, subtile);
|
||||
cost = Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, subtile);
|
||||
if (!cost.Succeeded()) return cost;
|
||||
|
||||
if (!CheckBuildHouseSameZ(subtile, maxz, noslope)) return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
bool house_completed = _settings_game.economy.place_houses == PH_ALLOWED_CONSTRUCTED;
|
||||
BuildTownHouse(t, tile, hs, house, Random(), house_completed, is_protected);
|
||||
}
|
||||
|
@ -3040,7 +3040,7 @@ void ClearTownHouse(Town *t, TileIndex tile)
|
|||
* @param text the new name or an empty string when resetting to the default
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRenameTown(DoCommandFlag flags, TownID town_id, const std::string &text)
|
||||
CommandCost CmdRenameTown(DoCommandFlags flags, TownID town_id, const std::string &text)
|
||||
{
|
||||
Town *t = Town::GetIfValid(town_id);
|
||||
if (t == nullptr) return CMD_ERROR;
|
||||
|
@ -3052,7 +3052,7 @@ CommandCost CmdRenameTown(DoCommandFlag flags, TownID town_id, const std::string
|
|||
if (!IsUniqueTownName(text)) return CommandCost(STR_ERROR_NAME_MUST_BE_UNIQUE);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
t->cached_name.clear();
|
||||
if (reset) {
|
||||
t->name.clear();
|
||||
|
@ -3090,7 +3090,7 @@ const CargoSpec *FindFirstCargoWithTownAcceptanceEffect(TownAcceptanceEffect eff
|
|||
* @param goal The new goal value.
|
||||
* @return Empty cost or an error.
|
||||
*/
|
||||
CommandCost CmdTownCargoGoal(DoCommandFlag flags, TownID town_id, TownAcceptanceEffect tae, uint32_t goal)
|
||||
CommandCost CmdTownCargoGoal(DoCommandFlags flags, TownID town_id, TownAcceptanceEffect tae, uint32_t goal)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
|
||||
|
@ -3103,7 +3103,7 @@ CommandCost CmdTownCargoGoal(DoCommandFlag flags, TownID town_id, TownAcceptance
|
|||
const CargoSpec *cargo = FindFirstCargoWithTownAcceptanceEffect(tae);
|
||||
if (cargo == nullptr) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
t->goal[tae] = goal;
|
||||
UpdateTownGrowth(t);
|
||||
InvalidateWindowData(WC_TOWN_VIEW, town_id);
|
||||
|
@ -3119,13 +3119,13 @@ CommandCost CmdTownCargoGoal(DoCommandFlag flags, TownID town_id, TownAcceptance
|
|||
* @param text The new text (empty to remove the text).
|
||||
* @return Empty cost or an error.
|
||||
*/
|
||||
CommandCost CmdTownSetText(DoCommandFlag flags, TownID town_id, const std::string &text)
|
||||
CommandCost CmdTownSetText(DoCommandFlags flags, TownID town_id, const std::string &text)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
Town *t = Town::GetIfValid(town_id);
|
||||
if (t == nullptr) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
t->text.clear();
|
||||
if (!text.empty()) t->text = text;
|
||||
InvalidateWindowData(WC_TOWN_VIEW, town_id);
|
||||
|
@ -3141,14 +3141,14 @@ CommandCost CmdTownSetText(DoCommandFlag flags, TownID town_id, const std::strin
|
|||
* @param growth_rate Amount of days between growth, or TOWN_GROWTH_RATE_NONE, or 0 to reset custom growth rate.
|
||||
* @return Empty cost or an error.
|
||||
*/
|
||||
CommandCost CmdTownGrowthRate(DoCommandFlag flags, TownID town_id, uint16_t growth_rate)
|
||||
CommandCost CmdTownGrowthRate(DoCommandFlags flags, TownID town_id, uint16_t growth_rate)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
|
||||
Town *t = Town::GetIfValid(town_id);
|
||||
if (t == nullptr) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (growth_rate == 0) {
|
||||
/* Just clear the flag, UpdateTownGrowth will determine a proper growth rate */
|
||||
ClrBit(t->flags, TOWN_CUSTOM_GROWTH);
|
||||
|
@ -3179,7 +3179,7 @@ CommandCost CmdTownGrowthRate(DoCommandFlag flags, TownID town_id, uint16_t grow
|
|||
* @param rating New rating of company (signed int16_t).
|
||||
* @return Empty cost or an error.
|
||||
*/
|
||||
CommandCost CmdTownRating(DoCommandFlag flags, TownID town_id, CompanyID company_id, int16_t rating)
|
||||
CommandCost CmdTownRating(DoCommandFlags flags, TownID town_id, CompanyID company_id, int16_t rating)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
|
||||
|
@ -3189,7 +3189,7 @@ CommandCost CmdTownRating(DoCommandFlag flags, TownID town_id, CompanyID company
|
|||
if (!Company::IsValidID(company_id)) return CMD_ERROR;
|
||||
|
||||
int16_t new_rating = Clamp(rating, RATING_MINIMUM, RATING_MAXIMUM);
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
t->ratings[company_id] = new_rating;
|
||||
InvalidateWindowData(WC_TOWN_AUTHORITY, town_id);
|
||||
}
|
||||
|
@ -3204,13 +3204,13 @@ CommandCost CmdTownRating(DoCommandFlag flags, TownID town_id, CompanyID company
|
|||
* @param grow_amount Amount to grow, or 0 to grow a random size up to the current amount of houses.
|
||||
* @return Empty cost or an error.
|
||||
*/
|
||||
CommandCost CmdExpandTown(DoCommandFlag flags, TownID town_id, uint32_t grow_amount)
|
||||
CommandCost CmdExpandTown(DoCommandFlags flags, TownID town_id, uint32_t grow_amount)
|
||||
{
|
||||
if (_game_mode != GM_EDITOR && _current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
Town *t = Town::GetIfValid(town_id);
|
||||
if (t == nullptr) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* The more houses, the faster we grow */
|
||||
if (grow_amount == 0) {
|
||||
uint amount = RandomRange(ClampTo<uint16_t>(t->cache.num_houses / 10)) + 3;
|
||||
|
@ -3241,7 +3241,7 @@ CommandCost CmdExpandTown(DoCommandFlag flags, TownID town_id, uint32_t grow_amo
|
|||
* @param town_id Town ID to delete.
|
||||
* @return Empty cost or an error.
|
||||
*/
|
||||
CommandCost CmdDeleteTown(DoCommandFlag flags, TownID town_id)
|
||||
CommandCost CmdDeleteTown(DoCommandFlags flags, TownID town_id)
|
||||
{
|
||||
if (_game_mode != GM_EDITOR && !_generating_world) return CMD_ERROR;
|
||||
Town *t = Town::GetIfValid(town_id);
|
||||
|
@ -3307,7 +3307,7 @@ CommandCost CmdDeleteTown(DoCommandFlag flags, TownID town_id)
|
|||
try_clear = true;
|
||||
} else {
|
||||
/* Tell to find a new town. */
|
||||
if (flags & DC_EXEC) o->town = nullptr;
|
||||
if (flags.Test(DoCommandFlag::Execute)) o->town = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3323,7 +3323,7 @@ CommandCost CmdDeleteTown(DoCommandFlag flags, TownID town_id)
|
|||
}
|
||||
|
||||
/* The town destructor will delete the other things related to the town. */
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
_town_kdtree.Remove(t->index);
|
||||
if (t->cache.sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeTown(t->index));
|
||||
delete t;
|
||||
|
@ -3358,9 +3358,9 @@ uint8_t GetTownActionCost(TownAction action)
|
|||
* @param flags Type of operation.
|
||||
* @return An empty cost.
|
||||
*/
|
||||
static CommandCost TownActionAdvertiseSmall(Town *t, DoCommandFlag flags)
|
||||
static CommandCost TownActionAdvertiseSmall(Town *t, DoCommandFlags flags)
|
||||
{
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
ModifyStationRatingAround(t->xy, _current_company, 0x40, 10);
|
||||
}
|
||||
return CommandCost();
|
||||
|
@ -3372,9 +3372,9 @@ static CommandCost TownActionAdvertiseSmall(Town *t, DoCommandFlag flags)
|
|||
* @param flags Type of operation.
|
||||
* @return An empty cost.
|
||||
*/
|
||||
static CommandCost TownActionAdvertiseMedium(Town *t, DoCommandFlag flags)
|
||||
static CommandCost TownActionAdvertiseMedium(Town *t, DoCommandFlags flags)
|
||||
{
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
ModifyStationRatingAround(t->xy, _current_company, 0x70, 15);
|
||||
}
|
||||
return CommandCost();
|
||||
|
@ -3386,9 +3386,9 @@ static CommandCost TownActionAdvertiseMedium(Town *t, DoCommandFlag flags)
|
|||
* @param flags Type of operation.
|
||||
* @return An empty cost.
|
||||
*/
|
||||
static CommandCost TownActionAdvertiseLarge(Town *t, DoCommandFlag flags)
|
||||
static CommandCost TownActionAdvertiseLarge(Town *t, DoCommandFlags flags)
|
||||
{
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
ModifyStationRatingAround(t->xy, _current_company, 0xA0, 20);
|
||||
}
|
||||
return CommandCost();
|
||||
|
@ -3400,12 +3400,12 @@ static CommandCost TownActionAdvertiseLarge(Town *t, DoCommandFlag flags)
|
|||
* @param flags Type of operation.
|
||||
* @return An empty cost.
|
||||
*/
|
||||
static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlag flags)
|
||||
static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlags flags)
|
||||
{
|
||||
/* Check if the company is allowed to fund new roads. */
|
||||
if (!_settings_game.economy.fund_roads) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
t->road_build_months = 6;
|
||||
|
||||
SetDParam(0, _current_company);
|
||||
|
@ -3431,7 +3431,7 @@ static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlag flags)
|
|||
static bool CheckClearTile(TileIndex tile)
|
||||
{
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE);
|
||||
CommandCost r = Command<CMD_LANDSCAPE_CLEAR>::Do(DC_NONE, tile);
|
||||
CommandCost r = Command<CMD_LANDSCAPE_CLEAR>::Do({}, tile);
|
||||
cur_company.Restore();
|
||||
return r.Succeeded();
|
||||
}
|
||||
|
@ -3493,7 +3493,7 @@ static bool SearchTileForStatue(TileIndex tile, void *user_data)
|
|||
* @param flags Used to check if the statue must be built or not.
|
||||
* @return Empty cost or an error.
|
||||
*/
|
||||
static CommandCost TownActionBuildStatue(Town *t, DoCommandFlag flags)
|
||||
static CommandCost TownActionBuildStatue(Town *t, DoCommandFlags flags)
|
||||
{
|
||||
if (!Object::CanAllocateItem()) return CommandCost(STR_ERROR_TOO_MANY_OBJECTS);
|
||||
|
||||
|
@ -3501,9 +3501,9 @@ static CommandCost TownActionBuildStatue(Town *t, DoCommandFlag flags)
|
|||
StatueBuildSearchData statue_data(INVALID_TILE, 0);
|
||||
if (!CircularTileSearch(&tile, 9, SearchTileForStatue, &statue_data)) return CommandCost(STR_ERROR_STATUE_NO_SUITABLE_PLACE);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Backup<CompanyID> cur_company(_current_company, OWNER_NONE);
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC, statue_data.best_position);
|
||||
Command<CMD_LANDSCAPE_CLEAR>::Do(DoCommandFlag::Execute, statue_data.best_position);
|
||||
cur_company.Restore();
|
||||
BuildObject(OBJECT_STATUE, statue_data.best_position, _current_company, t);
|
||||
t->statues.Set(_current_company); // Once found and built, "inform" the Town.
|
||||
|
@ -3518,12 +3518,12 @@ static CommandCost TownActionBuildStatue(Town *t, DoCommandFlag flags)
|
|||
* @param flags Type of operation.
|
||||
* @return An empty cost.
|
||||
*/
|
||||
static CommandCost TownActionFundBuildings(Town *t, DoCommandFlag flags)
|
||||
static CommandCost TownActionFundBuildings(Town *t, DoCommandFlags flags)
|
||||
{
|
||||
/* Check if it's allowed to buy the rights */
|
||||
if (!_settings_game.economy.fund_buildings) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* And grow for 3 months */
|
||||
t->fund_buildings_months = 3;
|
||||
|
||||
|
@ -3551,13 +3551,13 @@ static CommandCost TownActionFundBuildings(Town *t, DoCommandFlag flags)
|
|||
* @param flags Type of operation.
|
||||
* @return An empty cost.
|
||||
*/
|
||||
static CommandCost TownActionBuyRights(Town *t, DoCommandFlag flags)
|
||||
static CommandCost TownActionBuyRights(Town *t, DoCommandFlags flags)
|
||||
{
|
||||
/* Check if it's allowed to buy the rights */
|
||||
if (!_settings_game.economy.exclusive_rights) return CMD_ERROR;
|
||||
if (t->exclusivity != INVALID_COMPANY) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
t->exclusive_counter = 12;
|
||||
t->exclusivity = _current_company;
|
||||
|
||||
|
@ -3584,9 +3584,9 @@ static CommandCost TownActionBuyRights(Town *t, DoCommandFlag flags)
|
|||
* @param flags Type of operation.
|
||||
* @return An empty cost.
|
||||
*/
|
||||
static CommandCost TownActionBribe(Town *t, DoCommandFlag flags)
|
||||
static CommandCost TownActionBribe(Town *t, DoCommandFlags flags)
|
||||
{
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (Chance16(1, 14)) {
|
||||
/* set as unwanted for 6 months */
|
||||
t->unwanted[_current_company] = 6;
|
||||
|
@ -3599,7 +3599,7 @@ static CommandCost TownActionBribe(Town *t, DoCommandFlag flags)
|
|||
}
|
||||
|
||||
/* only show error message to the executing player. All errors are handled command.c
|
||||
* but this is special, because it can only 'fail' on a DC_EXEC */
|
||||
* but this is special, because it can only 'fail' on a DoCommandFlag::Execute */
|
||||
if (IsLocalCompany()) ShowErrorMessage(STR_ERROR_BRIBE_FAILED, INVALID_STRING_ID, WL_INFO);
|
||||
|
||||
/* decrease by a lot!
|
||||
|
@ -3611,7 +3611,7 @@ static CommandCost TownActionBribe(Town *t, DoCommandFlag flags)
|
|||
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
|
||||
}
|
||||
} else {
|
||||
ChangeTownRating(t, RATING_BRIBE_UP_STEP, RATING_BRIBE_MAXIMUM, DC_EXEC);
|
||||
ChangeTownRating(t, RATING_BRIBE_UP_STEP, RATING_BRIBE_MAXIMUM, DoCommandFlag::Execute);
|
||||
if (t->exclusivity != _current_company && t->exclusivity != INVALID_COMPANY) {
|
||||
t->exclusivity = INVALID_COMPANY;
|
||||
t->exclusive_counter = 0;
|
||||
|
@ -3621,7 +3621,7 @@ static CommandCost TownActionBribe(Town *t, DoCommandFlag flags)
|
|||
return CommandCost();
|
||||
}
|
||||
|
||||
typedef CommandCost TownActionProc(Town *t, DoCommandFlag flags);
|
||||
typedef CommandCost TownActionProc(Town *t, DoCommandFlags flags);
|
||||
static TownActionProc * const _town_action_proc[] = {
|
||||
TownActionAdvertiseSmall,
|
||||
TownActionAdvertiseMedium,
|
||||
|
@ -3696,7 +3696,7 @@ TownActions GetMaskOfTownActions(CompanyID cid, const Town *t)
|
|||
* @param action action to perform, @see _town_action_proc for the list of available actions
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdDoTownAction(DoCommandFlag flags, TownID town_id, TownAction action)
|
||||
CommandCost CmdDoTownAction(DoCommandFlags flags, TownID town_id, TownAction action)
|
||||
{
|
||||
Town *t = Town::GetIfValid(town_id);
|
||||
if (t == nullptr || to_underlying(action) >= std::size(_town_action_proc)) return CMD_ERROR;
|
||||
|
@ -3708,7 +3708,7 @@ CommandCost CmdDoTownAction(DoCommandFlag flags, TownID town_id, TownAction acti
|
|||
CommandCost ret = _town_action_proc[to_underlying(action)](t, flags);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
SetWindowDirty(WC_TOWN_AUTHORITY, town_id);
|
||||
}
|
||||
|
||||
|
@ -3885,15 +3885,15 @@ static void UpdateTownGrowth(Town *t)
|
|||
/**
|
||||
* Checks whether the local authority allows construction of a new station (rail, road, airport, dock) on the given tile
|
||||
* @param tile The tile where the station shall be constructed.
|
||||
* @param flags Command flags. DC_NO_TEST_TOWN_RATING is tested.
|
||||
* @param flags Command flags. DoCommandFlag::NoTestTownRating is tested.
|
||||
* @return Succeeded or failed command.
|
||||
*/
|
||||
CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags)
|
||||
CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
/* The required rating is hardcoded to RATING_VERYPOOR (see below), not the authority attitude setting, so we can bail out like this. */
|
||||
if (_settings_game.difficulty.town_council_tolerance == TOWN_COUNCIL_PERMISSIVE) return CommandCost();
|
||||
|
||||
if (!Company::IsValidID(_current_company) || (flags & DC_NO_TEST_TOWN_RATING)) return CommandCost();
|
||||
if (!Company::IsValidID(_current_company) || flags.Test(DoCommandFlag::NoTestTownRating)) return CommandCost();
|
||||
|
||||
Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
|
||||
if (t == nullptr) return CommandCost();
|
||||
|
@ -4007,12 +4007,12 @@ static int GetRating(const Town *t)
|
|||
* @param t Town to affect
|
||||
* @param add Value to add
|
||||
* @param max Minimum (add < 0) resp. maximum (add > 0) rating that should be achievable with this change.
|
||||
* @param flags Command flags, especially DC_NO_MODIFY_TOWN_RATING is tested
|
||||
* @param flags Command flags, especially DoCommandFlag::NoModifyTownRating is tested
|
||||
*/
|
||||
void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
|
||||
void ChangeTownRating(Town *t, int add, int max, DoCommandFlags flags)
|
||||
{
|
||||
/* if magic_bulldozer cheat is active, town doesn't penalize for removing stuff */
|
||||
if (t == nullptr || (flags & DC_NO_MODIFY_TOWN_RATING) ||
|
||||
if (t == nullptr || flags.Test(DoCommandFlag::NoModifyTownRating) ||
|
||||
!Company::IsValidID(_current_company) ||
|
||||
(_cheats.magic_bulldozer.value && add < 0)) {
|
||||
return;
|
||||
|
@ -4046,11 +4046,11 @@ void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
|
|||
* @param type Type of action that is wanted.
|
||||
* @return A succeeded command if the action is allowed, a failed command if it is not allowed.
|
||||
*/
|
||||
CommandCost CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType type)
|
||||
CommandCost CheckforTownRating(DoCommandFlags flags, Town *t, TownRatingCheckType type)
|
||||
{
|
||||
/* if magic_bulldozer cheat is active, town doesn't restrict your destructive actions */
|
||||
if (t == nullptr || !Company::IsValidID(_current_company) ||
|
||||
_cheats.magic_bulldozer.value || (flags & DC_NO_TEST_TOWN_RATING)) {
|
||||
_cheats.magic_bulldozer.value || flags.Test(DoCommandFlag::NoTestTownRating)) {
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
|
@ -4113,7 +4113,7 @@ static IntervalTimer<TimerGameEconomy> _economy_towns_yearly({TimerGameEconomy::
|
|||
}
|
||||
});
|
||||
|
||||
static CommandCost TerraformTile_Town(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
|
||||
static CommandCost TerraformTile_Town(TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new)
|
||||
{
|
||||
if (AutoslopeEnabled()) {
|
||||
HouseID house = GetHouseType(tile);
|
||||
|
|
|
@ -18,16 +18,16 @@
|
|||
enum TownAcceptanceEffect : uint8_t;
|
||||
using HouseID = uint16_t;
|
||||
|
||||
std::tuple<CommandCost, Money, TownID> CmdFoundTown(DoCommandFlag flags, TileIndex tile, TownSize size, bool city, TownLayout layout, bool random_location, uint32_t townnameparts, const std::string &text);
|
||||
CommandCost CmdRenameTown(DoCommandFlag flags, TownID town_id, const std::string &text);
|
||||
CommandCost CmdDoTownAction(DoCommandFlag flags, TownID town_id, TownAction action);
|
||||
CommandCost CmdTownGrowthRate(DoCommandFlag flags, TownID town_id, uint16_t growth_rate);
|
||||
CommandCost CmdTownRating(DoCommandFlag flags, TownID town_id, CompanyID company_id, int16_t rating);
|
||||
CommandCost CmdTownCargoGoal(DoCommandFlag flags, TownID town_id, TownAcceptanceEffect tae, uint32_t goal);
|
||||
CommandCost CmdTownSetText(DoCommandFlag flags, TownID town_id, const std::string &text);
|
||||
CommandCost CmdExpandTown(DoCommandFlag flags, TownID town_id, uint32_t grow_amount);
|
||||
CommandCost CmdDeleteTown(DoCommandFlag flags, TownID town_id);
|
||||
CommandCost CmdPlaceHouse(DoCommandFlag flags, TileIndex tile, HouseID house, bool house_protected);
|
||||
std::tuple<CommandCost, Money, TownID> CmdFoundTown(DoCommandFlags flags, TileIndex tile, TownSize size, bool city, TownLayout layout, bool random_location, uint32_t townnameparts, const std::string &text);
|
||||
CommandCost CmdRenameTown(DoCommandFlags flags, TownID town_id, const std::string &text);
|
||||
CommandCost CmdDoTownAction(DoCommandFlags flags, TownID town_id, TownAction action);
|
||||
CommandCost CmdTownGrowthRate(DoCommandFlags flags, TownID town_id, uint16_t growth_rate);
|
||||
CommandCost CmdTownRating(DoCommandFlags flags, TownID town_id, CompanyID company_id, int16_t rating);
|
||||
CommandCost CmdTownCargoGoal(DoCommandFlags flags, TownID town_id, TownAcceptanceEffect tae, uint32_t goal);
|
||||
CommandCost CmdTownSetText(DoCommandFlags flags, TownID town_id, const std::string &text);
|
||||
CommandCost CmdExpandTown(DoCommandFlags flags, TownID town_id, uint32_t grow_amount);
|
||||
CommandCost CmdDeleteTown(DoCommandFlags flags, TownID town_id);
|
||||
CommandCost CmdPlaceHouse(DoCommandFlags flags, TileIndex tile, HouseID house, bool house_protected);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_FOUND_TOWN, CmdFoundTown, CMD_DEITY | CMD_NO_TEST, CMDT_LANDSCAPE_CONSTRUCTION) // founding random town can fail only in exec run
|
||||
DEF_CMD_TRAIT(CMD_RENAME_TOWN, CmdRenameTown, CMD_DEITY | CMD_SERVER, CMDT_OTHER_MANAGEMENT)
|
||||
|
|
|
@ -1287,7 +1287,7 @@ public:
|
|||
|
||||
case WID_TF_EXPAND_ALL_TOWNS:
|
||||
for (Town *t : Town::Iterate()) {
|
||||
Command<CMD_EXPAND_TOWN>::Do(DC_EXEC, t->index, 0);
|
||||
Command<CMD_EXPAND_TOWN>::Do(DoCommandFlag::Execute, t->index, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -613,14 +613,14 @@ void GetTrainSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs,
|
|||
* @param[out] ret the vehicle that has been built.
|
||||
* @return the cost of this operation or an error.
|
||||
*/
|
||||
static CommandCost CmdBuildRailWagon(DoCommandFlag flags, TileIndex tile, const Engine *e, Vehicle **ret)
|
||||
static CommandCost CmdBuildRailWagon(DoCommandFlags flags, TileIndex tile, const Engine *e, Vehicle **ret)
|
||||
{
|
||||
const RailVehicleInfo *rvi = &e->u.rail;
|
||||
|
||||
/* Check that the wagon can drive on the track in question */
|
||||
if (!IsCompatibleRail(rvi->railtype, GetRailType(tile))) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Train *v = new Train();
|
||||
*ret = v;
|
||||
v->spritenum = rvi->image_index;
|
||||
|
@ -679,7 +679,7 @@ static CommandCost CmdBuildRailWagon(DoCommandFlag flags, TileIndex tile, const
|
|||
w->engine_type == e->index && ///< Same type
|
||||
w->First() != v && ///< Don't connect to ourself
|
||||
!(w->vehstatus & VS_CRASHED)) { ///< Not crashed/flooded
|
||||
if (Command<CMD_MOVE_RAIL_VEHICLE>::Do(DC_EXEC, v->index, w->Last()->index, true).Succeeded()) {
|
||||
if (Command<CMD_MOVE_RAIL_VEHICLE>::Do(DoCommandFlag::Execute, v->index, w->Last()->index, true).Succeeded()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -696,7 +696,7 @@ void NormalizeTrainVehInDepot(const Train *u)
|
|||
for (const Train *v : Train::Iterate()) {
|
||||
if (v->IsFreeWagon() && v->tile == u->tile &&
|
||||
v->track == TRACK_BIT_DEPOT) {
|
||||
if (Command<CMD_MOVE_RAIL_VEHICLE>::Do(DC_EXEC, v->index, u->index, true).Failed()) {
|
||||
if (Command<CMD_MOVE_RAIL_VEHICLE>::Do(DoCommandFlag::Execute, v->index, u->index, true).Failed()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -747,7 +747,7 @@ static void AddRearEngineToMultiheadedTrain(Train *v)
|
|||
* @param[out] ret the vehicle that has been built.
|
||||
* @return the cost of this operation or an error.
|
||||
*/
|
||||
CommandCost CmdBuildRailVehicle(DoCommandFlag flags, TileIndex tile, const Engine *e, Vehicle **ret)
|
||||
CommandCost CmdBuildRailVehicle(DoCommandFlags flags, TileIndex tile, const Engine *e, Vehicle **ret)
|
||||
{
|
||||
const RailVehicleInfo *rvi = &e->u.rail;
|
||||
|
||||
|
@ -757,7 +757,7 @@ CommandCost CmdBuildRailVehicle(DoCommandFlag flags, TileIndex tile, const Engin
|
|||
* We need to see if the engine got power on the tile to avoid electric engines in non-electric depots */
|
||||
if (!HasPowerOnRail(rvi->railtype, GetRailType(tile))) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
DiagDirection dir = GetRailDepotDirection(tile);
|
||||
int x = TileX(tile) * TILE_SIZE + _vehicle_initial_x_fract[dir];
|
||||
int y = TileY(tile) * TILE_SIZE + _vehicle_initial_y_fract[dir];
|
||||
|
@ -1184,13 +1184,13 @@ static void NormaliseTrainHead(Train *head)
|
|||
/**
|
||||
* Move a rail vehicle around inside the depot.
|
||||
* @param flags type of operation
|
||||
* Note: DC_AUTOREPLACE is set when autoreplace tries to undo its modifications or moves vehicles to temporary locations inside the depot.
|
||||
* Note: DoCommandFlag::AutoReplace is set when autoreplace tries to undo its modifications or moves vehicles to temporary locations inside the depot.
|
||||
* @param src_veh source vehicle index
|
||||
* @param dest_veh what wagon to put the source wagon AFTER, XXX - INVALID_VEHICLE to make a new line
|
||||
* @param move_chain move all vehicles following the source vehicle
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdMoveRailVehicle(DoCommandFlag flags, VehicleID src_veh, VehicleID dest_veh, bool move_chain)
|
||||
CommandCost CmdMoveRailVehicle(DoCommandFlags flags, VehicleID src_veh, VehicleID dest_veh, bool move_chain)
|
||||
{
|
||||
Train *src = Train::GetIfValid(src_veh);
|
||||
if (src == nullptr) return CMD_ERROR;
|
||||
|
@ -1204,7 +1204,7 @@ CommandCost CmdMoveRailVehicle(DoCommandFlag flags, VehicleID src_veh, VehicleID
|
|||
/* if nothing is selected as destination, try and find a matching vehicle to drag to. */
|
||||
Train *dst;
|
||||
if (dest_veh == INVALID_VEHICLE) {
|
||||
dst = (src->IsEngine() || (flags & DC_AUTOREPLACE)) ? nullptr : FindGoodVehiclePos(src);
|
||||
dst = (src->IsEngine() || flags.Test(DoCommandFlag::AutoReplace)) ? nullptr : FindGoodVehiclePos(src);
|
||||
} else {
|
||||
dst = Train::GetIfValid(dest_veh);
|
||||
if (dst == nullptr) return CMD_ERROR;
|
||||
|
@ -1274,7 +1274,7 @@ CommandCost CmdMoveRailVehicle(DoCommandFlag flags, VehicleID src_veh, VehicleID
|
|||
/* (Re)arrange the trains in the wanted arrangement. */
|
||||
ArrangeTrains(&dst_head, dst, &src_head, src, move_chain);
|
||||
|
||||
if ((flags & DC_AUTOREPLACE) == 0) {
|
||||
if (!flags.Test(DoCommandFlag::AutoReplace)) {
|
||||
/* If the autoreplace flag is set we do not need to test for the validity
|
||||
* because we are going to revert the train to its original state. As we
|
||||
* assume the original state was correct autoreplace can skip this. */
|
||||
|
@ -1288,7 +1288,7 @@ CommandCost CmdMoveRailVehicle(DoCommandFlag flags, VehicleID src_veh, VehicleID
|
|||
}
|
||||
|
||||
/* do it? */
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Remove old heads from the statistics */
|
||||
if (original_src_head_front_engine) GroupStatistics::CountVehicle(original_src_head, -1);
|
||||
if (original_dst_head_front_engine) GroupStatistics::CountVehicle(original_dst_head, -1);
|
||||
|
@ -1356,7 +1356,7 @@ CommandCost CmdMoveRailVehicle(DoCommandFlag flags, VehicleID src_veh, VehicleID
|
|||
if (src_head != nullptr && src_head->IsFrontEngine()) GroupStatistics::CountVehicle(src_head, 1);
|
||||
if (dst_head != nullptr && dst_head->IsFrontEngine()) GroupStatistics::CountVehicle(dst_head, 1);
|
||||
|
||||
if ((flags & DC_NO_CARGO_CAP_CHECK) == 0) {
|
||||
if (!flags.Test(DoCommandFlag::NoCargoCapacityCheck)) {
|
||||
CheckCargoCapacity(src_head);
|
||||
CheckCargoCapacity(dst_head);
|
||||
}
|
||||
|
@ -1388,7 +1388,7 @@ CommandCost CmdMoveRailVehicle(DoCommandFlag flags, VehicleID src_veh, VehicleID
|
|||
* @param user the user for the order backup.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, bool sell_chain, bool backup_order, ClientID user)
|
||||
CommandCost CmdSellRailWagon(DoCommandFlags flags, Vehicle *t, bool sell_chain, bool backup_order, ClientID user)
|
||||
{
|
||||
Train *v = Train::From(t)->GetFirstEnginePart();
|
||||
Train *first = v->First();
|
||||
|
@ -1408,7 +1408,7 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, bool sell_chain, b
|
|||
ArrangeTrains(&sell_head, nullptr, &new_head, v, sell_chain);
|
||||
|
||||
/* We don't need to validate the second train; it's going to be sold. */
|
||||
CommandCost ret = ValidateTrains(nullptr, nullptr, first, new_head, (flags & DC_AUTOREPLACE) == 0);
|
||||
CommandCost ret = ValidateTrains(nullptr, nullptr, first, new_head, !flags.Test(DoCommandFlag::AutoReplace));
|
||||
if (ret.Failed()) {
|
||||
/* Restore the train we had. */
|
||||
RestoreTrainBackup(original);
|
||||
|
@ -1425,7 +1425,7 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, bool sell_chain, b
|
|||
for (Train *part = sell_head; part != nullptr; part = part->Next()) cost.AddCost(-part->value);
|
||||
|
||||
/* do it? */
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* First normalise the sub types of the chain. */
|
||||
NormaliseSubtypes(new_head);
|
||||
|
||||
|
@ -2056,7 +2056,7 @@ void ReverseTrainDirection(Train *v)
|
|||
* @param reverse_single_veh if true, reverse a unit in a train (needs to be in a depot)
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdReverseTrainDirection(DoCommandFlag flags, VehicleID veh_id, bool reverse_single_veh)
|
||||
CommandCost CmdReverseTrainDirection(DoCommandFlags flags, VehicleID veh_id, bool reverse_single_veh)
|
||||
{
|
||||
Train *v = Train::GetIfValid(veh_id);
|
||||
if (v == nullptr) return CMD_ERROR;
|
||||
|
@ -2077,7 +2077,7 @@ CommandCost CmdReverseTrainDirection(DoCommandFlag flags, VehicleID veh_id, bool
|
|||
return CommandCost(STR_ERROR_TRAINS_CAN_ONLY_BE_ALTERED_INSIDE_A_DEPOT);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
ToggleBit(v->flags, VRF_REVERSE_DIRECTION);
|
||||
|
||||
front->ConsistChanged(CCF_ARRANGE);
|
||||
|
@ -2091,7 +2091,7 @@ CommandCost CmdReverseTrainDirection(DoCommandFlag flags, VehicleID veh_id, bool
|
|||
if (!v->IsPrimaryVehicle()) return CMD_ERROR;
|
||||
if ((v->vehstatus & VS_CRASHED) || v->breakdown_ctr != 0) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Properly leave the station if we are loading and won't be loading anymore */
|
||||
if (v->current_order.IsType(OT_LOADING)) {
|
||||
const Vehicle *last = v;
|
||||
|
@ -2129,7 +2129,7 @@ CommandCost CmdReverseTrainDirection(DoCommandFlag flags, VehicleID veh_id, bool
|
|||
* @param veh_id train to ignore the red signal
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdForceTrainProceed(DoCommandFlag flags, VehicleID veh_id)
|
||||
CommandCost CmdForceTrainProceed(DoCommandFlags flags, VehicleID veh_id)
|
||||
{
|
||||
Train *t = Train::GetIfValid(veh_id);
|
||||
if (t == nullptr) return CMD_ERROR;
|
||||
|
@ -2140,7 +2140,7 @@ CommandCost CmdForceTrainProceed(DoCommandFlag flags, VehicleID veh_id)
|
|||
if (ret.Failed()) return ret;
|
||||
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* If we are forced to proceed, cancel that order.
|
||||
* If we are marked stuck we would want to force the train
|
||||
* to proceed to the next signal. In the other cases we
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
#include "engine_type.h"
|
||||
#include "vehicle_type.h"
|
||||
|
||||
CommandCost CmdBuildRailVehicle(DoCommandFlag flags, TileIndex tile, const Engine *e, Vehicle **ret);
|
||||
CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, bool sell_chain, bool backup_order, ClientID user);
|
||||
CommandCost CmdBuildRailVehicle(DoCommandFlags flags, TileIndex tile, const Engine *e, Vehicle **ret);
|
||||
CommandCost CmdSellRailWagon(DoCommandFlags flags, Vehicle *t, bool sell_chain, bool backup_order, ClientID user);
|
||||
|
||||
CommandCost CmdMoveRailVehicle(DoCommandFlag flags, VehicleID src_veh, VehicleID dest_veh, bool move_chain);
|
||||
CommandCost CmdForceTrainProceed(DoCommandFlag flags, VehicleID veh_id);
|
||||
CommandCost CmdReverseTrainDirection(DoCommandFlag flags, VehicleID veh_id, bool reverse_single_veh);
|
||||
CommandCost CmdMoveRailVehicle(DoCommandFlags flags, VehicleID src_veh, VehicleID dest_veh, bool move_chain);
|
||||
CommandCost CmdForceTrainProceed(DoCommandFlags flags, VehicleID veh_id);
|
||||
CommandCost CmdReverseTrainDirection(DoCommandFlags flags, VehicleID veh_id, bool reverse_single_veh);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_MOVE_RAIL_VEHICLE, CmdMoveRailVehicle, CMD_LOCATION, CMDT_VEHICLE_CONSTRUCTION)
|
||||
DEF_CMD_TRAIT(CMD_FORCE_TRAIN_PROCEED, CmdForceTrainProceed, CMD_LOCATION, CMDT_VEHICLE_MANAGEMENT)
|
||||
|
|
|
@ -389,7 +389,7 @@ void GenerateTrees()
|
|||
* @param diagonal Whether to use the Orthogonal (false) or Diagonal (true) iterator.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdPlantTree(DoCommandFlag flags, TileIndex tile, TileIndex start_tile, uint8_t tree_to_plant, bool diagonal)
|
||||
CommandCost CmdPlantTree(DoCommandFlags flags, TileIndex tile, TileIndex start_tile, uint8_t tree_to_plant, bool diagonal)
|
||||
{
|
||||
StringID msg = INVALID_STRING_ID;
|
||||
CommandCost cost(EXPENSES_OTHER);
|
||||
|
@ -418,7 +418,7 @@ CommandCost CmdPlantTree(DoCommandFlag flags, TileIndex tile, TileIndex start_ti
|
|||
break;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
AddTreeCount(current_tile, 1);
|
||||
MarkTileDirtyByTile(current_tile);
|
||||
if (c != nullptr) c->tree_limit -= 1 << 16;
|
||||
|
@ -479,7 +479,7 @@ CommandCost CmdPlantTree(DoCommandFlag flags, TileIndex tile, TileIndex start_ti
|
|||
if (t != nullptr) ChangeTownRating(t, RATING_TREE_UP_STEP, RATING_TREE_MAXIMUM, flags);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (treetype == TREE_INVALID) {
|
||||
treetype = GetRandomTreeType(current_tile, GB(Random(), 24, 8));
|
||||
if (treetype == TREE_INVALID) treetype = TREE_CACTUS;
|
||||
|
@ -602,7 +602,7 @@ static Foundation GetFoundation_Trees(TileIndex, Slope)
|
|||
return FOUNDATION_NONE;
|
||||
}
|
||||
|
||||
static CommandCost ClearTile_Trees(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost ClearTile_Trees(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
uint num;
|
||||
|
||||
|
@ -614,7 +614,7 @@ static CommandCost ClearTile_Trees(TileIndex tile, DoCommandFlag flags)
|
|||
num = GetTreeCount(tile);
|
||||
if (IsInsideMM(GetTreeType(tile), TREE_RAINFOREST, TREE_CACTUS)) num *= 4;
|
||||
|
||||
if (flags & DC_EXEC) DoClearSquare(tile);
|
||||
if (flags.Test(DoCommandFlag::Execute)) DoClearSquare(tile);
|
||||
|
||||
return CommandCost(EXPENSES_CONSTRUCTION, num * _price[PR_CLEAR_TREES]);
|
||||
}
|
||||
|
@ -890,7 +890,7 @@ void InitializeTrees()
|
|||
_trees_tick_ctr = 0;
|
||||
}
|
||||
|
||||
static CommandCost TerraformTile_Trees(TileIndex tile, DoCommandFlag flags, int, Slope)
|
||||
static CommandCost TerraformTile_Trees(TileIndex tile, DoCommandFlags flags, int, Slope)
|
||||
{
|
||||
return Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include "command_type.h"
|
||||
|
||||
CommandCost CmdPlantTree(DoCommandFlag flags, TileIndex tile, TileIndex start_tile, uint8_t tree_to_plant, bool diagonal);
|
||||
CommandCost CmdPlantTree(DoCommandFlags flags, TileIndex tile, TileIndex start_tile, uint8_t tree_to_plant, bool diagonal);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_PLANT_TREE, CmdPlantTree, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
|
||||
|
|
|
@ -197,9 +197,9 @@ static CommandCost CheckBridgeSlope(BridgePieces bridge_piece, Axis axis, Slope
|
|||
* @param flags Type of operation.
|
||||
* @return A succeeded (the requested bridge is available) or failed (it cannot be built) command.
|
||||
*/
|
||||
CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags)
|
||||
CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlags flags)
|
||||
{
|
||||
if (flags & DC_QUERY_COST) {
|
||||
if (flags.Test(DoCommandFlag::QueryCost)) {
|
||||
if (bridge_len <= _settings_game.construction.max_bridge_length) return CommandCost();
|
||||
return CommandCost(STR_ERROR_BRIDGE_TOO_LONG);
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ static Money TunnelBridgeClearCost(TileIndex tile, Price base_price)
|
|||
* @param road_rail_type rail type or road types.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildBridge(DoCommandFlag flags, TileIndex tile_end, TileIndex tile_start, TransportType transport_type, BridgeType bridge_type, uint8_t road_rail_type)
|
||||
CommandCost CmdBuildBridge(DoCommandFlags flags, TileIndex tile_end, TileIndex tile_start, TransportType transport_type, BridgeType bridge_type, uint8_t road_rail_type)
|
||||
{
|
||||
CompanyID company = _current_company;
|
||||
|
||||
|
@ -373,7 +373,7 @@ CommandCost CmdBuildBridge(DoCommandFlag flags, TileIndex tile_end, TileIndex ti
|
|||
}
|
||||
}
|
||||
|
||||
if (!(flags & DC_QUERY_COST)) {
|
||||
if (!flags.Test(DoCommandFlag::QueryCost)) {
|
||||
/* Do not replace the bridge with the same bridge type. */
|
||||
if ((bridge_type == GetBridgeType(tile_start)) && (transport_type != TRANSPORT_ROAD || road_rt == roadtype || tram_rt == roadtype)) {
|
||||
return CommandCost(STR_ERROR_ALREADY_BUILT);
|
||||
|
@ -497,7 +497,7 @@ CommandCost CmdBuildBridge(DoCommandFlag flags, TileIndex tile_end, TileIndex ti
|
|||
break;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* We do this here because when replacing a bridge with another
|
||||
* type calling SetBridgeMiddle isn't needed. After all, the
|
||||
* tile already has the has_bridge_above bits set. */
|
||||
|
@ -517,7 +517,7 @@ CommandCost CmdBuildBridge(DoCommandFlag flags, TileIndex tile_end, TileIndex ti
|
|||
}
|
||||
|
||||
/* do the drill? */
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
DiagDirection dir = AxisToDiagDir(direction);
|
||||
|
||||
Company *c = Company::GetIfValid(company);
|
||||
|
@ -572,18 +572,18 @@ CommandCost CmdBuildBridge(DoCommandFlag flags, TileIndex tile_end, TileIndex ti
|
|||
DirtyCompanyInfrastructureWindows(company);
|
||||
}
|
||||
|
||||
if ((flags & DC_EXEC) && transport_type == TRANSPORT_RAIL) {
|
||||
if (flags.Test(DoCommandFlag::Execute) && transport_type == TRANSPORT_RAIL) {
|
||||
Track track = AxisToTrack(direction);
|
||||
AddSideToSignalBuffer(tile_start, INVALID_DIAGDIR, company);
|
||||
YapfNotifyTrackLayoutChange(tile_start, track);
|
||||
}
|
||||
|
||||
/* Human players that build bridges get a selection to choose from (DC_QUERY_COST)
|
||||
/* Human players that build bridges get a selection to choose from (DoCommandFlag::QueryCost)
|
||||
* It's unnecessary to execute this command every time for every bridge.
|
||||
* So it is done only for humans and cost is computed in bridge_gui.cpp.
|
||||
* For (non-spectated) AI, Towns this has to be of course calculated. */
|
||||
Company *c = Company::GetIfValid(company);
|
||||
if (!(flags & DC_QUERY_COST) || (c != nullptr && c->is_ai && company != _local_company)) {
|
||||
if (!flags.Test(DoCommandFlag::QueryCost) || (c != nullptr && c->is_ai && company != _local_company)) {
|
||||
switch (transport_type) {
|
||||
case TRANSPORT_ROAD:
|
||||
if (road_rt != INVALID_ROADTYPE) {
|
||||
|
@ -621,7 +621,7 @@ CommandCost CmdBuildBridge(DoCommandFlag flags, TileIndex tile_end, TileIndex ti
|
|||
* @param road_rail_type railtype or roadtype
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildTunnel(DoCommandFlag flags, TileIndex start_tile, TransportType transport_type, uint8_t road_rail_type)
|
||||
CommandCost CmdBuildTunnel(DoCommandFlags flags, TileIndex start_tile, TransportType transport_type, uint8_t road_rail_type)
|
||||
{
|
||||
CompanyID company = _current_company;
|
||||
|
||||
|
@ -767,7 +767,7 @@ CommandCost CmdBuildTunnel(DoCommandFlag flags, TileIndex start_tile, TransportT
|
|||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Company *c = Company::GetIfValid(company);
|
||||
uint num_pieces = (tiles + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR;
|
||||
if (transport_type == TRANSPORT_RAIL) {
|
||||
|
@ -843,7 +843,7 @@ static inline CommandCost CheckAllowRemoveTunnelBridge(TileIndex tile)
|
|||
* @param flags Command flags.
|
||||
* @return Succeeded or failed command.
|
||||
*/
|
||||
static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
CommandCost ret = CheckAllowRemoveTunnelBridge(tile);
|
||||
if (ret.Failed()) return ret;
|
||||
|
@ -874,7 +874,7 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
|
|||
Money base_cost = TunnelBridgeClearCost(tile, PR_CLEAR_TUNNEL);
|
||||
uint len = GetTunnelBridgeLength(tile, endtile) + 2; // Don't forget the end tiles.
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) {
|
||||
/* We first need to request values before calling DoClearSquare */
|
||||
DiagDirection dir = GetTunnelBridgeDirection(tile);
|
||||
|
@ -923,7 +923,7 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
|
|||
* @param flags Command flags.
|
||||
* @return Succeeded or failed command.
|
||||
*/
|
||||
static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost DoClearBridge(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
CommandCost ret = CheckAllowRemoveTunnelBridge(tile);
|
||||
if (ret.Failed()) return ret;
|
||||
|
@ -955,7 +955,7 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
|
|||
Money base_cost = TunnelBridgeClearCost(tile, PR_CLEAR_BRIDGE);
|
||||
uint len = GetTunnelBridgeLength(tile, endtile) + 2; // Don't forget the end tiles.
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* read this value before actual removal of bridge */
|
||||
bool rail = GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL;
|
||||
Owner owner = GetTileOwner(tile);
|
||||
|
@ -1014,13 +1014,13 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
|
|||
* @param flags Command flags.
|
||||
* @return Succeeded or failed command.
|
||||
*/
|
||||
static CommandCost ClearTile_TunnelBridge(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost ClearTile_TunnelBridge(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
if (IsTunnel(tile)) {
|
||||
if (flags & DC_AUTO) return CommandCost(STR_ERROR_MUST_DEMOLISH_TUNNEL_FIRST);
|
||||
if (flags.Test(DoCommandFlag::Auto)) return CommandCost(STR_ERROR_MUST_DEMOLISH_TUNNEL_FIRST);
|
||||
return DoClearTunnel(tile, flags);
|
||||
} else { // IsBridge(tile)
|
||||
if (flags & DC_AUTO) return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
|
||||
if (flags.Test(DoCommandFlag::Auto)) return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
|
||||
return DoClearBridge(tile, flags);
|
||||
}
|
||||
}
|
||||
|
@ -1844,7 +1844,7 @@ static void ChangeTileOwner_TunnelBridge(TileIndex tile, Owner old_owner, Owner
|
|||
if (tt == TRANSPORT_RAIL) {
|
||||
/* Since all of our vehicles have been removed, it is safe to remove the rail
|
||||
* bridge / tunnel. */
|
||||
[[maybe_unused]] CommandCost ret = Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC | DC_BANKRUPT, tile);
|
||||
[[maybe_unused]] CommandCost ret = Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile);
|
||||
assert(ret.Succeeded());
|
||||
} else {
|
||||
/* In any other case, we can safely reassign the ownership to OWNER_NONE. */
|
||||
|
@ -2033,7 +2033,7 @@ static VehicleEnterTileStatus VehicleEnter_TunnelBridge(Vehicle *v, TileIndex ti
|
|||
return VETSB_CONTINUE;
|
||||
}
|
||||
|
||||
static CommandCost TerraformTile_TunnelBridge(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
|
||||
static CommandCost TerraformTile_TunnelBridge(TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new)
|
||||
{
|
||||
if (_settings_game.construction.build_on_slopes && AutoslopeEnabled() && IsBridge(tile) && GetTunnelBridgeTransportType(tile) != TRANSPORT_WATER) {
|
||||
DiagDirection direction = GetTunnelBridgeDirection(tile);
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
#include "transport_type.h"
|
||||
#include "bridge.h"
|
||||
|
||||
CommandCost CmdBuildBridge(DoCommandFlag flags, TileIndex tile_end, TileIndex tile_start, TransportType transport_type, BridgeType bridge_type, uint8_t road_rail_type);
|
||||
CommandCost CmdBuildTunnel(DoCommandFlag flags, TileIndex start_tile, TransportType transport_type, uint8_t road_rail_type);
|
||||
CommandCost CmdBuildBridge(DoCommandFlags flags, TileIndex tile_end, TileIndex tile_start, TransportType transport_type, BridgeType bridge_type, uint8_t road_rail_type);
|
||||
CommandCost CmdBuildTunnel(DoCommandFlags flags, TileIndex start_tile, TransportType transport_type, uint8_t road_rail_type);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_BUILD_BRIDGE, CmdBuildBridge, CMD_DEITY | CMD_AUTO | CMD_NO_WATER, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
DEF_CMD_TRAIT(CMD_BUILD_TUNNEL, CmdBuildTunnel, CMD_DEITY | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
|
|
|
@ -327,7 +327,7 @@ void ShowNewGrfVehicleError(EngineID engine, StringID part1, StringID part2, GRF
|
|||
SetDParamStr(0, grfconfig->GetName());
|
||||
SetDParam(1, engine);
|
||||
ShowErrorMessage(part1, part2, WL_CRITICAL);
|
||||
if (!_networking) Command<CMD_PAUSE>::Do(DC_EXEC, critical ? PM_PAUSED_ERROR : PM_PAUSED_NORMAL, true);
|
||||
if (!_networking) Command<CMD_PAUSE>::Do(DoCommandFlag::Execute, critical ? PM_PAUSED_ERROR : PM_PAUSED_NORMAL, true);
|
||||
}
|
||||
|
||||
/* debug output */
|
||||
|
@ -1087,7 +1087,7 @@ void CallVehicleTicks()
|
|||
|
||||
const Company *c = Company::Get(_current_company);
|
||||
SubtractMoneyFromCompany(CommandCost(EXPENSES_NEW_VEHICLES, (Money)c->settings.engine_renew_money));
|
||||
CommandCost res = Command<CMD_AUTOREPLACE_VEHICLE>::Do(DC_EXEC, v->index);
|
||||
CommandCost res = Command<CMD_AUTOREPLACE_VEHICLE>::Do(DoCommandFlag::Execute, v->index);
|
||||
SubtractMoneyFromCompany(CommandCost(EXPENSES_NEW_VEHICLES, -(Money)c->settings.engine_renew_money));
|
||||
|
||||
if (!IsLocalCompany()) continue;
|
||||
|
@ -1626,7 +1626,7 @@ void VehicleEnterDepot(Vehicle *v)
|
|||
|
||||
if (v->current_order.IsRefit()) {
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner);
|
||||
CommandCost cost = std::get<0>(Command<CMD_REFIT_VEHICLE>::Do(DC_EXEC, v->index, v->current_order.GetRefitCargo(), 0xFF, false, false, 0));
|
||||
CommandCost cost = std::get<0>(Command<CMD_REFIT_VEHICLE>::Do(DoCommandFlag::Execute, v->index, v->current_order.GetRefitCargo(), 0xFF, false, false, 0));
|
||||
cur_company.Restore();
|
||||
|
||||
if (cost.Failed()) {
|
||||
|
@ -2580,7 +2580,7 @@ bool Vehicle::IsWaitingForUnbunching() const
|
|||
* @param command the command to execute.
|
||||
* @return the cost of the depot action.
|
||||
*/
|
||||
CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommandFlags command)
|
||||
CommandCost Vehicle::SendToDepot(DoCommandFlags flags, DepotCommandFlags command)
|
||||
{
|
||||
CommandCost ret = CheckOwnership(this->owner);
|
||||
if (ret.Failed()) return ret;
|
||||
|
@ -2589,7 +2589,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommandFlags command)
|
|||
if (this->IsStoppedInDepot()) return CMD_ERROR;
|
||||
|
||||
/* No matter why we're headed to the depot, unbunching data is no longer valid. */
|
||||
if (flags & DC_EXEC) this->ResetDepotUnbunching();
|
||||
if (flags.Test(DoCommandFlag::Execute)) this->ResetDepotUnbunching();
|
||||
|
||||
if (this->current_order.IsType(OT_GOTO_DEPOT)) {
|
||||
bool halt_in_depot = (this->current_order.GetDepotActionType() & ODATFB_HALT) != 0;
|
||||
|
@ -2597,7 +2597,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommandFlags command)
|
|||
/* We called with a different DEPOT_SERVICE setting.
|
||||
* Now we change the setting to apply the new one and let the vehicle head for the same depot.
|
||||
* Note: the if is (true for requesting service == true for ordered to stop in depot) */
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
this->current_order.SetDepotOrderType(ODTF_MANUAL);
|
||||
this->current_order.SetDepotActionType(halt_in_depot ? ODATF_SERVICE_ONLY : ODATFB_HALT);
|
||||
SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP);
|
||||
|
@ -2606,7 +2606,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommandFlags command)
|
|||
}
|
||||
|
||||
if (command.Test(DepotCommandFlag::DontCancel)) return CMD_ERROR; // Requested no cancellation of depot orders
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* If the orders to 'goto depot' are in the orders list (forced servicing),
|
||||
* then skip to the next order; effectively cancelling this forced service */
|
||||
if (this->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) this->IncrementRealOrderIndex();
|
||||
|
@ -2626,7 +2626,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommandFlags command)
|
|||
static const StringID no_depot[] = {STR_ERROR_UNABLE_TO_FIND_ROUTE_TO, STR_ERROR_UNABLE_TO_FIND_LOCAL_DEPOT, STR_ERROR_UNABLE_TO_FIND_LOCAL_DEPOT, STR_ERROR_CAN_T_SEND_AIRCRAFT_TO_HANGAR};
|
||||
if (!closestDepot.found) return CommandCost(no_depot[this->type]);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (this->current_order.IsType(OT_LOADING)) this->LeaveStation();
|
||||
|
||||
if (this->IsGroundVehicle() && this->GetNumManualOrders() > 0) {
|
||||
|
@ -2641,7 +2641,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommandFlags command)
|
|||
|
||||
/* If there is no depot in front and the train is not already reversing, reverse automatically (trains only) */
|
||||
if (this->type == VEH_TRAIN && (closestDepot.reverse ^ HasBit(Train::From(this)->flags, VRF_REVERSING))) {
|
||||
Command<CMD_REVERSE_TRAIN_DIRECTION>::Do(DC_EXEC, this->index, false);
|
||||
Command<CMD_REVERSE_TRAIN_DIRECTION>::Do(DoCommandFlag::Execute, this->index, false);
|
||||
}
|
||||
|
||||
if (this->type == VEH_AIRCRAFT) {
|
||||
|
|
|
@ -800,7 +800,7 @@ public:
|
|||
|
||||
virtual void SetDestTile(TileIndex tile) { this->dest_tile = tile; }
|
||||
|
||||
CommandCost SendToDepot(DoCommandFlag flags, DepotCommandFlags command);
|
||||
CommandCost SendToDepot(DoCommandFlags flags, DepotCommandFlags command);
|
||||
|
||||
void UpdateVisualEffect(bool allow_power_change = true);
|
||||
void ShowVisualEffect() const;
|
||||
|
|
|
@ -98,7 +98,7 @@ const StringID _send_to_depot_msg_table[] = {
|
|||
* @param client_id User
|
||||
* @return the cost of this operation + the new vehicle ID + the refitted capacity + the refitted mail capacity (aircraft) or an error
|
||||
*/
|
||||
std::tuple<CommandCost, VehicleID, uint, uint16_t, CargoArray> CmdBuildVehicle(DoCommandFlag flags, TileIndex tile, EngineID eid, bool use_free_vehicles, CargoType cargo, ClientID client_id)
|
||||
std::tuple<CommandCost, VehicleID, uint, uint16_t, CargoArray> CmdBuildVehicle(DoCommandFlags flags, TileIndex tile, EngineID eid, bool use_free_vehicles, CargoType cargo, ClientID client_id)
|
||||
{
|
||||
/* Elementary check for valid location. */
|
||||
if (!IsDepotTile(tile) || !IsTileOwner(tile, _current_company)) return { CMD_ERROR, INVALID_VEHICLE, 0, 0, {} };
|
||||
|
@ -134,13 +134,13 @@ std::tuple<CommandCost, VehicleID, uint, uint16_t, CargoArray> CmdBuildVehicle(D
|
|||
/* Check whether we can allocate a unit number. Autoreplace does not allocate
|
||||
* an unit number as it will (always) reuse the one of the replaced vehicle
|
||||
* and (train) wagons don't have an unit number in any scenario. */
|
||||
UnitID unit_num = (flags & DC_QUERY_COST || flags & DC_AUTOREPLACE || (type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_WAGON)) ? 0 : GetFreeUnitNumber(type);
|
||||
UnitID unit_num = (flags.Test(DoCommandFlag::QueryCost) || flags.Test(DoCommandFlag::AutoReplace) || (type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_WAGON)) ? 0 : GetFreeUnitNumber(type);
|
||||
if (unit_num == UINT16_MAX) return { CommandCost(STR_ERROR_TOO_MANY_VEHICLES_IN_GAME), INVALID_VEHICLE, 0, 0, {} };
|
||||
|
||||
/* If we are refitting we need to temporarily purchase the vehicle to be able to
|
||||
* test it. */
|
||||
DoCommandFlag subflags = flags;
|
||||
if (refitting && !(flags & DC_EXEC)) subflags |= DC_EXEC | DC_AUTOREPLACE;
|
||||
DoCommandFlags subflags = flags;
|
||||
if (refitting && !flags.Test(DoCommandFlag::Execute)) subflags.Set(DoCommandFlag::Execute).Set(DoCommandFlag::AutoReplace);
|
||||
|
||||
/* Vehicle construction needs random bits, so we have to save the random
|
||||
* seeds to prevent desyncs. */
|
||||
|
@ -161,7 +161,7 @@ std::tuple<CommandCost, VehicleID, uint, uint16_t, CargoArray> CmdBuildVehicle(D
|
|||
uint16_t refitted_mail_capacity = 0;
|
||||
CargoArray cargo_capacities{};
|
||||
if (value.Succeeded()) {
|
||||
if (subflags & DC_EXEC) {
|
||||
if (subflags.Test(DoCommandFlag::Execute)) {
|
||||
v->unitnumber = unit_num;
|
||||
v->value = value.GetCost();
|
||||
veh_id = v->index;
|
||||
|
@ -186,8 +186,8 @@ std::tuple<CommandCost, VehicleID, uint, uint16_t, CargoArray> CmdBuildVehicle(D
|
|||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (type == VEH_TRAIN && use_free_vehicles && !(flags & DC_AUTOREPLACE) && Train::From(v)->IsEngine()) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (type == VEH_TRAIN && use_free_vehicles && !flags.Test(DoCommandFlag::AutoReplace) && Train::From(v)->IsEngine()) {
|
||||
/* Move any free wagons to the new vehicle. */
|
||||
NormalizeTrainVehInDepot(Train::From(v));
|
||||
}
|
||||
|
@ -200,22 +200,22 @@ std::tuple<CommandCost, VehicleID, uint, uint16_t, CargoArray> CmdBuildVehicle(D
|
|||
}
|
||||
}
|
||||
|
||||
if (subflags & DC_EXEC) {
|
||||
if (subflags.Test(DoCommandFlag::Execute)) {
|
||||
GroupStatistics::CountEngine(v, 1);
|
||||
GroupStatistics::UpdateAutoreplace(_current_company);
|
||||
|
||||
if (v->IsPrimaryVehicle()) {
|
||||
GroupStatistics::CountVehicle(v, 1);
|
||||
if (!(subflags & DC_AUTOREPLACE)) OrderBackup::Restore(v, client_id);
|
||||
if (!subflags.Test(DoCommandFlag::AutoReplace)) OrderBackup::Restore(v, client_id);
|
||||
}
|
||||
|
||||
Company::Get(v->owner)->freeunits[v->type].UseID(v->unitnumber);
|
||||
}
|
||||
|
||||
|
||||
/* If we are not in DC_EXEC undo everything */
|
||||
/* If we are not in DoCommandFlag::Execute undo everything */
|
||||
if (flags != subflags) {
|
||||
Command<CMD_SELL_VEHICLE>::Do(DC_EXEC, v->index, false, false, INVALID_CLIENT_ID);
|
||||
Command<CMD_SELL_VEHICLE>::Do(DoCommandFlag::Execute, v->index, false, false, INVALID_CLIENT_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ std::tuple<CommandCost, VehicleID, uint, uint16_t, CargoArray> CmdBuildVehicle(D
|
|||
* @param client_id User.
|
||||
* @return the cost of this operation or an error.
|
||||
*/
|
||||
CommandCost CmdSellVehicle(DoCommandFlag flags, VehicleID v_id, bool sell_chain, bool backup_order, ClientID client_id)
|
||||
CommandCost CmdSellVehicle(DoCommandFlags flags, VehicleID v_id, bool sell_chain, bool backup_order, ClientID client_id)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(v_id);
|
||||
if (v == nullptr) return CMD_ERROR;
|
||||
|
@ -263,7 +263,7 @@ CommandCost CmdSellVehicle(DoCommandFlag flags, VehicleID v_id, bool sell_chain,
|
|||
} else {
|
||||
ret = CommandCost(EXPENSES_NEW_VEHICLES, -front->value);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (front->IsPrimaryVehicle() && backup_order) OrderBackup::Backup(front, client_id);
|
||||
delete front;
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ struct RefitResult {
|
|||
* @param auto_refit Refitting is done as automatic refitting outside a depot.
|
||||
* @return Refit cost + refittet capacity + mail capacity (aircraft).
|
||||
*/
|
||||
static std::tuple<CommandCost, uint, uint16_t, CargoArray> RefitVehicle(Vehicle *v, bool only_this, uint8_t num_vehicles, CargoType new_cargo_type, uint8_t new_subtype, DoCommandFlag flags, bool auto_refit)
|
||||
static std::tuple<CommandCost, uint, uint16_t, CargoArray> RefitVehicle(Vehicle *v, bool only_this, uint8_t num_vehicles, CargoType new_cargo_type, uint8_t new_subtype, DoCommandFlags flags, bool auto_refit)
|
||||
{
|
||||
CommandCost cost(v->GetExpenseType(false));
|
||||
uint total_capacity = 0;
|
||||
|
@ -438,7 +438,7 @@ static std::tuple<CommandCost, uint, uint16_t, CargoArray> RefitVehicle(Vehicle
|
|||
|
||||
bool auto_refit_allowed;
|
||||
CommandCost refit_cost = GetRefitCost(v, v->engine_type, new_cargo_type, actual_subtype, &auto_refit_allowed);
|
||||
if (auto_refit && (flags & DC_QUERY_COST) == 0 && !auto_refit_allowed) {
|
||||
if (auto_refit && !flags.Test(DoCommandFlag::QueryCost) && !auto_refit_allowed) {
|
||||
/* Sorry, auto-refitting not allowed, subtract the cargo amount again from the total.
|
||||
* When querrying cost/capacity (for example in order refit GUI), we always assume 'allowed'.
|
||||
* It is not predictable. */
|
||||
|
@ -466,7 +466,7 @@ static std::tuple<CommandCost, uint, uint16_t, CargoArray> RefitVehicle(Vehicle
|
|||
refit_result.push_back({v, amount, mail_capacity, actual_subtype});
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Store the result */
|
||||
for (RefitResult &result : refit_result) {
|
||||
Vehicle *u = result.v;
|
||||
|
@ -501,7 +501,7 @@ static std::tuple<CommandCost, uint, uint16_t, CargoArray> RefitVehicle(Vehicle
|
|||
* Only used if "refit only this vehicle" is false.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
std::tuple<CommandCost, uint, uint16_t, CargoArray> CmdRefitVehicle(DoCommandFlag flags, VehicleID veh_id, CargoType new_cargo_type, uint8_t new_subtype, bool auto_refit, bool only_this, uint8_t num_vehicles)
|
||||
std::tuple<CommandCost, uint, uint16_t, CargoArray> CmdRefitVehicle(DoCommandFlags flags, VehicleID veh_id, CargoType new_cargo_type, uint8_t new_subtype, bool auto_refit, bool only_this, uint8_t num_vehicles)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(veh_id);
|
||||
if (v == nullptr) return { CMD_ERROR, 0, 0, {} };
|
||||
|
@ -521,7 +521,7 @@ std::tuple<CommandCost, uint, uint16_t, CargoArray> CmdRefitVehicle(DoCommandFla
|
|||
if (v != front && (v->type == VEH_SHIP || v->type == VEH_AIRCRAFT)) return { CMD_ERROR, 0, 0, {} };
|
||||
|
||||
/* Allow auto-refitting only during loading and normal refitting only in a depot. */
|
||||
if ((flags & DC_QUERY_COST) == 0 && // used by the refit GUI, including the order refit GUI.
|
||||
if (!flags.Test(DoCommandFlag::QueryCost) && // used by the refit GUI, including the order refit GUI.
|
||||
!free_wagon && // used by autoreplace/renew
|
||||
(!auto_refit || !front->current_order.IsType(OT_LOADING)) && // refit inside stations
|
||||
!front->IsStoppedInDepot()) { // refit inside depots
|
||||
|
@ -538,7 +538,7 @@ std::tuple<CommandCost, uint, uint16_t, CargoArray> CmdRefitVehicle(DoCommandFla
|
|||
|
||||
auto [cost, refit_capacity, mail_capacity, cargo_capacities] = RefitVehicle(v, only_this, num_vehicles, new_cargo_type, new_subtype, flags, auto_refit);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Update the cached variables */
|
||||
switch (v->type) {
|
||||
case VEH_TRAIN:
|
||||
|
@ -580,13 +580,13 @@ std::tuple<CommandCost, uint, uint16_t, CargoArray> CmdRefitVehicle(DoCommandFla
|
|||
* Start/Stop a vehicle
|
||||
* @param flags type of operation
|
||||
* @param veh_id vehicle to start/stop, don't forget to change CcStartStopVehicle if you modify this!
|
||||
* @param evaluate_startstop_cb Shall the start/stop newgrf callback be evaluated (only valid with DC_AUTOREPLACE for network safety)
|
||||
* @param evaluate_startstop_cb Shall the start/stop newgrf callback be evaluated (only valid with DoCommandFlag::AutoReplace for network safety)
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdStartStopVehicle(DoCommandFlag flags, VehicleID veh_id, bool evaluate_startstop_cb)
|
||||
CommandCost CmdStartStopVehicle(DoCommandFlags flags, VehicleID veh_id, bool evaluate_startstop_cb)
|
||||
{
|
||||
/* Disable the effect of p2 bit 0, when DC_AUTOREPLACE is not set */
|
||||
if ((flags & DC_AUTOREPLACE) == 0) evaluate_startstop_cb = true;
|
||||
/* Disable the effect of evaluate_startstop_cb, when DoCommandFlag::AutoReplace is not set */
|
||||
if (!flags.Test(DoCommandFlag::AutoReplace)) evaluate_startstop_cb = true;
|
||||
|
||||
Vehicle *v = Vehicle::GetIfValid(veh_id);
|
||||
if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
||||
|
@ -642,8 +642,8 @@ CommandCost CmdStartStopVehicle(DoCommandFlag flags, VehicleID veh_id, bool eval
|
|||
if (error != STR_NULL) return CommandCost(error);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (v->IsStoppedInDepot() && (flags & DC_AUTOREPLACE) == 0) DeleteVehicleNews(veh_id, AdviceType::VehicleWaiting);
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (v->IsStoppedInDepot() && !flags.Test(DoCommandFlag::AutoReplace)) DeleteVehicleNews(veh_id, AdviceType::VehicleWaiting);
|
||||
|
||||
v->vehstatus ^= VS_STOPPED;
|
||||
if (v->type != VEH_TRAIN) v->cur_speed = 0; // trains can stop 'slowly'
|
||||
|
@ -669,7 +669,7 @@ CommandCost CmdStartStopVehicle(DoCommandFlag flags, VehicleID veh_id, bool eval
|
|||
* @param vli VehicleListIdentifier
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdMassStartStopVehicle(DoCommandFlag flags, TileIndex tile, bool do_start, bool vehicle_list_window, const VehicleListIdentifier &vli)
|
||||
CommandCost CmdMassStartStopVehicle(DoCommandFlags flags, TileIndex tile, bool do_start, bool vehicle_list_window, const VehicleListIdentifier &vli)
|
||||
{
|
||||
VehicleList list;
|
||||
|
||||
|
@ -703,7 +703,7 @@ CommandCost CmdMassStartStopVehicle(DoCommandFlag flags, TileIndex tile, bool do
|
|||
* @param vehicle_type Vehicle type
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdDepotSellAllVehicles(DoCommandFlag flags, TileIndex tile, VehicleType vehicle_type)
|
||||
CommandCost CmdDepotSellAllVehicles(DoCommandFlags flags, TileIndex tile, VehicleType vehicle_type)
|
||||
{
|
||||
VehicleList list;
|
||||
|
||||
|
@ -737,7 +737,7 @@ CommandCost CmdDepotSellAllVehicles(DoCommandFlag flags, TileIndex tile, Vehicle
|
|||
* @param vehicle_type Type of vehicle
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdDepotMassAutoReplace(DoCommandFlag flags, TileIndex tile, VehicleType vehicle_type)
|
||||
CommandCost CmdDepotMassAutoReplace(DoCommandFlags flags, TileIndex tile, VehicleType vehicle_type)
|
||||
{
|
||||
VehicleList list;
|
||||
CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES);
|
||||
|
@ -837,7 +837,7 @@ static void CloneVehicleName(const Vehicle *src, Vehicle *dst)
|
|||
* @param share_orders shared orders, else copied orders
|
||||
* @return the cost of this operation + the new vehicle ID or an error
|
||||
*/
|
||||
std::tuple<CommandCost, VehicleID> CmdCloneVehicle(DoCommandFlag flags, TileIndex tile, VehicleID veh_id, bool share_orders)
|
||||
std::tuple<CommandCost, VehicleID> CmdCloneVehicle(DoCommandFlags flags, TileIndex tile, VehicleID veh_id, bool share_orders)
|
||||
{
|
||||
CommandCost total_cost(EXPENSES_NEW_VEHICLES);
|
||||
|
||||
|
@ -862,7 +862,7 @@ std::tuple<CommandCost, VehicleID> CmdCloneVehicle(DoCommandFlag flags, TileInde
|
|||
if (v->type == VEH_TRAIN && (!v->IsFrontEngine() || Train::From(v)->crash_anim_pos >= 4400)) return { CMD_ERROR, INVALID_VEHICLE };
|
||||
|
||||
/* check that we can allocate enough vehicles */
|
||||
if (!(flags & DC_EXEC)) {
|
||||
if (!flags.Test(DoCommandFlag::Execute)) {
|
||||
int veh_counter = 0;
|
||||
do {
|
||||
veh_counter++;
|
||||
|
@ -888,8 +888,8 @@ std::tuple<CommandCost, VehicleID> CmdCloneVehicle(DoCommandFlag flags, TileInde
|
|||
* 'new' vehicles whereas they would immediately be joined with a primary
|
||||
* engine. This caused the vehicle to be not build as 'the limit' had been
|
||||
* reached, resulting in partially build vehicles and such. */
|
||||
DoCommandFlag build_flags = flags;
|
||||
if ((flags & DC_EXEC) && !v->IsPrimaryVehicle()) build_flags |= DC_AUTOREPLACE;
|
||||
DoCommandFlags build_flags = flags;
|
||||
if (flags.Test(DoCommandFlag::Execute) && !v->IsPrimaryVehicle()) build_flags.Set(DoCommandFlag::AutoReplace);
|
||||
|
||||
CommandCost cost;
|
||||
std::tie(cost, new_veh_id, std::ignore, std::ignore, std::ignore) = Command<CMD_BUILD_VEHICLE>::Do(build_flags, tile, v->engine_type, false, INVALID_CARGO, INVALID_CLIENT_ID);
|
||||
|
@ -902,7 +902,7 @@ std::tuple<CommandCost, VehicleID> CmdCloneVehicle(DoCommandFlag flags, TileInde
|
|||
|
||||
total_cost.AddCost(cost);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
w = Vehicle::Get(new_veh_id);
|
||||
|
||||
if (v->type == VEH_TRAIN && HasBit(Train::From(v)->flags, VRF_REVERSE_DIRECTION)) {
|
||||
|
@ -931,12 +931,12 @@ std::tuple<CommandCost, VehicleID> CmdCloneVehicle(DoCommandFlag flags, TileInde
|
|||
}
|
||||
} while (v->type == VEH_TRAIN && (v = v->GetNextVehicle()) != nullptr);
|
||||
|
||||
if ((flags & DC_EXEC) && v_front->type == VEH_TRAIN) {
|
||||
if (flags.Test(DoCommandFlag::Execute) && v_front->type == VEH_TRAIN) {
|
||||
/* for trains this needs to be the front engine due to the callback function */
|
||||
new_veh_id = w_front->index;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Cloned vehicles belong to the same group */
|
||||
Command<CMD_ADD_VEHICLE_GROUP>::Do(flags, v_front->group_id, w_front->index, false, VehicleListIdentifier{});
|
||||
}
|
||||
|
@ -954,7 +954,7 @@ std::tuple<CommandCost, VehicleID> CmdCloneVehicle(DoCommandFlag flags, TileInde
|
|||
* vehicles in a different loop. */
|
||||
do {
|
||||
do {
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
assert(w != nullptr);
|
||||
|
||||
/* Find out what's the best sub type */
|
||||
|
@ -986,10 +986,10 @@ std::tuple<CommandCost, VehicleID> CmdCloneVehicle(DoCommandFlag flags, TileInde
|
|||
}
|
||||
} while (v != nullptr);
|
||||
|
||||
if ((flags & DC_EXEC) && v->type == VEH_TRAIN) w = w->GetNextVehicle();
|
||||
if (flags.Test(DoCommandFlag::Execute) && v->type == VEH_TRAIN) w = w->GetNextVehicle();
|
||||
} while (v->type == VEH_TRAIN && (v = v->GetNextVehicle()) != nullptr);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/*
|
||||
* Set the orders of the vehicle. Cannot do it earlier as we need
|
||||
* the vehicle refitted before doing this, otherwise the moved
|
||||
|
@ -1024,7 +1024,7 @@ std::tuple<CommandCost, VehicleID> CmdCloneVehicle(DoCommandFlag flags, TileInde
|
|||
* @param vli identifier of the vehicle list
|
||||
* @return 0 for success and CMD_ERROR if no vehicle is able to go to depot
|
||||
*/
|
||||
static CommandCost SendAllVehiclesToDepot(DoCommandFlag flags, bool service, const VehicleListIdentifier &vli)
|
||||
static CommandCost SendAllVehiclesToDepot(DoCommandFlags flags, bool service, const VehicleListIdentifier &vli)
|
||||
{
|
||||
VehicleList list;
|
||||
|
||||
|
@ -1039,11 +1039,11 @@ static CommandCost SendAllVehiclesToDepot(DoCommandFlag flags, bool service, con
|
|||
if (ret.Succeeded()) {
|
||||
had_success = true;
|
||||
|
||||
/* Return 0 if DC_EXEC is not set this is a valid goto depot command)
|
||||
/* Return 0 if DoCommandFlag::Execute is not set this is a valid goto depot command)
|
||||
* In this case we know that at least one vehicle can be sent to a depot
|
||||
* and we will issue the command. We can now safely quit the loop, knowing
|
||||
* it will succeed at least once. With DC_EXEC we really need to send them to the depot */
|
||||
if (!(flags & DC_EXEC)) break;
|
||||
* it will succeed at least once. With DoCommandFlag::Execute we really need to send them to the depot */
|
||||
if (!flags.Test(DoCommandFlag::Execute)) break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1058,7 +1058,7 @@ static CommandCost SendAllVehiclesToDepot(DoCommandFlag flags, bool service, con
|
|||
* @param vli VehicleListIdentifier.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSendVehicleToDepot(DoCommandFlag flags, VehicleID veh_id, DepotCommandFlags depot_cmd, const VehicleListIdentifier &vli)
|
||||
CommandCost CmdSendVehicleToDepot(DoCommandFlags flags, VehicleID veh_id, DepotCommandFlags depot_cmd, const VehicleListIdentifier &vli)
|
||||
{
|
||||
if (depot_cmd.Test(DepotCommandFlag::MassSend)) {
|
||||
/* Mass goto depot requested */
|
||||
|
@ -1080,7 +1080,7 @@ CommandCost CmdSendVehicleToDepot(DoCommandFlag flags, VehicleID veh_id, DepotCo
|
|||
* @param text the new name or an empty string when resetting to the default
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRenameVehicle(DoCommandFlag flags, VehicleID veh_id, const std::string &text)
|
||||
CommandCost CmdRenameVehicle(DoCommandFlags flags, VehicleID veh_id, const std::string &text)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(veh_id);
|
||||
if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
||||
|
@ -1092,10 +1092,10 @@ CommandCost CmdRenameVehicle(DoCommandFlag flags, VehicleID veh_id, const std::s
|
|||
|
||||
if (!reset) {
|
||||
if (Utf8StringLength(text) >= MAX_LENGTH_VEHICLE_NAME_CHARS) return CMD_ERROR;
|
||||
if (!(flags & DC_AUTOREPLACE) && !IsUniqueVehicleName(text)) return CommandCost(STR_ERROR_NAME_MUST_BE_UNIQUE);
|
||||
if (!flags.Test(DoCommandFlag::AutoReplace) && !IsUniqueVehicleName(text)) return CommandCost(STR_ERROR_NAME_MUST_BE_UNIQUE);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (reset) {
|
||||
v->name.clear();
|
||||
} else {
|
||||
|
@ -1118,7 +1118,7 @@ CommandCost CmdRenameVehicle(DoCommandFlag flags, VehicleID veh_id, const std::s
|
|||
* @param is_percent service interval is percentage flag
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdChangeServiceInt(DoCommandFlag flags, VehicleID veh_id, uint16_t serv_int, bool is_custom, bool is_percent)
|
||||
CommandCost CmdChangeServiceInt(DoCommandFlags flags, VehicleID veh_id, uint16_t serv_int, bool is_custom, bool is_percent)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(veh_id);
|
||||
if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
||||
|
@ -1135,7 +1135,7 @@ CommandCost CmdChangeServiceInt(DoCommandFlag flags, VehicleID veh_id, uint16_t
|
|||
serv_int = CompanyServiceInterval(company, v->type);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
v->SetServiceInterval(serv_int);
|
||||
v->SetServiceIntervalIsCustom(is_custom);
|
||||
v->SetServiceIntervalIsPercent(is_percent);
|
||||
|
|
|
@ -17,17 +17,17 @@
|
|||
#include "vehiclelist_cmd.h"
|
||||
#include "cargo_type.h"
|
||||
|
||||
std::tuple<CommandCost, VehicleID, uint, uint16_t, CargoArray> CmdBuildVehicle(DoCommandFlag flags, TileIndex tile, EngineID eid, bool use_free_vehicles, CargoType cargo, ClientID client_id);
|
||||
CommandCost CmdSellVehicle(DoCommandFlag flags, VehicleID v_id, bool sell_chain, bool backup_order, ClientID client_id);
|
||||
std::tuple<CommandCost, uint, uint16_t, CargoArray> CmdRefitVehicle(DoCommandFlag flags, VehicleID veh_id, CargoType new_cargo_type, uint8_t new_subtype, bool auto_refit, bool only_this, uint8_t num_vehicles);
|
||||
CommandCost CmdSendVehicleToDepot(DoCommandFlag flags, VehicleID veh_id, DepotCommandFlags depot_cmd, const VehicleListIdentifier &vli);
|
||||
CommandCost CmdChangeServiceInt(DoCommandFlag flags, VehicleID veh_id, uint16_t serv_int, bool is_custom, bool is_percent);
|
||||
CommandCost CmdRenameVehicle(DoCommandFlag flags, VehicleID veh_id, const std::string &text);
|
||||
std::tuple<CommandCost, VehicleID> CmdCloneVehicle(DoCommandFlag flags, TileIndex tile, VehicleID veh_id, bool share_orders);
|
||||
CommandCost CmdStartStopVehicle(DoCommandFlag flags, VehicleID veh_id, bool evaluate_startstop_cb);
|
||||
CommandCost CmdMassStartStopVehicle(DoCommandFlag flags, TileIndex tile, bool do_start, bool vehicle_list_window, const VehicleListIdentifier &vli);
|
||||
CommandCost CmdDepotSellAllVehicles(DoCommandFlag flags, TileIndex tile, VehicleType vehicle_type);
|
||||
CommandCost CmdDepotMassAutoReplace(DoCommandFlag flags, TileIndex tile, VehicleType vehicle_type);
|
||||
std::tuple<CommandCost, VehicleID, uint, uint16_t, CargoArray> CmdBuildVehicle(DoCommandFlags flags, TileIndex tile, EngineID eid, bool use_free_vehicles, CargoType cargo, ClientID client_id);
|
||||
CommandCost CmdSellVehicle(DoCommandFlags flags, VehicleID v_id, bool sell_chain, bool backup_order, ClientID client_id);
|
||||
std::tuple<CommandCost, uint, uint16_t, CargoArray> CmdRefitVehicle(DoCommandFlags flags, VehicleID veh_id, CargoType new_cargo_type, uint8_t new_subtype, bool auto_refit, bool only_this, uint8_t num_vehicles);
|
||||
CommandCost CmdSendVehicleToDepot(DoCommandFlags flags, VehicleID veh_id, DepotCommandFlags depot_cmd, const VehicleListIdentifier &vli);
|
||||
CommandCost CmdChangeServiceInt(DoCommandFlags flags, VehicleID veh_id, uint16_t serv_int, bool is_custom, bool is_percent);
|
||||
CommandCost CmdRenameVehicle(DoCommandFlags flags, VehicleID veh_id, const std::string &text);
|
||||
std::tuple<CommandCost, VehicleID> CmdCloneVehicle(DoCommandFlags flags, TileIndex tile, VehicleID veh_id, bool share_orders);
|
||||
CommandCost CmdStartStopVehicle(DoCommandFlags flags, VehicleID veh_id, bool evaluate_startstop_cb);
|
||||
CommandCost CmdMassStartStopVehicle(DoCommandFlags flags, TileIndex tile, bool do_start, bool vehicle_list_window, const VehicleListIdentifier &vli);
|
||||
CommandCost CmdDepotSellAllVehicles(DoCommandFlags flags, TileIndex tile, VehicleType vehicle_type);
|
||||
CommandCost CmdDepotMassAutoReplace(DoCommandFlags flags, TileIndex tile, VehicleType vehicle_type);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_BUILD_VEHICLE, CmdBuildVehicle, CMD_CLIENT_ID, CMDT_VEHICLE_CONSTRUCTION)
|
||||
DEF_CMD_TRAIT(CMD_SELL_VEHICLE, CmdSellVehicle, CMD_CLIENT_ID | CMD_LOCATION, CMDT_VEHICLE_CONSTRUCTION)
|
||||
|
|
|
@ -1008,7 +1008,7 @@ struct RefitWindow : public Window {
|
|||
StringID GetCapacityString(const RefitOption &option) const
|
||||
{
|
||||
assert(_current_company == _local_company);
|
||||
auto [cost, refit_capacity, mail_capacity, cargo_capacities] = Command<CMD_REFIT_VEHICLE>::Do(DC_QUERY_COST, this->selected_vehicle, option.cargo, option.subtype, this->auto_refit, false, this->num_vehicles);
|
||||
auto [cost, refit_capacity, mail_capacity, cargo_capacities] = Command<CMD_REFIT_VEHICLE>::Do(DoCommandFlag::QueryCost, this->selected_vehicle, option.cargo, option.subtype, this->auto_refit, false, this->num_vehicles);
|
||||
|
||||
if (cost.Failed()) return INVALID_STRING_ID;
|
||||
|
||||
|
|
|
@ -3601,7 +3601,7 @@ void InitializeSpriteSorter()
|
|||
* @param ref company or client id depending on the target
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdScrollViewport(DoCommandFlag flags, TileIndex tile, ViewportScrollTarget target, uint32_t ref)
|
||||
CommandCost CmdScrollViewport(DoCommandFlags flags, TileIndex tile, ViewportScrollTarget target, uint32_t ref)
|
||||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
switch (target) {
|
||||
|
@ -3617,7 +3617,7 @@ CommandCost CmdScrollViewport(DoCommandFlag flags, TileIndex tile, ViewportScrol
|
|||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
ResetObjectToPlace();
|
||||
ScrollMainWindowToTile(tile);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "command_type.h"
|
||||
#include "viewport_type.h"
|
||||
|
||||
CommandCost CmdScrollViewport(DoCommandFlag flags, TileIndex tile, ViewportScrollTarget target, uint32_t ref);
|
||||
CommandCost CmdScrollViewport(DoCommandFlags flags, TileIndex tile, ViewportScrollTarget target, uint32_t ref);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_SCROLL_VIEWPORT, CmdScrollViewport, CMD_DEITY, CMDT_OTHER_MANAGEMENT)
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ static Foundation GetFoundation_Void(TileIndex, Slope)
|
|||
return FOUNDATION_NONE;
|
||||
}
|
||||
|
||||
static CommandCost ClearTile_Void(TileIndex, DoCommandFlag)
|
||||
static CommandCost ClearTile_Void(TileIndex, DoCommandFlags)
|
||||
{
|
||||
return CommandCost(STR_ERROR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ static TrackStatus GetTileTrackStatus_Void(TileIndex, TransportType, uint, DiagD
|
|||
return 0;
|
||||
}
|
||||
|
||||
static CommandCost TerraformTile_Void(TileIndex, DoCommandFlag, int, Slope)
|
||||
static CommandCost TerraformTile_Void(TileIndex, DoCommandFlags, int, Slope)
|
||||
{
|
||||
return CommandCost(STR_ERROR_OFF_EDGE_OF_MAP);
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ void ClearNeighbourNonFloodingStates(TileIndex tile)
|
|||
* @param axis depot orientation (Axis)
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildShipDepot(DoCommandFlag flags, TileIndex tile, Axis axis)
|
||||
CommandCost CmdBuildShipDepot(DoCommandFlags flags, TileIndex tile, Axis axis)
|
||||
{
|
||||
if (!IsValidAxis(axis)) return CMD_ERROR;
|
||||
TileIndex tile2 = tile + TileOffsByAxis(axis);
|
||||
|
@ -132,19 +132,19 @@ CommandCost CmdBuildShipDepot(DoCommandFlag flags, TileIndex tile, Axis axis)
|
|||
CommandCost cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_DEPOT_SHIP]);
|
||||
|
||||
bool add_cost = !IsWaterTile(tile);
|
||||
CommandCost ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags | DC_AUTO, tile);
|
||||
CommandCost ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags | DoCommandFlag::Auto, tile);
|
||||
if (ret.Failed()) return ret;
|
||||
if (add_cost) {
|
||||
cost.AddCost(ret);
|
||||
}
|
||||
add_cost = !IsWaterTile(tile2);
|
||||
ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags | DC_AUTO, tile2);
|
||||
ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags | DoCommandFlag::Auto, tile2);
|
||||
if (ret.Failed()) return ret;
|
||||
if (add_cost) {
|
||||
cost.AddCost(ret);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Depot *depot = new Depot(tile);
|
||||
depot->build_date = TimerGameCalendar::date;
|
||||
|
||||
|
@ -267,7 +267,7 @@ void MakeWaterKeepingClass(TileIndex tile, Owner o)
|
|||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
|
||||
static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
if (!IsShipDepot(tile)) return CMD_ERROR;
|
||||
|
||||
|
@ -277,15 +277,15 @@ static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags)
|
|||
TileIndex tile2 = GetOtherShipDepotTile(tile);
|
||||
|
||||
/* do not check for ship on tile when company goes bankrupt */
|
||||
if (!(flags & DC_BANKRUPT)) {
|
||||
if (!flags.Test(DoCommandFlag::Bankrupt)) {
|
||||
ret = EnsureNoVehicleOnGround(tile);
|
||||
if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile2);
|
||||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
bool do_clear = (flags & DC_FORCE_CLEAR_TILE) != 0;
|
||||
bool do_clear = flags.Test(DoCommandFlag::ForceClearTile);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
delete Depot::GetByTile(tile);
|
||||
|
||||
Company *c = Company::GetIfValid(GetTileOwner(tile));
|
||||
|
@ -309,7 +309,7 @@ static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags)
|
|||
* @param flags Operation to perform.
|
||||
* @return The cost in case of success, or an error code if it failed.
|
||||
*/
|
||||
static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlag flags)
|
||||
static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlags flags)
|
||||
{
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
|
||||
|
@ -353,7 +353,7 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlag
|
|||
return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Update company infrastructure counts. */
|
||||
Company *c = Company::GetIfValid(_current_company);
|
||||
if (c != nullptr) {
|
||||
|
@ -387,7 +387,7 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlag
|
|||
* @param flags Operation to perform.
|
||||
* @return The cost in case of success, or an error code if it failed.
|
||||
*/
|
||||
static CommandCost RemoveLock(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost RemoveLock(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
if (GetTileOwner(tile) != OWNER_NONE) {
|
||||
CommandCost ret = CheckTileOwnership(tile);
|
||||
|
@ -402,7 +402,7 @@ static CommandCost RemoveLock(TileIndex tile, DoCommandFlag flags)
|
|||
if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile - delta);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
/* Remove middle part from company infrastructure count. */
|
||||
Company *c = Company::GetIfValid(GetTileOwner(tile));
|
||||
if (c != nullptr) {
|
||||
|
@ -432,7 +432,7 @@ static CommandCost RemoveLock(TileIndex tile, DoCommandFlag flags)
|
|||
* @param tile tile where to place the lock
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildLock(DoCommandFlag flags, TileIndex tile)
|
||||
CommandCost CmdBuildLock(DoCommandFlags flags, TileIndex tile)
|
||||
{
|
||||
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile));
|
||||
if (dir == INVALID_DIAGDIR) return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
||||
|
@ -469,7 +469,7 @@ void MakeRiverAndModifyDesertZoneAround(TileIndex tile)
|
|||
* @param diagonal Whether to use the Orthogonal (0) or Diagonal (1) iterator.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildCanal(DoCommandFlag flags, TileIndex tile, TileIndex start_tile, WaterClass wc, bool diagonal)
|
||||
CommandCost CmdBuildCanal(DoCommandFlags flags, TileIndex tile, TileIndex start_tile, WaterClass wc, bool diagonal)
|
||||
{
|
||||
if (start_tile >= Map::Size() || !IsValidWaterClass(wc)) return CMD_ERROR;
|
||||
|
||||
|
@ -498,7 +498,7 @@ CommandCost CmdBuildCanal(DoCommandFlag flags, TileIndex tile, TileIndex start_t
|
|||
|
||||
if (!water) cost.AddCost(ret);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (IsTileType(current_tile, MP_WATER) && IsCanal(current_tile)) {
|
||||
Owner owner = GetTileOwner(current_tile);
|
||||
if (Company::IsValidID(owner)) {
|
||||
|
@ -547,11 +547,11 @@ CommandCost CmdBuildCanal(DoCommandFlag flags, TileIndex tile, TileIndex start_t
|
|||
}
|
||||
|
||||
|
||||
static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)
|
||||
static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
switch (GetWaterTileType(tile)) {
|
||||
case WATER_TILE_CLEAR: {
|
||||
if (flags & DC_NO_WATER) return CommandCost(STR_ERROR_CAN_T_BUILD_ON_WATER);
|
||||
if (flags.Test(DoCommandFlag::NoWater)) return CommandCost(STR_ERROR_CAN_T_BUILD_ON_WATER);
|
||||
|
||||
Money base_cost = IsCanal(tile) ? _price[PR_CLEAR_CANAL] : _price[PR_CLEAR_WATER];
|
||||
/* Make sure freeform edges are allowed or it's not an edge tile. */
|
||||
|
@ -570,7 +570,7 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)
|
|||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (IsCanal(tile) && Company::IsValidID(owner)) {
|
||||
Company::Get(owner)->infrastructure.water--;
|
||||
DirtyCompanyInfrastructureWindows(owner);
|
||||
|
@ -590,7 +590,7 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)
|
|||
CommandCost ret = EnsureNoVehicleOnGround(tile);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
DoClearSquare(tile);
|
||||
MarkCanalsAndRiversAroundDirty(tile);
|
||||
ClearNeighbourNonFloodingStates(tile);
|
||||
|
@ -610,14 +610,14 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)
|
|||
{ { 1, 0}, {0, -1}, {-1, 0}, {0, 1} }, // LOCK_PART_UPPER
|
||||
};
|
||||
|
||||
if (flags & DC_AUTO) return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
|
||||
if (flags.Test(DoCommandFlag::Auto)) return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
|
||||
if (_current_company == OWNER_WATER) return CMD_ERROR;
|
||||
/* move to the middle tile.. */
|
||||
return RemoveLock(tile + ToTileIndexDiff(_lock_tomiddle_offs[GetLockPart(tile)][GetLockDirection(tile)]), flags);
|
||||
}
|
||||
|
||||
case WATER_TILE_DEPOT:
|
||||
if (flags & DC_AUTO) return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
|
||||
if (flags.Test(DoCommandFlag::Auto)) return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
|
||||
return RemoveShipDepot(tile, flags);
|
||||
|
||||
default:
|
||||
|
@ -1157,7 +1157,7 @@ static void DoFloodTile(TileIndex target)
|
|||
[[fallthrough]];
|
||||
|
||||
case MP_CLEAR:
|
||||
if (Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC, target).Succeeded()) {
|
||||
if (Command<CMD_LANDSCAPE_CLEAR>::Do(DoCommandFlag::Execute, target).Succeeded()) {
|
||||
MakeShore(target);
|
||||
MarkTileDirtyByTile(target);
|
||||
flooded = true;
|
||||
|
@ -1172,7 +1172,7 @@ static void DoFloodTile(TileIndex target)
|
|||
FloodVehicles(target);
|
||||
|
||||
/* flood flat tile */
|
||||
if (Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC, target).Succeeded()) {
|
||||
if (Command<CMD_LANDSCAPE_CLEAR>::Do(DoCommandFlag::Execute, target).Succeeded()) {
|
||||
MakeSea(target);
|
||||
MarkTileDirtyByTile(target);
|
||||
flooded = true;
|
||||
|
@ -1225,7 +1225,7 @@ static void DoDryUp(TileIndex tile)
|
|||
case MP_WATER:
|
||||
assert(IsCoast(tile));
|
||||
|
||||
if (Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC, tile).Succeeded()) {
|
||||
if (Command<CMD_LANDSCAPE_CLEAR>::Do(DoCommandFlag::Execute, tile).Succeeded()) {
|
||||
MakeClear(tile, CLEAR_GRASS, 3);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
|
@ -1395,7 +1395,7 @@ static void ChangeTileOwner_Water(TileIndex tile, Owner old_owner, Owner new_own
|
|||
}
|
||||
|
||||
/* Remove depot */
|
||||
if (IsShipDepot(tile)) Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC | DC_BANKRUPT, tile);
|
||||
if (IsShipDepot(tile)) Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile);
|
||||
|
||||
/* Set owner of canals and locks ... and also canal under dock there was before.
|
||||
* Check if the new owner after removing depot isn't OWNER_WATER. */
|
||||
|
@ -1410,7 +1410,7 @@ static VehicleEnterTileStatus VehicleEnter_Water(Vehicle *, TileIndex, int, int)
|
|||
return VETSB_CONTINUE;
|
||||
}
|
||||
|
||||
static CommandCost TerraformTile_Water(TileIndex tile, DoCommandFlag flags, int, Slope)
|
||||
static CommandCost TerraformTile_Water(TileIndex tile, DoCommandFlags flags, int, Slope)
|
||||
{
|
||||
/* Canals can't be terraformed */
|
||||
if (IsWaterTile(tile) && IsCanal(tile)) return CommandCost(STR_ERROR_MUST_DEMOLISH_CANAL_FIRST);
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
#include "command_type.h"
|
||||
#include "water_map.h"
|
||||
|
||||
CommandCost CmdBuildShipDepot(DoCommandFlag flags, TileIndex tile, Axis axis);
|
||||
CommandCost CmdBuildCanal(DoCommandFlag flags, TileIndex tile, TileIndex start_tile, WaterClass wc, bool diagonal);
|
||||
CommandCost CmdBuildLock(DoCommandFlag flags, TileIndex tile);
|
||||
CommandCost CmdBuildShipDepot(DoCommandFlags flags, TileIndex tile, Axis axis);
|
||||
CommandCost CmdBuildCanal(DoCommandFlags flags, TileIndex tile, TileIndex start_tile, WaterClass wc, bool diagonal);
|
||||
CommandCost CmdBuildLock(DoCommandFlags flags, TileIndex tile);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_BUILD_SHIP_DEPOT, CmdBuildShipDepot, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
DEF_CMD_TRAIT(CMD_BUILD_CANAL, CmdBuildCanal, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
|
|
|
@ -135,7 +135,7 @@ Axis GetAxisForNewRoadWaypoint(TileIndex tile)
|
|||
return INVALID_AXIS;
|
||||
}
|
||||
|
||||
extern CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags);
|
||||
extern CommandCost ClearTile_Station(TileIndex tile, DoCommandFlags flags);
|
||||
|
||||
/**
|
||||
* Check whether the given tile is suitable for a waypoint.
|
||||
|
@ -150,7 +150,7 @@ static CommandCost IsValidTileForWaypoint(TileIndex tile, Axis axis, StationID *
|
|||
* Or it points to a waypoint if we're only allowed to build on exactly that waypoint. */
|
||||
if (waypoint != nullptr && IsTileType(tile, MP_STATION)) {
|
||||
if (!IsRailWaypoint(tile)) {
|
||||
return ClearTile_Station(tile, DC_AUTO); // get error message
|
||||
return ClearTile_Station(tile, DoCommandFlag::Auto); // get error message
|
||||
} else {
|
||||
StationID wp = GetStationIndex(tile);
|
||||
if (*waypoint == INVALID_STATION) {
|
||||
|
@ -182,8 +182,8 @@ static CommandCost IsValidTileForWaypoint(TileIndex tile, Axis axis, StationID *
|
|||
extern void GetStationLayout(uint8_t *layout, uint numtracks, uint plat_len, const StationSpec *statspec);
|
||||
extern CommandCost FindJoiningWaypoint(StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, Waypoint **wp, bool is_road);
|
||||
extern CommandCost CanExpandRailStation(const BaseStation *st, TileArea &new_ta);
|
||||
extern CommandCost CalculateRoadStopCost(TileArea tile_area, DoCommandFlag flags, bool is_drive_through, StationType station_type, Axis axis, DiagDirection ddir, StationID *est, RoadType rt, Money unit_cost);
|
||||
extern CommandCost RemoveRoadWaypointStop(TileIndex tile, DoCommandFlag flags, int replacement_spec_index);
|
||||
extern CommandCost CalculateRoadStopCost(TileArea tile_area, DoCommandFlags flags, bool is_drive_through, StationType station_type, Axis axis, DiagDirection ddir, StationID *est, RoadType rt, Money unit_cost);
|
||||
extern CommandCost RemoveRoadWaypointStop(TileIndex tile, DoCommandFlags flags, int replacement_spec_index);
|
||||
|
||||
/**
|
||||
* Convert existing rail to waypoint. Eg build a waypoint station over
|
||||
|
@ -199,7 +199,7 @@ extern CommandCost RemoveRoadWaypointStop(TileIndex tile, DoCommandFlag flags, i
|
|||
* @param adjacent allow waypoints directly adjacent to other waypoints.
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildRailWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis axis, uint8_t width, uint8_t height, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
|
||||
CommandCost CmdBuildRailWaypoint(DoCommandFlags flags, TileIndex start_tile, Axis axis, uint8_t width, uint8_t height, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
|
||||
{
|
||||
if (!IsValidAxis(axis)) return CMD_ERROR;
|
||||
/* Check if the given station class is valid */
|
||||
|
@ -264,7 +264,7 @@ CommandCost CmdBuildRailWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis
|
|||
if (!Waypoint::CanAllocateItem()) return CommandCost(STR_ERROR_TOO_MANY_STATIONS_LOADING);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (wp == nullptr) {
|
||||
wp = new Waypoint(start_tile);
|
||||
} else if (!wp->IsInUse()) {
|
||||
|
@ -331,7 +331,7 @@ CommandCost CmdBuildRailWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis
|
|||
* @param adjacent allow waypoints directly adjacent to other waypoints.
|
||||
* @return the cost of this operation or an error.
|
||||
*/
|
||||
CommandCost CmdBuildRoadWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis axis, uint8_t width, uint8_t height, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
|
||||
CommandCost CmdBuildRoadWaypoint(DoCommandFlags flags, TileIndex start_tile, Axis axis, uint8_t width, uint8_t height, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
|
||||
{
|
||||
if (!IsValidAxis(axis)) return CMD_ERROR;
|
||||
/* Check if the given station class is valid */
|
||||
|
@ -390,7 +390,7 @@ CommandCost CmdBuildRoadWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis
|
|||
/* Check if we can allocate a custom stationspec to this station */
|
||||
if (AllocateSpecToRoadStop(roadstopspec, wp, false) == -1) return CommandCost(STR_ERROR_TOO_MANY_STATION_SPECS);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (wp == nullptr) {
|
||||
wp = new Waypoint(start_tile);
|
||||
SetBit(wp->waypoint_flags, WPF_ROAD);
|
||||
|
@ -464,7 +464,7 @@ CommandCost CmdBuildRoadWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis
|
|||
* @param tile tile where to place the buoy
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildBuoy(DoCommandFlag flags, TileIndex tile)
|
||||
CommandCost CmdBuildBuoy(DoCommandFlags flags, TileIndex tile)
|
||||
{
|
||||
if (tile == 0 || !HasTileWaterGround(tile)) return CommandCost(STR_ERROR_SITE_UNSUITABLE);
|
||||
if (IsBridgeAbove(tile)) return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
|
||||
|
@ -477,12 +477,12 @@ CommandCost CmdBuildBuoy(DoCommandFlag flags, TileIndex tile)
|
|||
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_WAYPOINT_BUOY]);
|
||||
if (!IsWaterTile(tile)) {
|
||||
CommandCost ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags | DC_AUTO, tile);
|
||||
CommandCost ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags | DoCommandFlag::Auto, tile);
|
||||
if (ret.Failed()) return ret;
|
||||
cost.AddCost(ret);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (wp == nullptr) {
|
||||
wp = new Waypoint(tile);
|
||||
} else {
|
||||
|
@ -520,21 +520,21 @@ CommandCost CmdBuildBuoy(DoCommandFlag flags, TileIndex tile)
|
|||
* @pre IsBuoyTile(tile)
|
||||
* @return cost or failure of operation
|
||||
*/
|
||||
CommandCost RemoveBuoy(TileIndex tile, DoCommandFlag flags)
|
||||
CommandCost RemoveBuoy(TileIndex tile, DoCommandFlags flags)
|
||||
{
|
||||
/* XXX: strange stuff, allow clearing as invalid company when clearing landscape */
|
||||
if (!Company::IsValidID(_current_company) && !(flags & DC_BANKRUPT)) return CommandCost(INVALID_STRING_ID);
|
||||
if (!Company::IsValidID(_current_company) && !flags.Test(DoCommandFlag::Bankrupt)) return CommandCost(INVALID_STRING_ID);
|
||||
|
||||
Waypoint *wp = Waypoint::GetByTile(tile);
|
||||
|
||||
if (HasStationInUse(wp->index, false, _current_company)) return CommandCost(STR_ERROR_BUOY_IS_IN_USE);
|
||||
/* remove the buoy if there is a ship on tile when company goes bankrupt... */
|
||||
if (!(flags & DC_BANKRUPT)) {
|
||||
if (!flags.Test(DoCommandFlag::Bankrupt)) {
|
||||
CommandCost ret = EnsureNoVehicleOnGround(tile);
|
||||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
wp->facilities.Reset(StationFacility::Dock);
|
||||
|
||||
InvalidateWindowData(WC_WAYPOINT_VIEW, wp->index);
|
||||
|
@ -574,7 +574,7 @@ static bool IsUniqueWaypointName(const std::string &name)
|
|||
* @param text the new name or an empty string when resetting to the default
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRenameWaypoint(DoCommandFlag flags, StationID waypoint_id, const std::string &text)
|
||||
CommandCost CmdRenameWaypoint(DoCommandFlags flags, StationID waypoint_id, const std::string &text)
|
||||
{
|
||||
Waypoint *wp = Waypoint::GetIfValid(waypoint_id);
|
||||
if (wp == nullptr) return CMD_ERROR;
|
||||
|
@ -591,7 +591,7 @@ CommandCost CmdRenameWaypoint(DoCommandFlag flags, StationID waypoint_id, const
|
|||
if (!IsUniqueWaypointName(text)) return CommandCost(STR_ERROR_NAME_MUST_BE_UNIQUE);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (reset) {
|
||||
wp->name.clear();
|
||||
} else {
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
enum StationClassID : uint16_t;
|
||||
enum RoadStopClassID : uint16_t;
|
||||
|
||||
CommandCost CmdBuildRailWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis axis, uint8_t width, uint8_t height, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent);
|
||||
CommandCost CmdRemoveFromRailWaypoint(DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail);
|
||||
CommandCost CmdBuildRoadWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis axis, uint8_t width, uint8_t height, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent);
|
||||
CommandCost CmdRemoveFromRoadWaypoint(DoCommandFlag flags, TileIndex start, TileIndex end);
|
||||
CommandCost CmdBuildBuoy(DoCommandFlag flags, TileIndex tile);
|
||||
CommandCost CmdRenameWaypoint(DoCommandFlag flags, StationID waypoint_id, const std::string &text);
|
||||
CommandCost CmdBuildRailWaypoint(DoCommandFlags flags, TileIndex start_tile, Axis axis, uint8_t width, uint8_t height, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent);
|
||||
CommandCost CmdRemoveFromRailWaypoint(DoCommandFlags flags, TileIndex start, TileIndex end, bool keep_rail);
|
||||
CommandCost CmdBuildRoadWaypoint(DoCommandFlags flags, TileIndex start_tile, Axis axis, uint8_t width, uint8_t height, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent);
|
||||
CommandCost CmdRemoveFromRoadWaypoint(DoCommandFlags flags, TileIndex start, TileIndex end);
|
||||
CommandCost CmdBuildBuoy(DoCommandFlags flags, TileIndex tile);
|
||||
CommandCost CmdRenameWaypoint(DoCommandFlags flags, StationID waypoint_id, const std::string &text);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_BUILD_RAIL_WAYPOINT, CmdBuildRailWaypoint, 0, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
DEF_CMD_TRAIT(CMD_REMOVE_FROM_RAIL_WAYPOINT, CmdRemoveFromRailWaypoint, 0, CMDT_LANDSCAPE_CONSTRUCTION)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
enum StationClassID : uint16_t;
|
||||
|
||||
CommandCost RemoveBuoy(TileIndex tile, DoCommandFlag flags);
|
||||
CommandCost RemoveBuoy(TileIndex tile, DoCommandFlags flags);
|
||||
|
||||
Axis GetAxisForNewRailWaypoint(TileIndex tile);
|
||||
Axis GetAxisForNewRoadWaypoint(TileIndex tile);
|
||||
|
|
Loading…
Reference in New Issue