(svn r10959) [NewGRF_ports] -Change: Rename FSMState to FSMCommand. nof_elements changed to num_positions. nof_depots changed to num_depots.
--- a/src/aircraft_cmd.cpp Tue Aug 21 17:42:30 2007 +0000
+++ b/src/aircraft_cmd.cpp Tue Aug 21 19:33:49 2007 +0000
@@ -144,7 +144,7 @@
if (st->owner != v->owner || !(st->facilities & FACIL_AIRPORT)) continue;
const AirportFTAClass *afc = st->Airport();
- if (afc->nof_depots == 0 || (
+ if (afc->num_depots == 0 || (
/* don't crash the plane if we know it can't land at the airport */
afc->flags & AirportFTAClass::SHORT_STRIP &&
AircraftVehInfo(v->engine_type)->subtype & AIR_FAST &&
@@ -424,7 +424,7 @@
depots = apc->depots[i];
}
- assert(i != apc->nof_depots); //asserts if depot not found
+ assert(i != apc->num_depots); //asserts if depot not found
if (st->airport_tile + ToTileIndexDiff(depots) == tile) {
/* adjust all the initial position data by the orientation of the airport */
@@ -625,7 +625,7 @@
StationID next_airport_index = v->u.air.targetairport;
const Station *st = GetStation(next_airport_index);
/* If the station is not a valid airport or if it has no hangars */
- if (!st->IsValid() || st->airport_tile == 0 || st->Airport()->nof_depots == 0) {
+ if (!st->IsValid() || st->airport_tile == 0 || st->Airport()->num_depots == 0) {
/* the aircraft has to search for a hangar on its own */
StationID station = FindNearestHangar(v);
@@ -1084,7 +1084,7 @@
tile = st->xy;
/* Jump into our "holding pattern" state machine if possible */
- if (v->u.air.pos >= afc->nof_elements) v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, afc);
+ if (v->u.air.pos >= afc->num_positions) v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, afc);
}
/* get airport moving data */
@@ -1886,7 +1886,7 @@
* --> get out of the way to the hangar. */
if (v->current_order.type == OT_GOTO_STATION && ChooseTerminal(v, apc)) return; // if successfully chosen, return
- v->u.air.state = (apc->nof_depots != 0) ? HANGAR : TAKEOFF;
+ v->u.air.state = (apc->num_depots != 0) ? HANGAR : TAKEOFF;
AirportMove(v, apc);
}
@@ -1902,7 +1902,7 @@
* must go to a hangar. */
if (v->current_order.type == OT_GOTO_STATION && ChooseTerminal(v, apc)) return; // if successfully chosen, return
- v->u.air.state = (apc->nof_depots != 0) ? HANGAR : HELITAKEOFF;
+ v->u.air.state = (apc->num_depots != 0) ? HANGAR : HELITAKEOFF;
AirportMove(v, apc);
}
@@ -1959,9 +1959,9 @@
Station *st = GetStation(v->u.air.targetairport);
/* error handling */
- if (v->u.air.pos >= apc->nof_elements) {
- DEBUG(misc, 0, "[Ap] position %d is not valid for current airport. Max position is %d", v->u.air.pos, apc->nof_elements-1);
- assert(v->u.air.pos < apc->nof_elements);
+ if (v->u.air.pos >= apc->num_positions) {
+ DEBUG(misc, 0, "[Ap] position %d is not valid for current airport. Max position is %d", v->u.air.pos, apc->num_positions-1);
+ assert(v->u.air.pos < apc->num_positions);
}
AirportFTA *current = &apc->layout[v->u.air.pos];
@@ -2276,7 +2276,7 @@
void UpdateAirplanesOnNewStation(const Station *st)
{
/* only 1 station is updated per function call, so it is enough to get entry_point once */
- const AirportFTAClass *ap = st->Airport();
+ const AirportFTAClass *apc = st->Airport();
Vehicle *v;
FOR_ALL_VEHICLES(v) {
@@ -2285,7 +2285,7 @@
/* update position of airplane. If plane is not flying, landing, or taking off
* you cannot delete airport, so it doesn't matter */
if (v->u.air.state >= FLYING) { // circle around
- v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, ap);
+ v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, apc);
v->u.air.state = FLYING;
UpdateAircraftCache(v);
/* landing plane needs to be reset to flying height (only if in pause mode upgrade,
@@ -2298,9 +2298,9 @@
byte takeofftype = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : ENDTAKEOFF;
/* search in airportdata for that heading
* easiest to do, since this doesn't happen a lot */
- for (uint cnt = 0; cnt < ap->nof_elements; cnt++) {
- if (ap->layout[cnt].heading == takeofftype) {
- v->u.air.pos = ap->layout[cnt].position;
+ for (uint cnt = 0; cnt < apc->num_positions; cnt++) {
+ if (apc->layout[cnt].heading == takeofftype) {
+ v->u.air.pos = apc->layout[cnt].position;
UpdateAircraftCache(v);
break;
}
--- a/src/airport.cpp Tue Aug 21 17:42:30 2007 +0000
+++ b/src/airport.cpp Tue Aug 21 19:33:49 2007 +0000
@@ -23,7 +23,7 @@
* - false: give a summarized report which only shows current and next position */
//#define DEBUG_AIRPORT false
-static byte AirportTestFTA(uint nof_elements, const AirportFTA *layout, const byte *terminals);
+static byte AirportTestFTA(uint num_positions, const AirportFTA *layout, const byte *terminals);
#ifdef DEBUG_AIRPORT
static void AirportPrintOut(uint nof_elements, const AirportFTA *layout, bool full_report);
@@ -32,7 +32,7 @@
AirportFTAClass::~AirportFTAClass()
{
- for (uint i = 0; i < nof_elements; i++) {
+ for (uint i = 0; i < num_positions; i++) {
AirportFTA *current = layout[i].next;
while (current != NULL) {
AirportFTA *next = current->next;
@@ -43,11 +43,11 @@
free(layout);
}
-static byte AirportTestFTA(uint nof_elements, const AirportFTA *layout, const byte *terminals)
+static byte AirportTestFTA(uint num_positions, const AirportFTA *layout, const byte *terminals)
{
uint next_position = 0;
- for (uint i = 0; i < nof_elements; i++) {
+ for (uint i = 0; i < num_positions; i++) {
uint position = layout[i].position;
if (position != next_position) return i;
const AirportFTA *first = &layout[i];
@@ -67,7 +67,7 @@
/* Obviously the elements of the linked list must have the same identifier */
if (position != current->position) return i;
/* A next position must be within bounds */
- if (current->next_position >= nof_elements) return i;
+ if (current->next_position >= num_positions) return i;
}
next_position++;
}
--- a/src/airport.h Tue Aug 21 17:42:30 2007 +0000
+++ b/src/airport.h Tue Aug 21 19:33:49 2007 +0000
@@ -8,7 +8,7 @@
#include "fsmport.h"
#include <list>
-typedef FSMState AirportFTA;
+typedef FSMCommand AirportFTA;
typedef FSMPortMovingData AirportMovingData;
enum {MAX_TERMINALS = 36};
--- a/src/fsmport.cpp Tue Aug 21 17:42:30 2007 +0000
+++ b/src/fsmport.cpp Tue Aug 21 19:33:49 2007 +0000
@@ -8,10 +8,10 @@
FSMPortClass::~FSMPortClass()
{
- for (uint i = 0; i < nof_elements; i++) {
- FSMState *current = layout[i].next;
+ for (uint i = 0; i < num_positions; i++) {
+ FSMCommand *current = layout[i].next;
while (current != NULL) {
- FSMState *next = current->next;
+ FSMCommand *next = current->next;
free(current);
current = next;
};
--- a/src/fsmport.h Tue Aug 21 17:42:30 2007 +0000
+++ b/src/fsmport.h Tue Aug 21 19:33:49 2007 +0000
@@ -18,8 +18,8 @@
byte block; //block number for this specific location
};
-struct FSMState {
- FSMState *next; ///< Possible extra movement choices from this position
+struct FSMCommand {
+ FSMCommand *next; ///< Possible extra movement choices from this position
FSMblockmap reserveblock; ///< The blocks to reserve at this state
FSMblockmap releaseblock; ///< The blocks to release at this state
byte position; ///< The position that a vehicle is at
@@ -33,23 +33,23 @@
struct FSMPortClass {
public:
- FSMPortClass(FSMportsSpec *spec_) : moving_data(NULL), layout(NULL), nof_elements(0), depots(NULL),
- nof_depots(0), size_x(0), size_y(0), delta_z(0), catchment(0), spec(spec_) {}
+ FSMPortClass(FSMportsSpec *spec_) : moving_data(NULL), layout(NULL), num_positions(0), depots(NULL),
+ num_depots(0), size_x(0), size_y(0), delta_z(0), catchment(0), spec(spec_) {}
~FSMPortClass();
const FSMPortMovingData *MovingData(byte position) const
{
- assert(position < this->nof_elements);
+ assert(position < this->num_positions);
return &this->moving_data[position];
}
FSMPortMovingData *moving_data;
- FSMState *layout;
- byte nof_elements; // number of positions the airport consists of
+ FSMCommand *layout;
+ byte num_positions; // number of positions the airport consists of
TileIndexDiffC *depots; // gives the position of the depots on the airports
- byte nof_depots; // number of depots this airport has
+ byte num_depots; // number of depots this airport has
byte size_x;
byte size_y;
--- a/src/newgrf.cpp Tue Aug 21 17:42:30 2007 +0000
+++ b/src/newgrf.cpp Tue Aug 21 19:33:49 2007 +0000
@@ -2250,12 +2250,12 @@
break;
case 0x1A: // Finite State Machine and Movement Orders
- fsmportspec->portFSM->nof_elements = grf_load_byte(&buf);
- fsmportspec->portFSM->layout = MallocT<AirportFTA>(fsmportspec->portFSM->nof_elements);
- fsmportspec->portFSM->moving_data = MallocT<AirportMovingData>(fsmportspec->portFSM->nof_elements);
+ fsmportspec->portFSM->num_positions = grf_load_byte(&buf);
+ fsmportspec->portFSM->layout = MallocT<AirportFTA>(fsmportspec->portFSM->num_positions);
+ fsmportspec->portFSM->moving_data = MallocT<AirportMovingData>(fsmportspec->portFSM->num_positions);
fsmportspec->portFSM->size_x = fsmportspec->size_x[0];
fsmportspec->portFSM->size_y = fsmportspec->size_y[0];
- for (byte element = 0; element < fsmportspec->portFSM->nof_elements; element++) {
+ for (byte element = 0; element < fsmportspec->portFSM->num_positions; element++) {
AirportMovingData md;
md.x = grf_load_word(&buf);
md.y = grf_load_word(&buf);
@@ -2309,9 +2309,9 @@
break;
case 0x1D: // Hangar locations
- fsmportspec->portFSM->nof_depots = grf_load_byte(&buf);
- fsmportspec->portFSM->depots = MallocT<TileIndexDiffC>(fsmportspec->portFSM->nof_depots);
- for (uint depot = 0; depot < fsmportspec->portFSM->nof_depots; depot++) {
+ fsmportspec->portFSM->num_depots = grf_load_byte(&buf);
+ fsmportspec->portFSM->depots = MallocT<TileIndexDiffC>(fsmportspec->portFSM->num_depots);
+ for (uint depot = 0; depot < fsmportspec->portFSM->num_depots; depot++) {
TileIndexDiffC depot_tile;
depot_tile.x = grf_load_byte(&buf);
depot_tile.y = grf_load_byte(&buf);
--- a/src/order_cmd.cpp Tue Aug 21 17:42:30 2007 +0000
+++ b/src/order_cmd.cpp Tue Aug 21 19:33:49 2007 +0000
@@ -239,7 +239,7 @@
if (!CheckOwnership(st->owner) ||
!(st->facilities & FACIL_AIRPORT) ||
- st->Airport()->nof_depots == 0) {
+ st->Airport()->num_depots == 0) {
return CMD_ERROR;
}
} else {
--- a/src/station_cmd.cpp Tue Aug 21 17:42:30 2007 +0000
+++ b/src/station_cmd.cpp Tue Aug 21 19:33:49 2007 +0000
@@ -63,10 +63,10 @@
byte num_depots;
if (IsCustomFSMportsSpecIndex(t)) {
hangar_list = st->fsmportsspeclist[1].spec->portFSM->depots;
- num_depots = st->fsmportsspeclist[1].spec->portFSM->nof_depots;
+ num_depots = st->fsmportsspeclist[1].spec->portFSM->num_depots;
} else {
hangar_list = st->Airport()->depots;
- num_depots = st->Airport()->nof_depots;
+ num_depots = st->Airport()->num_depots;
}
for (uint i = 0; i < num_depots; i++) {
TileIndexDiffC depot = RotateFSMPosition(hangar_list[i],
@@ -1760,7 +1760,7 @@
END_TILE_LOOP(tile_cur, w,h,tile)
if (flags & DC_EXEC) {
- for (uint i = 0; i < fsmportsspec->portFSM->nof_depots; ++i) {
+ for (uint i = 0; i < fsmportsspec->portFSM->num_depots; ++i) {
DeleteWindowById(
WC_VEHICLE_DEPOT, tile + ToTileIndexDiff(fsmportsspec->portFSM->depots[i])
);