summaryrefslogtreecommitdiff
path: root/train_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 /train_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 'train_cmd.c')
-rw-r--r--train_cmd.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/train_cmd.c b/train_cmd.c
index 5386addf4..4700ab4d4 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -1057,23 +1057,27 @@ int32 CmdForceTrainProceed(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
// p1 = vehicle to refit
-// p2 = new cargo
-
+// p2 = new cargo (0xFF)
+// p2 = skip check for stopped in hanger (0x0100)
int32 CmdRefitRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
int32 cost;
uint num;
- SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
+ byte SkipStoppedInDepotCheck = (p2 & 0x100) >> 8;
+
+ p2 = p2 & 0xFF;
+ SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
+
v = &_vehicles[p1];
- if (!CheckOwnership(v->owner) || CheckStoppedInDepot(v) < 0)
+ if (!CheckOwnership(v->owner) || ((CheckStoppedInDepot(v) < 0) && !(SkipStoppedInDepotCheck)))
return CMD_ERROR;
cost = 0;
num = 0;
-
+
do {
/* XXX: We also refit all the attached wagons en-masse if they
* can be refitted. This is how TTDPatch does it. TODO: Have
@@ -1084,12 +1088,16 @@ int32 CmdRefitRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
cost += (_price.build_railvehicle >> 8);
num += v->cargo_cap;
if (flags & DC_EXEC) {
- v->cargo_count = 0;
+ //autorefitted train cars wants to keep the cargo
+ //it will be checked if the cargo is valid in CmdReplaceVehicle
+ if (!(SkipStoppedInDepotCheck))
+ v->cargo_count = 0;
v->cargo_type = (byte)p2;
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
}
}
- } while ( (v=v->next) != NULL);
+ // SkipStoppedInDepotCheck is called by CmdReplace and it should only apply to the single car it is called for
+ } while ( (v=v->next) != NULL || SkipStoppedInDepotCheck );
_returned_refit_amount = num;
@@ -2618,7 +2626,7 @@ void TrainEnterDepot(Vehicle *v, uint tile)
v->load_unload_time_rem = 0;
v->cur_speed = 0;
- MaybeRenewVehicle(v);
+ MaybeReplaceVehicle(v);
TriggerVehicle(v, VEHICLE_TRIGGER_DEPOT);