(svn r19193) -Codechange: increase the maximum number of airport tiles to 256 and introduce AirportTileOverrideManager
This commit is contained in:
@@ -11,10 +11,15 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "airport.h"
|
||||
#include "newgrf.h"
|
||||
#include "newgrf_airporttiles.h"
|
||||
#include "table/airporttiles.h"
|
||||
|
||||
|
||||
AirportTileSpec AirportTileSpec::tiles[NUM_AIRPORTTILES];
|
||||
|
||||
AirportTileOverrideManager _airporttile_mngr(NEW_AIRPORTTILE_OFFSET, NUM_AIRPORTTILES, INVALID_AIRPORTTILE);
|
||||
|
||||
/**
|
||||
* Retrieve airport tile spec for the given airport tile
|
||||
* @param gfx index of airport tile
|
||||
@@ -22,8 +27,43 @@
|
||||
*/
|
||||
/* static */ const AirportTileSpec *AirportTileSpec::Get(StationGfx gfx)
|
||||
{
|
||||
assert(gfx < NUM_AIRPORTTILES);
|
||||
extern const AirportTileSpec _origin_airporttile_specs[];
|
||||
return &_origin_airporttile_specs[gfx];
|
||||
assert(gfx < lengthof(AirportTileSpec::tiles));
|
||||
return &AirportTileSpec::tiles[gfx];
|
||||
}
|
||||
|
||||
/**
|
||||
* This function initializes the tile array of AirportTileSpec
|
||||
*/
|
||||
void AirportTileSpec::ResetAirportTiles()
|
||||
{
|
||||
memset(&AirportTileSpec::tiles, 0, sizeof(AirportTileSpec::tiles));
|
||||
memcpy(&AirportTileSpec::tiles, &_origin_airporttile_specs, sizeof(_origin_airporttile_specs));
|
||||
|
||||
/* Reset any overrides that have been set. */
|
||||
_airporttile_mngr.ResetOverride();
|
||||
}
|
||||
|
||||
void AirportTileOverrideManager::SetEntitySpec(const AirportTileSpec *airpts)
|
||||
{
|
||||
StationGfx airpt_id = this->AddEntityID(airpts->grf_prop.local_id, airpts->grf_prop.grffile->grfid, airpts->grf_prop.subst_id);
|
||||
|
||||
if (airpt_id == invalid_ID) {
|
||||
grfmsg(1, "AirportTile.SetEntitySpec: Too many airport tiles allocated. Ignoring.");
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(&AirportTileSpec::tiles[airpt_id], airpts, sizeof(*airpts));
|
||||
|
||||
/* Now add the overrides. */
|
||||
for (int i = 0; i < max_offset; i++) {
|
||||
AirportTileSpec *overridden_airpts = &AirportTileSpec::tiles[i];
|
||||
|
||||
if (entity_overrides[i] != airpts->grf_prop.local_id || grfid_overrides[i] != airpts->grf_prop.grffile->grfid) continue;
|
||||
|
||||
overridden_airpts->grf_prop.override = airpt_id;
|
||||
overridden_airpts->enabled = false;
|
||||
entity_overrides[i] = invalid_ID;
|
||||
grfid_overrides[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user