summaryrefslogtreecommitdiff
path: root/roadveh_cmd.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-01-29 01:02:47 +0000
committerbjarni <bjarni@openttd.org>2005-01-29 01:02:47 +0000
commitdb4721a31d05a259b8c3f6fa2118f81799e1dfa6 (patch)
tree0d0ec4513dede4a34d5a0b379893ef26e1520b53 /roadveh_cmd.c
parent27cd24c3169eb5bc254e32ee294dd560b3b9079a (diff)
downloadopenttd-db4721a31d05a259b8c3f6fa2118f81799e1dfa6.tar.xz
(svn r1710) - Fix: [autoreplace] vehicles do no longer go to a depot all the time if the owner clicked 'stop replacing' ( ship+aircraft+road vehicles )
Diffstat (limited to 'roadveh_cmd.c')
-rw-r--r--roadveh_cmd.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 9fa910cab..efc03e98c 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -293,7 +293,9 @@ static int FindClosestRoadDepot(Vehicle *v)
/* Send a road vehicle to the nearest depot
p1 = index of the road vehicle
- p2 = bit 0 = do not stop in depot, bit 1 = have depot in orders */
+ p2 = bit 0 = do not stop in depot
+ bit 1 = set v->set_for_replacement
+ bit 2 = clear v->set_for_replacement */
int32 CmdSendRoadVehToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v = GetVehicle(p1);
@@ -303,8 +305,9 @@ int32 CmdSendRoadVehToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return CMD_ERROR;
if (HASBIT(p2, 0)) v->set_for_replacement = true;
+ if (HASBIT(p2, 2)) v->set_for_replacement = false;
- if (HASBIT(p2, 1)) return CMD_ERROR; // vehicle has a depot in schedule. It just needed to set set_for_replacement
+ if (HASBIT(p2, 1) || HASBIT(p2, 2)) return CMD_ERROR; // vehicle has a depot in schedule. It just needed to alter set_for_replacement
if (v->current_order.type == OT_GOTO_DEPOT) {
if (flags & DC_EXEC) {
@@ -658,6 +661,13 @@ static void HandleRoadVehLoading(Vehicle *v)
DoCommandP(v->tile, v->index, flags, NULL, CMD_SEND_ROADVEH_TO_DEPOT | CMD_SHOW_NO_ERROR);
_current_player = OWNER_NONE;
}
+ } else { // no need to go to a depot
+ if (v->set_for_replacement) {
+ // it seems that the user clicked "Stop replacing"
+ _current_player = _local_player;
+ DoCommandP(v->tile, v->index, 1 | (1 << 2), NULL, CMD_SEND_ROADVEH_TO_DEPOT | CMD_SHOW_NO_ERROR);
+ _current_player = OWNER_NONE;
+ }
}
}
}