Update to 12.0-beta1

This commit is contained in:
dP
2021-08-15 14:57:29 +03:00
parent ac7d3eba75
commit 9df4f2c4fc
666 changed files with 61302 additions and 20466 deletions

View File

@@ -16,6 +16,7 @@
#include "object_base.h"
#include "company_base.h"
#include "company_func.h"
#include "core/backup_type.hpp"
#include "table/strings.h"
@@ -184,7 +185,7 @@ static CommandCost TerraformTileHeight(TerraformerState *ts, TileIndex tile, int
* @param text unused
* @return the cost of this operation or an error
*/
CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
{
_terraform_err_tile = INVALID_TILE;
@@ -226,18 +227,18 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
* Pass == 1: Collect the actual cost. */
for (int pass = 0; pass < 2; pass++) {
for (TileIndexSet::const_iterator it = ts.dirty_tiles.begin(); it != ts.dirty_tiles.end(); it++) {
TileIndex tile = *it;
TileIndex t = *it;
assert(tile < MapSize());
assert(t < MapSize());
/* MP_VOID tiles can be terraformed but as tunnels and bridges
* cannot go under / over these tiles they don't need checking. */
if (IsTileType(tile, MP_VOID)) continue;
if (IsTileType(t, MP_VOID)) continue;
/* Find new heights of tile corners */
int z_N = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0));
int z_W = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0));
int z_S = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1));
int z_E = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1));
int z_N = TerraformGetHeightOfTile(&ts, t + TileDiffXY(0, 0));
int z_W = TerraformGetHeightOfTile(&ts, t + TileDiffXY(1, 0));
int z_S = TerraformGetHeightOfTile(&ts, t + TileDiffXY(1, 1));
int z_E = TerraformGetHeightOfTile(&ts, t + TileDiffXY(0, 1));
/* Find min and max height of tile */
int z_min = std::min({z_N, z_W, z_S, z_E});
@@ -252,35 +253,35 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (pass == 0) {
/* Check if bridge would take damage */
if (IsBridgeAbove(tile)) {
int bridge_height = GetBridgeHeight(GetSouthernBridgeEnd(tile));
if (IsBridgeAbove(t)) {
int bridge_height = GetBridgeHeight(GetSouthernBridgeEnd(t));
/* Check if bridge would take damage. */
if (direction == 1 && bridge_height <= z_max) {
_terraform_err_tile = tile; // highlight the tile under the bridge
_terraform_err_tile = t; // highlight the tile under the bridge
return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
}
/* Is the bridge above not too high afterwards? */
if (direction == -1 && bridge_height > (z_min + _settings_game.construction.max_bridge_height)) {
_terraform_err_tile = tile;
_terraform_err_tile = t;
return_cmd_error(STR_ERROR_BRIDGE_TOO_HIGH_AFTER_LOWER_LAND);
}
}
/* Check if tunnel would take damage */
if (direction == -1 && IsTunnelInWay(tile, z_min)) {
_terraform_err_tile = tile; // highlight the tile above the tunnel
if (direction == -1 && IsTunnelInWay(t, z_min)) {
_terraform_err_tile = t; // highlight the tile above the tunnel
return_cmd_error(STR_ERROR_EXCAVATION_WOULD_DAMAGE);
}
}
/* Is the tile already cleared? */
const ClearedObjectArea *coa = FindClearedObject(tile);
bool indirectly_cleared = coa != nullptr && coa->first_tile != tile;
const ClearedObjectArea *coa = FindClearedObject(t);
bool indirectly_cleared = coa != nullptr && coa->first_tile != t;
/* Check tiletype-specific things, and add extra-cost */
const bool curr_gen = _generating_world;
if (_game_mode == GM_EDITOR) _generating_world = true; // used to create green terraformed land
Backup<bool> old_generating_world(_generating_world, FILE_LINE);
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;
if (pass == 0) {
tile_flags &= ~DC_EXEC;
@@ -288,13 +289,13 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
}
CommandCost cost;
if (indirectly_cleared) {
cost = DoCommand(tile, 0, 0, tile_flags, CMD_LANDSCAPE_CLEAR);
cost = DoCommand(t, 0, 0, tile_flags, CMD_LANDSCAPE_CLEAR);
} else {
cost = _tile_type_procs[GetTileType(tile)]->terraform_tile_proc(tile, tile_flags, z_min, tileh);
cost = _tile_type_procs[GetTileType(t)]->terraform_tile_proc(t, tile_flags, z_min, tileh);
}
_generating_world = curr_gen;
old_generating_world.Restore();
if (cost.Failed()) {
_terraform_err_tile = tile;
_terraform_err_tile = t;
return cost;
}
if (pass == 1) total_cost.AddCost(cost);
@@ -310,7 +311,7 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
/* Mark affected areas dirty. */
for (TileIndexSet::const_iterator it = ts.dirty_tiles.begin(); it != ts.dirty_tiles.end(); it++) {
MarkTileDirtyByTile(*it);
TileIndexToHeightMap::const_iterator new_height = ts.tile_to_new_height.find(tile);
TileIndexToHeightMap::const_iterator new_height = ts.tile_to_new_height.find(*it);
if (new_height == ts.tile_to_new_height.end()) continue;
MarkTileDirtyByTile(*it, 0, new_height->second);
}
@@ -318,10 +319,10 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
/* change the height */
for (TileIndexToHeightMap::const_iterator it = ts.tile_to_new_height.begin();
it != ts.tile_to_new_height.end(); it++) {
TileIndex tile = it->first;
TileIndex t = it->first;
int height = it->second;
SetTileHeight(tile, (uint)height);
SetTileHeight(t, (uint)height);
}
if (c != nullptr) c->terraform_limit -= (uint32)ts.tile_to_new_height.size() << 16;
@@ -341,7 +342,7 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
* @param text unused
* @return the cost of this operation or an error
*/
CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
{
if (p1 >= MapSize()) return CMD_ERROR;