diff options
author | tron <tron@openttd.org> | 2005-01-29 19:45:14 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-01-29 19:45:14 +0000 |
commit | 3a89108a55b6ee45550ed8b5e01434b51c2f6995 (patch) | |
tree | 911339d12234fdbe85e78c906881ba0d7989b09c /map.c | |
parent | 752b3f0dd614217d68f361e2d0b2cc599a37c860 (diff) | |
download | openttd-3a89108a55b6ee45550ed8b5e01434b51c2f6995.tar.xz |
(svn r1722) -Feature: Bigger maps - anyone?
Diffstat (limited to 'map.c')
-rw-r--r-- | map.c | 53 |
1 files changed, 41 insertions, 12 deletions
@@ -1,22 +1,51 @@ #include "stdafx.h" #include "ttd.h" +#include "functions.h" #include "map.h" -#define TILE_X_BITS 8 -#define TILE_Y_BITS 8 +uint _map_log_x; +uint _map_log_y; -uint _map_log_x = TILE_X_BITS; -uint _map_log_y = TILE_Y_BITS; +byte *_map_type_and_height = NULL; +byte *_map_owner = NULL; +uint16 *_map2 = NULL; +byte *_map3_lo = NULL; +byte *_map3_hi = NULL; +byte *_map5 = NULL; +byte *_map_extra_bits = NULL; -#define MAP_SIZE ((1 << TILE_X_BITS) * (1 << TILE_Y_BITS)) -byte _map_type_and_height [MAP_SIZE]; -byte _map5 [MAP_SIZE]; -byte _map3_lo [MAP_SIZE]; -byte _map3_hi [MAP_SIZE]; -byte _map_owner [MAP_SIZE]; -uint16 _map2 [MAP_SIZE]; -byte _map_extra_bits [MAP_SIZE / 4]; +void InitMap(uint log_x, uint log_y) +{ + uint map_size; + + assert(log_x <= 15 && log_y <= 15); + + _map_log_x = log_x; + _map_log_y = log_y; + + map_size = MapSize(); + + _map_type_and_height = + realloc(_map_type_and_height, map_size * sizeof(_map_type_and_height[0])); + _map_owner = realloc(_map_owner, map_size * sizeof(_map_owner[0])); + _map2 = realloc(_map2, map_size * sizeof(_map2[0])); + _map3_lo = realloc(_map3_lo, map_size * sizeof(_map3_lo[0])); + _map3_hi = realloc(_map3_hi, map_size * sizeof(_map3_hi[0])); + _map5 = realloc(_map5, map_size * sizeof(_map5[0])); + _map_extra_bits = + realloc(_map_extra_bits, map_size * sizeof(_map_extra_bits[0] / 4)); + + // XXX TODO handle memory shortage more gracefully + if (_map_type_and_height == NULL || + _map_owner == NULL || + _map2 == NULL || + _map3_lo == NULL || + _map3_hi == NULL || + _map5 == NULL || + _map_extra_bits == NULL) + error("Failed to allocate memory for the map"); +} #ifdef _DEBUG |