src/newgrf.cpp
branchnoai
changeset 10645 8cbdb511a674
parent 10513 33cb70ff2f5d
child 10715 6bdf79ffb022
equal deleted inserted replaced
10644:6c4314786d68 10645:8cbdb511a674
   464 				if (speed == 0xFFFF) speed = 0;
   464 				if (speed == 0xFFFF) speed = 0;
   465 
   465 
   466 				rvi->max_speed = speed;
   466 				rvi->max_speed = speed;
   467 			} break;
   467 			} break;
   468 
   468 
   469 			case 0x0B: { // Power
   469 			case 0x0B: // Power
   470 				uint16 power = grf_load_word(&buf);
   470 				rvi->power = grf_load_word(&buf);
   471 
   471 				dewagonize(rvi->power, e);
   472 				if (rvi->railveh_type == RAILVEH_MULTIHEAD) power /= 2;
   472 				break;
   473 
   473 
   474 				rvi->power = power;
   474 			case 0x0D: // Running cost factor
   475 				dewagonize(power, e);
   475 				rvi->running_cost = grf_load_byte(&buf);
   476 			} break;
   476 				break;
   477 
       
   478 			case 0x0D: { // Running cost factor
       
   479 				uint8 runcostfact = grf_load_byte(&buf);
       
   480 
       
   481 				if (rvi->railveh_type == RAILVEH_MULTIHEAD) runcostfact /= 2;
       
   482 
       
   483 				rvi->running_cost = runcostfact;
       
   484 			} break;
       
   485 
   477 
   486 			case 0x0E: { // Running cost base
   478 			case 0x0E: { // Running cost base
   487 				uint32 base = grf_load_dword(&buf);
   479 				uint32 base = grf_load_dword(&buf);
   488 
   480 
   489 				/* These magic numbers are used in GRFs to specify the base cost:
   481 				/* These magic numbers are used in GRFs to specify the base cost:
   511 
   503 
   512 			case 0x13: { // Dual-headed
   504 			case 0x13: { // Dual-headed
   513 				uint8 dual = grf_load_byte(&buf);
   505 				uint8 dual = grf_load_byte(&buf);
   514 
   506 
   515 				if (dual != 0) {
   507 				if (dual != 0) {
   516 					if (rvi->railveh_type != RAILVEH_MULTIHEAD) {
       
   517 						// adjust power and running cost if needed
       
   518 						rvi->power /= 2;
       
   519 						rvi->running_cost /= 2;
       
   520 					}
       
   521 					rvi->railveh_type = RAILVEH_MULTIHEAD;
   508 					rvi->railveh_type = RAILVEH_MULTIHEAD;
   522 				} else {
   509 				} else {
   523 					if (rvi->railveh_type == RAILVEH_MULTIHEAD) {
       
   524 						// adjust power and running cost if needed
       
   525 						rvi->power *= 2;
       
   526 						rvi->running_cost *= 2;
       
   527 					}
       
   528 					rvi->railveh_type = rvi->power == 0 ?
   510 					rvi->railveh_type = rvi->power == 0 ?
   529 						RAILVEH_WAGON : RAILVEH_SINGLEHEAD;
   511 						RAILVEH_WAGON : RAILVEH_SINGLEHEAD;
   530 				}
   512 				}
   531 			} break;
   513 			} break;
   532 
   514