src/order_cmd.cpp
branchNewGRF_ports
changeset 10731 67db0d431d5e
parent 10724 68a692eacf22
child 10991 d8811e327d12
--- a/src/order_cmd.cpp	Mon May 26 20:45:25 2008 +0000
+++ b/src/order_cmd.cpp	Tue May 27 00:50:55 2008 +0000
@@ -152,11 +152,15 @@
 
 void Order::ConvertFromOldSavegame()
 {
-	/* First handle non-stop, because those bits are going to be reused. */
-	if (_patches.sg_new_nonstop) {
-		this->SetNonStopType((this->flags & 0x08) ? ONSF_NO_STOP_AT_ANY_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
+	uint8 old_flags = this->flags;
+	this->flags = 0;
+
+	/* First handle non-stop */
+	if (_settings.gui.sg_new_nonstop) {
+		/* OFB_NON_STOP */
+		this->SetNonStopType((old_flags & 8) ? ONSF_NO_STOP_AT_ANY_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 	} else {
-		this->SetNonStopType((this->flags & 0x08) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
+		this->SetNonStopType((old_flags & 8) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
 	}
 
 	switch (this->GetType()) {
@@ -165,31 +169,31 @@
 		default: return;
 	}
 
-	/* Then the load/depot action flags because those bits are going to be reused too
-	 * and they reuse the non-stop bits. */
 	if (this->GetType() != OT_GOTO_DEPOT) {
-		if ((this->flags & 4) == 0) {
+		/* Then the load flags */
+		if ((old_flags & 2) != 0) { // OFB_UNLOAD
+			this->SetLoadType(OLFB_NO_LOAD);
+		} else if ((old_flags & 4) == 0) { // !OFB_FULL_LOAD
 			this->SetLoadType(OLF_LOAD_IF_POSSIBLE);
 		} else {
-			this->SetLoadType(_patches.sg_full_load_any ? OLF_FULL_LOAD_ANY : OLFB_FULL_LOAD);
+			this->SetLoadType(_settings.gui.sg_full_load_any ? OLF_FULL_LOAD_ANY : OLFB_FULL_LOAD);
+		}
+
+		/* Finally fix the unload flags */
+		if ((old_flags & 1) != 0) { // OFB_TRANSFER
+			this->SetUnloadType(OUFB_TRANSFER);
+		} else if ((old_flags & 2) != 0) { // OFB_UNLOAD
+			this->SetUnloadType(OUFB_UNLOAD);
+		} else {
+			this->SetUnloadType(OUF_UNLOAD_IF_POSSIBLE);
 		}
 	} else {
-		this->SetDepotActionType(((this->flags & 6) == 4) ? ODATFB_HALT : ODATF_SERVICE_ONLY);
-	}
+		/* Then the depot action flags */
+		this->SetDepotActionType(((old_flags & 6) == 4) ? ODATFB_HALT : ODATF_SERVICE_ONLY);
 
-	/* Finally fix the unload/depot type flags. */
-	if (this->GetType() != OT_GOTO_DEPOT) {
-		uint t = ((this->flags & 1) == 0) ? OUF_UNLOAD_IF_POSSIBLE : OUFB_TRANSFER;
-		if ((this->flags & 2) != 0) t |= OUFB_UNLOAD;
-		this->SetUnloadType((OrderUnloadFlags)t);
-
-		if ((this->GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) {
-			this->SetUnloadType(OUFB_TRANSFER);
-			this->SetLoadType(OLFB_NO_LOAD);
-		}
-	} else {
-		uint t = ((this->flags & 6) == 6) ? ODTFB_SERVICE : ODTF_MANUAL;
-		if ((this->flags & 2) != 0) t |= ODTFB_PART_OF_ORDERS;
+		/* Finally fix the depot type flags */
+		uint t = ((old_flags & 6) == 6) ? ODTFB_SERVICE : ODTF_MANUAL;
+		if ((old_flags & 2) != 0) t |= ODTFB_PART_OF_ORDERS;
 		this->SetDepotOrderType((OrderDepotTypeFlags)t);
 	}
 }
@@ -451,7 +455,7 @@
 
 	if (!HasOrderPoolFree(1)) return_cmd_error(STR_8831_NO_MORE_SPACE_FOR_ORDERS);
 
-	if (v->type == VEH_SHIP && IsHumanPlayer(v->owner) && _patches.pathfinder_for_ships != VPF_NPF) {
+	if (v->type == VEH_SHIP && IsHumanPlayer(v->owner) && _settings.pf.pathfinder_for_ships != VPF_NPF) {
 		/* Make sure the new destination is not too far away from the previous */
 		const Order *prev = NULL;
 		uint n = 0;
@@ -546,7 +550,7 @@
 		}
 
 		/* Make sure to rebuild the whole list */
-		RebuildVehicleLists();
+		InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 0);
 	}
 
 	return CommandCost();
@@ -561,7 +565,7 @@
 	if (flags & DC_EXEC) {
 		DeleteVehicleOrders(dst);
 		InvalidateVehicleOrder(dst);
-		RebuildVehicleLists();
+		InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0);
 	}
 	return CommandCost();
 }
@@ -673,7 +677,7 @@
 			cur_order_id++;
 		}
 
-		RebuildVehicleLists();
+		InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 0);
 	}
 
 	return CommandCost();
@@ -811,7 +815,7 @@
 		}
 
 		/* Make sure to rebuild the whole list */
-		RebuildVehicleLists();
+		InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 0);
 	}
 
 	return CommandCost();
@@ -1075,7 +1079,7 @@
 				InvalidateVehicleOrder(dst);
 				InvalidateVehicleOrder(src);
 
-				RebuildVehicleLists();
+				InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0);
 			}
 		} break;
 
@@ -1134,7 +1138,7 @@
 
 				InvalidateVehicleOrder(dst);
 
-				RebuildVehicleLists();
+				InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0);
 			}
 		} break;
 
@@ -1273,7 +1277,7 @@
 			}
 
 			/* Copy timetable if enabled */
-			if (_patches.timetabling && !DoCommandP(0, v->index | (i << 16) | (1 << 25),
+			if (_settings.order.timetabling && !DoCommandP(0, v->index | (i << 16) | (1 << 25),
 					bak->order[i].wait_time << 16 | bak->order[i].travel_time, NULL,
 					CMD_CHANGE_TIMETABLE | CMD_NO_TEST_IF_IN_NETWORK)) {
 				break;
@@ -1386,13 +1390,13 @@
 void CheckOrders(const Vehicle* v)
 {
 	/* Does the user wants us to check things? */
-	if (_patches.order_review_system == 0) return;
+	if (_settings.gui.order_review_system == 0) return;
 
 	/* Do nothing for crashed vehicles */
 	if (v->vehstatus & VS_CRASHED) return;
 
 	/* Do nothing for stopped vehicles if setting is '1' */
-	if (_patches.order_review_system == 1 && v->vehstatus & VS_STOPPED)
+	if (_settings.gui.order_review_system == 1 && v->vehstatus & VS_STOPPED)
 		return;
 
 	/* do nothing we we're not the first vehicle in a share-chain */
@@ -1571,7 +1575,7 @@
 
 Date GetServiceIntervalClamped(uint index)
 {
-	return (_patches.servint_ispercent) ? Clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : Clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
+	return (_settings.vehicle.servint_ispercent) ? Clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : Clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
 }
 
 /**