Files
@ r1226:5b2629ab068b
Branch filter:
Location: cpp/openttd-patchpack/source/map.c - annotation
r1226:5b2629ab068b
2.5 KiB
text/x-c
(svn r1730) - Fix: Ships and Aircrafts have to be build in depots owned by _current_player (hacked client protection)
now all 4 types of vehicles have to be build in depots. Note: there is a wordaround for AI players since the AI handle aircraft building in a weird way
now all 4 types of vehicles have to be build in depots. Note: there is a wordaround for AI players since the AI handle aircraft building in a weird way
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | r679:3a7b08cc8504 r679:3a7b08cc8504 r1218:b56319aa5250 r679:3a7b08cc8504 r679:3a7b08cc8504 r1218:b56319aa5250 r1218:b56319aa5250 r927:dedf35f80507 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r689:c33ae44e7bfc r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r863:a3262138da98 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r1218:b56319aa5250 r900:6c526ed4f41b r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r957:2afd05ac6e7d r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r955:63797b6ea518 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r1202:95cf4c0fd209 r909:898755bd4512 r909:898755bd4512 r909:898755bd4512 r909:898755bd4512 r909:898755bd4512 r900:6c526ed4f41b | #include "stdafx.h"
#include "ttd.h"
#include "functions.h"
#include "map.h"
uint _map_log_x;
uint _map_log_y;
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;
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
TileIndex TileAdd(TileIndex tile, TileIndexDiff add,
const char *exp, const char *file, int line)
{
int dx;
int dy;
uint x;
uint y;
dx = add & MapMaxX();
if (dx >= (int)MapSizeX() / 2) dx -= MapSizeX();
dy = (add - dx) / (int)MapSizeX();
x = TileX(tile) + dx;
y = TileY(tile) + dy;
if (x >= MapSizeX() || y >= MapSizeY()) {
char buf[512];
sprintf(buf, "TILE_ADD(%s) when adding 0x%.4X and 0x%.4X failed",
exp, tile, add);
#if !defined(_MSC_VER)
fprintf(stderr, "%s:%d %s\n", file, line, buf);
#else
_assert(buf, (char*)file, line);
#endif
}
assert(TILE_XY(x,y) == TILE_MASK(tile + add));
return TILE_XY(x,y);
}
#endif
uint ScaleByMapSize(uint n)
{
int shift = (int)MapLogX() - 8 + (int)MapLogY() - 8;
if (shift < 0)
return (n + (1 << -shift) - 1) >> -shift;
else
return n << shift;
}
uint ScaleByMapSize1D(uint n)
{
int shift = ((int)MapLogX() - 8 + (int)MapLogY() - 8) / 2;
if (shift < 0)
return (n + (1 << -shift) - 1) >> -shift;
else
return n << shift;
}
const TileIndexDiffC _tileoffs_by_dir[] = {
{-1, 0},
{ 0, 1},
{ 1, 0},
{ 0, -1}
};
|