unmovable_map.h
author Darkvater
Sat, 22 Apr 2006 13:56:16 +0000
changeset 3630 0f7828d892ae
parent 3427 98d955156735
child 3705 539e1366ccae
permissions -rw-r--r--
(svn r4529) - Codechange: Use proper naming for hex numbers in debug prints eg. 0xF3A6. Use fixed lengths where applicable (newgrf). Unfortunately '%#X' is unusable since it gives 0XFF3 and '%#x' gives 0xff3 while we want 0xFF3 :P
3310
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
     1
/* $Id$ */
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
     2
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
     3
enum {
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
     4
	HQ_NUM_TILE = 4,
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
     5
	HQ_NUM_SIZE = 5
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
     6
};
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
     7
3310
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
     8
typedef enum UnmovableType {
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
     9
	UNMOVABLE_TRANSMITTER = 0,
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    10
	UNMOVABLE_LIGHTHOUSE  = 1,
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    11
	UNMOVABLE_STATUE      = 2,
3385
41ebb01a92f2 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
    12
	UNMOVABLE_OWNED_LAND  = 3,
41ebb01a92f2 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
    13
	UNMOVABLE_HQ_NORTH    = 0x80,
41ebb01a92f2 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
    14
	UNMOVABLE_HQ_WEST     = 0x81,
41ebb01a92f2 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
    15
	UNMOVABLE_HQ_EAST     = 0x82,
41ebb01a92f2 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
    16
	UNMOVABLE_HQ_SOUTH    = 0x83,
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    17
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    18
	UNMOVABLE_HQ_END      = UNMOVABLE_HQ_NORTH + HQ_NUM_SIZE * HQ_NUM_TILE
3310
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    19
} UnmovableType;
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    20
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    21
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    22
3310
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    23
static inline UnmovableType GetUnmovableType(TileIndex t)
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    24
{
3369
00c2ca209a89 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3310
diff changeset
    25
	assert(IsTileType(t, MP_UNMOVABLE));
3310
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    26
	return _m[t].m5;
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    27
}
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    28
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    29
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    30
static inline bool IsTransmitterTile(TileIndex t)
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    31
{
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    32
	return
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    33
		IsTileType(t, MP_UNMOVABLE) &&
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    34
		GetUnmovableType(t) == UNMOVABLE_TRANSMITTER;
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    35
}
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    36
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    37
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    38
static inline bool IsOwnedLand(TileIndex t)
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    39
{
3369
00c2ca209a89 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3310
diff changeset
    40
	assert(IsTileType(t, MP_UNMOVABLE));
3310
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    41
	return GetUnmovableType(t) == UNMOVABLE_OWNED_LAND;
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    42
}
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    43
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    44
static inline bool IsOwnedLandTile(TileIndex t)
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    45
{
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    46
	return IsTileType(t, MP_UNMOVABLE) && IsOwnedLand(t);
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    47
}
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    48
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    49
static inline bool IsCompanyHQ(TileIndex t)
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    50
{
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    51
	return IS_INT_INSIDE(GetUnmovableType(t), UNMOVABLE_HQ_NORTH, UNMOVABLE_HQ_END);
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    52
}
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    53
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    54
static inline byte GetCompanyHQSize(TileIndex t)
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    55
{
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    56
	assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    57
	return GB(_m[t].m5, 2, 3);
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    58
}
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    59
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    60
static inline byte GetCompanyHQSection(TileIndex t)
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    61
{
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    62
	assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    63
	return GB(_m[t].m5, 0, 5);
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    64
}
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3388
diff changeset
    65
3310
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    66
3388
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
    67
static inline void EnlargeCompanyHQ(TileIndex t, byte size)
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
    68
{
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
    69
	if (size <= _m[t].m5 - UNMOVABLE_HQ_NORTH) return;
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
    70
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
    71
	_m[t + TileDiffXY(0, 0)].m5 = UNMOVABLE_HQ_NORTH + size * 4;
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
    72
	_m[t + TileDiffXY(0, 1)].m5 = UNMOVABLE_HQ_WEST  + size * 4;
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
    73
	_m[t + TileDiffXY(1, 0)].m5 = UNMOVABLE_HQ_EAST  + size * 4;
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
    74
	_m[t + TileDiffXY(1, 1)].m5 = UNMOVABLE_HQ_SOUTH + size * 4;
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
    75
}
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
    76
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
    77
3310
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    78
static inline void MakeUnmovable(TileIndex t, UnmovableType u, Owner o)
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    79
{
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    80
	SetTileType(t, MP_UNMOVABLE);
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    81
	SetTileOwner(t, o);
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    82
	_m[t].m2 = 0;
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    83
	_m[t].m3 = 0;
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    84
	_m[t].m4 = 0;
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    85
	_m[t].m5 = u;
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    86
}
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    87
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    88
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    89
static inline void MakeTransmitter(TileIndex t)
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    90
{
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    91
	MakeUnmovable(t, UNMOVABLE_TRANSMITTER, OWNER_NONE);
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    92
}
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    93
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    94
static inline void MakeLighthouse(TileIndex t)
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    95
{
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    96
	MakeUnmovable(t, UNMOVABLE_LIGHTHOUSE, OWNER_NONE);
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    97
}
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    98
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    99
static inline void MakeStatue(TileIndex t, Owner o)
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   100
{
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   101
	MakeUnmovable(t, UNMOVABLE_STATUE, o);
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   102
}
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   103
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   104
static inline void MakeOwnedLand(TileIndex t, Owner o)
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   105
{
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   106
	MakeUnmovable(t, UNMOVABLE_OWNED_LAND, o);
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   107
}
3385
41ebb01a92f2 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   108
41ebb01a92f2 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   109
static inline void MakeCompanyHQ(TileIndex t, Owner o)
41ebb01a92f2 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   110
{
41ebb01a92f2 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   111
	MakeUnmovable(t + TileDiffXY(0, 0), UNMOVABLE_HQ_NORTH, o);
41ebb01a92f2 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   112
	MakeUnmovable(t + TileDiffXY(0, 1), UNMOVABLE_HQ_WEST, o);
41ebb01a92f2 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   113
	MakeUnmovable(t + TileDiffXY(1, 0), UNMOVABLE_HQ_EAST, o);
41ebb01a92f2 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   114
	MakeUnmovable(t + TileDiffXY(1, 1), UNMOVABLE_HQ_SOUTH, o);
41ebb01a92f2 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   115
}
41ebb01a92f2 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   116