src/oldloader.cpp
branchnoai
changeset 9869 6404afe43575
parent 9837 c9ec4f82e0d0
child 10142 56ee7da4ad56
equal deleted inserted replaced
9868:3998f2e73dda 9869:6404afe43575
   343 		/* Sometimes primary vehicles would have a nothing (invalid) order
   343 		/* Sometimes primary vehicles would have a nothing (invalid) order
   344 		 * or vehicles that could not have an order would still have a
   344 		 * or vehicles that could not have an order would still have a
   345 		 * (loading) order which causes assertions and the like later on.
   345 		 * (loading) order which causes assertions and the like later on.
   346 		 */
   346 		 */
   347 		if (!IsPlayerBuildableVehicleType(v) ||
   347 		if (!IsPlayerBuildableVehicleType(v) ||
   348 				(v->IsPrimaryVehicle() && v->current_order.type == OT_NOTHING)) {
   348 				(v->IsPrimaryVehicle() && v->current_order.IsType(OT_NOTHING))) {
   349 			v->current_order.type = OT_DUMMY;
   349 			v->current_order.MakeDummy();
   350 		}
   350 		}
   351 
   351 
   352 		FOR_ALL_VEHICLES_FROM(u, v->index + 1) {
   352 		FOR_ALL_VEHICLES_FROM(u, v->index + 1) {
   353 			/* If a vehicle has the same orders, add the link to eachother
   353 			/* If a vehicle has the same orders, add the link to eachother
   354 			 * in both vehicles */
   354 			 * in both vehicles */
   502 
   502 
   503 static bool LoadOldOrder(LoadgameState *ls, int num)
   503 static bool LoadOldOrder(LoadgameState *ls, int num)
   504 {
   504 {
   505 	if (!LoadChunk(ls, NULL, order_chunk)) return false;
   505 	if (!LoadChunk(ls, NULL, order_chunk)) return false;
   506 
   506 
   507 	AssignOrder(new (num) Order(), UnpackOldOrder(_old_order));
   507 	new (num) Order(UnpackOldOrder(_old_order));
   508 
   508 
   509 	/* Relink the orders to eachother (in TTD(Patch) the orders for one
   509 	/* Relink the orders to eachother (in TTD(Patch) the orders for one
   510 	vehicle are behind eachother, with an invalid order (OT_NOTHING) as indication that
   510 	vehicle are behind eachother, with an invalid order (OT_NOTHING) as indication that
   511 	it is the last order */
   511 	it is the last order */
   512 	if (num > 0 && GetOrder(num)->IsValid())
   512 	if (num > 0 && GetOrder(num)->IsValid())
  1006 	OCL_SVAR( OC_FILE_U16 | OC_VAR_I32, Vehicle, x_pos ),
  1006 	OCL_SVAR( OC_FILE_U16 | OC_VAR_I32, Vehicle, x_pos ),
  1007 	OCL_SVAR( OC_FILE_U16 | OC_VAR_I32, Vehicle, y_pos ),
  1007 	OCL_SVAR( OC_FILE_U16 | OC_VAR_I32, Vehicle, y_pos ),
  1008 	OCL_SVAR(  OC_UINT8, Vehicle, z_pos ),
  1008 	OCL_SVAR(  OC_UINT8, Vehicle, z_pos ),
  1009 	OCL_SVAR(  OC_UINT8, Vehicle, direction ),
  1009 	OCL_SVAR(  OC_UINT8, Vehicle, direction ),
  1010 	OCL_NULL( 2 ),         ///< x_offs and y_offs, calculated automatically
  1010 	OCL_NULL( 2 ),         ///< x_offs and y_offs, calculated automatically
  1011 	OCL_NULL( 2 ),         ///< sprite_width and sprite_height, calculated automatically
  1011 	OCL_NULL( 2 ),         ///< x_extent and y_extent, calculated automatically
  1012 	OCL_NULL( 1 ),         ///< z_height, calculated automatically
  1012 	OCL_NULL( 1 ),         ///< z_extent, calculated automatically
  1013 
  1013 
  1014 	OCL_SVAR(  OC_UINT8, Vehicle, owner ),
  1014 	OCL_SVAR(  OC_UINT8, Vehicle, owner ),
  1015 	OCL_SVAR(   OC_TILE, Vehicle, tile ),
  1015 	OCL_SVAR(   OC_TILE, Vehicle, tile ),
  1016 	OCL_SVAR( OC_UINT16, Vehicle, cur_image ),
  1016 	OCL_SVAR( OC_UINT16, Vehicle, cur_image ),
  1017 
  1017 
  1099 			 * we go over that limit something is very wrong. In that case
  1099 			 * we go over that limit something is very wrong. In that case
  1100 			 * we just assume there are no orders for the vehicle.
  1100 			 * we just assume there are no orders for the vehicle.
  1101 			 */
  1101 			 */
  1102 			if (old_id < 5000) v->orders = GetOrder(old_id);
  1102 			if (old_id < 5000) v->orders = GetOrder(old_id);
  1103 		}
  1103 		}
  1104 		AssignOrder(&v->current_order, UnpackOldOrder(_old_order));
  1104 		v->current_order.AssignOrder(UnpackOldOrder(_old_order));
  1105 
  1105 
  1106 		/* For some reason we need to correct for this */
  1106 		/* For some reason we need to correct for this */
  1107 		switch (v->spritenum) {
  1107 		switch (v->spritenum) {
  1108 			case 0xfd: break;
  1108 			case 0xfd: break;
  1109 			case 0xff: v->spritenum = 0xfe; break;
  1109 			case 0xff: v->spritenum = 0xfe; break;