diff options
author | truelight <truelight@openttd.org> | 2007-10-11 11:06:04 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2007-10-11 11:06:04 +0000 |
commit | 645e5b1fb08d4f75a7940857872bc4fdc8876ef7 (patch) | |
tree | 2f02157b68131ccb2d373fae8a24ef9d92b428de /src | |
parent | 1ff0197ca406eb1eb197a18a5a8e525f9c0f28bc (diff) | |
download | openttd-645e5b1fb08d4f75a7940857872bc4fdc8876ef7.tar.xz |
(svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
-Fix: planting tree in desert doesn't make it grassy for the first tile-cycle (Csaboka)
-Fix: when a tree dies in desert, it no longer becomes a snowy tile for the first tile-cycle (Csaboka)
Diffstat (limited to 'src')
-rw-r--r-- | src/openttd.cpp | 14 | ||||
-rw-r--r-- | src/saveload.cpp | 2 | ||||
-rw-r--r-- | src/tree_cmd.cpp | 43 |
3 files changed, 44 insertions, 15 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp index aa55e788c..1b6407720 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -76,6 +76,7 @@ #include "water_map.h" #include "industry_map.h" #include "unmovable_map.h" +#include "tree_map.h" #include <stdarg.h> @@ -2196,6 +2197,19 @@ bool AfterLoadGame() } } + /* Before version 81, the density of grass was always stored as zero, and + * grassy trees were always drawn fully grassy. Furthermore, trees on rough + * land used to have zero density, now they have full density. Therefore, + * make all grassy/rough land trees have a density of 3. */ + if (CheckSavegameVersion(81)) { + for (TileIndex t = 0; t < map_size; t++) { + if (GetTileType(t) == MP_TREES) { + TreeGround groundType = GetTreeGround(t); + if (groundType != TREE_GROUND_SNOW_DESERT) SetTreeGroundDensity(t, groundType, 3); + } + } + } + return true; } diff --git a/src/saveload.cpp b/src/saveload.cpp index a3f531431..352eff38c 100644 --- a/src/saveload.cpp +++ b/src/saveload.cpp @@ -29,7 +29,7 @@ #include "strings.h" #include <list> -extern const uint16 SAVEGAME_VERSION = 80; +extern const uint16 SAVEGAME_VERSION = 81; uint16 _sl_version; ///< the major savegame version identifier byte _sl_minor_version; ///< the minor savegame version, DO NOT USE! diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 123fd8a49..062670066 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -85,7 +85,7 @@ static void PlaceTree(TileIndex tile, uint32 r) SetTreeGroundDensity(tile, TREE_GROUND_SNOW_DESERT, 3); SetTreeCounter(tile, (TreeGround)GB(r, 24, 3)); } else { - SetTreeGroundDensity(tile, (TreeGround)GB(r, 28, 1), 0); + SetTreeGroundDensity(tile, (TreeGround)GB(r, 28, 1), 3); SetTreeCounter(tile, (TreeGround)GB(r, 24, 4)); } } @@ -346,9 +346,10 @@ CommandCost CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) growth = _game_mode == GM_EDITOR ? 3 : 0; switch (GetClearGround(tile)) { - case CLEAR_ROUGH: MakeTree(tile, treetype, 0, growth, TREE_GROUND_ROUGH, 0); break; - case CLEAR_SNOW: MakeTree(tile, treetype, 0, growth, TREE_GROUND_SNOW_DESERT, GetClearDensity(tile)); break; - default: MakeTree(tile, treetype, 0, growth, TREE_GROUND_GRASS, 0); break; + case CLEAR_ROUGH: MakeTree(tile, treetype, 0, growth, TREE_GROUND_ROUGH, 3); break; + case CLEAR_SNOW: + case CLEAR_DESERT: MakeTree(tile, treetype, 0, growth, TREE_GROUND_SNOW_DESERT, GetClearDensity(tile)); break; + default: MakeTree(tile, treetype, 0, growth, TREE_GROUND_GRASS, GetClearDensity(tile)); break; } MarkTileDirtyByTile(tile); @@ -385,7 +386,7 @@ static void DrawTile_Trees(TileInfo *ti) byte z; switch (GetTreeGround(ti->tile)) { - case TREE_GROUND_GRASS: DrawClearLandTile(ti, 3); break; + case TREE_GROUND_GRASS: DrawClearLandTile(ti, GetTreeDensity(ti->tile)); break; case TREE_GROUND_ROUGH: DrawHillyLandTile(ti); break; default: DrawGroundSprite(_tree_sprites_1[GetTreeDensity(ti->tile)] + _tileh_to_sprite[ti->tileh], PAL_NONE); break; } @@ -557,7 +558,7 @@ static void TileLoopTreesAlps(TileIndex tile) if (k < 0) { if (GetTreeGround(tile) != TREE_GROUND_SNOW_DESERT) return; - SetTreeGroundDensity(tile, TREE_GROUND_GRASS, 0); + SetTreeGroundDensity(tile, TREE_GROUND_GRASS, 3); } else { uint density = min((uint)k / TILE_HEIGHT, 3); @@ -586,6 +587,16 @@ static void TileLoop_Trees(TileIndex tile) TileLoopClearHelper(tile); + uint treeCounter = GetTreeCounter(tile); + + /* Handle growth of grass at every 8th processings, like it's done for grass */ + if ((treeCounter & 7) == 7 && GetTreeGround(tile) == TREE_GROUND_GRASS) { + uint density = GetTreeDensity(tile); + if (density < 3) { + SetTreeGroundDensity(tile, TREE_GROUND_GRASS, density + 1); + MarkTileDirtyByTile(tile); + } + } if (GetTreeCounter(tile) < 15) { AddTreeCounter(tile, 1); return; @@ -622,11 +633,12 @@ static void TileLoop_Trees(TileIndex tile) switch (GetClearGround(tile)) { case CLEAR_GRASS: if (GetClearDensity(tile) != 3) return; - MakeTree(tile, treetype, 0, 0, TREE_GROUND_GRASS, 0); + MakeTree(tile, treetype, 0, 0, TREE_GROUND_GRASS, 3); break; - case CLEAR_ROUGH: MakeTree(tile, treetype, 0, 0, TREE_GROUND_ROUGH, 0); break; - case CLEAR_SNOW: MakeTree(tile, treetype, 0, 0, TREE_GROUND_SNOW_DESERT, GetClearDensity(tile)); break; + case CLEAR_ROUGH: MakeTree(tile, treetype, 0, 0, TREE_GROUND_ROUGH, 3); break; + case CLEAR_DESERT: return; // Cacti don't spread + case CLEAR_SNOW: MakeTree(tile, treetype, 0, 0, TREE_GROUND_SNOW_DESERT, GetClearDensity(tile)); break; default: return; } break; @@ -646,9 +658,12 @@ static void TileLoop_Trees(TileIndex tile) } else { /* just one tree, change type into MP_CLEAR */ switch (GetTreeGround(tile)) { - case TREE_GROUND_GRASS: MakeClear(tile, CLEAR_GRASS, 3); break; + case TREE_GROUND_GRASS: MakeClear(tile, CLEAR_GRASS, GetTreeDensity(tile)); break; case TREE_GROUND_ROUGH: MakeClear(tile, CLEAR_ROUGH, 3); break; - default: MakeClear(tile, CLEAR_SNOW, GetTreeDensity(tile)); break; + default: // snow or desert + if (_opt.landscape == LT_TROPIC) MakeClear(tile, CLEAR_DESERT, GetTreeDensity(tile)); + else MakeClear(tile, CLEAR_SNOW, GetTreeDensity(tile)); + break; } } break; @@ -675,7 +690,7 @@ void OnTick_Trees() !IsBridgeAbove(tile) && (ct = GetClearGround(tile), ct == CLEAR_GRASS || ct == CLEAR_ROUGH) && (tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) { - MakeTree(tile, tree, 0, 0, ct == CLEAR_ROUGH ? TREE_GROUND_ROUGH : TREE_GROUND_GRASS, 0); + MakeTree(tile, tree, 0, 0, ct == CLEAR_ROUGH ? TREE_GROUND_ROUGH : TREE_GROUND_GRASS, GetClearDensity(tile)); } /* byte underflow */ @@ -689,8 +704,8 @@ void OnTick_Trees() (ct = GetClearGround(tile), ct == CLEAR_GRASS || ct == CLEAR_ROUGH || ct == CLEAR_SNOW) && (tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) { switch (ct) { - case CLEAR_GRASS: MakeTree(tile, tree, 0, 0, TREE_GROUND_GRASS, 0); break; - case CLEAR_ROUGH: MakeTree(tile, tree, 0, 0, TREE_GROUND_ROUGH, 0); break; + case CLEAR_GRASS: MakeTree(tile, tree, 0, 0, TREE_GROUND_GRASS, GetClearDensity(tile)); break; + case CLEAR_ROUGH: MakeTree(tile, tree, 0, 0, TREE_GROUND_ROUGH, 3); break; default: MakeTree(tile, tree, 0, 0, TREE_GROUND_SNOW_DESERT, GetClearDensity(tile)); break; } } |