(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.

pull/155/head
belugas 17 years ago
parent 8be486c27e
commit fa39916fe9

@ -16,6 +16,7 @@ extern "C" _CRTIMP void __cdecl _assert(void *, void *, unsigned);
#endif
uint _map_log_x; ///< 2^_map_log_x == _map_size_x
uint _map_log_y; ///< 2^_map_log_y == _map_size_y
uint _map_size_x; ///< Size of the map along the X
uint _map_size_y; ///< Size of the map along the Y
uint _map_size; ///< The number of tiles on the map
@ -43,6 +44,7 @@ void AllocateMap(uint size_x, uint size_y)
DEBUG(map, 1, "Allocating map of size %dx%d", size_x, size_y);
_map_log_x = FindFirstBit(size_x);
_map_log_y = FindFirstBit(size_y);
_map_size_x = size_x;
_map_size_y = size_y;
_map_size = size_x * size_y;

@ -56,6 +56,17 @@ static inline uint MapLogX()
return _map_log_x;
}
/**
* Logarithm of the map size along the y side.
* @note try to avoid using this one
* @return 2^"return value" == MapSizeY()
*/
static inline uint MapLogY()
{
extern uint _map_log_y;
return _map_log_y;
}
/**
* Get the size of the map along the X
* @return the number of tiles along the X of the map

@ -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;

Loading…
Cancel
Save