2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
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"
|
2005-06-02 19:30:21 +00:00
|
|
|
#include "openttd.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-02-26 18:25:03 +00:00
|
|
|
#include "bridge.h"
|
2007-03-20 13:47:00 +00:00
|
|
|
#include "landscape.h"
|
2005-07-21 18:44:27 +00:00
|
|
|
#include "variables.h"
|
2006-03-23 20:47:56 +00:00
|
|
|
#include "unmovable_map.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"
|
2006-08-20 18:44:26 +00:00
|
|
|
#include "industry.h"
|
2007-06-19 21:15:14 +00:00
|
|
|
#include "water_map.h"
|
2007-12-21 22:50:51 +00:00
|
|
|
#include "tile_cmd.h"
|
2007-12-25 11:26:07 +00:00
|
|
|
#include "functions.h"
|
2007-12-25 23:42:52 +00:00
|
|
|
#include "economy_func.h"
|
2008-01-09 09:45:45 +00:00
|
|
|
#include "viewport_func.h"
|
2008-01-13 14:37:30 +00:00
|
|
|
#include "settings_type.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"
|
|
|
|
|
2007-06-18 10:48:15 +00:00
|
|
|
static CommandCost ClearTile_Clear(TileIndex tile, byte flags)
|
2005-01-22 22:47:58 +00:00
|
|
|
{
|
2009-01-10 00:31:47 +00:00
|
|
|
static const Money *clear_price_table[] = {
|
2007-11-27 16:02:13 +00:00
|
|
|
&_price.clear_grass,
|
|
|
|
&_price.clear_roughland,
|
|
|
|
&_price.clear_rocks,
|
|
|
|
&_price.clear_fields,
|
|
|
|
&_price.clear_roughland,
|
|
|
|
&_price.clear_roughland,
|
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) {
|
|
|
|
price.AddCost(*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
|
|
|
{
|
2007-01-14 19:57:49 +00:00
|
|
|
DrawGroundSprite(SPR_FLAT_BARE_LAND + _tileh_to_sprite[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) {
|
2007-01-14 19:57:49 +00:00
|
|
|
DrawGroundSprite(SPR_FLAT_ROUGH_LAND + _tileh_to_sprite[ti->tileh], PAL_NONE);
|
2004-08-09 17:04:08 +00:00
|
|
|
} else {
|
2007-01-14 19:57:49 +00:00
|
|
|
DrawGroundSprite(_landscape_clear_sprites[GB(ti->x ^ ti->y, 4, 3)], PAL_NONE);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-28 19:18:27 +00:00
|
|
|
void DrawClearLandFence(const TileInfo *ti)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
byte z = ti->z;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2006-04-23 13:48:16 +00:00
|
|
|
if (ti->tileh & SLOPE_S) {
|
2006-04-23 19:35:36 +00:00
|
|
|
z += TILE_HEIGHT;
|
|
|
|
if (ti->tileh == SLOPE_STEEP_S) z += TILE_HEIGHT;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-02-05 11:54:25 +00:00
|
|
|
if (GetFenceSW(ti->tile) != 0) {
|
2007-01-14 19:57:49 +00:00
|
|
|
DrawGroundSpriteAt(_clear_land_fence_sprites_1[GetFenceSW(ti->tile) - 1] + _fence_mod_by_tileh[ti->tileh], PAL_NONE, ti->x, ti->y, z);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-02-05 11:54:25 +00:00
|
|
|
if (GetFenceSE(ti->tile) != 0) {
|
2007-01-14 19:57:49 +00:00
|
|
|
DrawGroundSpriteAt(_clear_land_fence_sprites_1[GetFenceSE(ti->tile) - 1] + _fence_mod_by_tileh_2[ti->tileh], PAL_NONE, ti->x, ti->y, z);
|
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:
|
2007-01-14 19:57:49 +00:00
|
|
|
DrawGroundSprite(SPR_FLAT_ROCKY_LAND_1 + _tileh_to_sprite[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:
|
2007-01-14 19:57:49 +00:00
|
|
|
DrawGroundSprite(_clear_land_sprites_1[GetFieldType(ti->tile)] + _tileh_to_sprite[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_SNOW:
|
2007-01-14 19:57:49 +00:00
|
|
|
DrawGroundSprite(_clear_land_sprites_2[GetClearDensity(ti->tile)] + _tileh_to_sprite[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_DESERT:
|
2007-01-14 19:57:49 +00:00
|
|
|
DrawGroundSprite(_clear_land_sprites_3[GetClearDensity(ti->tile)] + _tileh_to_sprite[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
|
|
|
|
2005-07-28 19:18:27 +00:00
|
|
|
DrawClearLandFence(ti);
|
2006-12-27 12:38:02 +00:00
|
|
|
DrawBridgeMiddle(ti);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-08-06 16:32:49 +00:00
|
|
|
static uint GetSlopeZ_Clear(TileIndex tile, uint x, uint y)
|
2005-01-22 22:47:58 +00:00
|
|
|
{
|
2006-08-06 16:32:49 +00:00
|
|
|
uint z;
|
2007-01-10 18:56:51 +00:00
|
|
|
Slope tileh = GetTileSlope(tile, &z);
|
2006-08-06 16:32:49 +00:00
|
|
|
|
|
|
|
return z + GetPartialZ(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
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void GetAcceptedCargo_Clear(TileIndex tile, AcceptedCargo ac)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2004-09-10 19:02:27 +00:00
|
|
|
/* unused */
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void AnimateTile_Clear(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
/* unused */
|
|
|
|
}
|
|
|
|
|
2005-02-04 20:17:15 +00:00
|
|
|
void TileLoopClearHelper(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-07-28 19:23:19 +00:00
|
|
|
byte self;
|
|
|
|
byte neighbour;
|
2005-02-04 20:17:15 +00:00
|
|
|
TileIndex dirty = INVALID_TILE;
|
|
|
|
|
2006-04-04 21:35:13 +00:00
|
|
|
self = (IsTileType(tile, MP_CLEAR) && IsClearGround(tile, CLEAR_FIELDS));
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-04-04 21:35:13 +00:00
|
|
|
neighbour = (IsTileType(TILE_ADDXY(tile, 1, 0), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 1, 0), CLEAR_FIELDS));
|
2006-02-05 11:54:25 +00:00
|
|
|
if (GetFenceSW(tile) == 0) {
|
2005-07-28 19:23:19 +00:00
|
|
|
if (self != neighbour) {
|
2006-02-05 11:54:25 +00:00
|
|
|
SetFenceSW(tile, 3);
|
2004-08-09 17:04:08 +00:00
|
|
|
dirty = tile;
|
2004-09-10 19:02:27 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
} else {
|
2005-07-28 19:23:19 +00:00
|
|
|
if (self == 0 && neighbour == 0) {
|
2006-02-05 11:54:25 +00:00
|
|
|
SetFenceSW(tile, 0);
|
2004-08-09 17:04:08 +00:00
|
|
|
dirty = tile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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));
|
2006-02-05 11:54:25 +00:00
|
|
|
if (GetFenceSE(tile) == 0) {
|
2005-07-28 19:23:19 +00:00
|
|
|
if (self != neighbour) {
|
2006-02-05 11:54:25 +00:00
|
|
|
SetFenceSE(tile, 3);
|
2004-08-09 17:04:08 +00:00
|
|
|
dirty = tile;
|
2004-09-10 19:02:27 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
} else {
|
2005-07-28 19:23:19 +00:00
|
|
|
if (self == 0 && neighbour == 0) {
|
2006-02-05 11:54:25 +00:00
|
|
|
SetFenceSE(tile, 0);
|
2004-08-09 17:04:08 +00:00
|
|
|
dirty = tile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-28 19:23:19 +00:00
|
|
|
if (dirty != INVALID_TILE) MarkTileDirtyByTile(dirty);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* convert into snowy tiles */
|
2005-06-24 12:38:35 +00:00
|
|
|
static void TileLoopClearAlps(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-03-20 13:47:00 +00:00
|
|
|
int k = GetTileZ(tile) - GetSnowLine() + TILE_HEIGHT;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-07-22 07:36:01 +00:00
|
|
|
if (k < 0) { // well below the snow line
|
2006-04-04 21:35:13 +00:00
|
|
|
if (!IsClearGround(tile, CLEAR_SNOW)) return;
|
|
|
|
if (GetClearDensity(tile) == 0) SetClearGroundDensity(tile, CLEAR_GRASS, 3);
|
2004-08-09 17:04:08 +00:00
|
|
|
} else {
|
2006-04-04 21:35:13 +00:00
|
|
|
if (!IsClearGround(tile, CLEAR_SNOW)) {
|
|
|
|
SetClearGroundDensity(tile, CLEAR_SNOW, 0);
|
2006-02-01 15:31:21 +00:00
|
|
|
} else {
|
2006-07-22 07:36:01 +00:00
|
|
|
uint density = min((uint)k / TILE_HEIGHT, 3);
|
2006-02-01 15:31:21 +00:00
|
|
|
|
|
|
|
if (GetClearDensity(tile) < density) {
|
|
|
|
AddClearDensity(tile, 1);
|
|
|
|
} else if (GetClearDensity(tile) > density) {
|
|
|
|
AddClearDensity(tile, -1);
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void TileLoopClearDesert(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-04-04 21:35:13 +00:00
|
|
|
if (IsClearGround(tile, CLEAR_DESERT)) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-03-30 19:16:44 +00:00
|
|
|
if (GetTropicZone(tile) == TROPICZONE_DESERT) {
|
2006-04-04 21:35:13 +00:00
|
|
|
SetClearGroundDensity(tile, CLEAR_DESERT, 3);
|
2004-08-09 17:04:08 +00:00
|
|
|
} else {
|
2006-03-30 19:16:44 +00:00
|
|
|
if (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-25 16:44:57 +00:00
|
|
|
return;
|
2006-04-04 21:35:13 +00:00
|
|
|
SetClearGroundDensity(tile, CLEAR_DESERT, 1);
|
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
|
|
|
{
|
|
|
|
TileLoopClearHelper(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;
|
|
|
|
|
2006-04-04 21:35:13 +00:00
|
|
|
case CLEAR_FIELDS: {
|
2006-02-01 15:31:21 +00:00
|
|
|
uint field_type;
|
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 {
|
|
|
|
field_type = GetFieldType(tile);
|
|
|
|
field_type = (field_type < 8) ? field_type + 1 : 0;
|
|
|
|
SetFieldType(tile, field_type);
|
|
|
|
}
|
2006-02-01 15:31:21 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2006-02-01 15:31:21 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2009-01-02 22:42:05 +00:00
|
|
|
static bool ClickTile_Clear(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
/* not used */
|
2009-01-02 22:42:05 +00:00
|
|
|
return false;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
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[] = {
|
2006-02-01 15:31:21 +00:00
|
|
|
STR_080D_GRASS,
|
2004-08-09 17:04:08 +00:00
|
|
|
STR_080B_ROUGH_LAND,
|
|
|
|
STR_080A_ROCKS,
|
|
|
|
STR_080E_FIELDS,
|
|
|
|
STR_080F_SNOW_COVERED_LAND,
|
2006-02-01 15:31:21 +00:00
|
|
|
STR_0810_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) {
|
2006-02-01 15:31:21 +00:00
|
|
|
td->str = STR_080C_BARE_LAND;
|
|
|
|
} 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;
|
|
|
|
}
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void InitializeClearLand()
|
2005-01-22 20:23:18 +00:00
|
|
|
{
|
2008-05-29 15:13:28 +00:00
|
|
|
_settings_game.game_creation.snow_line = _settings_game.game_creation.snow_line_height * TILE_HEIGHT;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 17:17:04 +00:00
|
|
|
static CommandCost TerraformTile_Clear(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
GetSlopeZ_Clear, ///< get_slope_z_proc
|
|
|
|
ClearTile_Clear, ///< clear_tile_proc
|
|
|
|
GetAcceptedCargo_Clear, ///< get_accepted_cargo_proc
|
|
|
|
GetTileDesc_Clear, ///< get_tile_desc_proc
|
|
|
|
GetTileTrackStatus_Clear, ///< get_tile_track_status_proc
|
|
|
|
ClickTile_Clear, ///< click_tile_proc
|
|
|
|
AnimateTile_Clear, ///< animate_tile_proc
|
|
|
|
TileLoop_Clear, ///< tile_loop_clear
|
|
|
|
ChangeTileOwner_Clear, ///< change_tile_owner_clear
|
|
|
|
NULL, ///< get_produced_cargo_proc
|
|
|
|
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
|
|
|
};
|