mirror of https://github.com/OpenTTD/OpenTTD
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
parent
756212a71e
commit
80570009dd
10
clear_cmd.c
10
clear_cmd.c
|
@ -603,13 +603,13 @@ static void TileLoopClearDesert(TileIndex tile)
|
|||
{
|
||||
if (IsClearGround(tile, CL_DESERT)) return;
|
||||
|
||||
if (GetMapExtraBits(tile) == 1) {
|
||||
if (GetTropicZone(tile) == TROPICZONE_DESERT) {
|
||||
SetClearGroundDensity(tile, CL_DESERT, 3);
|
||||
} else {
|
||||
if (GetMapExtraBits(tile + TileDiffXY( 1, 0)) != 1 &&
|
||||
GetMapExtraBits(tile + TileDiffXY(-1, 0)) != 1 &&
|
||||
GetMapExtraBits(tile + TileDiffXY( 0, 1)) != 1 &&
|
||||
GetMapExtraBits(tile + TileDiffXY( 0, -1)) != 1)
|
||||
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)
|
||||
return;
|
||||
SetClearGroundDensity(tile, CL_DESERT, 1);
|
||||
}
|
||||
|
|
|
@ -1031,7 +1031,7 @@ static void ChopLumberMillTrees(Industry *i)
|
|||
SndPlayTileFx(SND_38_CHAINSAW, tile);
|
||||
|
||||
DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||
SetMapExtraBits(tile, 0);
|
||||
SetTropicZone(tile, TROPICZONE_INVALID);
|
||||
|
||||
i->cargo_waiting[0] = min(0xffff, i->cargo_waiting[0] + 45);
|
||||
|
||||
|
@ -1181,7 +1181,7 @@ static bool CheckNewIndustry_Farm(TileIndex tile, int type)
|
|||
|
||||
static bool CheckNewIndustry_Plantation(TileIndex tile, int type)
|
||||
{
|
||||
if (GetMapExtraBits(tile) == 1) {
|
||||
if (GetTropicZone(tile) == TROPICZONE_DESERT) {
|
||||
_error_message = STR_0239_SITE_UNSUITABLE;
|
||||
return false;
|
||||
}
|
||||
|
@ -1191,7 +1191,7 @@ static bool CheckNewIndustry_Plantation(TileIndex tile, int type)
|
|||
|
||||
static bool CheckNewIndustry_Water(TileIndex tile, int type)
|
||||
{
|
||||
if (GetMapExtraBits(tile) != 1) {
|
||||
if (GetTropicZone(tile) != TROPICZONE_DESERT) {
|
||||
_error_message = STR_0318_CAN_ONLY_BE_BUILT_IN_DESERT;
|
||||
return false;
|
||||
}
|
||||
|
@ -1201,7 +1201,7 @@ static bool CheckNewIndustry_Water(TileIndex tile, int type)
|
|||
|
||||
static bool CheckNewIndustry_Lumbermill(TileIndex tile, int type)
|
||||
{
|
||||
if (GetMapExtraBits(tile) != 2) {
|
||||
if (GetTropicZone(tile) != TROPICZONE_RAINFOREST) {
|
||||
_error_message = STR_0317_CAN_ONLY_BE_BUILT_IN_RAINFOREST;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -590,7 +590,7 @@ static void CreateDesertOrRainForest(void)
|
|||
if (TileHeight(t) >= 4 || IsTileType(t, MP_WATER)) break;
|
||||
}
|
||||
if (data == endof(_make_desert_or_rainforest_data))
|
||||
SetMapExtraBits(tile, 1);
|
||||
SetTropicZone(tile, TROPICZONE_DESERT);
|
||||
}
|
||||
|
||||
for (i = 0; i != 256; i++)
|
||||
|
@ -603,7 +603,7 @@ static void CreateDesertOrRainForest(void)
|
|||
if (IsTileType(t, MP_CLEAR) && IsClearGround(t, CL_DESERT)) break;
|
||||
}
|
||||
if (data == endof(_make_desert_or_rainforest_data))
|
||||
SetMapExtraBits(tile, 2);
|
||||
SetTropicZone(tile, TROPICZONE_RAINFOREST);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1814,7 +1814,7 @@ static void TileLoop_Track(TileIndex tile)
|
|||
break;
|
||||
|
||||
case LT_DESERT:
|
||||
if (GetMapExtraBits(tile) == 1) { /* convert into desert? */
|
||||
if (GetTropicZone(tile) == TROPICZONE_DESERT) { /* convert into desert? */
|
||||
new_ground = RAIL_GROUND_ICE_DESERT;
|
||||
goto modify_me;
|
||||
}
|
||||
|
|
|
@ -920,7 +920,7 @@ static void TileLoop_Road(TileIndex tile)
|
|||
break;
|
||||
|
||||
case LT_DESERT:
|
||||
if (GetMapExtraBits(tile) == 1 && !(_m[tile].m4 & 0x80)) {
|
||||
if (GetTropicZone(tile) == TROPICZONE_DESERT && !(_m[tile].m4 & 0x80)) {
|
||||
_m[tile].m4 |= 0x80;
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ static void GenerateDesertArea(TileIndex end, TileIndex start)
|
|||
_generating_world = true;
|
||||
BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
|
||||
if (GetTileType(tile) != MP_WATER) {
|
||||
SetMapExtraBits(tile, (_ctrl_pressed) ? 0 : 1);
|
||||
SetTropicZone(tile, (_ctrl_pressed) ? TROPICZONE_INVALID : TROPICZONE_DESERT);
|
||||
DoCommandP(tile, 0, 0, NULL, CMD_LANDSCAPE_CLEAR);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
|
|
12
tile.c
12
tile.c
|
@ -3,18 +3,6 @@
|
|||
#include "stdafx.h"
|
||||
#include "tile.h"
|
||||
|
||||
void SetMapExtraBits(TileIndex tile, byte bits)
|
||||
{
|
||||
assert(tile < MapSize());
|
||||
SB(_m[tile].extra, 0, 2, bits & 3);
|
||||
}
|
||||
|
||||
uint GetMapExtraBits(TileIndex tile)
|
||||
{
|
||||
assert(tile < MapSize());
|
||||
return GB(_m[tile].extra, 0, 2);
|
||||
}
|
||||
|
||||
/** Converts the heights of 4 corners into a tileh, and returns the minimum height of the tile
|
||||
* @param n,w,e,s the four corners
|
||||
* @param h uint pointer to write the height to
|
||||
|
|
31
tile.h
31
tile.h
|
@ -20,9 +20,11 @@ typedef enum TileTypes {
|
|||
MP_UNMOVABLE,
|
||||
} TileType;
|
||||
|
||||
|
||||
void SetMapExtraBits(TileIndex tile, byte flags);
|
||||
uint GetMapExtraBits(TileIndex tile);
|
||||
typedef enum TropicZones {
|
||||
TROPICZONE_INVALID = 0,
|
||||
TROPICZONE_DESERT = 1,
|
||||
TROPICZONE_RAINFOREST = 2,
|
||||
} TropicZone;
|
||||
|
||||
uint GetTileh(uint n, uint w, uint e, uint s, uint *h);
|
||||
uint GetTileSlope(TileIndex tile, uint *h);
|
||||
|
@ -106,4 +108,27 @@ static inline bool IsTileOwner(TileIndex tile, Owner owner)
|
|||
return GetTileOwner(tile) == owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tropic zone
|
||||
* @param tile the tile to set the zone of
|
||||
* @param type the new type
|
||||
* @pre assert(tile < MapSize());
|
||||
*/
|
||||
static inline void SetTropicZone(TileIndex tile, TropicZone type)
|
||||
{
|
||||
assert(tile < MapSize());
|
||||
SB(_m[tile].extra, 0, 2, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tropic zone
|
||||
* @param tile the tile to get the zone of
|
||||
* @pre assert(tile < MapSize());
|
||||
* @return the zone type
|
||||
*/
|
||||
static inline TropicZone GetTropicZone(TileIndex tile)
|
||||
{
|
||||
assert(tile < MapSize());
|
||||
return (TropicZone)GB(_m[tile].extra, 0, 2);
|
||||
}
|
||||
#endif /* TILE_H */
|
||||
|
|
|
@ -1762,7 +1762,7 @@ static void UpdateTownGrowRate(Town *t)
|
|||
if (TilePixelHeight(t->xy) >= _opt.snow_line && t->act_food == 0 && t->population > 90)
|
||||
return;
|
||||
} else if (_opt.landscape == LT_DESERT) {
|
||||
if (GetMapExtraBits(t->xy) == 1 && (t->act_food==0 || t->act_water==0) && t->population > 60)
|
||||
if (GetTropicZone(t->xy) == TROPICZONE_DESERT && (t->act_food==0 || t->act_water==0) && t->population > 60)
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
26
tree_cmd.c
26
tree_cmd.c
|
@ -26,10 +26,10 @@ static TreeType GetRandomTreeType(TileIndex tile, uint seed)
|
|||
return seed * TR_COUNT_SUB_ARCTIC / 256 + TR_SUB_ARCTIC;
|
||||
|
||||
case LT_DESERT:
|
||||
switch (GetMapExtraBits(tile)) {
|
||||
case 0: return seed * TR_COUNT_SUB_TROPICAL / 256 + TR_SUB_TROPICAL;
|
||||
case 1: return (seed > 12) ? TR_INVALID : TR_CACTUS;
|
||||
default: return seed * TR_COUNT_RAINFOREST / 256 + TR_RAINFOREST;
|
||||
switch (GetTropicZone(tile)) {
|
||||
case TROPICZONE_INVALID: return seed * TR_COUNT_SUB_TROPICAL / 256 + TR_SUB_TROPICAL;
|
||||
case TROPICZONE_DESERT: return (seed > 12) ? TR_INVALID : TR_CACTUS;
|
||||
default: return seed * TR_COUNT_RAINFOREST / 256 + TR_RAINFOREST;
|
||||
}
|
||||
|
||||
default:
|
||||
|
@ -105,7 +105,7 @@ void PlaceTreesRandomly(void)
|
|||
do {
|
||||
uint32 r = Random();
|
||||
TileIndex tile = RandomTileSeed(r);
|
||||
if (IsTileType(tile, MP_CLEAR) && GetMapExtraBits(tile) == 2) {
|
||||
if (IsTileType(tile, MP_CLEAR) && GetTropicZone(tile) == TROPICZONE_RAINFOREST) {
|
||||
PlaceTree(tile, r);
|
||||
}
|
||||
} while (--i);
|
||||
|
@ -208,7 +208,7 @@ int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
|
|||
MarkTileDirtyByTile(tile);
|
||||
|
||||
if (_game_mode == GM_EDITOR && IS_INT_INSIDE(treetype, TR_RAINFOREST, TR_CACTUS))
|
||||
SetMapExtraBits(tile, 2);
|
||||
SetTropicZone(tile, TROPICZONE_RAINFOREST);
|
||||
}
|
||||
cost += _price.build_trees;
|
||||
break;
|
||||
|
@ -376,15 +376,15 @@ static void AnimateTile_Trees(TileIndex tile)
|
|||
|
||||
static void TileLoopTreesDesert(TileIndex tile)
|
||||
{
|
||||
switch (GetMapExtraBits(tile)) {
|
||||
case 1:
|
||||
switch (GetTropicZone(tile)) {
|
||||
case TROPICZONE_DESERT:
|
||||
if (GetTreeGround(tile) != TR_SNOW_DESERT) {
|
||||
SetTreeGroundDensity(tile, TR_SNOW_DESERT, 3);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: {
|
||||
case TROPICZONE_RAINFOREST: {
|
||||
static const SoundFx forest_sounds[] = {
|
||||
SND_42_LOON_BIRD,
|
||||
SND_43_LION,
|
||||
|
@ -396,6 +396,8 @@ static void TileLoopTreesDesert(TileIndex tile)
|
|||
if (CHANCE16I(1, 200, r)) SndPlayTileFx(forest_sounds[GB(r, 16, 2)], tile);
|
||||
break;
|
||||
}
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -452,7 +454,9 @@ static void TileLoop_Trees(TileIndex tile)
|
|||
|
||||
switch (GetTreeGrowth(tile)) {
|
||||
case 3: /* regular sized tree */
|
||||
if (_opt.landscape == LT_DESERT && GetTreeType(tile) != TR_CACTUS && GetMapExtraBits(tile) == 1) {
|
||||
if (_opt.landscape == LT_DESERT &&
|
||||
GetTreeType(tile) != TR_CACTUS &&
|
||||
GetTropicZone(tile) == TROPICZONE_DESERT) {
|
||||
AddTreeGrowth(tile, 1);
|
||||
} else {
|
||||
switch (GB(Random(), 0, 3)) {
|
||||
|
@ -526,7 +530,7 @@ void OnTick_Trees(void)
|
|||
|
||||
/* place a tree at a random rainforest spot */
|
||||
if (_opt.landscape == LT_DESERT &&
|
||||
(r = Random(), tile = RandomTileSeed(r), GetMapExtraBits(tile) == 2) &&
|
||||
(r = Random(), tile = RandomTileSeed(r), GetTropicZone(tile) == TROPICZONE_RAINFOREST) &&
|
||||
IsTileType(tile, MP_CLEAR) &&
|
||||
(ct = GetClearGround(tile), ct == CL_GRASS || ct == CL_ROUGH) &&
|
||||
(tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TR_INVALID) {
|
||||
|
|
|
@ -1225,7 +1225,7 @@ static void TileLoop_TunnelBridge(TileIndex tile)
|
|||
break;
|
||||
|
||||
case LT_DESERT:
|
||||
if (GetMapExtraBits(tile) == 1 && !(_m[tile].m4 & 0x80)) {
|
||||
if (GetTropicZone(tile) == TROPICZONE_DESERT && !(_m[tile].m4 & 0x80)) {
|
||||
_m[tile].m4 |= 0x80;
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue