mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
(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 )
This commit is contained in:
parent
60c07f7a9e
commit
6252d595e2
@ -399,8 +399,12 @@ int32 CmdStartStopAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// p1 = vehicle
|
||||
// p2 = if set, the aircraft will try to goto a depot, but not stop
|
||||
/* Send an aircraft to the hangar in the next station
|
||||
p1 = index of the aircraft
|
||||
p2 = bit 0..15 = index of station with hangar to use (only used if bit 17 is set)
|
||||
bit 16 = set v->set_for_replacement & do not stop in hangar
|
||||
bit 17 = goto the hangar in airport given in bit 0..15 instead of next stop
|
||||
bit 18 = clear v->set_for_replacement */
|
||||
int32 CmdSendAircraftToHangar(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
Vehicle *v;
|
||||
@ -409,11 +413,16 @@ int32 CmdSendAircraftToHangar(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
|
||||
v = GetVehicle(p1);
|
||||
|
||||
if (HASBIT(p2, 16)) v->set_for_replacement = true; //now all clients knows that the vehicle wants to be replaced
|
||||
|
||||
if (!CheckOwnership(v->owner))
|
||||
return CMD_ERROR;
|
||||
|
||||
if (HASBIT(p2, 16)) v->set_for_replacement = true; //now all clients knows that the vehicle wants to be replaced
|
||||
|
||||
if (HASBIT(p2, 18)) {
|
||||
v->set_for_replacement = false;
|
||||
return CMD_ERROR; // no need to send aircraft to a depot. We just told that it don't have to anymore
|
||||
}
|
||||
|
||||
if (v->current_order.type == OT_GOTO_DEPOT && p2 == 0) {
|
||||
if (flags & DC_EXEC) {
|
||||
if (v->current_order.flags & OF_UNLOAD) v->cur_order_index++;
|
||||
@ -1525,6 +1534,13 @@ static void AircraftEventHandler_HeliTakeOff(Vehicle *v, const AirportFTAClass *
|
||||
DoCommandP(v->tile, v->index, next_airport, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | 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)) << 16, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_SHOW_NO_ERROR);
|
||||
_current_player = OWNER_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1589,6 +1605,13 @@ static void AircraftEventHandler_Landing(Vehicle *v, const AirportFTAClass *Airp
|
||||
_current_player = _local_player;
|
||||
DoCommandP(v->tile, v->index, 1 << 16, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | 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)) << 16, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_SHOW_NO_ERROR);
|
||||
_current_player = OWNER_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
ship_cmd.c
14
ship_cmd.c
@ -299,6 +299,13 @@ static void HandleShipLoading(Vehicle *v)
|
||||
DoCommandP(v->tile, v->index, flags, NULL, CMD_SEND_SHIP_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_SHIP_TO_DEPOT | CMD_SHOW_NO_ERROR);
|
||||
_current_player = OWNER_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(b.flags & OF_NON_STOP))
|
||||
@ -949,7 +956,9 @@ int32 CmdStartStopShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
|
||||
/* Send a ship to the nearest depot
|
||||
p1 = index of the ship
|
||||
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 CmdSendShipToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
Vehicle *v;
|
||||
@ -961,8 +970,9 @@ int32 CmdSendShipToDepot(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) {
|
||||
|
Loading…
Reference in New Issue
Block a user