|
@@ -177,49 +177,49 @@ CommandCost CmdClearOrderBackup(TileInde
|
|
|
/**
|
|
|
* Reset the OrderBackups from GUI/game logic.
|
|
|
* @param t The tile of the order backup.
|
|
|
* @param from_gui Whether the call came from the GUI, i.e. whether
|
|
|
* it must be synced over the network.
|
|
|
*/
|
|
|
/* static */ void OrderBackup::Reset(TileIndex t, bool from_gui)
|
|
|
{
|
|
|
/* The user has CLIENT_ID_SERVER as default when network play is not active,
|
|
|
* but compiled it. A network client has its own variable for the unique
|
|
|
* client/user identifier. Finally if networking isn't compiled in the
|
|
|
* default is just plain and simple: 0. */
|
|
|
uint32 user = _networking && !_network_server ? _network_own_client_id : CLIENT_ID_SERVER;
|
|
|
|
|
|
for (OrderBackup *ob : OrderBackup::Iterate()) {
|
|
|
/* If it's not a backup of us, ignore it. */
|
|
|
if (ob->user != user) continue;
|
|
|
/* If it's not for our chosen tile either, ignore it. */
|
|
|
if (t != INVALID_TILE && t != ob->tile) continue;
|
|
|
|
|
|
if (from_gui) {
|
|
|
/* We need to circumvent the "prevention" from this command being executed
|
|
|
* while the game is paused, so use the internal method. Nor do we want
|
|
|
* this command to get its cost estimated when shift is pressed. */
|
|
|
DoCommandPInternal(ob->tile, 0, user, CMD_CLEAR_ORDER_BACKUP, nullptr, nullptr, true, false);
|
|
|
DoCommandPInternal(ob->tile, 0, user, CMD_CLEAR_ORDER_BACKUP, nullptr, {}, true, false);
|
|
|
} else {
|
|
|
/* The command came from the game logic, i.e. the clearing of a tile.
|
|
|
* In that case we have no need to actually sync this, just do it. */
|
|
|
delete ob;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Clear the group of all backups having this group ID.
|
|
|
* @param group The group to clear.
|
|
|
*/
|
|
|
/* static */ void OrderBackup::ClearGroup(GroupID group)
|
|
|
{
|
|
|
for (OrderBackup *ob : OrderBackup::Iterate()) {
|
|
|
if (ob->group == group) ob->group = DEFAULT_GROUP;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Clear/update the (clone) vehicle from an order backup.
|
|
|
* @param v The vehicle to clear.
|
|
|
* @pre v != nullptr
|
|
|
* @note If it is not possible to set another vehicle as clone
|