equal
deleted
inserted
replaced
20 uint _map_size_x; |
20 uint _map_size_x; |
21 uint _map_size_y; |
21 uint _map_size_y; |
22 uint _map_tile_mask; |
22 uint _map_tile_mask; |
23 uint _map_size; |
23 uint _map_size; |
24 |
24 |
25 Tile* _m = NULL; |
25 Tile *_m = NULL; |
|
26 TileExtended *_me = NULL; |
26 |
27 |
27 |
28 |
28 void AllocateMap(uint size_x, uint size_y) |
29 void AllocateMap(uint size_x, uint size_y) |
29 { |
30 { |
30 /* Make sure that the map size is within the limits and that |
31 /* Make sure that the map size is within the limits and that |
42 _map_size_y = size_y; |
43 _map_size_y = size_y; |
43 _map_size = size_x * size_y; |
44 _map_size = size_x * size_y; |
44 _map_tile_mask = _map_size - 1; |
45 _map_tile_mask = _map_size - 1; |
45 |
46 |
46 free(_m); |
47 free(_m); |
|
48 free(_me); |
|
49 |
47 _m = CallocT<Tile>(_map_size); |
50 _m = CallocT<Tile>(_map_size); |
48 |
51 _me = CallocT<TileExtended>(_map_size); |
49 /* XXX TODO handle memory shortage more gracefully */ |
52 |
50 if (_m == NULL) error("Failed to allocate memory for the map"); |
53 /* XXX @todo handle memory shortage more gracefully |
|
54 * Maybe some attemps could be made to try with smaller maps down to 64x64 |
|
55 * Maybe check for available memory before doing the calls, after all, we know how big |
|
56 * the map is */ |
|
57 if ((_m == NULL) || (_me == NULL)) error("Failed to allocate memory for the map"); |
51 } |
58 } |
52 |
59 |
53 |
60 |
54 #ifdef _DEBUG |
61 #ifdef _DEBUG |
55 TileIndex TileAdd(TileIndex tile, TileIndexDiff add, |
62 TileIndex TileAdd(TileIndex tile, TileIndexDiff add, |