(svn r27908) -Codechange: Mark airport tile tables and FTAs "const" to be sure that they are really constant

This commit is contained in:
adf88 2017-08-31 06:55:38 +00:00
parent b56453f93b
commit 6dec889306
4 changed files with 24 additions and 24 deletions

View File

@ -27,7 +27,7 @@
* @param delta_z Height of the airport above the land. * @param delta_z Height of the airport above the land.
*/ */
#define AIRPORT_GENERIC(name, terminals, num_helipads, flags, delta_z) \ #define AIRPORT_GENERIC(name, terminals, num_helipads, flags, delta_z) \
static AirportFTAClass _airportfta_ ## name(_airport_moving_data_ ## name, terminals, \ static const AirportFTAClass _airportfta_ ## name(_airport_moving_data_ ## name, terminals, \
num_helipads, _airport_entries_ ## name, flags, _airport_fta_ ## name, delta_z); num_helipads, _airport_entries_ ## name, flags, _airport_fta_ ## name, delta_z);
/** /**

View File

@ -3750,7 +3750,7 @@ static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, B
const AirportTileTable *copy_from; const AirportTileTable *copy_from;
try { try {
for (byte j = 0; j < as->num_table; j++) { for (byte j = 0; j < as->num_table; j++) {
as->rotation[j] = (Direction)buf->ReadByte(); const_cast<Direction&>(as->rotation[j]) = (Direction)buf->ReadByte();
for (int k = 0;; k++) { for (int k = 0;; k++) {
att[k].ti.x = buf->ReadByte(); // Offsets from northermost tile att[k].ti.x = buf->ReadByte(); // Offsets from northermost tile
att[k].ti.y = buf->ReadByte(); att[k].ti.y = buf->ReadByte();

View File

@ -100,7 +100,7 @@ struct HangarTileTable {
struct AirportSpec { struct AirportSpec {
const struct AirportFTAClass *fsm; ///< the finite statemachine for the default airports const struct AirportFTAClass *fsm; ///< the finite statemachine for the default airports
const AirportTileTable * const *table; ///< list of the tiles composing the airport const AirportTileTable * const *table; ///< list of the tiles composing the airport
Direction *rotation; ///< the rotation of each tiletable const Direction *rotation; ///< the rotation of each tiletable
byte num_table; ///< number of elements in the table byte num_table; ///< number of elements in the table
const HangarTileTable *depot_table; ///< gives the position of the depots on the airports const HangarTileTable *depot_table; ///< gives the position of the depots on the airports
byte nof_depots; ///< the number of hangar tiles in this airport byte nof_depots; ///< the number of hangar tiles in this airport
@ -133,7 +133,7 @@ struct AirportSpec {
return (byte)(this - specs); return (byte)(this - specs);
} }
static AirportSpec dummy; ///< The dummy airport. static const AirportSpec dummy; ///< The dummy airport.
private: private:
static AirportSpec specs[NUM_AIRPORTS]; ///< Specs of the airports. static AirportSpec specs[NUM_AIRPORTS]; ///< Specs of the airports.

View File

@ -28,7 +28,7 @@
#define MKEND {{-0x80, 0}, 0} #define MKEND {{-0x80, 0}, 0}
/** Tiles for Country Airfield (small) */ /** Tiles for Country Airfield (small) */
static AirportTileTable _tile_table_country_0[] = { static const AirportTileTable _tile_table_country_0[] = {
MK(0, 0, APT_SMALL_BUILDING_1), MK(0, 0, APT_SMALL_BUILDING_1),
MK(1, 0, APT_SMALL_BUILDING_2), MK(1, 0, APT_SMALL_BUILDING_2),
MK(2, 0, APT_SMALL_BUILDING_3), MK(2, 0, APT_SMALL_BUILDING_3),
@ -44,12 +44,12 @@ static AirportTileTable _tile_table_country_0[] = {
MKEND MKEND
}; };
static AirportTileTable *_tile_table_country[] = { static const AirportTileTable * const _tile_table_country[] = {
_tile_table_country_0, _tile_table_country_0,
}; };
/** Tiles for Commuter Airfield (small) */ /** Tiles for Commuter Airfield (small) */
static AirportTileTable _tile_table_commuter_0[] = { static const AirportTileTable _tile_table_commuter_0[] = {
MK(0, 0, APT_TOWER), MK(0, 0, APT_TOWER),
MK(1, 0, APT_BUILDING_3), MK(1, 0, APT_BUILDING_3),
MK(2, 0, APT_HELIPAD_2_FENCE_NW), MK(2, 0, APT_HELIPAD_2_FENCE_NW),
@ -73,12 +73,12 @@ static AirportTileTable _tile_table_commuter_0[] = {
MKEND MKEND
}; };
static AirportTileTable *_tile_table_commuter[] = { static const AirportTileTable * const _tile_table_commuter[] = {
_tile_table_commuter_0, _tile_table_commuter_0,
}; };
/** Tiles for City Airport (large) */ /** Tiles for City Airport (large) */
static AirportTileTable _tile_table_city_0[] = { static const AirportTileTable _tile_table_city_0[] = {
MK(0, 0, APT_BUILDING_1), MK(0, 0, APT_BUILDING_1),
MK(1, 0, APT_APRON_FENCE_NW), MK(1, 0, APT_APRON_FENCE_NW),
MK(2, 0, APT_STAND_1), MK(2, 0, APT_STAND_1),
@ -118,12 +118,12 @@ static AirportTileTable _tile_table_city_0[] = {
MKEND MKEND
}; };
static AirportTileTable *_tile_table_city[] = { static const AirportTileTable * const _tile_table_city[] = {
_tile_table_city_0, _tile_table_city_0,
}; };
/** Tiles for Metropolitain Airport (large) - 2 runways */ /** Tiles for Metropolitain Airport (large) - 2 runways */
static AirportTileTable _tile_table_metropolitan_0[] = { static const AirportTileTable _tile_table_metropolitan_0[] = {
MK(0, 0, APT_BUILDING_1), MK(0, 0, APT_BUILDING_1),
MK(1, 0, APT_APRON_FENCE_NW), MK(1, 0, APT_APRON_FENCE_NW),
MK(2, 0, APT_STAND_1), MK(2, 0, APT_STAND_1),
@ -163,12 +163,12 @@ static AirportTileTable _tile_table_metropolitan_0[] = {
MKEND MKEND
}; };
static AirportTileTable *_tile_table_metropolitan[] = { static const AirportTileTable * const _tile_table_metropolitan[] = {
_tile_table_metropolitan_0, _tile_table_metropolitan_0,
}; };
/** Tiles for International Airport (large) - 2 runways */ /** Tiles for International Airport (large) - 2 runways */
static AirportTileTable _tile_table_international_0[] = { static const AirportTileTable _tile_table_international_0[] = {
MK(0, 0, APT_RUNWAY_END_FENCE_NW), MK(0, 0, APT_RUNWAY_END_FENCE_NW),
MK(1, 0, APT_RUNWAY_FENCE_NW), MK(1, 0, APT_RUNWAY_FENCE_NW),
MK(2, 0, APT_RUNWAY_FENCE_NW), MK(2, 0, APT_RUNWAY_FENCE_NW),
@ -221,12 +221,12 @@ static AirportTileTable _tile_table_international_0[] = {
MKEND MKEND
}; };
static AirportTileTable *_tile_table_international[] = { static const AirportTileTable * const _tile_table_international[] = {
_tile_table_international_0, _tile_table_international_0,
}; };
/** Tiles for International Airport (large) - 2 runways */ /** Tiles for International Airport (large) - 2 runways */
static AirportTileTable _tile_table_intercontinental_0[] = { static const AirportTileTable _tile_table_intercontinental_0[] = {
MK(0, 0, APT_RADAR_FENCE_NE), MK(0, 0, APT_RADAR_FENCE_NE),
MK(1, 0, APT_RUNWAY_END_FENCE_NE_NW), MK(1, 0, APT_RUNWAY_END_FENCE_NE_NW),
MK(2, 0, APT_RUNWAY_FENCE_NW), MK(2, 0, APT_RUNWAY_FENCE_NW),
@ -329,22 +329,22 @@ static AirportTileTable _tile_table_intercontinental_0[] = {
MKEND MKEND
}; };
static AirportTileTable *_tile_table_intercontinental[] = { static const AirportTileTable * const _tile_table_intercontinental[] = {
_tile_table_intercontinental_0, _tile_table_intercontinental_0,
}; };
/** Tiles for Heliport */ /** Tiles for Heliport */
static AirportTileTable _tile_table_heliport_0[] = { static const AirportTileTable _tile_table_heliport_0[] = {
MK(0, 0, APT_HELIPORT), MK(0, 0, APT_HELIPORT),
MKEND MKEND
}; };
static AirportTileTable *_tile_table_heliport[] = { static const AirportTileTable * const _tile_table_heliport[] = {
_tile_table_heliport_0, _tile_table_heliport_0,
}; };
/** Tiles for Helidepot */ /** Tiles for Helidepot */
static AirportTileTable _tile_table_helidepot_0[] = { static const AirportTileTable _tile_table_helidepot_0[] = {
MK(0, 0, APT_LOW_BUILDING_FENCE_N), MK(0, 0, APT_LOW_BUILDING_FENCE_N),
MK(1, 0, APT_DEPOT_SE), MK(1, 0, APT_DEPOT_SE),
MK(0, 1, APT_HELIPAD_2_FENCE_NE_SE), MK(0, 1, APT_HELIPAD_2_FENCE_NE_SE),
@ -352,12 +352,12 @@ static AirportTileTable _tile_table_helidepot_0[] = {
MKEND MKEND
}; };
static AirportTileTable *_tile_table_helidepot[] = { static const AirportTileTable * const _tile_table_helidepot[] = {
_tile_table_helidepot_0, _tile_table_helidepot_0,
}; };
/** Tiles for Helistation */ /** Tiles for Helistation */
static AirportTileTable _tile_table_helistation_0[] = { static const AirportTileTable _tile_table_helistation_0[] = {
MK(0, 0, APT_DEPOT_SE), MK(0, 0, APT_DEPOT_SE),
MK(1, 0, APT_LOW_BUILDING_FENCE_NW), MK(1, 0, APT_LOW_BUILDING_FENCE_NW),
MK(2, 0, APT_HELIPAD_3_FENCE_NW), MK(2, 0, APT_HELIPAD_3_FENCE_NW),
@ -369,11 +369,11 @@ static AirportTileTable _tile_table_helistation_0[] = {
MKEND MKEND
}; };
static AirportTileTable *_tile_table_helistation[] = { static const AirportTileTable * const _tile_table_helistation[] = {
_tile_table_helistation_0, _tile_table_helistation_0,
}; };
static Direction _default_airports_rotation[] = { static const Direction _default_airports_rotation[] = {
DIR_N, DIR_N,
}; };
@ -410,7 +410,7 @@ extern const AirportSpec _origin_airport_specs[] = {
assert_compile(NEW_AIRPORT_OFFSET == lengthof(_origin_airport_specs)); assert_compile(NEW_AIRPORT_OFFSET == lengthof(_origin_airport_specs));
AirportSpec AirportSpec::dummy = AS_GENERIC(&_airportfta_dummy, NULL, _default_airports_rotation, 0, NULL, 0, 0, 0, 0, 0, MIN_YEAR, MIN_YEAR, 0, ATP_TTDP_LARGE, APC_BEGIN, STR_NULL, 0, false); const AirportSpec AirportSpec::dummy = AS_GENERIC(&_airportfta_dummy, NULL, _default_airports_rotation, 0, NULL, 0, 0, 0, 0, 0, MIN_YEAR, MIN_YEAR, 0, ATP_TTDP_LARGE, APC_BEGIN, STR_NULL, 0, false);
#undef AS #undef AS
#undef AS_ND #undef AS_ND