equal
deleted
inserted
replaced
1447 const RailVehicleInfo *rvi = RailVehInfo(new_engine_type); |
1447 const RailVehicleInfo *rvi = RailVehInfo(new_engine_type); |
1448 const RailVehicleInfo *rvi2 = RailVehInfo(old_engine_type); |
1448 const RailVehicleInfo *rvi2 = RailVehInfo(old_engine_type); |
1449 byte capacity = rvi->capacity; |
1449 byte capacity = rvi->capacity; |
1450 Vehicle *first = GetFirstVehicleInChain(v); |
1450 Vehicle *first = GetFirstVehicleInChain(v); |
1451 |
1451 |
|
1452 //if (v->owner == _local_player) InvalidateWindowClasses(WC_TRAINS_LIST); |
1452 /* rvi->image_index is the new sprite for the engine. Adding +1 makes the engine head the other way |
1453 /* rvi->image_index is the new sprite for the engine. Adding +1 makes the engine head the other way |
1453 if it is a multiheaded engine (rear engine) |
1454 if it is a multiheaded engine (rear engine) |
1454 (rvi->flags & RVI_MULTIHEAD && sprite - rvi2->image_index) is true if the engine is heading the other way, otherwise 0*/ |
1455 (rvi->flags & RVI_MULTIHEAD && sprite - rvi2->image_index) is true if the engine is heading the other way, otherwise 0*/ |
1455 v->spritenum = rvi->image_index + (( rvi->flags & RVI_MULTIHEAD && sprite - rvi2->image_index) ? 1 : 0); |
1456 v->spritenum = rvi->image_index + (( rvi->flags & RVI_MULTIHEAD && sprite - rvi2->image_index) ? 1 : 0); |
1456 |
1457 |
1505 Vehicle *veh = v->next; |
1506 Vehicle *veh = v->next; |
1506 do { |
1507 do { |
1507 veh->u.rail.first_engine = new_engine_type; |
1508 veh->u.rail.first_engine = new_engine_type; |
1508 } while ( (veh=veh->next) != NULL ); |
1509 } while ( (veh=veh->next) != NULL ); |
1509 } |
1510 } |
1510 |
1511 InvalidateWindowClasses(WC_TRAINS_LIST); |
1511 break; |
1512 break; |
1512 } |
1513 } |
1513 case VEH_Road: |
1514 case VEH_Road: |
1514 { |
1515 { |
1515 const RoadVehicleInfo *rvi = RoadVehInfo(new_engine_type); |
1516 const RoadVehicleInfo *rvi = RoadVehInfo(new_engine_type); |
1516 |
1517 |
1517 v->spritenum = rvi->image_index; |
1518 v->spritenum = rvi->image_index; |
1518 v->cargo_type = rvi->cargo_type; |
1519 v->cargo_type = rvi->cargo_type; |
1519 v->cargo_cap = rvi->capacity; |
1520 v->cargo_cap = rvi->capacity; |
1520 v->max_speed = rvi->max_speed; |
1521 v->max_speed = rvi->max_speed; |
|
1522 InvalidateWindowClasses(WC_ROADVEH_LIST); |
1521 break; |
1523 break; |
1522 } |
1524 } |
1523 case VEH_Ship: |
1525 case VEH_Ship: |
1524 { |
1526 { |
1525 const ShipVehicleInfo *svi = ShipVehInfo(new_engine_type); |
1527 const ShipVehicleInfo *svi = ShipVehInfo(new_engine_type); |
1531 |
1533 |
1532 // 0x0100 means that we skip the check for being stopped inside the depot |
1534 // 0x0100 means that we skip the check for being stopped inside the depot |
1533 // since we do not stop it for autorefitting |
1535 // since we do not stop it for autorefitting |
1534 if (v->cargo_type != cargo_type) |
1536 if (v->cargo_type != cargo_type) |
1535 CmdRefitShip(v->x_pos, v->y_pos, DC_EXEC, v->index , cargo_type + 0x0100 ); |
1537 CmdRefitShip(v->x_pos, v->y_pos, DC_EXEC, v->index , cargo_type + 0x0100 ); |
|
1538 InvalidateWindowClasses(WC_SHIPS_LIST); |
1536 break; |
1539 break; |
1537 } |
1540 } |
1538 case VEH_Aircraft: |
1541 case VEH_Aircraft: |
1539 { |
1542 { |
1540 const AircraftVehicleInfo *avi = AircraftVehInfo(new_engine_type); |
1543 const AircraftVehicleInfo *avi = AircraftVehInfo(new_engine_type); |
1551 } else { |
1554 } else { |
1552 // 0x0100 means that we skip the check for being stopped inside the hangar |
1555 // 0x0100 means that we skip the check for being stopped inside the hangar |
1553 // since we do not stop it for autorefitting |
1556 // since we do not stop it for autorefitting |
1554 CmdRefitAircraft(v->x_pos, v->y_pos, DC_EXEC, v->index , cargo_type + 0x0100 ); |
1557 CmdRefitAircraft(v->x_pos, v->y_pos, DC_EXEC, v->index , cargo_type + 0x0100 ); |
1555 } |
1558 } |
|
1559 InvalidateWindowClasses(WC_AIRCRAFT_LIST); |
1556 break; |
1560 break; |
1557 } |
1561 } |
1558 default: return CMD_ERROR; |
1562 default: return CMD_ERROR; |
1559 } |
1563 } |
1560 // makes sure that the cargo is still valid compared to new capacity |
1564 // makes sure that the cargo is still valid compared to new capacity |
1563 v->cargo_count = 0; |
1567 v->cargo_count = 0; |
1564 else if ( v->cargo_count > v->cargo_cap ) |
1568 else if ( v->cargo_count > v->cargo_cap ) |
1565 v->cargo_count = v->cargo_cap; |
1569 v->cargo_count = v->cargo_cap; |
1566 } |
1570 } |
1567 } |
1571 } |
|
1572 InvalidateWindow(WC_REPLACE_VEHICLE, v->type); |
|
1573 ResortVehicleLists(); |
1568 } |
1574 } |
1569 //needs to be down here because refitting will change SET_EXPENSES_TYPE if called |
1575 //needs to be down here because refitting will change SET_EXPENSES_TYPE if called |
1570 SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); |
1576 SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); |
1571 |
1577 |
1572 return cost; |
1578 return cost; |