2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file clear_cmd.cpp Commands related to clear tiles. */
|
2007-02-23 11:50:43 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
2006-03-05 10:19:33 +00:00
|
|
|
#include "clear_map.h"
|
2007-12-21 21:50:46 +00:00
|
|
|
#include "command_func.h"
|
2007-03-20 13:47:00 +00:00
|
|
|
#include "landscape.h"
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
#include "genworld.h"
|
2008-01-09 09:45:45 +00:00
|
|
|
#include "viewport_func.h"
|
2009-01-21 02:31:55 +00:00
|
|
|
#include "water.h"
|
2010-01-15 16:41:15 +00:00
|
|
|
#include "core/random_func.hpp"
|
2011-11-04 21:05:08 +00:00
|
|
|
#include "newgrf_generic.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/strings.h"
|
|
|
|
#include "table/sprites.h"
|
|
|
|
#include "table/clear_land.h"
|
|
|
|
|
2009-02-09 21:20:05 +00:00
|
|
|
static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlag flags)
|
2005-01-22 22:47:58 +00:00
|
|
|
{
|
2009-11-07 22:47:54 +00:00
|
|
|
static const Price clear_price_table[] = {
|
|
|
|
PR_CLEAR_GRASS,
|
|
|
|
PR_CLEAR_ROUGH,
|
|
|
|
PR_CLEAR_ROCKS,
|
2010-01-29 00:11:30 +00:00
|
|
|
PR_CLEAR_FIELDS,
|
2009-11-07 22:47:54 +00:00
|
|
|
PR_CLEAR_ROUGH,
|
|
|
|
PR_CLEAR_ROUGH,
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
2008-01-09 16:55:48 +00:00
|
|
|
CommandCost price(EXPENSES_CONSTRUCTION);
|
2006-02-01 15:31:21 +00:00
|
|
|
|
2007-06-18 19:53:50 +00:00
|
|
|
if (!IsClearGround(tile, CLEAR_GRASS) || GetClearDensity(tile) != 0) {
|
2009-11-07 22:47:54 +00:00
|
|
|
price.AddCost(_price[clear_price_table[GetClearGround(tile)]]);
|
2006-02-01 15:31:21 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-07-28 19:18:27 +00:00
|
|
|
if (flags & DC_EXEC) DoClearSquare(tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-02-01 15:31:21 +00:00
|
|
|
return price;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-09-18 20:56:44 +00:00
|
|
|
void DrawClearLandTile(const TileInfo *ti, byte set)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2010-07-19 17:00:54 +00:00
|
|
|
DrawGroundSprite(SPR_FLAT_BARE_LAND + SlopeToSpriteOffset(ti->tileh) + set * 19, PAL_NONE);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-09-18 20:56:44 +00:00
|
|
|
void DrawHillyLandTile(const TileInfo *ti)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-04-23 13:48:16 +00:00
|
|
|
if (ti->tileh != SLOPE_FLAT) {
|
2010-07-19 17:00:54 +00:00
|
|
|
DrawGroundSprite(SPR_FLAT_ROUGH_LAND + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
|
2004-08-09 17:04:08 +00:00
|
|
|
} else {
|
2009-09-07 13:38:57 +00:00
|
|
|
DrawGroundSprite(_landscape_clear_sprites_rough[GB(ti->x ^ ti->y, 4, 3)], PAL_NONE);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-08 19:48:47 +00:00
|
|
|
static void DrawClearLandFence(const TileInfo *ti)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2011-11-08 19:48:47 +00:00
|
|
|
/* combine fences into one sprite object */
|
|
|
|
StartSpriteCombine();
|
2010-01-18 12:09:25 +00:00
|
|
|
|
2011-11-08 19:48:47 +00:00
|
|
|
int maxz = GetSlopeMaxPixelZ(ti->tileh);
|
2010-01-18 12:09:25 +00:00
|
|
|
|
2011-11-08 19:48:47 +00:00
|
|
|
bool fence_nw = GetFenceNW(ti->tile) != 0;
|
|
|
|
if (fence_nw) {
|
|
|
|
int z = GetSlopePixelZInCorner(ti->tileh, CORNER_W);
|
|
|
|
SpriteID sprite = _clear_land_fence_sprites[GetFenceNW(ti->tile) - 1] + _fence_mod_by_tileh_nw[ti->tileh];
|
|
|
|
AddSortableSpriteToDraw(sprite, PAL_NONE, ti->x, ti->y - 15, 16, 31, maxz - z + 4, ti->z + z, false, 0, 15, -z);
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2011-11-08 19:48:47 +00:00
|
|
|
bool fence_ne = GetFenceNE(ti->tile) != 0;
|
|
|
|
if (fence_ne) {
|
|
|
|
int z = GetSlopePixelZInCorner(ti->tileh, CORNER_E);
|
|
|
|
SpriteID sprite = _clear_land_fence_sprites[GetFenceNE(ti->tile) - 1] + _fence_mod_by_tileh_ne[ti->tileh];
|
|
|
|
AddSortableSpriteToDraw(sprite, PAL_NONE, ti->x - 15, ti->y, 31, 16, maxz - z + 4, ti->z + z, false, 15, 0, -z);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2011-11-08 19:48:47 +00:00
|
|
|
bool fence_sw = GetFenceSW(ti->tile) != 0;
|
|
|
|
bool fence_se = GetFenceSE(ti->tile) != 0;
|
|
|
|
|
|
|
|
if (fence_sw || fence_se) {
|
|
|
|
int z = GetSlopePixelZInCorner(ti->tileh, CORNER_S);
|
|
|
|
|
|
|
|
if (fence_sw) {
|
|
|
|
SpriteID sprite = _clear_land_fence_sprites[GetFenceSW(ti->tile) - 1] + _fence_mod_by_tileh_sw[ti->tileh];
|
|
|
|
AddSortableSpriteToDraw(sprite, PAL_NONE, ti->x, ti->y, 16, 16, maxz - z + 4, ti->z + z, false, 0, 0, -z);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fence_se) {
|
|
|
|
SpriteID sprite = _clear_land_fence_sprites[GetFenceSE(ti->tile) - 1] + _fence_mod_by_tileh_se[ti->tileh];
|
|
|
|
AddSortableSpriteToDraw(sprite, PAL_NONE, ti->x, ti->y, 16, 16, maxz - z + 4, ti->z + z, false, 0, 0, -z);
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2011-11-08 19:48:47 +00:00
|
|
|
EndSpriteCombine();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void DrawTile_Clear(TileInfo *ti)
|
|
|
|
{
|
2006-03-08 15:28:38 +00:00
|
|
|
switch (GetClearGround(ti->tile)) {
|
2006-04-04 21:35:13 +00:00
|
|
|
case CLEAR_GRASS:
|
2006-03-08 15:28:38 +00:00
|
|
|
DrawClearLandTile(ti, GetClearDensity(ti->tile));
|
2006-02-01 15:31:21 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-04-04 21:35:13 +00:00
|
|
|
case CLEAR_ROUGH:
|
2006-02-01 15:31:21 +00:00
|
|
|
DrawHillyLandTile(ti);
|
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-04-04 21:35:13 +00:00
|
|
|
case CLEAR_ROCKS:
|
2010-07-19 17:00:54 +00:00
|
|
|
DrawGroundSprite(SPR_FLAT_ROCKY_LAND_1 + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
|
2006-02-01 15:31:21 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-04-04 21:35:13 +00:00
|
|
|
case CLEAR_FIELDS:
|
2010-07-19 17:00:54 +00:00
|
|
|
DrawGroundSprite(_clear_land_sprites_farmland[GetFieldType(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
|
2011-11-08 19:48:47 +00:00
|
|
|
DrawClearLandFence(ti);
|
2006-02-01 15:31:21 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-04-04 21:35:13 +00:00
|
|
|
case CLEAR_SNOW:
|
|
|
|
case CLEAR_DESERT:
|
2010-07-19 17:00:54 +00:00
|
|
|
DrawGroundSprite(_clear_land_sprites_snow_desert[GetClearDensity(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
|
2006-02-01 15:31:21 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2006-12-27 12:38:02 +00:00
|
|
|
DrawBridgeMiddle(ti);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2011-11-04 11:36:10 +00:00
|
|
|
static int GetSlopePixelZ_Clear(TileIndex tile, uint x, uint y)
|
2005-01-22 22:47:58 +00:00
|
|
|
{
|
2011-11-04 11:30:37 +00:00
|
|
|
int z;
|
2011-11-04 10:18:13 +00:00
|
|
|
Slope tileh = GetTilePixelSlope(tile, &z);
|
2006-08-06 16:32:49 +00:00
|
|
|
|
2011-11-04 10:18:13 +00:00
|
|
|
return z + GetPartialPixelZ(x & 0xF, y & 0xF, tileh);
|
2005-01-22 22:47:58 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-07-26 16:51:10 +00:00
|
|
|
static Foundation GetFoundation_Clear(TileIndex tile, Slope tileh)
|
2004-08-13 18:27:33 +00:00
|
|
|
{
|
2007-07-26 16:51:10 +00:00
|
|
|
return FOUNDATION_NONE;
|
2004-08-13 18:27:33 +00:00
|
|
|
}
|
|
|
|
|
2011-11-08 19:48:47 +00:00
|
|
|
static void UpdateFences(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2011-11-08 19:48:47 +00:00
|
|
|
assert(IsTileType(tile, MP_CLEAR) && IsClearGround(tile, CLEAR_FIELDS));
|
2009-06-10 07:19:48 +00:00
|
|
|
bool dirty = false;
|
2005-02-04 20:17:15 +00:00
|
|
|
|
2009-06-10 07:19:48 +00:00
|
|
|
bool neighbour = (IsTileType(TILE_ADDXY(tile, 1, 0), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 1, 0), CLEAR_FIELDS));
|
2011-11-08 19:48:47 +00:00
|
|
|
if (!neighbour && GetFenceSW(tile) == 0) {
|
|
|
|
SetFenceSW(tile, 3);
|
|
|
|
dirty = true;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-04-04 21:35:13 +00:00
|
|
|
neighbour = (IsTileType(TILE_ADDXY(tile, 0, 1), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 0, 1), CLEAR_FIELDS));
|
2011-11-08 19:48:47 +00:00
|
|
|
if (!neighbour && GetFenceSE(tile) == 0) {
|
|
|
|
SetFenceSE(tile, 3);
|
|
|
|
dirty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
neighbour = (IsTileType(TILE_ADDXY(tile, -1, 0), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, -1, 0), CLEAR_FIELDS));
|
|
|
|
if (!neighbour && GetFenceNE(tile) == 0) {
|
|
|
|
SetFenceNE(tile, 3);
|
|
|
|
dirty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
neighbour = (IsTileType(TILE_ADDXY(tile, 0, -1), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 0, -1), CLEAR_FIELDS));
|
|
|
|
if (!neighbour && GetFenceNW(tile) == 0) {
|
|
|
|
SetFenceNW(tile, 3);
|
|
|
|
dirty = true;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2009-06-10 07:19:48 +00:00
|
|
|
if (dirty) MarkTileDirtyByTile(tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-30 19:30:49 +00:00
|
|
|
/** Convert to or from snowy tiles. */
|
2005-06-24 12:38:35 +00:00
|
|
|
static void TileLoopClearAlps(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2011-11-04 10:25:58 +00:00
|
|
|
int k = GetTileZ(tile) - GetSnowLine() + 1;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-12-30 19:30:49 +00:00
|
|
|
if (k < 0) {
|
|
|
|
/* Below the snow line, do nothing if no snow. */
|
2010-01-04 18:33:43 +00:00
|
|
|
if (!IsSnowTile(tile)) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
} else {
|
2009-12-30 19:30:49 +00:00
|
|
|
/* At or above the snow line, make snow tile if needed. */
|
2010-01-04 18:33:43 +00:00
|
|
|
if (!IsSnowTile(tile)) {
|
|
|
|
MakeSnow(tile);
|
2009-12-30 19:30:49 +00:00
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
|
return;
|
2006-02-01 15:31:21 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2009-12-30 19:30:49 +00:00
|
|
|
/* Update snow density. */
|
|
|
|
uint curent_density = GetClearDensity(tile);
|
2011-11-04 10:25:58 +00:00
|
|
|
uint req_density = (k < 0) ? 0u : min((uint)k, 3);
|
2009-12-30 19:30:49 +00:00
|
|
|
|
|
|
|
if (curent_density < req_density) {
|
|
|
|
AddClearDensity(tile, 1);
|
|
|
|
} else if (curent_density > req_density) {
|
|
|
|
AddClearDensity(tile, -1);
|
|
|
|
} else {
|
|
|
|
/* Density at the required level. */
|
2010-01-04 22:26:25 +00:00
|
|
|
if (k >= 0) return;
|
|
|
|
ClearSnow(tile);
|
2009-12-30 19:30:49 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
|
}
|
|
|
|
|
2010-05-08 14:36:56 +00:00
|
|
|
/**
|
|
|
|
* Tests if at least one surrounding tile is desert
|
|
|
|
* @param tile tile to check
|
|
|
|
* @return does this tile have at least one desert tile around?
|
|
|
|
*/
|
|
|
|
static inline bool NeighbourIsDesert(TileIndex tile)
|
|
|
|
{
|
|
|
|
return GetTropicZone(tile + TileDiffXY( 1, 0)) == TROPICZONE_DESERT ||
|
|
|
|
GetTropicZone(tile + TileDiffXY( -1, 0)) == TROPICZONE_DESERT ||
|
|
|
|
GetTropicZone(tile + TileDiffXY( 0, 1)) == TROPICZONE_DESERT ||
|
|
|
|
GetTropicZone(tile + TileDiffXY( 0, -1)) == TROPICZONE_DESERT;
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void TileLoopClearDesert(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2010-05-08 14:36:56 +00:00
|
|
|
/* Current desert level - 0 if it is not desert */
|
|
|
|
uint current = 0;
|
|
|
|
if (IsClearGround(tile, CLEAR_DESERT)) current = GetClearDensity(tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2010-05-08 14:36:56 +00:00
|
|
|
/* Expected desert level - 0 if it shouldn't be desert */
|
|
|
|
uint expected = 0;
|
2006-03-30 19:16:44 +00:00
|
|
|
if (GetTropicZone(tile) == TROPICZONE_DESERT) {
|
2010-05-08 14:36:56 +00:00
|
|
|
expected = 3;
|
|
|
|
} else if (NeighbourIsDesert(tile)) {
|
|
|
|
expected = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (current == expected) return;
|
|
|
|
|
|
|
|
if (expected == 0) {
|
|
|
|
SetClearGroundDensity(tile, CLEAR_GRASS, 3);
|
2004-08-09 17:04:08 +00:00
|
|
|
} else {
|
2010-05-08 14:36:56 +00:00
|
|
|
/* Transition from clear to desert is not smooth (after clearing desert tile) */
|
|
|
|
SetClearGroundDensity(tile, CLEAR_DESERT, expected);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void TileLoop_Clear(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2009-01-21 02:31:55 +00:00
|
|
|
/* If the tile is at any edge flood it to prevent maps without water. */
|
|
|
|
if (_settings_game.construction.freeform_edges && DistanceFromEdge(tile) == 1) {
|
2011-11-04 11:30:37 +00:00
|
|
|
int z;
|
2011-11-04 10:31:46 +00:00
|
|
|
Slope slope = GetTileSlope(tile, &z);
|
2009-01-21 02:31:55 +00:00
|
|
|
if (z == 0 && slope == SLOPE_FLAT) {
|
|
|
|
DoFloodTile(tile);
|
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-01-03 00:45:22 +00:00
|
|
|
AmbientSoundEffect(tile);
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2008-05-29 15:13:28 +00:00
|
|
|
switch (_settings_game.game_creation.landscape) {
|
2007-03-22 03:42:43 +00:00
|
|
|
case LT_TROPIC: TileLoopClearDesert(tile); break;
|
|
|
|
case LT_ARCTIC: TileLoopClearAlps(tile); break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-02-01 15:31:21 +00:00
|
|
|
switch (GetClearGround(tile)) {
|
2006-04-04 21:35:13 +00:00
|
|
|
case CLEAR_GRASS:
|
2006-02-01 15:31:21 +00:00
|
|
|
if (GetClearDensity(tile) == 3) return;
|
|
|
|
|
|
|
|
if (_game_mode != GM_EDITOR) {
|
|
|
|
if (GetClearCounter(tile) < 7) {
|
|
|
|
AddClearCounter(tile, 1);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
SetClearCounter(tile, 0);
|
|
|
|
AddClearDensity(tile, 1);
|
|
|
|
}
|
|
|
|
} else {
|
2006-04-04 21:35:13 +00:00
|
|
|
SetClearGroundDensity(tile, GB(Random(), 0, 8) > 21 ? CLEAR_GRASS : CLEAR_ROUGH, 3);
|
2006-02-01 15:31:21 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-11-08 19:48:47 +00:00
|
|
|
case CLEAR_FIELDS:
|
|
|
|
UpdateFences(tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-02-01 15:31:21 +00:00
|
|
|
if (_game_mode == GM_EDITOR) return;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2006-02-01 15:31:21 +00:00
|
|
|
if (GetClearCounter(tile) < 7) {
|
|
|
|
AddClearCounter(tile, 1);
|
2004-08-09 17:04:08 +00:00
|
|
|
return;
|
2006-02-01 15:31:21 +00:00
|
|
|
} else {
|
|
|
|
SetClearCounter(tile, 0);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2006-02-01 15:31:21 +00:00
|
|
|
|
2006-08-21 09:22:44 +00:00
|
|
|
if (GetIndustryIndexOfField(tile) == INVALID_INDUSTRY && GetFieldType(tile) >= 7) {
|
2006-08-20 18:44:26 +00:00
|
|
|
/* This farmfield is no longer farmfield, so make it grass again */
|
2006-10-11 21:20:53 +00:00
|
|
|
MakeClear(tile, CLEAR_GRASS, 2);
|
2006-08-20 18:44:26 +00:00
|
|
|
} else {
|
2011-11-08 19:48:47 +00:00
|
|
|
uint field_type = GetFieldType(tile);
|
2006-08-20 18:44:26 +00:00
|
|
|
field_type = (field_type < 8) ? field_type + 1 : 0;
|
|
|
|
SetFieldType(tile, field_type);
|
|
|
|
}
|
2006-02-01 15:31:21 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2004-08-09 17:04:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
|
}
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void GenerateClearTile()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
uint i, gi;
|
2005-06-24 12:38:35 +00:00
|
|
|
TileIndex tile;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
/* add rough tiles */
|
2005-11-14 08:09:57 +00:00
|
|
|
i = ScaleByMapSize(GB(Random(), 0, 10) + 0x400);
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
gi = ScaleByMapSize(GB(Random(), 0, 7) + 0x80);
|
|
|
|
|
|
|
|
SetGeneratingWorldProgress(GWP_ROUGH_ROCKY, gi + i);
|
2004-08-09 17:04:08 +00:00
|
|
|
do {
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
IncreaseGeneratingWorldProgress(GWP_ROUGH_ROCKY);
|
2005-07-13 19:51:31 +00:00
|
|
|
tile = RandomTile();
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
if (IsTileType(tile, MP_CLEAR) && !IsClearGround(tile, CLEAR_DESERT)) SetClearGroundDensity(tile, CLEAR_ROUGH, 3);
|
2004-08-09 17:04:08 +00:00
|
|
|
} while (--i);
|
|
|
|
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
/* add rocky tiles */
|
|
|
|
i = gi;
|
2004-08-09 17:04:08 +00:00
|
|
|
do {
|
2005-07-21 06:31:02 +00:00
|
|
|
uint32 r = Random();
|
2005-07-13 19:51:31 +00:00
|
|
|
tile = RandomTileSeed(r);
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
|
|
|
|
IncreaseGeneratingWorldProgress(GWP_ROUGH_ROCKY);
|
|
|
|
if (IsTileType(tile, MP_CLEAR) && !IsClearGround(tile, CLEAR_DESERT)) {
|
2005-07-21 06:31:02 +00:00
|
|
|
uint j = GB(r, 16, 4) + 5;
|
2006-02-01 06:32:03 +00:00
|
|
|
for (;;) {
|
2005-06-24 12:38:35 +00:00
|
|
|
TileIndex tile_new;
|
|
|
|
|
2006-04-04 21:35:13 +00:00
|
|
|
SetClearGroundDensity(tile, CLEAR_ROCKS, 3);
|
2004-08-09 17:04:08 +00:00
|
|
|
do {
|
|
|
|
if (--j == 0) goto get_out;
|
2007-07-24 13:03:24 +00:00
|
|
|
tile_new = tile + TileOffsByDiagDir((DiagDirection)GB(Random(), 0, 2));
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
} while (!IsTileType(tile_new, MP_CLEAR) || IsClearGround(tile_new, CLEAR_DESERT));
|
2004-08-09 17:04:08 +00:00
|
|
|
tile = tile_new;
|
|
|
|
}
|
|
|
|
get_out:;
|
|
|
|
}
|
|
|
|
} while (--i);
|
|
|
|
}
|
|
|
|
|
2008-02-20 17:49:50 +00:00
|
|
|
static TrackStatus GetTileTrackStatus_Clear(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-07-28 19:18:27 +00:00
|
|
|
static const StringID _clear_land_str[] = {
|
2009-08-05 17:59:21 +00:00
|
|
|
STR_LAI_CLEAR_DESCRIPTION_GRASS,
|
|
|
|
STR_LAI_CLEAR_DESCRIPTION_ROUGH_LAND,
|
|
|
|
STR_LAI_CLEAR_DESCRIPTION_ROCKS,
|
|
|
|
STR_LAI_CLEAR_DESCRIPTION_FIELDS,
|
|
|
|
STR_LAI_CLEAR_DESCRIPTION_SNOW_COVERED_LAND,
|
|
|
|
STR_LAI_CLEAR_DESCRIPTION_DESERT
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void GetTileDesc_Clear(TileIndex tile, TileDesc *td)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-04-04 21:35:13 +00:00
|
|
|
if (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) == 0) {
|
2009-08-05 17:59:21 +00:00
|
|
|
td->str = STR_LAI_CLEAR_DESCRIPTION_BARE_LAND;
|
2006-02-01 15:31:21 +00:00
|
|
|
} else {
|
|
|
|
td->str = _clear_land_str[GetClearGround(tile)];
|
|
|
|
}
|
2008-05-21 22:15:39 +00:00
|
|
|
td->owner[0] = GetTileOwner(tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
static void ChangeTileOwner_Clear(TileIndex tile, Owner old_owner, Owner new_owner)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-11-04 11:36:10 +00:00
|
|
|
static CommandCost TerraformTile_Clear(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
|
2007-08-30 17:17:04 +00:00
|
|
|
{
|
|
|
|
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
|
|
|
}
|
|
|
|
|
2007-01-10 18:56:51 +00:00
|
|
|
extern const TileTypeProcs _tile_type_clear_procs = {
|
2007-02-23 11:50:43 +00:00
|
|
|
DrawTile_Clear, ///< draw_tile_proc
|
2011-11-04 10:18:13 +00:00
|
|
|
GetSlopePixelZ_Clear, ///< get_slope_z_proc
|
2007-02-23 11:50:43 +00:00
|
|
|
ClearTile_Clear, ///< clear_tile_proc
|
2009-06-25 20:08:59 +00:00
|
|
|
NULL, ///< add_accepted_cargo_proc
|
2007-02-23 11:50:43 +00:00
|
|
|
GetTileDesc_Clear, ///< get_tile_desc_proc
|
|
|
|
GetTileTrackStatus_Clear, ///< get_tile_track_status_proc
|
2009-06-25 20:08:59 +00:00
|
|
|
NULL, ///< click_tile_proc
|
|
|
|
NULL, ///< animate_tile_proc
|
2011-11-08 17:37:32 +00:00
|
|
|
TileLoop_Clear, ///< tile_loop_proc
|
|
|
|
ChangeTileOwner_Clear, ///< change_tile_owner_proc
|
2009-06-27 17:05:20 +00:00
|
|
|
NULL, ///< add_produced_cargo_proc
|
2007-02-23 11:50:43 +00:00
|
|
|
NULL, ///< vehicle_enter_tile_proc
|
2007-07-26 16:51:10 +00:00
|
|
|
GetFoundation_Clear, ///< get_foundation_proc
|
2007-08-30 17:17:04 +00:00
|
|
|
TerraformTile_Clear, ///< terraform_tile_proc
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|