summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-11-08 17:28:52 +0000
committerfrosch <frosch@openttd.org>2011-11-08 17:28:52 +0000
commit5aaecae6e2ea2c2236375274439645e669081328 (patch)
tree1f3f00675122f9121a07babbac593bb4bc6107aa /src
parent0f28b20a7364558d730f84c32b445f3dad95795c (diff)
downloadopenttd-5aaecae6e2ea2c2236375274439645e669081328.tar.xz
(svn r23153) -Change: [NewGRF v8] Use heightlevel units in variable 20/A0.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf.cpp16
-rw-r--r--src/newgrf.h2
-rw-r--r--src/newgrf_spritegroup.cpp2
3 files changed, 14 insertions, 6 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index e5fc2a1c1..b6461a6ce 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -5443,9 +5443,10 @@ void CheckForMissingSprites()
*
* @param param variable number (as for VarAction2, for Action7/9/D you have to subtract 0x80 first).
* @param value returns the value of the variable.
+ * @param grffile NewGRF querying the variable
* @return true iff the variable is known and the value is returned in 'value'.
*/
-bool GetGlobalVariable(byte param, uint32 *value)
+bool GetGlobalVariable(byte param, uint32 *value, const GRFFile *grffile)
{
switch (param) {
case 0x00: // current date
@@ -5546,9 +5547,16 @@ bool GetGlobalVariable(byte param, uint32 *value)
/* case 0x1F: // locale dependent settings not implemented to avoid desync */
- case 0x20: // snow line height
- *value = _settings_game.game_creation.landscape == LT_ARCTIC ? GetSnowLine() * TILE_HEIGHT : 0xFF;
+ case 0x20: { // snow line height
+ byte snowline = GetSnowLine();
+ if (_settings_game.game_creation.landscape == LT_ARCTIC && snowline <= MAX_TILE_HEIGHT) {
+ *value = Clamp(snowline * (grffile->grf_version >= 8 ? 1 : TILE_HEIGHT), 0, 0xFE);
+ } else {
+ /* No snow */
+ *value = 0xFF;
+ }
return true;
+ }
case 0x21: // OpenTTD version
*value = _openttd_newgrf_version;
@@ -5574,7 +5582,7 @@ static uint32 GetParamVal(byte param, uint32 *cond_val)
{
/* First handle variable common with VarAction2 */
uint32 value;
- if (GetGlobalVariable(param - 0x80, &value)) return value;
+ if (GetGlobalVariable(param - 0x80, &value, _cur.grffile)) return value;
/* Non-common variable */
switch (param) {
diff --git a/src/newgrf.h b/src/newgrf.h
index 4ffd99aa8..bd6c673e8 100644
--- a/src/newgrf.h
+++ b/src/newgrf.h
@@ -174,7 +174,7 @@ void ResetPersistentNewGRFData();
void CDECL grfmsg(int severity, const char *str, ...) WARN_FORMAT(2, 3);
bool HasGrfMiscBit(GrfMiscBit bit);
-bool GetGlobalVariable(byte param, uint32 *value);
+bool GetGlobalVariable(byte param, uint32 *value, const GRFFile *grffile);
StringID MapGRFStringID(uint32 grfid, StringID str);
void ShowNewGRFError();
diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp
index 2c89aa000..1ebf5bcf7 100644
--- a/src/newgrf_spritegroup.cpp
+++ b/src/newgrf_spritegroup.cpp
@@ -42,7 +42,7 @@ static inline uint32 GetVariable(const ResolverObject *object, byte variable, ui
{
/* First handle variables common with Action7/9/D */
uint32 value;
- if (GetGlobalVariable(variable, &value)) return value;
+ if (GetGlobalVariable(variable, &value, object->grffile)) return value;
/* Non-common variable */
switch (variable) {