summaryrefslogtreecommitdiff
path: root/src/newgrf.cpp
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2008-01-23 17:08:35 +0000
committerbelugas <belugas@openttd.org>2008-01-23 17:08:35 +0000
commit4a3e135086fb2c29221a70e1bd0adf279f36c3bd (patch)
tree9a885c0e543d6bc0b57a61d035fa6563b4b145aa /src/newgrf.cpp
parent0b888ccc001c3157d1990467036a557783ca38be (diff)
downloadopenttd-4a3e135086fb2c29221a70e1bd0adf279f36c3bd.tar.xz
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r--src/newgrf.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index d4514d38d..c4e44df5a 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -44,6 +44,7 @@
#include "road_func.h"
#include "player_base.h"
#include "settings_type.h"
+#include "map_func.h"
#include "table/strings.h"
#include "table/sprites.h"
@@ -4025,15 +4026,46 @@ static uint32 GetPatchVariable(uint8 param)
switch (param) {
/* start year - 1920 */
case 0x0B: return max(_patches.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR;
+
/* freight trains weight factor */
case 0x0E: return _patches.freight_trains;
+
/* empty wagon speed increase */
case 0x0F: return 0;
+
/* plane speed factor */
case 0x10: return 4;
+
/* 2CC colormap base sprite */
case 0x11: return SPR_2CCMAP_BASE;
+ /* map size: format = -MABXYSS
+ * M : the type of map
+ * bit 0 : set : squared map. Bit 1 is now not relevant
+ * clear : rectangle map. Bit 1 will indicate the bigger edge of the map
+ * bit 1 : set : Y is the bigger edge. Bit 0 is clear
+ * clear : X is the bigger edge.
+ * A : minimum edge(log2) of the map
+ * B : maximum edge(log2) of the map
+ * XY : edges(log2) of each side of the map.
+ * SS : combination of both X and Y, thus giving the size(log2) of the map
+ */
+ case 0x13: {
+ byte map_bits = 0;
+ byte log_X = MapLogX() - 6;
+ byte log_Y = MapLogY() - 6;
+ byte max_edge = max(log_X, log_Y);
+
+ if (log_X == log_Y) { // we have a squared map, since both edges are identical
+ SetBit(map_bits ,0);
+ } else {
+ if (max_edge == log_Y) SetBit(map_bits, 1); // edge Y been the biggest, mark it
+ }
+
+ return (map_bits << 24) | (min(log_X, log_Y) << 20) | (max_edge << 16) |
+ (log_X << 12) | (log_Y << 8) | (log_X + log_Y);
+ }
+
default:
grfmsg(2, "ParamSet: Unknown Patch variable 0x%02X.", param);
return 0;