(svn r25213) -Fix [FS#5537]: clarify on which tiles IsDesertTile and IsSnowTile work, i.e. the ones without infrastructure or buildings

-Feature: introduce GetTerrainType which allows one to get that information for tiles with buildings and infrastructure as well
pull/155/head
rubidium 11 years ago
parent 6871c04171
commit 9d9607e8ec

@ -41,6 +41,7 @@ description.sl_SI = Originalni zvoki Transport Tycoon Deluxe različice DOS.
description.sr_RS = Originalni skup zvukova Transport Tycoon Deluxe DOS izdanja.
description.sv_SE = Originalljuden från Transport Tycoon Deluxe, DOS-utgåvan.
description.tr_TR = Orijinal Transport Tycoon Deluxe DOS sürümü sesleri.
description.vi_VN = Âm thanh gốc từ phiên bản Transport Tycoon Deluxe trên DOS
description.zh_TW = 原版 Transport Tycoon Deluxe DOS 版的音效。
[files]

@ -42,6 +42,7 @@ description.sl_SI = Originalna grafika Transport Tycoon Deluxe za različico oke
description.sr_RS = Originalni skup grafika Transport Tycoon Deluxe Windows izdanja.
description.sv_SE = Originalgrafiken från Transport Tycoon Deluxe, Windows-utgåvan.
description.tr_TR = Orijinal Transport Tycoon Deluxe Windows sürümü grafikleri.
description.vi_VN = Đồ họa gốc từ phiên bản Transport Tycoon Deluxe trên Windows
description.zh_TW = 原版 Transport Tycoon Deluxe Windows 版的圖形。
[files]

@ -41,6 +41,7 @@ description.sl_SI = Originalna glasba Transport Tycoon Deluxe različice oken(wi
description.sr_RS = Originalni skup muzičkih numera Transport Tycoon Deluxe Windows izdanja.
description.sv_SE = Originalmusiken från Transport Tycoon Deluxe, Windows-utgåvan.
description.tr_TR = Orijinal Transport Tycoon Deluxe Windows sürümü müzikleri.
description.vi_VN = Nhạc gốc từ phiên bản Transport Tycoon Deluxe trên Windows
description.zh_TW = 原版 Transport Tycoon Deluxe Windows 版的音樂。
[files]

@ -41,6 +41,7 @@ description.sl_SI = Originalni zvoki Transport Tycoon Deluxe različice oken(win
description.sr_RS = Originalni skup zvukova Transport Tycoon Deluxe Windows izdanja.
description.sv_SE = Originalljuden från Transport Tycoon Deluxe, Windows-utgåvan.
description.tr_TR = Orijinal Transport Tycoon Deluxe Windows sürümü sesleri.
description.vi_VN = Âm thanh gốc từ phiên bản Transport Tycoon Deluxe trên Windows
description.zh_TW = 原版 Transport Tycoon Deluxe Windows 版的音效。
[files]

@ -66,6 +66,10 @@ void SQAITile_Register(Squirrel *engine)
SQAITile.DefSQConst(engine, ScriptTile::BT_CLEAR_ROCKY, "BT_CLEAR_ROCKY");
SQAITile.DefSQConst(engine, ScriptTile::BT_CLEAR_FIELDS, "BT_CLEAR_FIELDS");
SQAITile.DefSQConst(engine, ScriptTile::BT_CLEAR_HOUSE, "BT_CLEAR_HOUSE");
SQAITile.DefSQConst(engine, ScriptTile::TERRAIN_NORMAL, "TERRAIN_NORMAL");
SQAITile.DefSQConst(engine, ScriptTile::TERRAIN_DESERT, "TERRAIN_DESERT");
SQAITile.DefSQConst(engine, ScriptTile::TERRAIN_RAINFOREST, "TERRAIN_RAINFOREST");
SQAITile.DefSQConst(engine, ScriptTile::TERRAIN_SNOW, "TERRAIN_SNOW");
ScriptError::RegisterErrorMap(STR_ERROR_ALREADY_AT_SEA_LEVEL, ScriptTile::ERR_TILE_TOO_HIGH);
ScriptError::RegisterErrorMap(STR_ERROR_ALREADY_AT_SEA_LEVEL, ScriptTile::ERR_TILE_TOO_LOW);
@ -90,6 +94,7 @@ void SQAITile_Register(Squirrel *engine)
SQAITile.DefSQStaticMethod(engine, &ScriptTile::IsRoughTile, "IsRoughTile", 2, ".i");
SQAITile.DefSQStaticMethod(engine, &ScriptTile::IsSnowTile, "IsSnowTile", 2, ".i");
SQAITile.DefSQStaticMethod(engine, &ScriptTile::IsDesertTile, "IsDesertTile", 2, ".i");
SQAITile.DefSQStaticMethod(engine, &ScriptTile::GetTerrainType, "GetTerrainType", 2, ".i");
SQAITile.DefSQStaticMethod(engine, &ScriptTile::GetSlope, "GetSlope", 2, ".i");
SQAITile.DefSQStaticMethod(engine, &ScriptTile::GetComplementSlope, "GetComplementSlope", 2, ".i");
SQAITile.DefSQStaticMethod(engine, &ScriptTile::GetMinHeight, "GetMinHeight", 2, ".i");

@ -21,6 +21,7 @@
*
* API additions:
* \li AIStation::HasRating
* \li AITile::GetTerrainType
*
* Other changes:
* \li AIStation::GetRating does return -1 for cargo-station combinations that

@ -66,6 +66,10 @@ void SQGSTile_Register(Squirrel *engine)
SQGSTile.DefSQConst(engine, ScriptTile::BT_CLEAR_ROCKY, "BT_CLEAR_ROCKY");
SQGSTile.DefSQConst(engine, ScriptTile::BT_CLEAR_FIELDS, "BT_CLEAR_FIELDS");
SQGSTile.DefSQConst(engine, ScriptTile::BT_CLEAR_HOUSE, "BT_CLEAR_HOUSE");
SQGSTile.DefSQConst(engine, ScriptTile::TERRAIN_NORMAL, "TERRAIN_NORMAL");
SQGSTile.DefSQConst(engine, ScriptTile::TERRAIN_DESERT, "TERRAIN_DESERT");
SQGSTile.DefSQConst(engine, ScriptTile::TERRAIN_RAINFOREST, "TERRAIN_RAINFOREST");
SQGSTile.DefSQConst(engine, ScriptTile::TERRAIN_SNOW, "TERRAIN_SNOW");
ScriptError::RegisterErrorMap(STR_ERROR_ALREADY_AT_SEA_LEVEL, ScriptTile::ERR_TILE_TOO_HIGH);
ScriptError::RegisterErrorMap(STR_ERROR_ALREADY_AT_SEA_LEVEL, ScriptTile::ERR_TILE_TOO_LOW);
@ -90,6 +94,7 @@ void SQGSTile_Register(Squirrel *engine)
SQGSTile.DefSQStaticMethod(engine, &ScriptTile::IsRoughTile, "IsRoughTile", 2, ".i");
SQGSTile.DefSQStaticMethod(engine, &ScriptTile::IsSnowTile, "IsSnowTile", 2, ".i");
SQGSTile.DefSQStaticMethod(engine, &ScriptTile::IsDesertTile, "IsDesertTile", 2, ".i");
SQGSTile.DefSQStaticMethod(engine, &ScriptTile::GetTerrainType, "GetTerrainType", 2, ".i");
SQGSTile.DefSQStaticMethod(engine, &ScriptTile::GetSlope, "GetSlope", 2, ".i");
SQGSTile.DefSQStaticMethod(engine, &ScriptTile::GetComplementSlope, "GetComplementSlope", 2, ".i");
SQGSTile.DefSQStaticMethod(engine, &ScriptTile::GetMinHeight, "GetMinHeight", 2, ".i");

@ -20,10 +20,11 @@
* 1.4.0 is not yet released. The following changes are not set in stone yet.
*
* API additions:
* \li AIStation::HasRating
* \li GSStation::HasRating
* \li GSTile::GetTerrainType
*
* Other changes:
* \li AIStation::GetRating does return -1 for cargo-station combinations that
* \li GSStation::GetRating does return -1 for cargo-station combinations that
* do not have a rating yet instead of returning 69.
*
* \b 1.3.0

@ -135,6 +135,19 @@
return (::IsTileType(tile, MP_CLEAR) && ::IsClearGround(tile, CLEAR_DESERT));
}
/* static */ ScriptTile::TerrainType ScriptTile::GetTerrainType(TileIndex tile)
{
if (!::IsValidTile(tile)) return TERRAIN_NORMAL;
switch (::GetTerrainType(tile)) {
default:
case 0: return TERRAIN_NORMAL;
case 1: return TERRAIN_DESERT;
case 2: return TERRAIN_RAINFOREST;
case 4: return TERRAIN_SNOW;
}
}
/* static */ ScriptTile::Slope ScriptTile::GetSlope(TileIndex tile)
{
if (!::IsValidTile(tile)) return SLOPE_INVALID;

@ -120,6 +120,19 @@ public:
BT_CLEAR_HOUSE, ///< Clear a tile with a house
};
/**
* The types of terrain a tile can have.
*
* @note When a desert or rainforest tile are changed, their terrain type will remain the same. In other words, a sea tile can be of the desert terrain type.
* @note The snow terrain type can change to the normal terrain type and vice versa based on landscaping or variable snow lines from NewGRFs.
*/
enum TerrainType {
TERRAIN_NORMAL, ///< A normal tile (default); not desert, rainforest or snow.
TERRAIN_DESERT, ///< A tile in the desert (manually set in in scenarios, below certain height and certain distance from water in random games).
TERRAIN_RAINFOREST, ///< A tile in the rainforest (manually set in scenarios, certain distance away from deserts in random games),
TERRAIN_SNOW ///< A tile on or above the snowline level.
};
/**
* Check if this tile is buildable, i.e. no things on it that needs
* demolishing.
@ -222,7 +235,8 @@ public:
static bool IsRoughTile(TileIndex tile);
/**
* Check if the tile is a snow tile.
* Check if the tile without buildings or infrastructure is a snow tile.
* @note If you want to know if a tile (with or without buildings and infrastructure) is on or above the snowline, use ScriptTile::GetTerrainType(tile).
* @param tile The tile to check on.
* @pre ScriptMap::IsValidTile(tile).
* @return True if and only if the tile is snow tile.
@ -230,13 +244,24 @@ public:
static bool IsSnowTile(TileIndex tile);
/**
* Check if the tile is a desert tile.
* Check if the tile without buildings or infrastructure is a desert tile.
* @note If you want to know if a tile (with or without buildings and infrastructure) is in a desert, use ScriptTile::GetTerrainType(tile).
* @param tile The tile to check on.
* @pre ScriptMap::IsValidTile(tile).
* @return True if and only if the tile is desert tile.
*/
static bool IsDesertTile(TileIndex tile);
/**
* Get the type of terrain regardless of buildings or infrastructure.
* @note When a desert or rainforest tile are changed, their terrain type will remain the same. In other words, a sea tile can be of the desert terrain type.
* @note The snow terrain type can change to the normal terrain type and vice versa based on landscaping or variable snow lines from NewGRFs.
* @param tile The tile to check on.
* @pre ScriptMap::IsValidTile(tile).
* @return The #TerrainType.
*/
static TerrainType GetTerrainType(TileIndex tile);
/**
* Get the slope of a tile.
* This is the slope of the bare tile. A possible foundation on the tile does not influence this slope.

@ -23,6 +23,8 @@ namespace SQConvert {
template <> inline int Return<ScriptTile::TransportType>(HSQUIRRELVM vm, ScriptTile::TransportType res) { sq_pushinteger(vm, (int32)res); return 1; }
template <> inline ScriptTile::BuildType GetParam(ForceType<ScriptTile::BuildType>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptTile::BuildType)tmp; }
template <> inline int Return<ScriptTile::BuildType>(HSQUIRRELVM vm, ScriptTile::BuildType res) { sq_pushinteger(vm, (int32)res); return 1; }
template <> inline ScriptTile::TerrainType GetParam(ForceType<ScriptTile::TerrainType>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptTile::TerrainType)tmp; }
template <> inline int Return<ScriptTile::TerrainType>(HSQUIRRELVM vm, ScriptTile::TerrainType res) { sq_pushinteger(vm, (int32)res); return 1; }
/* Allow ScriptTile to be used as Squirrel parameter */
template <> inline ScriptTile *GetParam(ForceType<ScriptTile *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptTile *)instance; }

Loading…
Cancel
Save