src/unmovable_map.h
author rubidium
Thu, 18 Dec 2008 12:23:08 +0000
changeset 10436 8d3a9fbe8f19
parent 10012 c773e1c2c03b
permissions -rw-r--r--
(svn r14689) -Change: make configure die on commonly made user mistakes, like not having SDL development files or zlib headers installed; you can still compile a dedicated server or a binary without zlib, but you have to explicitly force it.
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
     1
/* $Id$ */
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8210
diff changeset
     3
/** @file unmovable_map.h Map accessors for unmovable tiles. */
6423
8e10e79e0fd1 (svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents: 6257
diff changeset
     4
4666
172a0cdf28a6 (svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents: 3971
diff changeset
     5
#ifndef UNMOVABLE_MAP_H
172a0cdf28a6 (svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents: 3971
diff changeset
     6
#define UNMOVABLE_MAP_H
172a0cdf28a6 (svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents: 3971
diff changeset
     7
8210
cc873256f63a (svn r11773) -Codechange: move some non-clear-land functions from clear_cmd.cpp to a more correct location.
rubidium
parents: 7954
diff changeset
     8
#include "core/bitmath_func.hpp"
cc873256f63a (svn r11773) -Codechange: move some non-clear-land functions from clear_cmd.cpp to a more correct location.
rubidium
parents: 7954
diff changeset
     9
#include "tile_map.h"
cc873256f63a (svn r11773) -Codechange: move some non-clear-land functions from clear_cmd.cpp to a more correct location.
rubidium
parents: 7954
diff changeset
    10
3427
3a512f7b7f6a (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
    11
enum {
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    12
	HQ_NUM_TILE = 4, ///< Number of HQ tiles
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    13
	HQ_NUM_SIZE = 5  ///< Number of stages of an HQ
3427
3a512f7b7f6a (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
    14
};
3a512f7b7f6a (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
    15
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    16
/** Types of unmovable structure */
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 5587
diff changeset
    17
enum UnmovableType {
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    18
	UNMOVABLE_TRANSMITTER = 0,    ///< The large antenna
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    19
	UNMOVABLE_LIGHTHOUSE  = 1,    ///< The nice lighthouse
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    20
	UNMOVABLE_STATUE      = 2,    ///< Statue in towns
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    21
	UNMOVABLE_OWNED_LAND  = 3,    ///< Owned land 'flag'
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    22
	UNMOVABLE_HQ_NORTH    = 0x80, ///< Offset for the northern HQ tile
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    23
	UNMOVABLE_HQ_WEST     = 0x81, ///< Offset for the western HQ tile
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    24
	UNMOVABLE_HQ_EAST     = 0x82, ///< Offset for the eastern HQ tile
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    25
	UNMOVABLE_HQ_SOUTH    = 0x83, ///< Offset for the southern HQ tile
3427
3a512f7b7f6a (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
    26
7954
57b51c69c072 (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 6489
diff changeset
    27
	/** End of the HQ (rather end + 1 for IsInside) */
3427
3a512f7b7f6a (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
    28
	UNMOVABLE_HQ_END      = UNMOVABLE_HQ_NORTH + HQ_NUM_SIZE * HQ_NUM_TILE
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 5587
diff changeset
    29
};
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    30
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    31
3427
3a512f7b7f6a (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
    32
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    33
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    34
 * Gets the UnmovableType of the given unmovable tile
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    35
 * @param t the tile to get the type from.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    36
 * @pre IsTileType(t, MP_UNMOVABLE)
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    37
 * @return the type.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    38
 */
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    39
static inline UnmovableType GetUnmovableType(TileIndex t)
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    40
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3310
diff changeset
    41
	assert(IsTileType(t, MP_UNMOVABLE));
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
    42
	return (UnmovableType)_m[t].m5;
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    43
}
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    44
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    45
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    46
 * Does the given tile have a transmitter?
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    47
 * @param t the tile to inspect.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    48
 * @return true if and only if the tile has a transmitter.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    49
 */
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    50
static inline bool IsTransmitterTile(TileIndex t)
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    51
{
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    52
	return IsTileType(t, MP_UNMOVABLE) && GetUnmovableType(t) == UNMOVABLE_TRANSMITTER;
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    53
}
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    54
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    55
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    56
 * Is this unmovable tile an 'owned land' tile?
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    57
 * @param t the tile to inspect.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    58
 * @pre IsTileType(t, MP_UNMOVABLE)
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    59
 * @return true if and only if the tile is an 'owned land' tile.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    60
 */
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    61
static inline bool IsOwnedLand(TileIndex t)
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    62
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3310
diff changeset
    63
	assert(IsTileType(t, MP_UNMOVABLE));
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    64
	return GetUnmovableType(t) == UNMOVABLE_OWNED_LAND;
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    65
}
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    66
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    67
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    68
 * Is the given tile (pre-)owned by someone (the little flags)?
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    69
 * @param t the tile to inspect.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    70
 * @return true if and only if the tile is an 'owned land' tile.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    71
 */
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    72
static inline bool IsOwnedLandTile(TileIndex t)
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    73
{
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    74
	return IsTileType(t, MP_UNMOVABLE) && IsOwnedLand(t);
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    75
}
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
    76
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    77
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    78
 * Is this unmovable tile a HQ tile?
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    79
 * @param t the tile to inspect.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    80
 * @pre IsTileType(t, MP_UNMOVABLE)
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    81
 * @return true if and only if the tile is a HQ tile.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    82
 */
3427
3a512f7b7f6a (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
    83
static inline bool IsCompanyHQ(TileIndex t)
3a512f7b7f6a (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
    84
{
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    85
	assert(IsTileType(t, MP_UNMOVABLE));
10012
c773e1c2c03b (svn r14171) -Codechange: Make the test for HQ a bit lighter.
belugas
parents: 9111
diff changeset
    86
	return HasBit(_m[t].m5, 7);
3427
3a512f7b7f6a (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
    87
}
3a512f7b7f6a (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
    88
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    89
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    90
 * Is this unmovable tile a statue?
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    91
 * @param t the tile to inspect.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    92
 * @pre IsTileType(t, MP_UNMOVABLE)
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    93
 * @return true if and only if the tile is a statue.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
    94
 */
6257
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
    95
static inline bool IsStatue(TileIndex t)
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
    96
{
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
    97
	assert(IsTileType(t, MP_UNMOVABLE));
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
    98
	return GetUnmovableType(t) == UNMOVABLE_STATUE;
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
    99
}
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
   100
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   101
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   102
 * Is the given tile a statue?
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   103
 * @param t the tile to inspect.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   104
 * @return true if and only if the tile is a statue.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   105
 */
6257
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
   106
static inline bool IsStatueTile(TileIndex t)
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
   107
{
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
   108
	return IsTileType(t, MP_UNMOVABLE) && IsStatue(t);
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
   109
}
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
   110
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   111
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   112
 * Get the town of the given statue tile.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   113
 * @param t the tile of the statue.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   114
 * @pre IsStatueTile(t)
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   115
 * @return the town the given statue is in.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   116
 */
6257
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
   117
static inline TownID GetStatueTownID(TileIndex t)
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
   118
{
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   119
	assert(IsStatueTile(t));
6257
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
   120
	return _m[t].m2;
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
   121
}
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
   122
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   123
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   124
 * Get the 'stage' of the HQ.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   125
 * @param t a tile of the HQ.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   126
 * @pre IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t)
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   127
 * @return the 'stage' of the HQ.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   128
 */
3427
3a512f7b7f6a (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
   129
static inline byte GetCompanyHQSize(TileIndex t)
3a512f7b7f6a (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
   130
{
3a512f7b7f6a (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
   131
	assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
3a512f7b7f6a (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
   132
	return GB(_m[t].m5, 2, 3);
3a512f7b7f6a (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
   133
}
3a512f7b7f6a (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
   134
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   135
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   136
 * Get the 'section' (including stage) of the HQ.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   137
 * @param t a tile of the HQ.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   138
 * @pre IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t)
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   139
 * @return the 'section' of the HQ.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   140
 */
3427
3a512f7b7f6a (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
   141
static inline byte GetCompanyHQSection(TileIndex t)
3a512f7b7f6a (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
   142
{
3a512f7b7f6a (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
   143
	assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
3a512f7b7f6a (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
   144
	return GB(_m[t].m5, 0, 5);
3a512f7b7f6a (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
   145
}
3a512f7b7f6a (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
   146
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   147
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   148
 * Enlarge the given HQ to the given size. If the new size
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   149
 * is larger than the current size, nothing happens.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   150
 * @param t the tile of the HQ.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   151
 * @param size the new size of the HQ.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   152
 * @pre t is the northern tile of the HQ
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   153
 */
3388
e94795a55f13 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
   154
static inline void EnlargeCompanyHQ(TileIndex t, byte size)
e94795a55f13 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
   155
{
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   156
	assert(GB(GetCompanyHQSection(t), 0, 2) == 0);
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   157
3705
3232570a91b7 (svn r4648) - Fix (r4196): Company HQ's were not upgraded during the monthly loops.
Darkvater
parents: 3427
diff changeset
   158
	size *= 4;
3388
e94795a55f13 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
   159
	if (size <= _m[t].m5 - UNMOVABLE_HQ_NORTH) return;
e94795a55f13 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
   160
3705
3232570a91b7 (svn r4648) - Fix (r4196): Company HQ's were not upgraded during the monthly loops.
Darkvater
parents: 3427
diff changeset
   161
	_m[t + TileDiffXY(0, 0)].m5 = UNMOVABLE_HQ_NORTH + size;
3232570a91b7 (svn r4648) - Fix (r4196): Company HQ's were not upgraded during the monthly loops.
Darkvater
parents: 3427
diff changeset
   162
	_m[t + TileDiffXY(0, 1)].m5 = UNMOVABLE_HQ_WEST  + size;
3232570a91b7 (svn r4648) - Fix (r4196): Company HQ's were not upgraded during the monthly loops.
Darkvater
parents: 3427
diff changeset
   163
	_m[t + TileDiffXY(1, 0)].m5 = UNMOVABLE_HQ_EAST  + size;
3232570a91b7 (svn r4648) - Fix (r4196): Company HQ's were not upgraded during the monthly loops.
Darkvater
parents: 3427
diff changeset
   164
	_m[t + TileDiffXY(1, 1)].m5 = UNMOVABLE_HQ_SOUTH + size;
3388
e94795a55f13 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
   165
}
e94795a55f13 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
   166
e94795a55f13 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3385
diff changeset
   167
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   168
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   169
 * Make an Unmovable tile.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   170
 * @note do not use this function directly. Use one of the other Make* functions.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   171
 * @param t the tile to make unmovable.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   172
 * @param u the unmovable type of the tile.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   173
 * @param o the new owner of the tile.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   174
 */
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   175
static inline void MakeUnmovable(TileIndex t, UnmovableType u, Owner o)
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   176
{
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   177
	SetTileType(t, MP_UNMOVABLE);
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   178
	SetTileOwner(t, o);
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   179
	_m[t].m2 = 0;
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   180
	_m[t].m3 = 0;
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   181
	_m[t].m4 = 0;
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   182
	_m[t].m5 = u;
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   183
}
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   184
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   185
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   186
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   187
 * Make a transmitter tile.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   188
 * @param t the tile to make a transmitter.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   189
 */
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   190
static inline void MakeTransmitter(TileIndex t)
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   191
{
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   192
	MakeUnmovable(t, UNMOVABLE_TRANSMITTER, OWNER_NONE);
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   193
}
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   194
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   195
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   196
 * Make a lighthouse tile.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   197
 * @param t the tile to make a transmitter.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   198
 */
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   199
static inline void MakeLighthouse(TileIndex t)
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   200
{
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   201
	MakeUnmovable(t, UNMOVABLE_LIGHTHOUSE, OWNER_NONE);
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   202
}
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   203
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   204
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   205
 * Make a statue tile.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   206
 * @param t the tile to make a statue.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   207
 * @param o the owner of the statue.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   208
 * @param town_id the town the statue was built in.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   209
 */
6257
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
   210
static inline void MakeStatue(TileIndex t, Owner o, TownID town_id)
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   211
{
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   212
	MakeUnmovable(t, UNMOVABLE_STATUE, o);
6257
5e5a864cacf6 (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents: 6248
diff changeset
   213
	_m[t].m2 = town_id;
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   214
}
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   215
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   216
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   217
 * Make an 'owned land' tile.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   218
 * @param t the tile to make an 'owned land' tile.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   219
 * @param o the owner of the land.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   220
 */
3310
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   221
static inline void MakeOwnedLand(TileIndex t, Owner o)
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   222
{
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   223
	MakeUnmovable(t, UNMOVABLE_OWNED_LAND, o);
a19f247b75b6 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents:
diff changeset
   224
}
3385
18e4ca6d3ef4 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   225
6489
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   226
/**
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   227
 * Make an HQ with the give tile as it's northern tile.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   228
 * @param t the tile to make the northern tile of a HQ.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   229
 * @param o the owner of the HQ.
511474c82dd3 (svn r9670) -Documentation: add documentation to some the _map files.
rubidium
parents: 6423
diff changeset
   230
 */
3385
18e4ca6d3ef4 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   231
static inline void MakeCompanyHQ(TileIndex t, Owner o)
18e4ca6d3ef4 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   232
{
18e4ca6d3ef4 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   233
	MakeUnmovable(t + TileDiffXY(0, 0), UNMOVABLE_HQ_NORTH, o);
18e4ca6d3ef4 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   234
	MakeUnmovable(t + TileDiffXY(0, 1), UNMOVABLE_HQ_WEST, o);
18e4ca6d3ef4 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   235
	MakeUnmovable(t + TileDiffXY(1, 0), UNMOVABLE_HQ_EAST, o);
18e4ca6d3ef4 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   236
	MakeUnmovable(t + TileDiffXY(1, 1), UNMOVABLE_HQ_SOUTH, o);
18e4ca6d3ef4 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3369
diff changeset
   237
}
4666
172a0cdf28a6 (svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents: 3971
diff changeset
   238
172a0cdf28a6 (svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents: 3971
diff changeset
   239
#endif /* UNMOVABLE_MAP_H */