(svn r1323) Adding autoreplace feature
This feature works much like autorenew, but it will get you a new engine type instead of a new one of the same type. Once ordered, it will automatically replace the engines while they visits a depot. The GUI for setting this up have been added on the vehicle overview windows Note: autorenew is now autoreplace, but to the same engine type Nice new features, that was added to make this possible - windows can now have two independant vertical scrollbars - CMD_SHOW_NO_ERROR have been added as a flag for DoCommandP. It will make it do the action instead of showing the red box with estimated costs even if shift is pressed - fixed problem where enginetypes where not initialized when loading a game. It's now done in InitializeGame()
This commit is contained in:
24
ship_cmd.c
24
ship_cmd.c
@@ -400,7 +400,7 @@ static void ShipEnterDepot(Vehicle *v)
|
||||
|
||||
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
||||
|
||||
MaybeRenewVehicle(v);
|
||||
MaybeReplaceVehicle(v);
|
||||
|
||||
TriggerVehicle(v, VEHICLE_TRIGGER_DEPOT);
|
||||
|
||||
@@ -975,30 +975,38 @@ int32 CmdChangeShipServiceInt(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
|
||||
|
||||
// p1 = vehicle
|
||||
// p2 = new cargo
|
||||
// p2 = new cargo (0xFF)
|
||||
// p2 = skip check for stopped in hanger (0x0100)
|
||||
int32 CmdRefitShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
Vehicle *v;
|
||||
int32 cost;
|
||||
byte SkipStoppedInDepotCheck = (p2 & 0x100) >> 8; //excludes the cargo value
|
||||
|
||||
p2 = p2 & 0xFF;
|
||||
SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
|
||||
|
||||
v = &_vehicles[p1];
|
||||
if (!CheckOwnership(v->owner))
|
||||
return CMD_ERROR;
|
||||
|
||||
if (!IsShipDepotTile(v->tile) ||
|
||||
!(v->vehstatus&VS_STOPPED) ||
|
||||
v->u.ship.state != 0x80)
|
||||
return_cmd_error(STR_980B_SHIP_MUST_BE_STOPPED_IN);
|
||||
|
||||
if (!( SkipStoppedInDepotCheck )) {
|
||||
if (!IsShipDepotTile(v->tile) ||
|
||||
!(v->vehstatus&VS_STOPPED) ||
|
||||
v->u.ship.state != 0x80)
|
||||
return_cmd_error(STR_980B_SHIP_MUST_BE_STOPPED_IN);
|
||||
}
|
||||
|
||||
cost = 0;
|
||||
if (IS_HUMAN_PLAYER(v->owner) && (byte)p2 != v->cargo_type) {
|
||||
cost = _price.ship_base >> 7;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
v->cargo_count = 0;
|
||||
//autorefitted ships wants to keep the cargo
|
||||
//it will be checked if the cargo is valid in CmdRenewVehicle
|
||||
if (!(SkipStoppedInDepotCheck))
|
||||
v->cargo_count = 0;
|
||||
v->cargo_type = (byte)p2;
|
||||
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
||||
}
|
||||
|
Reference in New Issue
Block a user