summaryrefslogtreecommitdiff
path: root/ship_cmd.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-01-02 17:23:04 +0000
committerbjarni <bjarni@openttd.org>2005-01-02 17:23:04 +0000
commit29d8c5bb5056dc8efa6c953595056697fc876760 (patch)
tree5fb0d626bc9f756094332a0dd97b98d42fce0a55 /ship_cmd.c
parenta11f46fed48fa6606f2d84c8f96d79efbad83197 (diff)
downloadopenttd-29d8c5bb5056dc8efa6c953595056697fc876760.tar.xz
(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()
Diffstat (limited to 'ship_cmd.c')
-rw-r--r--ship_cmd.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/ship_cmd.c b/ship_cmd.c
index 3c350d938..9d7a8553e 100644
--- a/ship_cmd.c
+++ b/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);
}