(svn r10853) [NewGRF_ports] -Feature: Added heliport to airportsbasic.grf. Added Heli-EndTakeoff stage.
Fix: Terminals (and especially helipads) were being incorrectly selected. Terminals may now be selected if the vehicle already owns the terminal bit.
Add: Added SetAll function if 0xFF found in blocklist.
Fix: Corrections to large airport (mostly heli-related).
Binary file bin/data/airportsbasic.grf has changed
--- a/bin/data/sprites/airportsbasic.nfo Sat Aug 11 19:50:48 2007 +0000
+++ b/bin/data/sprites/airportsbasic.nfo Sat Aug 11 19:57:00 2007 +0000
@@ -1,7 +1,7 @@
// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
- 0 * 4 19 00 00 00
+ 0 * 4 20 00 00 00
// Length of GRF in sprites
// if version of TTDPatch higher than X, skip two sprites
@@ -22,14 +22,15 @@
"City, Heliport" 00
// Define a sprite set for airports, one set, 4 views
- 8 * 4 01 0D 01 04
+ 8 * 4 01 0D 01 05
9 data\sprites/airportsbasic.pcx 178 8 09 8 18 0 0
10 data\sprites/airportsbasic.pcx 210 8 09 7 12 0 2
11 data\sprites/airportsbasic.pcx 242 8 09 64 96 0 0
12 data\sprites/airportsbasic.pcx 354 8 09 64 96 0 0
+ 13 data\sprites/airportsbasic.pcx 458 8 09 64 96 0 0
// Define a graphics set ID (cargo ID = 0
- 13 * 7 02 0D 00
+ 14 * 7 02 0D 00
// Little/lots set
00 01
// Set to define the graphics for (set #0)
@@ -39,7 +40,7 @@
// Small Airport
//----------------------------
// 11 properties to change, 1 station to change, station id = 0
- 14 * 657 00 0D 0C 01 00
+ 15 * 657 00 0D 0C 01 00
// Class ID
08 "SMLL"
@@ -268,7 +269,7 @@
// Large Airport
//------------------------------
// 11 properties to change, 1 airport to change, airport id = 1
- 15 * 1066 00 0D 0C 01 01
+ 16 * 1087 00 0D 0C 01 01
// Class ID
08 "LRGE"
@@ -476,23 +477,26 @@
// Large Airport : Position 02
\w26 \w41 \w0 01 \wx000B 01 // TERM1
- 03
+ 04
01 01 00 07
41 7E 43 42 7F 01 07
+ 51 7E 43 42 7F 01 07
40 42 00 07
// Large Airport : Position 03
\w56 \w20 \w0 02 \wx0007 02 // TERM2
- 03
+ 04
02 02 42 05
41 7E 43 42 7F 02 05
+ 51 7E 43 42 7F 02 05
40 42 00 05
// Large Airport : Position 04
\w38 \w8 \w0 03 \wx000B 03 // TERM3
- 03
+ 04
03 03 42 05
41 7E 43 42 7F 03 05
+ 51 7E 43 42 7F 03 05
40 42 00 05
// Large Airport : Position 05
@@ -578,7 +582,7 @@
00 00 00 19
// Large Airport : Position 13
- \w140 \w1 \w80 00 \wx0030 00
+ \w140 \w1 \w80 00 \wx00B0 00
01
00 00 00 14
@@ -595,17 +599,17 @@
// Large Airport : Position 16
\w44 \w63 \w80 51 \wx0000 00 // HELITAKEOFF
01
- 51 00 00 00
+ 00 00 00 00
// Large Airport : Position 17
\w28 \w74 \w80 54 \wx0030 44 // HELILANDING
01
- 54 44 00 18
+ 00 44 00 18
// Large Airport : Position 18
\w28 \w74 \w0 55 \wx0000 44 // HELIENDLANDING
01
- 55 44 00 11
+ 00 42 44 07
// Large Airport : Position 19
\w145 \w1 \w80 00 \wx00A0 00
@@ -613,22 +617,22 @@
00 00 00 14
// Large Airport : Position 1A
- \wxFFE0 \w1 \w80 00 \wx0030 00
+ \wxFFE0 \w1 \w80 00 \wx00B0 00
01
00 00 00 13
// Large Airport : Position 1B
- \w300 \wxFFD0 \w80 00 \wx0030 00
+ \w300 \wxFFD0 \w80 00 \wx00B0 00
01
00 00 00 1C
// Large Airport : Position 1C
- \w140 \wxFFD0 \w80 00 \wx0030 00
+ \w140 \wxFFD0 \w80 00 \wx00B0 00
01
00 00 00 13
// Large Airport : Position 1D
- \wxFFE0 \w120 \w80 00 \wx0030 00
+ \wxFFE0 \w120 \w80 00 \wx00B0 00
01
00 00 00 1A
@@ -649,7 +653,7 @@
//availability date varaction2
//small airport available from 1927 (1920+7) to 1964 (1920+44)
- 16 * 14 02 0D
+ 17 * 14 02 0D
02 // ID
81 01 // Variable 01 (current date)
00 FF
@@ -659,7 +663,7 @@
//availability date varaction2
//large airport available from 1951 (1920+31) to 2175 (1920+255)
- 17 * 14 02 0D
+ 18 * 14 02 0D
03 // ID
81 01 // Variable 01 (current date)
00 FF
@@ -667,7 +671,7 @@
01 FF 1F FF //1951-2175
00 FF
- 18 * 14 02 0D
+ 19 * 14 02 0D
04 // ID
81 0C // Check variable 0C (callback id)
00 FF
@@ -675,7 +679,7 @@
02 00 13 13 // Jump to action 2 ID 02 if this is callback 13
00 00 // Otherwise return the real sprites
- 19 * 14 02 0D
+ 20 * 14 02 0D
05 // ID
81 0C // Check variable 0C (callback id)
00 FF
@@ -684,17 +688,140 @@
00 00 // Otherwise return the real sprites
// Use graphics ID (1 station, ID 0, 0 cargo specific graphics, default cargo = 0)
- 20 * 7 03 0D 01 00 00 04 00
+ 21 * 7 03 0D 01 00 00 04 00
// Use graphics ID (1 station, ID 1, 0 cargo specific graphics, default cargo = 0)
- 21 * 7 03 0D 01 01 00 05 00
+ 22 * 7 03 0D 01 01 00 05 00
// Name
// Set the name of the station; all languages, 1 string, offset of CD 00, because 'generic strings' flag is set it's a word.
- 22 * 21 04 0D 9F 01 00 CD "Small airports" 00
- 23 * 20 04 0D 9F 01 00 CE "Small Airport" 00
- 24 * 21 04 0D 9F 01 01 CD "Large airports" 00
- 25 * 19 04 0D 9F 01 01 CE "City Airport" 00
+ 23 * 21 04 0D 9F 01 00 CD "Small airports" 00
+ 24 * 20 04 0D 9F 01 00 CE "Small Airport" 00
+ 25 * 21 04 0D 9F 01 01 CD "Large airports" 00
+ 26 * 19 04 0D 9F 01 01 CE "City Airport" 00
+
+//------------------------------
+// Heliport
+//------------------------------
+// 10 properties to change, 1 airport to change, airport id = 1
+ 27 * 206 00 0D 0A 01 02
+
+// Class ID
+ 08 "HELI"
+
+//Sprite layout
+ 09 02
+ // 58
+// 58 = 0x3A :
+ 8D 0F 00 00
+ 00 00 00 10 10 3C 49 8A 00 80
+ 80
+// 21 heliport mini pic
+ 31 04 00 08
+ 80
+
+
+// Prop0B Callbacks
+ 0B 01 //Availability
+
+// Define custom layouts
+ 0E 01
+ 01
+ 01 01 01
+ 00
+ 00 00
+
+// Prop19 Vehicle Type
+ 19 03 //Air
+
+// Define Finite State Machine
+ 1A 09 // positions 00-08
+
+ // Heliport : Position 00
+ \w5 \w9 \w60 25 \wx0003 25 // HELIPAD1
+ 02
+ 25 25 00 01
+ 51 00 00 01
+
+ // Heliport : Position 01
+ \w2 \w9 \w80 51 \wx0000 00 // HELITAKEOFF
+ 01
+ 00 00 7F 00
+
+ // Heliport : Position 02
+ \wxFFFD \w9 \w80 00 \wx0030 40
+ 02
+ 54 00 00 03
+ 51 00 25 01
+
+ // Heliport : Position 03
+ \w5 \w9 \w80 54 \wx0000 40 // HELILANDING
+ 01
+ 00 00 00 04
+
+ // Heliport : Position 04
+ \w2 \w9 \w60 55 \wx0000 40 // HELIENDLANDING
+ 01
+ 25 00 00 00
+
+ // Heliport : Position 05
+ \wxFFE1 \w59 \w80 00 \wx0030 00
+ 01
+ 00 00 00 06
+
+ // Heliport : Position 06
+ \wxFFE1 \wxFFCF \w80 00 \wx0030 00
+ 01
+ 00 00 00 07
+
+ // Heliport : Position 07
+ \w49 \wxFFCF \w80 00 \wx0030 00
+ 01
+ 00 00 00 08
+
+ // Heliport : Position 08
+ \w70 \w9 \w80 7F \wx0030 00 // FLYING
+ 02
+ 7F 00 00 05
+ 54 25 00 02
+
+// Prop1C Vehicle Entry Points
+ 1C 07 07 07 07
+
+// Prop1F Helipad Groups
+ 1F 01 01
+
+// Prop20 Port Subtype
+ 20 02
+
+// Prop22 Catchment area
+ 22 04
+
+//availability date varaction2
+//large airport available from 1975 (1920+55) to 2175 (1920+255)
+ 28 * 14 02 0D
+ 05 // ID
+ 81 01 // Variable 01 (current date)
+ 00 FF
+ 01
+ 01 FF 37 FF //1951-2175
+ 00 FF
+
+ 29 * 14 02 0D
+ 06 // ID
+ 81 0C // Check variable 0C (callback id)
+ 00 FF
+ 01
+ 05 00 13 13 // Jump to action 2 ID 02 if this is callback 13
+ 00 00 // Otherwise return the real sprites
+
+// Use graphics ID (1 station, ID 0, 0 cargo specific graphics, default cargo = 0)
+ 30 * 7 03 0D 01 02 00 06 00
+
+// Name
+ 31 * 16 04 0D 9F 01 02 CD "Heliports" 00
+ 32 * 15 04 0D 9F 01 02 CE "Heliport" 00
+
// The Fence Layouts
// 0F 00 00 01 10 06 67 8A 00 80 // fence west
Binary file bin/data/sprites/airportsbasic.pcx has changed
--- a/src/aircraft_cmd.cpp Sat Aug 11 19:50:48 2007 +0000
+++ b/src/aircraft_cmd.cpp Sat Aug 11 19:57:00 2007 +0000
@@ -1106,8 +1106,6 @@
u->cur_speed = 32;
count = UpdateAircraftSpeed(v);
if (count > 0) {
- v->tile = 0;
-
/* Reached altitude? */
if (v->z_pos >= 184) {
v->cur_speed = 0;
@@ -1729,6 +1727,11 @@
v->u.air.state = FLYING;
v->UpdateDeltaXY(INVALID_DIR);
+ /* release blocks reserved by aircraft on this airport */
+ Station *st = GetStation(v->u.air.targetairport);
+ st->airport_flags.ReleaseBlocks(&v->u.air.owned_blocks);
+ v->u.air.owned_blocks.ResetAll();
+
/* get the next position to go to, differs per airport */
AircraftNextAirportPos_and_Order(v);
@@ -1850,6 +1853,19 @@
v->u.air.state = (apc->nof_depots != 0) ? HANGAR : HELITAKEOFF;
}
+static void AircraftEventHandler_HeliEndTakeOff(Vehicle *v, const AirportFTAClass *apc)
+{
+ v->u.air.state = FLYING;
+
+ /* release blocks reserved by aircraft on this airport */
+ Station *st = GetStation(v->u.air.targetairport);
+ st->airport_flags.ReleaseBlocks(&v->u.air.owned_blocks);
+ v->u.air.owned_blocks.ResetAll();
+
+ /* get the next position to go to, differs per airport */
+ AircraftNextAirportPos_and_Order(v);
+}
+
typedef void AircraftStateHandler(Vehicle *v, const AirportFTAClass *apc);
static AircraftStateHandler * const _aircraft_state_handlers[] = {
AircraftEventHandler_General, // TO_ALL = 0
@@ -1864,6 +1880,7 @@
AircraftEventHandler_EndLanding, // ENDLANDING = 9
AircraftEventHandler_HeliLanding, // HELILANDING = 10
AircraftEventHandler_HeliEndLanding, // HELIENDLANDING = 11
+ AircraftEventHandler_HeliEndTakeOff, // HELIENDTAKEOFF = 12
};
byte MapStateToHandler(byte state)
@@ -1877,7 +1894,7 @@
if (state == 0x44) handler = 0x08; //landing
if (state == 0x45) handler = 0x09; //endlanding
if (state == 0x51) handler = 0x06; //helitakeoff
- if (state == 0x53) handler = 0x05; //heliendtakeoff
+ if (state == 0x53) handler = 0x0C; //heliendtakeoff
if (state == 0x54) handler = 0x0A; //helilanding
if (state == 0x55) handler = 0x0B; //heliendlanding
if (state == 0x7F) handler = 0x07; //flying
@@ -1990,7 +2007,7 @@
{
Station *st = GetStation(v->u.air.targetairport);
for (; i <= last_terminal; i++) {
- if (!(st->airport_flags.HasBlock(i))) { // if terminal's block is clear
+ if (!(st->airport_flags.HasBlock(i)) || (v->u.air.owned_blocks.HasBlock(i))) { // if terminal's block is clear, or aircraft has already got reservation
v->u.air.state = i; // set heading target (state) to that terminal/helipad
st->airport_flags.ReserveBlocks(SetFSMSingleBlock(&i)); // occupy terminal/helipad on airport
v->u.air.owned_blocks.ReserveBlocks(SetFSMSingleBlock(&i)); // occupy terminal/helipad on airport
@@ -2050,8 +2067,8 @@
}
}
- /* if there is only 1 terminalgroup, all terminals are checked (starting from 0 to max) */
- return FreeTerminal(v, 0, GetNumTerminals(apc));
+ /* if there is only 1 terminalgroup, all terminals are checked (starting from 1 to max) */
+ return FreeTerminal(v, 1, GetNumTerminals(apc));
}
static uint GetNumHelipads(const AirportFTAClass *apc)
@@ -2101,7 +2118,7 @@
} else {
/* only 1 helicoptergroup, check all helipads
* The blocks for helipads start after the last terminal (MAX_TERMINALS) */
- return FreeTerminal(v, MAX_TERMINALS + 1, GetNumHelipads(apc) + MAX_TERMINALS + 1);
+ return FreeTerminal(v, MAX_TERMINALS + 1, GetNumHelipads(apc) + MAX_TERMINALS);
}
return false; // it shouldn't get here anytime, but just to be sure
}
--- a/src/fsmblockmap.h Sat Aug 11 19:50:48 2007 +0000
+++ b/src/fsmblockmap.h Sat Aug 11 19:57:00 2007 +0000
@@ -27,10 +27,20 @@
blocks[1] = 0x0000000000000000;
};
+ void inline SetAll()
+ {
+ blocks[0] = 0xFFFFFFFFFFFFFFFF;
+ blocks[1] = 0xFFFFFFFFFFFFFFFF;
+ };
+
void Initialise(const byte *blocklist, int num_bytes)
{
ResetAll();
for (int i = 0; i < num_bytes; i++) {
+ if (blocklist[i] == 0xFF) {
+ SetAll();
+ break;
+ }
blocks[(blocklist[i] < 64) ? 0 : 1] |= GetBlockAsBits(blocklist[i]);
}
}
--- a/src/openttd.cpp Sat Aug 11 19:50:48 2007 +0000
+++ b/src/openttd.cpp Sat Aug 11 19:57:00 2007 +0000
@@ -1498,6 +1498,11 @@
ResetAirportToNewGRFSpec(t, st, 0x4450414F, 1);
}
break;
+ case AT_HELIPORT:
+ {
+ ResetAirportToNewGRFSpec(t, st, 0x4450414F, 2);
+ }
+ break;
case AT_COMMUTER:
{
ResetAirportToNewGRFSpec(t, st, 0x5850414F, 0);