(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
authorcelestar
Fri, 07 Jan 2005 09:51:16 +0000
changeset 924 433faaf547c1
parent 923 865f9716f7f5
child 925 f5fb2d73ca12
(svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
values.
-Feature: aircraft can now be refitted "mail-only"
-Feature: Passengers aircraft now ignore the amount of mail for "full
load any" options
aircraft_cmd.c
aircraft_gui.c
ttd.h
vehicle.c
--- a/aircraft_cmd.c	Fri Jan 07 09:28:16 2005 +0000
+++ b/aircraft_cmd.c	Fri Jan 07 09:51:16 2005 +0000
@@ -416,18 +416,30 @@
 	int32 cost;
 	byte SkipStoppedInHangerCheck = (p2 & 0x100) >> 8; //excludes the cargo value
 	byte new_cargo_type = p2 & 0xFF; //gets the cargo number
+	AircraftVehicleInfo *avi;
 
 	SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
 
 	v = GetVehicle(p1);
+	avi = AircraftVehInfo(v->engine_type);
 	if (!CheckOwnership(v->owner) || (!CheckStoppedInHangar(v) && !(SkipStoppedInHangerCheck)))
 		return CMD_ERROR;
 
-	pass = AircraftVehInfo(v->engine_type)->passenger_capacity;
-	if (new_cargo_type != CT_PASSENGERS) {
-		pass >>= 1;
-		if (new_cargo_type != CT_GOODS)
-			pass >>= 1;
+	switch (new_cargo_type) {
+		case CT_PASSENGERS:
+			pass = avi->passenger_capacity;
+			break;
+		case CT_MAIL:
+			pass = avi->passenger_capacity + avi->mail_capacity;
+			break;
+		case CT_GOODS:
+			pass = avi->passenger_capacity + avi->mail_capacity;
+			pass /= 2;
+			break;
+		default:
+			pass = avi->passenger_capacity + avi->mail_capacity;
+			pass /= 4;
+			break;
 	}
 	_aircraft_refit_capacity = pass;
 
@@ -440,7 +452,7 @@
 		v->cargo_cap = pass;
 
 		u = v->next;
-		mail = AircraftVehInfo(v->engine_type)->mail_capacity;
+		mail = avi->mail_capacity;
 		if (new_cargo_type != CT_PASSENGERS) {
 			mail = 0;
 		}
--- a/aircraft_gui.c	Fri Jan 07 09:28:16 2005 +0000
+++ b/aircraft_gui.c	Fri Jan 07 09:51:16 2005 +0000
@@ -204,15 +204,54 @@
 	}
 }
 
-const byte _aircraft_refit_normal[] = { 0,1,4,5,6,7,8,9,10,0xFF };
-const byte _aircraft_refit_arctic[] = { 0,1,4,5,6,7,9,11,10,0xFF };
-const byte _aircraft_refit_desert[] = { 0,4,5,8,6,7,9,10,0xFF };
-const byte _aircraft_refit_candy[] = { 0,1,3,5,7,8,9,6,4,10,11,0xFF };
+#define MAX_REFIT 0xFF
+
+const byte _aircraft_refit_normal[] = { 
+	CT_PASSENGERS,
+	CT_MAIL,
+	CT_GOODS,
+	CT_VALUABLES,
+	MAX_REFIT 
+};
+
+const byte _aircraft_refit_arctic[] = { 
+	CT_PASSENGERS,
+	CT_MAIL,
+	CT_GOODS,
+	CT_FOOD,
+	MAX_REFIT 
+};
+
+const byte _aircraft_refit_desert[] = { 
+	CT_PASSENGERS,
+	CT_MAIL,
+	CT_FRUIT,
+	CT_GOODS,
+	CT_DIAMONDS,
+	MAX_REFIT 
+};
+
+const byte _aircraft_refit_candy[] = { 
+	CT_PASSENGERS,
+	CT_SUGAR,
+	CT_TOYS,
+	CT_CANDY,
+	CT_COLA,
+	CT_COTTON_CANDY,
+	CT_BUBBLES,
+	CT_TOFFEE,
+	CT_BATTERIES,
+	CT_PLASTIC,
+	CT_FIZZY_DRINKS,
+	MAX_REFIT
+};
 
 const byte * const _aircraft_refit_types[4] = {
 	_aircraft_refit_normal, _aircraft_refit_arctic, _aircraft_refit_desert, _aircraft_refit_candy
 };
 
+#undef MAX_REFIT
+
 static void AircraftRefitWndProc(Window *w, WindowEvent *e)
 {
 	switch(e->event) {
--- a/ttd.h	Fri Jan 07 09:28:16 2005 +0000
+++ b/ttd.h	Fri Jan 07 09:51:16 2005 +0000
@@ -239,14 +239,18 @@
 	CT_FOOD = 11,
 
 	// Arctic
+	CT_WHEAT = 6,
 	CT_HILLY_UNUSED = 8,
 	CT_PAPER = 9,
+	CT_GOLD = 10,
 
 	// Tropic
 	CT_RUBBER = 1,
 	CT_FRUIT = 4,
+	CT_MAIZE = 6,
 	CT_COPPER_ORE = 8,
 	CT_WATER = 9,
+	CT_DIAMONDS = 10,
 
 	// Toyland
 	CT_SUGAR = 1,
--- a/vehicle.c	Fri Jan 07 09:28:16 2005 +0000
+++ b/vehicle.c	Fri Jan 07 09:51:16 2005 +0000
@@ -597,6 +597,14 @@
 {
 	uint32 full = 0, not_full = 0;
 
+	//special handling of aircraft
+	
+	//if the aircraft carries passengers and is NOT full, then
+	//continue loading, no matter how much mail is in
+	if ((v->type == VEH_Aircraft) && (v->cargo_type == CT_PASSENGERS) && (v->cargo_cap != v->cargo_count)) {
+		return true;
+	}
+
 	// patch should return "true" to continue loading, i.e. when there is no cargo type that is fully loaded.
 	do {
 		//Should never happen, but just in case future additions change this