summaryrefslogtreecommitdiff
path: root/aircraft_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 /aircraft_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 'aircraft_cmd.c')
-rw-r--r--aircraft_cmd.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 8236e414a..37c4e56d3 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -406,29 +406,32 @@ int32 CmdChangeAircraftServiceInt(int x, int y, uint32 flags, uint32 p1, uint32
}
// p1 = vehicle
-// p2 = new cargo type
+// p2 = new cargo type(0xFF)
+// p2 = skip check for stopped in hanger (0x0100)
int32 CmdRefitAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v,*u;
int pass, mail;
int32 cost;
+ byte SkipStoppedInHangerCheck = (p2 & 0x100) >> 8; //excludes the cargo value
+ byte new_cargo_type = p2 & 0xFF; //gets the cargo number
SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
v = &_vehicles[p1];
- if (!CheckOwnership(v->owner) || !CheckStoppedInHangar(v))
+ if (!CheckOwnership(v->owner) || (!CheckStoppedInHangar(v) && !(SkipStoppedInHangerCheck)))
return CMD_ERROR;
pass = AircraftVehInfo(v->engine_type)->passanger_capacity;
- if (p2 != 0) {
+ if (new_cargo_type != CT_PASSENGERS) {
pass >>= 1;
- if (p2 != 5)
+ if (new_cargo_type != CT_GOODS)
pass >>= 1;
}
_aircraft_refit_capacity = pass;
cost = 0;
- if (IS_HUMAN_PLAYER(v->owner) && (byte)p2 != v->cargo_type) {
+ if (IS_HUMAN_PLAYER(v->owner) && new_cargo_type != v->cargo_type) {
cost = _price.aircraft_base >> 7;
}
@@ -437,12 +440,15 @@ int32 CmdRefitAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
u = v->next;
mail = AircraftVehInfo(v->engine_type)->mail_capacity;
- if (p2 != 0) {
+ if (new_cargo_type != CT_PASSENGERS) {
mail = 0;
}
u->cargo_cap = mail;
- v->cargo_count = u->cargo_count = 0;
- v->cargo_type = (byte)p2;
+ //autorefitted planes wants to keep the cargo
+ //it will be checked if the cargo is valid in CmdReplaceVehicle
+ if (!(SkipStoppedInHangerCheck))
+ v->cargo_count = u->cargo_count = 0;
+ v->cargo_type = new_cargo_type;
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
}
@@ -1157,7 +1163,7 @@ static void AircraftEnterHangar(Vehicle *v)
ServiceAircraft(v);
- MaybeRenewVehicle(v);
+ MaybeReplaceVehicle(v);
TriggerVehicle(v, VEHICLE_TRIGGER_DEPOT);