src/newgrf.cpp
changeset 10029 8253082647a9
parent 10025 4aef0b1dd009
child 10030 f57f0b2e056d
equal deleted inserted replaced
10028:1a9583c2f529 10029:8253082647a9
   537 			case 0x15: { // Cargo type
   537 			case 0x15: { // Cargo type
   538 				uint8 ctype = grf_load_byte(&buf);
   538 				uint8 ctype = grf_load_byte(&buf);
   539 
   539 
   540 				if (ctype < NUM_CARGO && HasBit(_cargo_mask, ctype)) {
   540 				if (ctype < NUM_CARGO && HasBit(_cargo_mask, ctype)) {
   541 					rvi->cargo_type = ctype;
   541 					rvi->cargo_type = ctype;
       
   542 				} else if (ctype == 0xFF) {
       
   543 					/* 0xFF is specified as 'use first refittable' */
       
   544 					rvi->cargo_type = CT_INVALID;
   542 				} else {
   545 				} else {
   543 					rvi->cargo_type = CT_INVALID;
   546 					rvi->cargo_type = CT_INVALID;
   544 					grfmsg(2, "RailVehicleChangeInfo: Invalid cargo type %d, using first refittable", ctype);
   547 					grfmsg(2, "RailVehicleChangeInfo: Invalid cargo type %d, using first refittable", ctype);
   545 				}
   548 				}
   546 			} break;
   549 			} break;
   730 			case 0x10: { // Cargo type
   733 			case 0x10: { // Cargo type
   731 				uint8 cargo = grf_load_byte(&buf);
   734 				uint8 cargo = grf_load_byte(&buf);
   732 
   735 
   733 				if (cargo < NUM_CARGO && HasBit(_cargo_mask, cargo)) {
   736 				if (cargo < NUM_CARGO && HasBit(_cargo_mask, cargo)) {
   734 					rvi->cargo_type = cargo;
   737 					rvi->cargo_type = cargo;
       
   738 				} else if (cargo == 0xFF) {
       
   739 					rvi->cargo_type = CT_INVALID;
   735 				} else {
   740 				} else {
   736 					rvi->cargo_type = CT_INVALID;
       
   737 					grfmsg(2, "RoadVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo);
   741 					grfmsg(2, "RoadVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo);
   738 				}
   742 				}
   739 			} break;
   743 			} break;
   740 
   744 
   741 			case 0x11: // Cost factor
   745 			case 0x11: // Cost factor
   847 			case 0x0C: { // Cargo type
   851 			case 0x0C: { // Cargo type
   848 				uint8 cargo = grf_load_byte(&buf);
   852 				uint8 cargo = grf_load_byte(&buf);
   849 
   853 
   850 				if (cargo < NUM_CARGO && HasBit(_cargo_mask, cargo)) {
   854 				if (cargo < NUM_CARGO && HasBit(_cargo_mask, cargo)) {
   851 					svi->cargo_type = cargo;
   855 					svi->cargo_type = cargo;
       
   856 				} else if (cargo == 0xFF) {
       
   857 					svi->cargo_type = CT_INVALID;
   852 				} else {
   858 				} else {
   853 					svi->cargo_type = CT_INVALID;
   859 					svi->cargo_type = CT_INVALID;
   854 					grfmsg(2, "ShipVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo);
   860 					grfmsg(2, "ShipVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo);
   855 				}
   861 				}
   856 			} break;
   862 			} break;