src/order_cmd.cpp
changeset 10706 2526a335ff62
parent 10705 7527aad150cd
child 10751 ebd94f2d6385
equal deleted inserted replaced
10705:7527aad150cd 10706:2526a335ff62
   150 	this->travel_time   = 0;
   150 	this->travel_time   = 0;
   151 }
   151 }
   152 
   152 
   153 void Order::ConvertFromOldSavegame()
   153 void Order::ConvertFromOldSavegame()
   154 {
   154 {
   155 	/* First handle non-stop, because those bits are going to be reused. */
   155 	uint8 old_flags = this->flags;
       
   156 	this->flags = 0;
       
   157 
       
   158 	/* First handle non-stop */
   156 	if (_settings.gui.sg_new_nonstop) {
   159 	if (_settings.gui.sg_new_nonstop) {
   157 		/* OFB_NON_STOP */
   160 		/* OFB_NON_STOP */
   158 		this->SetNonStopType((this->flags & 8) ? ONSF_NO_STOP_AT_ANY_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
   161 		this->SetNonStopType((old_flags & 8) ? ONSF_NO_STOP_AT_ANY_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
   159 	} else {
   162 	} else {
   160 		this->SetNonStopType((this->flags & 8) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
   163 		this->SetNonStopType((old_flags & 8) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
   161 	}
   164 	}
   162 
   165 
   163 	switch (this->GetType()) {
   166 	switch (this->GetType()) {
   164 		/* Only a few types need the other savegame conversions. */
   167 		/* Only a few types need the other savegame conversions. */
   165 		case OT_GOTO_DEPOT: case OT_GOTO_STATION: case OT_LOADING: break;
   168 		case OT_GOTO_DEPOT: case OT_GOTO_STATION: case OT_LOADING: break;
   166 		default: return;
   169 		default: return;
   167 	}
   170 	}
   168 
   171 
   169 	/* Then the load/depot action flags because those bits are going to be reused too
       
   170 	 * and they reuse the non-stop bits. */
       
   171 	if (this->GetType() != OT_GOTO_DEPOT) {
   172 	if (this->GetType() != OT_GOTO_DEPOT) {
   172 		if ((this->flags & 2) != 0) { // OFB_UNLOAD
   173 		/* Then the load flags */
       
   174 		if ((old_flags & 2) != 0) { // OFB_UNLOAD
   173 			this->SetLoadType(OLFB_NO_LOAD);
   175 			this->SetLoadType(OLFB_NO_LOAD);
   174 		} else if ((this->flags & 4) == 0) { // !OFB_FULL_LOAD
   176 		} else if ((old_flags & 4) == 0) { // !OFB_FULL_LOAD
   175 			this->SetLoadType(OLF_LOAD_IF_POSSIBLE);
   177 			this->SetLoadType(OLF_LOAD_IF_POSSIBLE);
   176 		} else {
   178 		} else {
   177 			this->SetLoadType(_settings.gui.sg_full_load_any ? OLF_FULL_LOAD_ANY : OLFB_FULL_LOAD);
   179 			this->SetLoadType(_settings.gui.sg_full_load_any ? OLF_FULL_LOAD_ANY : OLFB_FULL_LOAD);
   178 		}
   180 		}
   179 	} else {
   181 
   180 		this->SetDepotActionType(((this->flags & 6) == 4) ? ODATFB_HALT : ODATF_SERVICE_ONLY);
   182 		/* Finally fix the unload flags */
   181 	}
   183 		if ((old_flags & 1) != 0) { // OFB_TRANSFER
   182 
       
   183 	/* Finally fix the unload/depot type flags. */
       
   184 	if (this->GetType() != OT_GOTO_DEPOT) {
       
   185 		if ((this->flags & 1) != 0) { // OFB_TRANSFER
       
   186 			this->SetUnloadType(OUFB_TRANSFER);
   184 			this->SetUnloadType(OUFB_TRANSFER);
   187 		} else if ((this->flags & 2) != 0) { // OFB_UNLOAD
   185 		} else if ((old_flags & 2) != 0) { // OFB_UNLOAD
   188 			this->SetUnloadType(OUFB_UNLOAD);
   186 			this->SetUnloadType(OUFB_UNLOAD);
   189 		} else {
   187 		} else {
   190 			this->SetUnloadType(OUF_UNLOAD_IF_POSSIBLE);
   188 			this->SetUnloadType(OUF_UNLOAD_IF_POSSIBLE);
   191 		}
   189 		}
   192 	} else {
   190 	} else {
   193 		uint t = ((this->flags & 6) == 6) ? ODTFB_SERVICE : ODTF_MANUAL;
   191 		/* Then the depot action flags */
   194 		if ((this->flags & 2) != 0) t |= ODTFB_PART_OF_ORDERS;
   192 		this->SetDepotActionType(((old_flags & 6) == 4) ? ODATFB_HALT : ODATF_SERVICE_ONLY);
       
   193 
       
   194 		/* Finally fix the depot type flags */
       
   195 		uint t = ((old_flags & 6) == 6) ? ODTFB_SERVICE : ODTF_MANUAL;
       
   196 		if ((old_flags & 2) != 0) t |= ODTFB_PART_OF_ORDERS;
   195 		this->SetDepotOrderType((OrderDepotTypeFlags)t);
   197 		this->SetDepotOrderType((OrderDepotTypeFlags)t);
   196 	}
   198 	}
   197 }
   199 }
   198 
   200 
   199 /**
   201 /**