(svn r10976) [NewGRF_ports] -Change: Additional changes to further support seaplanes. Checks now made in IsAircraftBuildable for seaplane requirement. NewGRF_ports
authorrichk
Fri, 24 Aug 2007 20:14:22 +0000
branchNewGRF_ports
changeset 6862 0b2c0e2b5356
parent 6861 e61565f715f8
child 6863 13335bf10adb
(svn r10976) [NewGRF_ports] -Change: Additional changes to further support seaplanes. Checks now made in IsAircraftBuildable for seaplane requirement.
Seaplaneport has bit 3 of subtype set.
Seaplane has bit 3 set in Action0Aircraft Prop 09 (Helicopter support). This overrides helicopters, so at the moment, no seaplane helicopters are permitted.
src/aircraft.h
src/engine.h
src/newgrf.cpp
--- a/src/aircraft.h	Thu Aug 23 22:33:11 2007 +0000
+++ b/src/aircraft.h	Fri Aug 24 20:14:22 2007 +0000
@@ -27,8 +27,9 @@
 	assert(v->type == VEH_AIRCRAFT);
 	/* To be fully correct the commented out functionality is the proper one,
 	 * but since value can only be 0 or 2, it is sufficient to only check <= 2
-	 * return (v->subtype == AIR_HELICOPTER) || (v->subtype == AIR_AIRCRAFT); */
-	return v->subtype <= AIR_AIRCRAFT;
+	 * return (v->subtype == AIR_HELICOPTER) || (v->subtype == AIR_AIRCRAFT);
+	 * limited to lower 3 bits so that seaplanes are still regarded as normal aircraft */
+	return (v->subtype & 0x07) <= AIR_AIRCRAFT;
 }
 
 /** Check if this aircraft is in a hangar
@@ -61,6 +62,7 @@
 	const AirportFTAClass *apc = st->Airport();
 	const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
 
+	if ((apc->flags & AirportFTAClass::SEAPLANES) && ((avi->subtype & AirportFTAClass::SEAPLANES) == 0)) return false;
 	return (apc->flags & (avi->subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS)) != 0;
 }
 
--- a/src/engine.h	Thu Aug 23 22:33:11 2007 +0000
+++ b/src/engine.h	Fri Aug 24 20:14:22 2007 +0000
@@ -66,7 +66,8 @@
 enum {
 	AIR_HELI = 0,
 	AIR_CTOL = 1, ///< Conventional Take Off and Landing, i.e. planes
-	AIR_FAST = 2
+	AIR_FAST = 2,
+	AIR_SEAPLANE = 8
 };
 
 struct AircraftVehicleInfo {
--- a/src/newgrf.cpp	Thu Aug 23 22:33:11 2007 +0000
+++ b/src/newgrf.cpp	Fri Aug 24 20:14:22 2007 +0000
@@ -799,13 +799,18 @@
 				avi->image_index = spriteid;
 			} break;
 
-			case 0x09: // Helicopter
-				if (grf_load_byte(&buf) == 0) {
+			case 0x09: { // Helicopter
+				uint subtype = grf_load_byte(&buf);
+				if ((subtype & 0x08) == 0x08) {
+					avi->subtype = AIR_SEAPLANE;
+					break;
+				}
+				if ((subtype & 0x03) == 0) {
 					avi->subtype = AIR_HELI;
 				} else {
 					SB(avi->subtype, 0, 1, 1); // AIR_CTOL
 				}
-				break;
+			} break;
 
 			case 0x0A: // Large
 				SB(avi->subtype, 1, 1, (grf_load_byte(&buf) != 0 ? 1 : 0)); // AIR_FAST