1
0
Fork 0

(svn r22839) [1.1] -Backport from trunk:

- Fix: [NewGRF] Also free allocated depot tables of NewGRF airports (r22760)
- Fix: [NewGRF] Invalid memory access when querying the grfID of the default objects [FS#4730] (r22757)
- Fix: When marking tile selections dirty, use the height information of the corners instead of the surface slope. This is more accurate when the foundation is kind of undefined [FS#4727] (r22755)
- Fix: Make aircraft point to the exit when leaving the hangar [FS#4696] (r22743, r22742, r22741)
release/1.1
rubidium 2011-08-25 13:27:56 +00:00
parent 85ee1737e4
commit 15d5df9496
7 changed files with 63 additions and 19 deletions

View File

@ -1243,12 +1243,18 @@ void AircraftNextAirportPos_and_Order(Aircraft *v)
v->pos = v->previous_pos = AircraftGetEntryPoint(v, apc, rotation);
}
/**
* Aircraft is about to leave the hangar.
* @param v Aircraft leaving.
*/
void AircraftLeaveHangar(Aircraft *v)
{
const Station *st = Station::GetByTile(v->tile);
v->cur_speed = 0;
v->subspeed = 0;
v->progress = 0;
v->direction = DIR_SE;
v->direction = st->airport.GetHangarExitDirection(v->tile);
v->vehstatus &= ~VS_HIDDEN;
{
Vehicle *u = v->Next();

View File

@ -7132,6 +7132,7 @@ static void ResetCustomAirports()
free((void*)as->table[j]);
}
free((void*)as->table);
free((void*)as->depot_table);
free(as);
}

View File

@ -52,6 +52,7 @@ enum TTDPAirportType {
/** A list of all hangar tiles in an airport */
struct HangarTileTable {
TileIndexDiffC ti; ///< Tile offset from the top-most airport tile.
Direction dir; ///< Direction of the exit.
byte hangar_num; ///< The hanger to which this tile belongs.
};

View File

@ -140,6 +140,11 @@ static uint32 GetObjectIDAtOffset(TileIndex tile, uint32 cur_grfid)
const ObjectSpec *spec = ObjectSpec::GetByTile(tile);
/* Default objects have no associated NewGRF file */
if (spec->grf_prop.grffile == NULL) {
return 0xFFFE; // Defined in another grf file
}
if (spec->grf_prop.grffile->grfid == cur_grfid) { // same object, same grf ?
return spec->grf_prop.local_id;
}

View File

@ -128,20 +128,28 @@ struct Airport : public TileArea {
}
/**
* Get the hangar number of the hangar on a specific tile.
* Get the exit direction of the hangar at a specific tile.
* @param tile The tile to query.
* @pre IsHangarTile(tile).
* @return The exit direction of the hangar, taking airport rotation into account.
*/
FORCEINLINE Direction GetHangarExitDirection(TileIndex tile) const
{
const AirportSpec *as = this->GetSpec();
const HangarTileTable *htt = GetHangarDataByTile(tile);
return ChangeDir(htt->dir, DirDifference(this->rotation, as->rotation[0]));
}
/**
* Get the hangar number of the hangar at a specific tile.
* @param tile The tile to query.
* @pre IsHangarTile(tile).
* @return The hangar number of the hangar at the given tile.
*/
FORCEINLINE uint GetHangarNum(TileIndex tile) const
{
const AirportSpec *as = this->GetSpec();
for (uint i = 0; i < as->nof_depots; i++) {
if (this->GetRotatedTileFromOffset(as->depot_table[i].ti) == tile) {
return as->depot_table[i].hangar_num;
}
}
NOT_REACHED();
const HangarTileTable *htt = GetHangarDataByTile(tile);
return htt->hangar_num;
}
/** Get the number of hangars on this airport. */
@ -158,6 +166,24 @@ struct Airport : public TileArea {
}
return num;
}
private:
/**
* Retrieve hangar information of a hangar at a given tile.
* @param tile %Tile containing the hangar.
* @return The requested hangar information.
* @pre The \a tile must be at a hangar tile at an airport.
*/
FORCEINLINE const HangarTileTable *GetHangarDataByTile(TileIndex tile) const
{
const AirportSpec *as = this->GetSpec();
for (uint i = 0; i < as->nof_depots; i++) {
if (this->GetRotatedTileFromOffset(as->depot_table[i].ti) == tile) {
return as->depot_table + i;
}
}
NOT_REACHED();
}
};
typedef SmallVector<Industry *, 2> IndustryVector;

View File

@ -417,7 +417,7 @@ static const AirportFTAbuildup _airport_fta_dummy[] = {
/* First element of terminals array tells us how many depots there are (to know size of array)
* this may be changed later when airports are moved to external file */
static const HangarTileTable _airport_depots_country[] = { {{3, 0}, 0} };
static const HangarTileTable _airport_depots_country[] = { {{3, 0}, DIR_SE, 0} };
static const byte _airport_terminal_country[] = {1, 2};
static const byte _airport_entries_country[] = {16, 15, 18, 17};
static const AirportFTAbuildup _airport_fta_country[] = {
@ -449,7 +449,7 @@ static const AirportFTAbuildup _airport_fta_country[] = {
{ MAX_ELEMENTS, 0, 0, 0 } // end marker. DO NOT REMOVE
};
static const HangarTileTable _airport_depots_commuter[] = { {{4, 0}, 0} };
static const HangarTileTable _airport_depots_commuter[] = { {{4, 0}, DIR_SE, 0} };
static const byte _airport_terminal_commuter[] = { 1, 3 };
static const byte _airport_entries_commuter[] = {22, 21, 24, 23};
static const AirportFTAbuildup _airport_fta_commuter[] = {
@ -499,7 +499,7 @@ static const AirportFTAbuildup _airport_fta_commuter[] = {
{ MAX_ELEMENTS, 0, 0, 0 } // end marker. DO NOT REMOVE
};
static const HangarTileTable _airport_depots_city[] = { {{5, 0}, 0} };
static const HangarTileTable _airport_depots_city[] = { {{5, 0}, DIR_SE, 0} };
static const byte _airport_terminal_city[] = { 1, 3 };
static const byte _airport_entries_city[] = {26, 29, 27, 28};
static const AirportFTAbuildup _airport_fta_city[] = {
@ -540,7 +540,7 @@ static const AirportFTAbuildup _airport_fta_city[] = {
{ MAX_ELEMENTS, 0, 0, 0 } // end marker. DO NOT REMOVE
};
static const HangarTileTable _airport_depots_metropolitan[] = { {{5, 0}, 0} };
static const HangarTileTable _airport_depots_metropolitan[] = { {{5, 0}, DIR_SE, 0} };
static const byte _airport_terminal_metropolitan[] = { 1, 3 };
static const byte _airport_entries_metropolitan[] = {20, 19, 22, 21};
static const AirportFTAbuildup _airport_fta_metropolitan[] = {
@ -579,7 +579,7 @@ static const AirportFTAbuildup _airport_fta_metropolitan[] = {
{ MAX_ELEMENTS, 0, 0, 0 } // end marker. DO NOT REMOVE
};
static const HangarTileTable _airport_depots_international[] = { {{0, 3}, 0}, {{6, 1}, 1} };
static const HangarTileTable _airport_depots_international[] = { {{0, 3}, DIR_SE, 0}, {{6, 1}, DIR_SE, 1} };
static const byte _airport_terminal_international[] = { 2, 3, 3 };
static const byte _airport_entries_international[] = { 38, 37, 40, 39 };
static const AirportFTAbuildup _airport_fta_international[] = {
@ -644,7 +644,7 @@ static const AirportFTAbuildup _airport_fta_international[] = {
};
/* intercontinental */
static const HangarTileTable _airport_depots_intercontinental[] = { {{0, 5}, 0}, {{8, 4}, 1} };
static const HangarTileTable _airport_depots_intercontinental[] = { {{0, 5}, DIR_SE, 0}, {{8, 4}, DIR_SE, 1} };
static const byte _airport_terminal_intercontinental[] = { 2, 4, 4 };
static const byte _airport_entries_intercontinental[] = { 44, 43, 46, 45 };
static const AirportFTAbuildup _airport_fta_intercontinental[] = {
@ -756,7 +756,7 @@ static const AirportFTAbuildup _airport_fta_heliport[] = {
#define _airport_fta_oilrig _airport_fta_heliport
/* helidepots */
static const HangarTileTable _airport_depots_helidepot[] = { {{1, 0}, 0} };
static const HangarTileTable _airport_depots_helidepot[] = { {{1, 0}, DIR_SE, 0} };
static const byte _airport_entries_helidepot[] = { 4, 4, 4, 4 };
static const AirportFTAbuildup _airport_fta_helidepot[] = {
{ 0, HANGAR, NOTHING_block, 1 },
@ -785,7 +785,7 @@ static const AirportFTAbuildup _airport_fta_helidepot[] = {
};
/* helistation */
static const HangarTileTable _airport_depots_helistation[] = { {{0, 0}, 0} };
static const HangarTileTable _airport_depots_helistation[] = { {{0, 0}, DIR_SE, 0} };
static const byte _airport_entries_helistation[] = { 25, 25, 25, 25 };
static const AirportFTAbuildup _airport_fta_helistation[] = {
{ 0, HANGAR, NOTHING_block, 8 }, { 0, HELIPAD1, 0, 1 }, { 0, HELIPAD2, 0, 1 }, { 0, HELIPAD3, 0, 1 }, { 0, HELITAKEOFF, 0, 1 }, { 0, 0, 0, 0 },

View File

@ -1715,8 +1715,13 @@ static void SetSelectionTilesDirty()
int bot_y = top_y;
do {
Point top = RemapCoords2(top_x, top_y); // topmost dirty point
Point bot = RemapCoords2(bot_x + TILE_SIZE - 1, bot_y + TILE_SIZE - 1); // bottommost point
/* topmost dirty point */
TileIndex top_tile = TileVirtXY(top_x, top_y);
Point top = RemapCoords(top_x, top_y, GetTileMaxZ(top_tile));
/* bottommost point */
TileIndex bottom_tile = TileVirtXY(bot_x, bot_y);
Point bot = RemapCoords(bot_x + TILE_SIZE, bot_y + TILE_SIZE, GetTileZ(bottom_tile)); // bottommost point
/* the 'x' coordinate of 'top' and 'bot' is the same (and always in the same distance from tile middle),
* tile height/slope affects only the 'y' on-screen coordinate! */