Mercurial > hg > openttd
annotate src/order_cmd.cpp @ 13851:06143488a65f draft
(svn r18380) -Fix (r9301): One could not share orders between buses carrying different cargos.
author | frosch <frosch@openttd.org> |
---|---|
date | Wed, 02 Dec 2009 17:35:54 +0000 (2009-12-02) |
parents | 91229a735ec1 |
children | 5caf1ea3a9f9 |
rev | line source |
---|---|
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2 |
12778
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12705
diff
changeset
|
3 /* |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12705
diff
changeset
|
4 * This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12705
diff
changeset
|
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12705
diff
changeset
|
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12705
diff
changeset
|
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12705
diff
changeset
|
8 */ |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12705
diff
changeset
|
9 |
9111
d48433370037
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents:
9090
diff
changeset
|
10 /** @file order_cmd.cpp Handling of orders. */ |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6337
diff
changeset
|
11 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
12 #include "stdafx.h" |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
13 #include "debug.h" |
8116
9cc845deddfe
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents:
8114
diff
changeset
|
14 #include "command_func.h" |
10208
39cf8eebfda5
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
10207
diff
changeset
|
15 #include "company_func.h" |
8763
d6e363672edb
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium <rubidium@openttd.org>
parents:
8679
diff
changeset
|
16 #include "news_func.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
17 #include "vehicle_gui.h" |
6329
34db8eef99ef
(svn r9301) -Codechange: Use cargo class to determine if a road vehicle can stop in bus or truck stops.
peter1138 <peter1138@openttd.org>
parents:
6263
diff
changeset
|
18 #include "cargotype.h" |
8114
2d6af5d7a142
(svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
8064
diff
changeset
|
19 #include "strings_func.h" |
8131
e300ac8001ae
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium <rubidium@openttd.org>
parents:
8130
diff
changeset
|
20 #include "functions.h" |
e300ac8001ae
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium <rubidium@openttd.org>
parents:
8130
diff
changeset
|
21 #include "window_func.h" |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
22 #include "timetable.h" |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
23 #include "vehicle_func.h" |
8962
322e2779f67a
(svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium <rubidium@openttd.org>
parents:
8961
diff
changeset
|
24 #include "depot_base.h" |
12225
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
12199
diff
changeset
|
25 #include "roadstop_base.h" |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
26 #include "core/pool_func.hpp" |
11981
cf1aad9b971c
(svn r16387) -Codechange: use Aircraft instead of Vehicle where appropriate
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
27 #include "aircraft.h" |
12114
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12082
diff
changeset
|
28 #include "roadveh.h" |
12228
240adc64d01a
(svn r16643) -Codechange: replace GetStationByTile() by Station::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
29 #include "station_base.h" |
12475
c133b51890f4
(svn r16912) -Codechange: split waypoint.h in waypoint_base.h and waypoint_func.h
rubidium <rubidium@openttd.org>
parents:
12472
diff
changeset
|
30 #include "waypoint_base.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
31 |
8264
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8258
diff
changeset
|
32 #include "table/strings.h" |
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8258
diff
changeset
|
33 |
8767
c0458cd19987
(svn r12466) -Codechange: move DestinationID to a more logical location.
rubidium <rubidium@openttd.org>
parents:
8763
diff
changeset
|
34 /* DestinationID must be at least as large as every these below, because it can |
c0458cd19987
(svn r12466) -Codechange: move DestinationID to a more logical location.
rubidium <rubidium@openttd.org>
parents:
8763
diff
changeset
|
35 * be any of them |
c0458cd19987
(svn r12466) -Codechange: move DestinationID to a more logical location.
rubidium <rubidium@openttd.org>
parents:
8763
diff
changeset
|
36 */ |
c0458cd19987
(svn r12466) -Codechange: move DestinationID to a more logical location.
rubidium <rubidium@openttd.org>
parents:
8763
diff
changeset
|
37 assert_compile(sizeof(DestinationID) >= sizeof(DepotID)); |
c0458cd19987
(svn r12466) -Codechange: move DestinationID to a more logical location.
rubidium <rubidium@openttd.org>
parents:
8763
diff
changeset
|
38 assert_compile(sizeof(DestinationID) >= sizeof(StationID)); |
c0458cd19987
(svn r12466) -Codechange: move DestinationID to a more logical location.
rubidium <rubidium@openttd.org>
parents:
8763
diff
changeset
|
39 |
8268
ab53b3bf7100
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium <rubidium@openttd.org>
parents:
8264
diff
changeset
|
40 TileIndex _backup_orders_tile; |
ab53b3bf7100
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium <rubidium@openttd.org>
parents:
8264
diff
changeset
|
41 BackuppedOrders _backup_orders_data; |
ab53b3bf7100
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium <rubidium@openttd.org>
parents:
8264
diff
changeset
|
42 |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
43 OrderPool _order_pool("Order"); |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
44 INSTANTIATE_POOL_METHODS(Order) |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
45 OrderListPool _orderlist_pool("OrderList"); |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
46 INSTANTIATE_POOL_METHODS(OrderList) |
8848
066a8010467f
(svn r12600) -Codechange: make GetNonStopType return a more augmented type; not is there a non-stop order but the kind of non-stop order, so one doesn't need to check _patches.new_nonstop type everywhere.
rubidium <rubidium@openttd.org>
parents:
8847
diff
changeset
|
47 |
8834
a2a57c9df9c9
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium <rubidium@openttd.org>
parents:
8833
diff
changeset
|
48 void Order::Free() |
a2a57c9df9c9
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium <rubidium@openttd.org>
parents:
8833
diff
changeset
|
49 { |
a2a57c9df9c9
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium <rubidium@openttd.org>
parents:
8833
diff
changeset
|
50 this->type = OT_NOTHING; |
a2a57c9df9c9
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium <rubidium@openttd.org>
parents:
8833
diff
changeset
|
51 this->flags = 0; |
a2a57c9df9c9
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium <rubidium@openttd.org>
parents:
8833
diff
changeset
|
52 this->dest = 0; |
a2a57c9df9c9
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium <rubidium@openttd.org>
parents:
8833
diff
changeset
|
53 this->next = NULL; |
a2a57c9df9c9
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium <rubidium@openttd.org>
parents:
8833
diff
changeset
|
54 } |
a2a57c9df9c9
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium <rubidium@openttd.org>
parents:
8833
diff
changeset
|
55 |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
56 void Order::MakeGoToStation(StationID destination) |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
57 { |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
58 this->type = OT_GOTO_STATION; |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
59 this->flags = 0; |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
60 this->dest = destination; |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
61 } |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
62 |
11809
57fd0a8c36cb
(svn r16199) -Codechange: Pass OrderNonStopFlags also to MakeGoToDepotOrder().
frosch <frosch@openttd.org>
parents:
11730
diff
changeset
|
63 void Order::MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type, OrderDepotActionFlags action, CargoID cargo, byte subtype) |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
64 { |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
65 this->type = OT_GOTO_DEPOT; |
8853
02787d6f3834
(svn r12615) -Codechange: rename some enums related to depot orders to make it more clear that they are no loading/unloading flags. Also add more type strictness.
rubidium <rubidium@openttd.org>
parents:
8851
diff
changeset
|
66 this->SetDepotOrderType(order); |
10350
7de8b332e3f9
(svn r14601) -Fix: the nearest depot and stop in depot orders didn't work together (the vehicle didn't stop).
rubidium <rubidium@openttd.org>
parents:
10327
diff
changeset
|
67 this->SetDepotActionType(action); |
11809
57fd0a8c36cb
(svn r16199) -Codechange: Pass OrderNonStopFlags also to MakeGoToDepotOrder().
frosch <frosch@openttd.org>
parents:
11730
diff
changeset
|
68 this->SetNonStopType(non_stop_type); |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
69 this->dest = destination; |
8838
db9c6b0c9f07
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium <rubidium@openttd.org>
parents:
8836
diff
changeset
|
70 this->SetRefit(cargo, subtype); |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
71 } |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
72 |
12538
6e39a114ed49
(svn r16976) -Codechange: remove WaypointID and MAX_LENGTH constants in favour of their Station variants
rubidium <rubidium@openttd.org>
parents:
12510
diff
changeset
|
73 void Order::MakeGoToWaypoint(StationID destination) |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
74 { |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
75 this->type = OT_GOTO_WAYPOINT; |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
76 this->flags = 0; |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
77 this->dest = destination; |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
78 } |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
79 |
8843
1f412a20da48
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium <rubidium@openttd.org>
parents:
8840
diff
changeset
|
80 void Order::MakeLoading(bool ordered) |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
81 { |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
82 this->type = OT_LOADING; |
8843
1f412a20da48
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium <rubidium@openttd.org>
parents:
8840
diff
changeset
|
83 if (!ordered) this->flags = 0; |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
84 } |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
85 |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
86 void Order::MakeLeaveStation() |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
87 { |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
88 this->type = OT_LEAVESTATION; |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
89 this->flags = 0; |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
90 } |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
91 |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
92 void Order::MakeDummy() |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
93 { |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
94 this->type = OT_DUMMY; |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
95 this->flags = 0; |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
96 } |
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
97 |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
98 void Order::MakeConditional(VehicleOrderID order) |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
99 { |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
100 this->type = OT_CONDITIONAL; |
8901
f30afabf2b45
(svn r12668) -Fix (12667): swapping of variables went wrong.
rubidium <rubidium@openttd.org>
parents:
8900
diff
changeset
|
101 this->flags = order; |
f30afabf2b45
(svn r12668) -Fix (12667): swapping of variables went wrong.
rubidium <rubidium@openttd.org>
parents:
8900
diff
changeset
|
102 this->dest = 0; |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
103 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
104 |
8838
db9c6b0c9f07
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium <rubidium@openttd.org>
parents:
8836
diff
changeset
|
105 void Order::SetRefit(CargoID cargo, byte subtype) |
db9c6b0c9f07
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium <rubidium@openttd.org>
parents:
8836
diff
changeset
|
106 { |
db9c6b0c9f07
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium <rubidium@openttd.org>
parents:
8836
diff
changeset
|
107 this->refit_cargo = cargo; |
db9c6b0c9f07
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium <rubidium@openttd.org>
parents:
8836
diff
changeset
|
108 this->refit_subtype = subtype; |
db9c6b0c9f07
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium <rubidium@openttd.org>
parents:
8836
diff
changeset
|
109 } |
db9c6b0c9f07
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium <rubidium@openttd.org>
parents:
8836
diff
changeset
|
110 |
8835
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
111 bool Order::Equals(const Order &other) const |
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
112 { |
10365
8a6982cd3a55
(svn r14616) -Fix [FS#2424]: a nearest depot order should be "equal" to the resolved nearest depot order; otherwise we keep resolving the nearest depot order every tick.
rubidium <rubidium@openttd.org>
parents:
10350
diff
changeset
|
113 /* In case of go to nearest depot orders we need "only" compare the flags |
8a6982cd3a55
(svn r14616) -Fix [FS#2424]: a nearest depot order should be "equal" to the resolved nearest depot order; otherwise we keep resolving the nearest depot order every tick.
rubidium <rubidium@openttd.org>
parents:
10350
diff
changeset
|
114 * with the other and not the nearest depot order bit or the actual |
8a6982cd3a55
(svn r14616) -Fix [FS#2424]: a nearest depot order should be "equal" to the resolved nearest depot order; otherwise we keep resolving the nearest depot order every tick.
rubidium <rubidium@openttd.org>
parents:
10350
diff
changeset
|
115 * destination because those get clear/filled in during the order |
8a6982cd3a55
(svn r14616) -Fix [FS#2424]: a nearest depot order should be "equal" to the resolved nearest depot order; otherwise we keep resolving the nearest depot order every tick.
rubidium <rubidium@openttd.org>
parents:
10350
diff
changeset
|
116 * evaluation. If we do not do this the order will continuously be seen as |
8a6982cd3a55
(svn r14616) -Fix [FS#2424]: a nearest depot order should be "equal" to the resolved nearest depot order; otherwise we keep resolving the nearest depot order every tick.
rubidium <rubidium@openttd.org>
parents:
10350
diff
changeset
|
117 * a different order and it will try to find a "nearest depot" every tick. */ |
8a6982cd3a55
(svn r14616) -Fix [FS#2424]: a nearest depot order should be "equal" to the resolved nearest depot order; otherwise we keep resolving the nearest depot order every tick.
rubidium <rubidium@openttd.org>
parents:
10350
diff
changeset
|
118 if ((this->type == OT_GOTO_DEPOT && this->type == other.type) && |
8a6982cd3a55
(svn r14616) -Fix [FS#2424]: a nearest depot order should be "equal" to the resolved nearest depot order; otherwise we keep resolving the nearest depot order every tick.
rubidium <rubidium@openttd.org>
parents:
10350
diff
changeset
|
119 ((this->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0 || |
8a6982cd3a55
(svn r14616) -Fix [FS#2424]: a nearest depot order should be "equal" to the resolved nearest depot order; otherwise we keep resolving the nearest depot order every tick.
rubidium <rubidium@openttd.org>
parents:
10350
diff
changeset
|
120 (other.GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0)) { |
8a6982cd3a55
(svn r14616) -Fix [FS#2424]: a nearest depot order should be "equal" to the resolved nearest depot order; otherwise we keep resolving the nearest depot order every tick.
rubidium <rubidium@openttd.org>
parents:
10350
diff
changeset
|
121 return |
8a6982cd3a55
(svn r14616) -Fix [FS#2424]: a nearest depot order should be "equal" to the resolved nearest depot order; otherwise we keep resolving the nearest depot order every tick.
rubidium <rubidium@openttd.org>
parents:
10350
diff
changeset
|
122 this->GetDepotOrderType() == other.GetDepotOrderType() && |
8a6982cd3a55
(svn r14616) -Fix [FS#2424]: a nearest depot order should be "equal" to the resolved nearest depot order; otherwise we keep resolving the nearest depot order every tick.
rubidium <rubidium@openttd.org>
parents:
10350
diff
changeset
|
123 (this->GetDepotActionType() & ~ODATFB_NEAREST_DEPOT) == (other.GetDepotActionType() & ~ODATFB_NEAREST_DEPOT); |
8a6982cd3a55
(svn r14616) -Fix [FS#2424]: a nearest depot order should be "equal" to the resolved nearest depot order; otherwise we keep resolving the nearest depot order every tick.
rubidium <rubidium@openttd.org>
parents:
10350
diff
changeset
|
124 } |
8a6982cd3a55
(svn r14616) -Fix [FS#2424]: a nearest depot order should be "equal" to the resolved nearest depot order; otherwise we keep resolving the nearest depot order every tick.
rubidium <rubidium@openttd.org>
parents:
10350
diff
changeset
|
125 |
8835
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
126 return |
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
127 this->type == other.type && |
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
128 this->flags == other.flags && |
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
129 this->dest == other.dest; |
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
130 } |
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
131 |
8839
ebb630745ebc
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium <rubidium@openttd.org>
parents:
8838
diff
changeset
|
132 uint32 Order::Pack() const |
8834
a2a57c9df9c9
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium <rubidium@openttd.org>
parents:
8833
diff
changeset
|
133 { |
8839
ebb630745ebc
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium <rubidium@openttd.org>
parents:
8838
diff
changeset
|
134 return this->dest << 16 | this->flags << 8 | this->type; |
8834
a2a57c9df9c9
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium <rubidium@openttd.org>
parents:
8833
diff
changeset
|
135 } |
a2a57c9df9c9
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium <rubidium@openttd.org>
parents:
8833
diff
changeset
|
136 |
12199
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
137 uint16 Order::MapOldOrder() const |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
138 { |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
139 uint16 order = this->GetType(); |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
140 switch (this->type) { |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
141 case OT_GOTO_STATION: |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
142 if (this->GetUnloadType() & OUFB_UNLOAD) SetBit(order, 5); |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
143 if (this->GetLoadType() & OLFB_FULL_LOAD) SetBit(order, 6); |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
144 if (this->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) SetBit(order, 7); |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
145 order |= GB(this->GetDestination(), 0, 8) << 8; |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
146 break; |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
147 case OT_GOTO_DEPOT: |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
148 if (!(this->GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) SetBit(order, 6); |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
149 SetBit(order, 7); |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
150 order |= GB(this->GetDestination(), 0, 8) << 8; |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
151 break; |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
152 case OT_LOADING: |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
153 if (this->GetLoadType() & OLFB_FULL_LOAD) SetBit(order, 6); |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
154 break; |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
155 } |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
156 return order; |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
157 } |
8e20cb543b87
(svn r16613) -Fix [NewGRF]: some of the var action 2 80+ variables contained wrong results due to OpenTTD codechanges
yexo <yexo@openttd.org>
parents:
12114
diff
changeset
|
158 |
8839
ebb630745ebc
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium <rubidium@openttd.org>
parents:
8838
diff
changeset
|
159 Order::Order(uint32 packed) |
8834
a2a57c9df9c9
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
rubidium <rubidium@openttd.org>
parents:
8833
diff
changeset
|
160 { |
8839
ebb630745ebc
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium <rubidium@openttd.org>
parents:
8838
diff
changeset
|
161 this->type = (OrderType)GB(packed, 0, 8); |
ebb630745ebc
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium <rubidium@openttd.org>
parents:
8838
diff
changeset
|
162 this->flags = GB(packed, 8, 8); |
ebb630745ebc
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium <rubidium@openttd.org>
parents:
8838
diff
changeset
|
163 this->dest = GB(packed, 16, 16); |
ebb630745ebc
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium <rubidium@openttd.org>
parents:
8838
diff
changeset
|
164 this->next = NULL; |
ebb630745ebc
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium <rubidium@openttd.org>
parents:
8838
diff
changeset
|
165 this->refit_cargo = CT_NO_REFIT; |
ebb630745ebc
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium <rubidium@openttd.org>
parents:
8838
diff
changeset
|
166 this->refit_subtype = 0; |
ebb630745ebc
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium <rubidium@openttd.org>
parents:
8838
diff
changeset
|
167 this->wait_time = 0; |
ebb630745ebc
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium <rubidium@openttd.org>
parents:
8838
diff
changeset
|
168 this->travel_time = 0; |
ebb630745ebc
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium <rubidium@openttd.org>
parents:
8838
diff
changeset
|
169 } |
ebb630745ebc
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium <rubidium@openttd.org>
parents:
8838
diff
changeset
|
170 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
171 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
172 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
173 * Updates the widgets of a vehicle which contains the order-data |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
174 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
175 */ |
10184
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
176 void InvalidateVehicleOrder(const Vehicle *v, int data) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
177 { |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
12892
diff
changeset
|
178 SetWindowDirty(WC_VEHICLE_VIEW, v->index); |
10184
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
179 |
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
180 if (data != 0) { |
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
181 /* Calls SetDirty() too */ |
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
182 InvalidateWindowData(WC_VEHICLE_ORDERS, v->index, data); |
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
183 InvalidateWindowData(WC_VEHICLE_TIMETABLE, v->index, data); |
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
184 return; |
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
185 } |
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
186 |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
12892
diff
changeset
|
187 SetWindowDirty(WC_VEHICLE_ORDERS, v->index); |
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
12892
diff
changeset
|
188 SetWindowDirty(WC_VEHICLE_TIMETABLE, v->index); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
189 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
190 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
191 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
192 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
193 * Assign data to an order (from an other order) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
194 * This function makes sure that the index is maintained correctly |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
195 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
196 */ |
8835
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
197 void Order::AssignOrder(const Order &other) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
198 { |
8835
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
199 this->type = other.type; |
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
200 this->flags = other.flags; |
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
201 this->dest = other.dest; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
202 |
8835
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
203 this->refit_cargo = other.refit_cargo; |
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
204 this->refit_subtype = other.refit_subtype; |
6980
cb6b3e277df0
(svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros <maedhros@openttd.org>
parents:
6950
diff
changeset
|
205 |
8835
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
206 this->wait_time = other.wait_time; |
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
207 this->travel_time = other.travel_time; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
208 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
209 |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
210 void OrderList::Initialize(Order *chain, Vehicle *v) |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
211 { |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
212 this->first = chain; |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
213 this->first_shared = v; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
214 |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
215 this->num_orders = 0; |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
216 this->num_vehicles = 1; |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
217 this->timetable_duration = 0; |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
218 |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
219 for (Order *o = this->first; o != NULL; o = o->next) { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
220 ++this->num_orders; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
221 this->timetable_duration += o->wait_time + o->travel_time; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
222 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
223 |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
224 for (Vehicle *u = this->first_shared->PreviousShared(); u != NULL; u = u->PreviousShared()) { |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
225 ++this->num_vehicles; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
226 this->first_shared = u; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
227 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
228 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
229 for (const Vehicle *u = v->NextShared(); u != NULL; u = u->NextShared()) ++this->num_vehicles; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
230 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
231 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
232 void OrderList::FreeChain(bool keep_orderlist) |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
233 { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
234 Order *next; |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
235 for (Order *o = this->first; o != NULL; o = next) { |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
236 next = o->next; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
237 delete o; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
238 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
239 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
240 if (keep_orderlist) { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
241 this->first = NULL; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
242 this->num_orders = 0; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
243 this->timetable_duration = 0; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
244 } else { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
245 delete this; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
246 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
247 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
248 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
249 Order *OrderList::GetOrderAt(int index) const |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
250 { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
251 if (index < 0) return NULL; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
252 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
253 Order *order = this->first; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
254 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
255 while (order != NULL && index-- > 0) |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
256 order = order->next; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
257 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
258 return order; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
259 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
260 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
261 void OrderList::InsertOrderAt(Order *new_order, int index) |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
262 { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
263 if (this->first == NULL) { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
264 this->first = new_order; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
265 } else { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
266 if (index == 0) { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
267 /* Insert as first or only order */ |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
268 new_order->next = this->first; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
269 this->first = new_order; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
270 } else if (index >= this->num_orders) { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
271 /* index is after the last order, add it to the end */ |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
272 this->GetLastOrder()->next = new_order; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
273 } else { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
274 /* Put the new order in between */ |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
275 Order *order = this->GetOrderAt(index - 1); |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
276 new_order->next = order->next; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
277 order->next = new_order; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
278 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
279 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
280 ++this->num_orders; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
281 this->timetable_duration += new_order->wait_time + new_order->travel_time; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
282 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
283 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
284 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
285 void OrderList::DeleteOrderAt(int index) |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
286 { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
287 if (index >= this->num_orders) return; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
288 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
289 Order *to_remove; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
290 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
291 if (index == 0) { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
292 to_remove = this->first; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
293 this->first = to_remove->next; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
294 } else { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
295 Order *prev = GetOrderAt(index - 1); |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
296 to_remove = prev->next; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
297 prev->next = to_remove->next; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
298 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
299 --this->num_orders; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
300 this->timetable_duration -= (to_remove->wait_time + to_remove->travel_time); |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
301 delete to_remove; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
302 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
303 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
304 void OrderList::MoveOrder(int from, int to) |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
305 { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
306 if (from >= this->num_orders || to >= this->num_orders || from == to) return; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
307 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
308 Order *moving_one; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
309 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
310 /* Take the moving order out of the pointer-chain */ |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
311 if (from == 0) { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
312 moving_one = this->first; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
313 this->first = moving_one->next; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
314 } else { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
315 Order *one_before = GetOrderAt(from - 1); |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
316 moving_one = one_before->next; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
317 one_before->next = moving_one->next; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
318 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
319 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
320 /* Insert the moving_order again in the pointer-chain */ |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
321 if (to == 0) { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
322 moving_one->next = this->first; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
323 this->first = moving_one; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
324 } else { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
325 Order *one_before = GetOrderAt(to - 1); |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
326 moving_one->next = one_before->next; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
327 one_before->next = moving_one; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
328 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
329 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
330 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
331 void OrderList::RemoveVehicle(Vehicle *v) |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
332 { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
333 --this->num_vehicles; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
334 if (v == this->first_shared) this->first_shared = v->NextShared(); |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
335 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
336 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
337 bool OrderList::IsVehicleInSharedOrdersList(const Vehicle *v) const |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
338 { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
339 for (const Vehicle *v_shared = this->first_shared; v_shared != NULL; v_shared = v_shared->NextShared()) { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
340 if (v_shared == v) return true; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
341 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
342 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
343 return false; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
344 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
345 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
346 int OrderList::GetPositionInSharedOrderList(const Vehicle *v) const |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
347 { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
348 int count = 0; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
349 for (const Vehicle *v_shared = v->PreviousShared(); v_shared != NULL; v_shared = v_shared->PreviousShared()) count++; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
350 return count; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
351 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
352 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
353 bool OrderList::IsCompleteTimetable() const |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
354 { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
355 for (Order *o = this->first; o != NULL; o = o->next) { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
356 if (!o->IsCompletelyTimetabled()) return false; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
357 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
358 return true; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
359 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
360 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
361 void OrderList::DebugCheckSanity() const |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
362 { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
363 VehicleOrderID check_num_orders = 0; |
10556
bb3057c7eed7
(svn r14813) -Codechange: use uint instead of 'just' unsigned.
rubidium <rubidium@openttd.org>
parents:
10546
diff
changeset
|
364 uint check_num_vehicles = 0; |
13679
91229a735ec1
(svn r18204) -Codechange: introduce a type for Ticks and use it; furthermore document some related variables/functions
rubidium <rubidium@openttd.org>
parents:
13466
diff
changeset
|
365 Ticks check_timetable_duration = 0; |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
366 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
367 DEBUG(misc, 6, "Checking OrderList %hu for sanity...", this->index); |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
368 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
369 for (const Order *o = this->first; o != NULL; o = o->next) { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
370 ++check_num_orders; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
371 check_timetable_duration += o->wait_time + o->travel_time; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
372 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
373 assert(this->num_orders == check_num_orders); |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
374 assert(this->timetable_duration == check_timetable_duration); |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
375 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
376 for (const Vehicle *v = this->first_shared; v != NULL; v = v->NextShared()) { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
377 ++check_num_vehicles; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
378 assert(v->orders.list == this); |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
379 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
380 assert(this->num_vehicles == check_num_vehicles); |
13679
91229a735ec1
(svn r18204) -Codechange: introduce a type for Ticks and use it; furthermore document some related variables/functions
rubidium <rubidium@openttd.org>
parents:
13466
diff
changeset
|
381 DEBUG(misc, 6, "... detected %u orders, %u vehicles, %i ticks", (uint)this->num_orders, |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
382 this->num_vehicles, this->timetable_duration); |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
383 } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
384 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
385 /** |
10652
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
386 * Checks whether the order goes to a station or not, i.e. whether the |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
387 * destination is a station |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
388 * @param v the vehicle to check for |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
389 * @param o the order to check |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
390 * @return true if the destination is a station |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
391 */ |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
392 static inline bool OrderGoesToStation(const Vehicle *v, const Order *o) |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
393 { |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
394 return o->IsType(OT_GOTO_STATION) || |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
395 (v->type == VEH_AIRCRAFT && o->IsType(OT_GOTO_DEPOT) && !(o->GetDepotActionType() & ODATFB_NEAREST_DEPOT)); |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
396 } |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
397 |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
398 /** |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
399 * Delete all news items regarding defective orders about a vehicle |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
400 * This could kill still valid warnings (for example about void order when just |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10184
diff
changeset
|
401 * another order gets added), but assume the company will notice the problems, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
402 * when (s)he's changing the orders. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
403 */ |
10647
592ae9307430
(svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents:
10582
diff
changeset
|
404 static void DeleteOrderWarnings(const Vehicle *v) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
405 { |
12619
2f530108f787
(svn r17062) -Change: unify the naming of some 125 strings
rubidium <rubidium@openttd.org>
parents:
12538
diff
changeset
|
406 DeleteVehicleNews(v->index, STR_NEWS_VEHICLE_HAS_TOO_FEW_ORDERS); |
2f530108f787
(svn r17062) -Change: unify the naming of some 125 strings
rubidium <rubidium@openttd.org>
parents:
12538
diff
changeset
|
407 DeleteVehicleNews(v->index, STR_NEWS_VEHICLE_HAS_VOID_ORDER); |
2f530108f787
(svn r17062) -Change: unify the naming of some 125 strings
rubidium <rubidium@openttd.org>
parents:
12538
diff
changeset
|
408 DeleteVehicleNews(v->index, STR_NEWS_VEHICLE_HAS_DUPLICATE_ENTRY); |
2f530108f787
(svn r17062) -Change: unify the naming of some 125 strings
rubidium <rubidium@openttd.org>
parents:
12538
diff
changeset
|
409 DeleteVehicleNews(v->index, STR_NEWS_VEHICLE_HAS_INVALID_ENTRY); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
410 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
411 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
412 |
6071 | 413 static TileIndex GetOrderLocation(const Order& o) |
414 { | |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
415 switch (o.GetType()) { |
6071 | 416 default: NOT_REACHED(); |
12503
9da198c570da
(svn r16940) -Codechange: make the pathfinders behave the same when finding waypoints or stations, i.e. don't force exactly one destination tile for a waypoint
rubidium <rubidium@openttd.org>
parents:
12475
diff
changeset
|
417 case OT_GOTO_WAYPOINT: return Waypoint::Get(o.GetDestination())->xy; |
9da198c570da
(svn r16940) -Codechange: make the pathfinders behave the same when finding waypoints or stations, i.e. don't force exactly one destination tile for a waypoint
rubidium <rubidium@openttd.org>
parents:
12475
diff
changeset
|
418 case OT_GOTO_STATION: return Station::Get(o.GetDestination())->xy; |
9da198c570da
(svn r16940) -Codechange: make the pathfinders behave the same when finding waypoints or stations, i.e. don't force exactly one destination tile for a waypoint
rubidium <rubidium@openttd.org>
parents:
12475
diff
changeset
|
419 case OT_GOTO_DEPOT: return Depot::Get(o.GetDestination())->xy; |
6071 | 420 } |
421 } | |
422 | |
9609
fe9766039f5b
(svn r13662) -Fix [FS#2113]: crash when adding conditional orders to ships.
rubidium <rubidium@openttd.org>
parents:
9593
diff
changeset
|
423 static uint GetOrderDistance(const Order *prev, const Order *cur, const Vehicle *v, int conditional_depth = 0) |
fe9766039f5b
(svn r13662) -Fix [FS#2113]: crash when adding conditional orders to ships.
rubidium <rubidium@openttd.org>
parents:
9593
diff
changeset
|
424 { |
12361
82830e1cd892
(svn r16785) -Codechange: make ships going to buoys use OT_GOTO_WAYPOINT too
rubidium <rubidium@openttd.org>
parents:
12228
diff
changeset
|
425 assert(v->type == VEH_SHIP); |
82830e1cd892
(svn r16785) -Codechange: make ships going to buoys use OT_GOTO_WAYPOINT too
rubidium <rubidium@openttd.org>
parents:
12228
diff
changeset
|
426 |
9609
fe9766039f5b
(svn r13662) -Fix [FS#2113]: crash when adding conditional orders to ships.
rubidium <rubidium@openttd.org>
parents:
9593
diff
changeset
|
427 if (cur->IsType(OT_CONDITIONAL)) { |
10544
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
428 if (conditional_depth > v->GetNumOrders()) return 0; |
9609
fe9766039f5b
(svn r13662) -Fix [FS#2113]: crash when adding conditional orders to ships.
rubidium <rubidium@openttd.org>
parents:
9593
diff
changeset
|
429 |
fe9766039f5b
(svn r13662) -Fix [FS#2113]: crash when adding conditional orders to ships.
rubidium <rubidium@openttd.org>
parents:
9593
diff
changeset
|
430 conditional_depth++; |
10131
31d04d81597e
(svn r14317) -Fix (r13662) [FS#2298]: Order distance processing for conditional orders on ships treated v->orders as an array, and didn't use the correct next order.
peter1138 <peter1138@openttd.org>
parents:
10020
diff
changeset
|
431 |
11991
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11983
diff
changeset
|
432 int dist1 = GetOrderDistance(prev, v->GetOrder(cur->GetConditionSkipToOrder()), v, conditional_depth); |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
433 int dist2 = GetOrderDistance(prev, cur->next == NULL ? v->orders.list->GetFirstOrder() : cur->next, v, conditional_depth); |
10131
31d04d81597e
(svn r14317) -Fix (r13662) [FS#2298]: Order distance processing for conditional orders on ships treated v->orders as an array, and didn't use the correct next order.
peter1138 <peter1138@openttd.org>
parents:
10020
diff
changeset
|
434 return max(dist1, dist2); |
9609
fe9766039f5b
(svn r13662) -Fix [FS#2113]: crash when adding conditional orders to ships.
rubidium <rubidium@openttd.org>
parents:
9593
diff
changeset
|
435 } |
fe9766039f5b
(svn r13662) -Fix [FS#2113]: crash when adding conditional orders to ships.
rubidium <rubidium@openttd.org>
parents:
9593
diff
changeset
|
436 |
fe9766039f5b
(svn r13662) -Fix [FS#2113]: crash when adding conditional orders to ships.
rubidium <rubidium@openttd.org>
parents:
9593
diff
changeset
|
437 return DistanceManhattan(GetOrderLocation(*prev), GetOrderLocation(*cur)); |
fe9766039f5b
(svn r13662) -Fix [FS#2113]: crash when adding conditional orders to ships.
rubidium <rubidium@openttd.org>
parents:
9593
diff
changeset
|
438 } |
6071 | 439 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
440 /** Add an order to the orderlist of a vehicle. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
441 * @param tile unused |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6370
diff
changeset
|
442 * @param flags operation to perform |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
443 * @param p1 various bitstuffed elements |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
444 * - p1 = (bit 0 - 15) - ID of the vehicle |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
445 * - p1 = (bit 16 - 31) - the selected order (if any). If the last order is given, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
446 * the order will be inserted before that one |
10993
8bb5d1f28e00
(svn r15333) -Fix: AIs weren't restricted to a maximum length for ship orders.
Yexo <Yexo@openttd.org>
parents:
10969
diff
changeset
|
447 * the maximum vehicle order id is 254. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
448 * @param p2 packed order to insert |
13067
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
449 * @param text unused |
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
450 * @return the cost of this operation or an error |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
451 */ |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11014
diff
changeset
|
452 CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
453 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
454 VehicleID veh = GB(p1, 0, 16); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
455 VehicleOrderID sel_ord = GB(p1, 16, 16); |
8839
ebb630745ebc
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
rubidium <rubidium@openttd.org>
parents:
8838
diff
changeset
|
456 Order new_order(p2); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
457 |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
458 Vehicle *v = Vehicle::GetIfValid(veh); |
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
459 if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
460 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
461 /* Check if the inserted order is to the correct destination (owner, type), |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
462 * and has the correct flags if any */ |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
463 switch (new_order.GetType()) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
464 case OT_GOTO_STATION: { |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
465 const Station *st = Station::GetIfValid(new_order.GetDestination()); |
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
466 if (st == NULL) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
467 |
10650
92ff04e7b1d9
(svn r14952) -Codechange: unify the "can vehicle go to station" tests
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
468 if (st->owner != OWNER_NONE && !CheckOwnership(st->owner)) return CMD_ERROR; |
10652
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
469 |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11719
diff
changeset
|
470 if (!CanVehicleUseStation(v, st)) return_cmd_error(STR_ERROR_CAN_T_ADD_ORDER); |
10652
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
471 for (Vehicle *u = v->FirstShared(); u != NULL; u = u->NextShared()) { |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11719
diff
changeset
|
472 if (!CanVehicleUseStation(u, st)) return_cmd_error(STR_ERROR_CAN_T_ADD_ORDER_SHARED); |
10652
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
473 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
474 |
8856
95480237d10c
(svn r12618) -Codechange: as load and unload type are now split, some case statements got ugly.
rubidium <rubidium@openttd.org>
parents:
8855
diff
changeset
|
475 /* Non stop not allowed for non-trains. */ |
8919
f15d5f7bf51b
(svn r12689) -Feature: non-stop(or rather no non-stop) and via orders for road vehicles.
rubidium <rubidium@openttd.org>
parents:
8911
diff
changeset
|
476 if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN && v->type != VEH_ROAD) return CMD_ERROR; |
8845
bb04cb5677d8
(svn r12595) -Codechange: hide Order's flags in the last few cases.
rubidium <rubidium@openttd.org>
parents:
8843
diff
changeset
|
477 |
9665
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
478 /* No load and no unload are mutual exclusive. */ |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
479 if ((new_order.GetLoadType() & OLFB_NO_LOAD) && (new_order.GetUnloadType() & OUFB_NO_UNLOAD)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
480 |
8856
95480237d10c
(svn r12618) -Codechange: as load and unload type are now split, some case statements got ugly.
rubidium <rubidium@openttd.org>
parents:
8855
diff
changeset
|
481 /* Filter invalid load/unload types. */ |
8873
9780f2a6cd20
(svn r12640) -Codechange: let GetLoadType make a difference between full load and full load any based on the patch setting instead of using the patch setting directly.
rubidium <rubidium@openttd.org>
parents:
8872
diff
changeset
|
482 switch (new_order.GetLoadType()) { |
9090
eaa19756eb5b
(svn r12949) -Fix [FS#1978]: no loading/no unloading orders were 'forgotten' during manual replaces.
rubidium <rubidium@openttd.org>
parents:
9076
diff
changeset
|
483 case OLF_LOAD_IF_POSSIBLE: case OLFB_FULL_LOAD: case OLF_FULL_LOAD_ANY: case OLFB_NO_LOAD: break; |
8873
9780f2a6cd20
(svn r12640) -Codechange: let GetLoadType make a difference between full load and full load any based on the patch setting instead of using the patch setting directly.
rubidium <rubidium@openttd.org>
parents:
8872
diff
changeset
|
484 default: return CMD_ERROR; |
9780f2a6cd20
(svn r12640) -Codechange: let GetLoadType make a difference between full load and full load any based on the patch setting instead of using the patch setting directly.
rubidium <rubidium@openttd.org>
parents:
8872
diff
changeset
|
485 } |
9090
eaa19756eb5b
(svn r12949) -Fix [FS#1978]: no loading/no unloading orders were 'forgotten' during manual replaces.
rubidium <rubidium@openttd.org>
parents:
9076
diff
changeset
|
486 switch (new_order.GetUnloadType()) { |
eaa19756eb5b
(svn r12949) -Fix [FS#1978]: no loading/no unloading orders were 'forgotten' during manual replaces.
rubidium <rubidium@openttd.org>
parents:
9076
diff
changeset
|
487 case OUF_UNLOAD_IF_POSSIBLE: case OUFB_UNLOAD: case OUFB_TRANSFER: case OUFB_NO_UNLOAD: break; |
eaa19756eb5b
(svn r12949) -Fix [FS#1978]: no loading/no unloading orders were 'forgotten' during manual replaces.
rubidium <rubidium@openttd.org>
parents:
9076
diff
changeset
|
488 default: return CMD_ERROR; |
eaa19756eb5b
(svn r12949) -Fix [FS#1978]: no loading/no unloading orders were 'forgotten' during manual replaces.
rubidium <rubidium@openttd.org>
parents:
9076
diff
changeset
|
489 } |
11657
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
490 |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
491 /* Filter invalid stop locations */ |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
492 switch (new_order.GetStopLocation()) { |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
493 case OSL_PLATFORM_NEAR_END: |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
494 case OSL_PLATFORM_MIDDLE: |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
495 if (v->type != VEH_TRAIN) return CMD_ERROR; |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
496 /* FALL THROUGH */ |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
497 case OSL_PLATFORM_FAR_END: |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
498 break; |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
499 |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
500 default: |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
501 return CMD_ERROR; |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
502 } |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
503 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
504 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
505 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
506 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
507 case OT_GOTO_DEPOT: { |
8894
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
508 if (new_order.GetDepotActionType() != ODATFB_NEAREST_DEPOT) { |
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
509 if (v->type == VEH_AIRCRAFT) { |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
510 const Station *st = Station::GetIfValid(new_order.GetDestination()); |
8894
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
511 |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
512 if (st == NULL || !CheckOwnership(st->owner) || |
10650
92ff04e7b1d9
(svn r14952) -Codechange: unify the "can vehicle go to station" tests
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
513 !CanVehicleUseStation(v, st) || |
92ff04e7b1d9
(svn r14952) -Codechange: unify the "can vehicle go to station" tests
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
514 st->Airport()->nof_depots == 0) { |
8894
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
515 return CMD_ERROR; |
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
516 } |
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
517 } else { |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
518 const Depot *dp = Depot::GetIfValid(new_order.GetDestination()); |
8894
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
519 |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
520 if (dp == NULL || !CheckOwnership(GetTileOwner(dp->xy))) return CMD_ERROR; |
8894
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
521 |
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
522 switch (v->type) { |
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
523 case VEH_TRAIN: |
8961
b33bcd7fa037
(svn r12753) -Codechange: do not use IsDepotTypeTile() where simpler function can be used
smatz <smatz@openttd.org>
parents:
8954
diff
changeset
|
524 if (!IsRailDepotTile(dp->xy)) return CMD_ERROR; |
8894
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
525 break; |
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
526 |
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
527 case VEH_ROAD: |
8961
b33bcd7fa037
(svn r12753) -Codechange: do not use IsDepotTypeTile() where simpler function can be used
smatz <smatz@openttd.org>
parents:
8954
diff
changeset
|
528 if (!IsRoadDepotTile(dp->xy)) return CMD_ERROR; |
8894
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
529 break; |
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
530 |
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
531 case VEH_SHIP: |
8961
b33bcd7fa037
(svn r12753) -Codechange: do not use IsDepotTypeTile() where simpler function can be used
smatz <smatz@openttd.org>
parents:
8954
diff
changeset
|
532 if (!IsShipDepotTile(dp->xy)) return CMD_ERROR; |
8894
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
533 break; |
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
534 |
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
535 default: return CMD_ERROR; |
2bcad37f1d27
(svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium <rubidium@openttd.org>
parents:
8885
diff
changeset
|
536 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
537 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
538 } else { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10184
diff
changeset
|
539 if (!IsCompanyBuildableVehicleType(v)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
540 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
541 |
8919
f15d5f7bf51b
(svn r12689) -Feature: non-stop(or rather no non-stop) and via orders for road vehicles.
rubidium <rubidium@openttd.org>
parents:
8911
diff
changeset
|
542 if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN && v->type != VEH_ROAD) return CMD_ERROR; |
9593
96017719e61f
(svn r13633) -Fix: restoring 'service at depot X' orders from the order backup failed.
rubidium <rubidium@openttd.org>
parents:
9559
diff
changeset
|
543 if (new_order.GetDepotOrderType() & ~(ODTFB_PART_OF_ORDERS | ((new_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) != 0 ? ODTFB_SERVICE : 0))) return CMD_ERROR; |
11719
15d3dd64a19b
(svn r16107) -Add [NoAI]: AIOF_STOP_IN_DEPOT to the orderflags in AIOrder to allow stop-in-depot orders
yexo <yexo@openttd.org>
parents:
11680
diff
changeset
|
544 if (new_order.GetDepotActionType() & ~(ODATFB_HALT | ODATFB_NEAREST_DEPOT)) return CMD_ERROR; |
15d3dd64a19b
(svn r16107) -Add [NoAI]: AIOF_STOP_IN_DEPOT to the orderflags in AIOrder to allow stop-in-depot orders
yexo <yexo@openttd.org>
parents:
11680
diff
changeset
|
545 if ((new_order.GetDepotOrderType() & ODTFB_SERVICE) && (new_order.GetDepotActionType() & ODATFB_HALT)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
546 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
547 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
548 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
549 case OT_GOTO_WAYPOINT: { |
12472
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12377
diff
changeset
|
550 const Waypoint *wp = Waypoint::GetIfValid(new_order.GetDestination()); |
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12377
diff
changeset
|
551 if (wp == NULL) return CMD_ERROR; |
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12377
diff
changeset
|
552 |
12361
82830e1cd892
(svn r16785) -Codechange: make ships going to buoys use OT_GOTO_WAYPOINT too
rubidium <rubidium@openttd.org>
parents:
12228
diff
changeset
|
553 switch (v->type) { |
82830e1cd892
(svn r16785) -Codechange: make ships going to buoys use OT_GOTO_WAYPOINT too
rubidium <rubidium@openttd.org>
parents:
12228
diff
changeset
|
554 default: return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
555 |
12472
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12377
diff
changeset
|
556 case VEH_TRAIN: |
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12377
diff
changeset
|
557 if (!CheckOwnership(wp->owner)) return CMD_ERROR; |
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12377
diff
changeset
|
558 break; |
12361
82830e1cd892
(svn r16785) -Codechange: make ships going to buoys use OT_GOTO_WAYPOINT too
rubidium <rubidium@openttd.org>
parents:
12228
diff
changeset
|
559 |
12472
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12377
diff
changeset
|
560 case VEH_SHIP: |
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12377
diff
changeset
|
561 if (!CheckOwnership(wp->owner) && wp->owner != OWNER_NONE) return CMD_ERROR; |
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12377
diff
changeset
|
562 break; |
12361
82830e1cd892
(svn r16785) -Codechange: make ships going to buoys use OT_GOTO_WAYPOINT too
rubidium <rubidium@openttd.org>
parents:
12228
diff
changeset
|
563 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
564 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
565 /* Order flags can be any of the following for waypoints: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
566 * [non-stop] |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
567 * non-stop orders (if any) are only valid for trains */ |
8881
4fd35184e35f
(svn r12648) -Feature: allow four different non-stop types in a single game instead of two. The "TTDP compatible order" setting now only sets the default behaviour of new trains.
rubidium <rubidium@openttd.org>
parents:
8874
diff
changeset
|
568 if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN) return CMD_ERROR; |
8863
84089dccec13
(svn r12630) -Fix (r12600): Missing 'break' made it impossible to add waypoints to vehicle orders.
maedhros <maedhros@openttd.org>
parents:
8862
diff
changeset
|
569 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
570 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
571 |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
572 case OT_CONDITIONAL: { |
9665
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
573 VehicleOrderID skip_to = new_order.GetConditionSkipToOrder(); |
10544
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
574 if (skip_to != 0 && skip_to >= v->GetNumOrders()) return CMD_ERROR; // Always allow jumping to the first (even when there is no order). |
9666
172788f5a052
(svn r13753) -Cleanup (r13752): save before commit instead of the other way around is usually better.
rubidium <rubidium@openttd.org>
parents:
9665
diff
changeset
|
575 if (new_order.GetConditionVariable() > OCV_END) return CMD_ERROR; |
9665
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
576 |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
577 OrderConditionComparator occ = new_order.GetConditionComparator(); |
9666
172788f5a052
(svn r13753) -Cleanup (r13752): save before commit instead of the other way around is usually better.
rubidium <rubidium@openttd.org>
parents:
9665
diff
changeset
|
578 if (occ > OCC_END) return CMD_ERROR; |
9665
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
579 switch (new_order.GetConditionVariable()) { |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
580 case OCV_REQUIRES_SERVICE: |
9666
172788f5a052
(svn r13753) -Cleanup (r13752): save before commit instead of the other way around is usually better.
rubidium <rubidium@openttd.org>
parents:
9665
diff
changeset
|
581 if (occ != OCC_IS_TRUE && occ != OCC_IS_FALSE) return CMD_ERROR; |
9665
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
582 break; |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
583 |
9665
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
584 case OCV_UNCONDITIONALLY: |
9666
172788f5a052
(svn r13753) -Cleanup (r13752): save before commit instead of the other way around is usually better.
rubidium <rubidium@openttd.org>
parents:
9665
diff
changeset
|
585 if (occ != OCC_EQUALS) return CMD_ERROR; |
172788f5a052
(svn r13753) -Cleanup (r13752): save before commit instead of the other way around is usually better.
rubidium <rubidium@openttd.org>
parents:
9665
diff
changeset
|
586 if (new_order.GetConditionValue() != 0) return CMD_ERROR; |
9665
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
587 break; |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
588 |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
589 case OCV_LOAD_PERCENTAGE: |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
590 case OCV_RELIABILITY: |
9666
172788f5a052
(svn r13753) -Cleanup (r13752): save before commit instead of the other way around is usually better.
rubidium <rubidium@openttd.org>
parents:
9665
diff
changeset
|
591 if (new_order.GetConditionValue() > 100) return CMD_ERROR; |
9665
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
592 /* FALL THROUGH */ |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
593 default: |
9666
172788f5a052
(svn r13753) -Cleanup (r13752): save before commit instead of the other way around is usually better.
rubidium <rubidium@openttd.org>
parents:
9665
diff
changeset
|
594 if (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) return CMD_ERROR; |
9665
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
595 break; |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
596 } |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
597 } break; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
598 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
599 default: return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
600 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
601 |
10544
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
602 if (sel_ord > v->GetNumOrders()) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
603 |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11719
diff
changeset
|
604 if (v->GetNumOrders() >= MAX_VEH_ORDER_ID) return_cmd_error(STR_ERROR_TOO_MANY_ORDERS); |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11719
diff
changeset
|
605 if (!Order::CanAllocateItem()) return_cmd_error(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS); |
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11719
diff
changeset
|
606 if (v->orders.list == NULL && !OrderList::CanAllocateItem()) return_cmd_error(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
607 |
10993
8bb5d1f28e00
(svn r15333) -Fix: AIs weren't restricted to a maximum length for ship orders.
Yexo <Yexo@openttd.org>
parents:
10969
diff
changeset
|
608 if (v->type == VEH_SHIP && _settings_game.pf.pathfinder_for_ships != VPF_NPF) { |
8551
bfe75aee55ee
(svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents:
8469
diff
changeset
|
609 /* Make sure the new destination is not too far away from the previous */ |
6071 | 610 const Order *prev = NULL; |
611 uint n = 0; | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
612 |
6071 | 613 /* Find the last goto station or depot order before the insert location. |
614 * If the order is to be inserted at the beginning of the order list this | |
615 * finds the last order in the list. */ | |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
616 const Order *o; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
617 FOR_VEHICLE_ORDERS(v, o) { |
12361
82830e1cd892
(svn r16785) -Codechange: make ships going to buoys use OT_GOTO_WAYPOINT too
rubidium <rubidium@openttd.org>
parents:
12228
diff
changeset
|
618 switch (o->GetType()) { |
82830e1cd892
(svn r16785) -Codechange: make ships going to buoys use OT_GOTO_WAYPOINT too
rubidium <rubidium@openttd.org>
parents:
12228
diff
changeset
|
619 case OT_GOTO_STATION: |
82830e1cd892
(svn r16785) -Codechange: make ships going to buoys use OT_GOTO_WAYPOINT too
rubidium <rubidium@openttd.org>
parents:
12228
diff
changeset
|
620 case OT_GOTO_DEPOT: |
82830e1cd892
(svn r16785) -Codechange: make ships going to buoys use OT_GOTO_WAYPOINT too
rubidium <rubidium@openttd.org>
parents:
12228
diff
changeset
|
621 case OT_GOTO_WAYPOINT: |
82830e1cd892
(svn r16785) -Codechange: make ships going to buoys use OT_GOTO_WAYPOINT too
rubidium <rubidium@openttd.org>
parents:
12228
diff
changeset
|
622 prev = o; |
82830e1cd892
(svn r16785) -Codechange: make ships going to buoys use OT_GOTO_WAYPOINT too
rubidium <rubidium@openttd.org>
parents:
12228
diff
changeset
|
623 break; |
82830e1cd892
(svn r16785) -Codechange: make ships going to buoys use OT_GOTO_WAYPOINT too
rubidium <rubidium@openttd.org>
parents:
12228
diff
changeset
|
624 |
82830e1cd892
(svn r16785) -Codechange: make ships going to buoys use OT_GOTO_WAYPOINT too
rubidium <rubidium@openttd.org>
parents:
12228
diff
changeset
|
625 default: break; |
82830e1cd892
(svn r16785) -Codechange: make ships going to buoys use OT_GOTO_WAYPOINT too
rubidium <rubidium@openttd.org>
parents:
12228
diff
changeset
|
626 } |
6071 | 627 if (++n == sel_ord && prev != NULL) break; |
628 } | |
629 if (prev != NULL) { | |
9609
fe9766039f5b
(svn r13662) -Fix [FS#2113]: crash when adding conditional orders to ships.
rubidium <rubidium@openttd.org>
parents:
9593
diff
changeset
|
630 uint dist = GetOrderDistance(prev, &new_order, v); |
6071 | 631 if (dist >= 130) { |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11719
diff
changeset
|
632 return_cmd_error(STR_ERROR_TOO_FAR_FROM_PREVIOUS_DESTINATION); |
6071 | 633 } |
634 } | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
635 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
636 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
637 if (flags & DC_EXEC) { |
7391
1b2a34c4f7fa
(svn r10760) -Codechange: make the order struct use the pool item class as super class.
rubidium <rubidium@openttd.org>
parents:
7049
diff
changeset
|
638 Order *new_o = new Order(); |
8835
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
639 new_o->AssignOrder(new_order); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
640 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
641 /* Create new order and link in list */ |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
642 if (v->orders.list == NULL) { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
643 v->orders.list = new OrderList(new_o, v); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
644 } else { |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
645 v->orders.list->InsertOrderAt(new_o, sel_ord); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
646 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
647 |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9937
diff
changeset
|
648 Vehicle *u = v->FirstShared(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
649 DeleteOrderWarnings(u); |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9937
diff
changeset
|
650 for (; u != NULL; u = u->NextShared()) { |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
651 assert(v->orders.list == u->orders.list); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
652 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
653 /* If there is added an order before the current one, we need |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
654 to update the selected order */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
655 if (sel_ord <= u->cur_order_index) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
656 uint cur = u->cur_order_index + 1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
657 /* Check if we don't go out of bound */ |
10544
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
658 if (cur < u->GetNumOrders()) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
659 u->cur_order_index = cur; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
660 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
661 /* Update any possible open window of the vehicle */ |
10184
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
662 InvalidateVehicleOrder(u, INVALID_VEH_ORDER_ID | (sel_ord << 8)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
663 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
664 |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
665 /* As we insert an order, the order to skip to will be 'wrong'. */ |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
666 VehicleOrderID cur_order_id = 0; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
667 Order *order; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
668 FOR_VEHICLE_ORDERS(v, order) { |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
669 if (order->IsType(OT_CONDITIONAL)) { |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
670 VehicleOrderID order_id = order->GetConditionSkipToOrder(); |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
671 if (order_id >= sel_ord) { |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
672 order->SetConditionSkipToOrder(order_id + 1); |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
673 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
674 if (order_id == cur_order_id) { |
10544
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
675 order->SetConditionSkipToOrder((order_id + 1) % v->GetNumOrders()); |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
676 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
677 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
678 cur_order_id++; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
679 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
680 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
681 /* Make sure to rebuild the whole list */ |
9297
add307f2e6ea
(svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium <rubidium@openttd.org>
parents:
9234
diff
changeset
|
682 InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
683 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
684 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
685 return CommandCost(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
686 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
687 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
688 /** Declone an order-list |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
689 * @param *dst delete the orders of this vehicle |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
690 * @param flags execution flags |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
691 */ |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11014
diff
changeset
|
692 static CommandCost DecloneOrder(Vehicle *dst, DoCommandFlag flags) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
693 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
694 if (flags & DC_EXEC) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
695 DeleteVehicleOrders(dst); |
10184
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
696 InvalidateVehicleOrder(dst, -1); |
9297
add307f2e6ea
(svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium <rubidium@openttd.org>
parents:
9234
diff
changeset
|
697 InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
698 } |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
699 return CommandCost(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
700 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
701 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
702 /** Delete an order from the orderlist of a vehicle. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
703 * @param tile unused |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6370
diff
changeset
|
704 * @param flags operation to perform |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
705 * @param p1 the ID of the vehicle |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
706 * @param p2 the order to delete (max 255) |
13067
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
707 * @param text unused |
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
708 * @return the cost of this operation or an error |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
709 */ |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11014
diff
changeset
|
710 CommandCost CmdDeleteOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
711 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
712 VehicleID veh_id = p1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
713 VehicleOrderID sel_ord = p2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
714 Order *order; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
715 |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
716 Vehicle *v = Vehicle::GetIfValid(veh_id); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
717 |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
718 if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
719 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
720 /* If we did not select an order, we maybe want to de-clone the orders */ |
10544
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
721 if (sel_ord >= v->GetNumOrders()) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
722 return DecloneOrder(v, flags); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
723 |
11991
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11983
diff
changeset
|
724 order = v->GetOrder(sel_ord); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
725 if (order == NULL) return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
726 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
727 if (flags & DC_EXEC) { |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
728 v->orders.list->DeleteOrderAt(sel_ord); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
729 |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9937
diff
changeset
|
730 Vehicle *u = v->FirstShared(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
731 DeleteOrderWarnings(u); |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9937
diff
changeset
|
732 for (; u != NULL; u = u->NextShared()) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
733 if (sel_ord < u->cur_order_index) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
734 u->cur_order_index--; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
735 |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
736 assert(v->orders.list == u->orders.list); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
737 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
738 /* NON-stop flag is misused to see if a train is in a station that is |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
739 * on his order list or not */ |
8843
1f412a20da48
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium <rubidium@openttd.org>
parents:
8840
diff
changeset
|
740 if (sel_ord == u->cur_order_index && u->current_order.IsType(OT_LOADING)) { |
8848
066a8010467f
(svn r12600) -Codechange: make GetNonStopType return a more augmented type; not is there a non-stop order but the kind of non-stop order, so one doesn't need to check _patches.new_nonstop type everywhere.
rubidium <rubidium@openttd.org>
parents:
8847
diff
changeset
|
741 u->current_order.SetNonStopType(ONSF_STOP_EVERYWHERE); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
742 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
743 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
744 /* Update any possible open window of the vehicle */ |
10184
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
745 InvalidateVehicleOrder(u, sel_ord | (INVALID_VEH_ORDER_ID << 8)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
746 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
747 |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
748 /* As we delete an order, the order to skip to will be 'wrong'. */ |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
749 VehicleOrderID cur_order_id = 0; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
750 FOR_VEHICLE_ORDERS(v, order) { |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
751 if (order->IsType(OT_CONDITIONAL)) { |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
752 VehicleOrderID order_id = order->GetConditionSkipToOrder(); |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
753 if (order_id >= sel_ord) { |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
754 order->SetConditionSkipToOrder(max(order_id - 1, 0)); |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
755 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
756 if (order_id == cur_order_id) { |
10544
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
757 order->SetConditionSkipToOrder((order_id + 1) % v->GetNumOrders()); |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
758 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
759 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
760 cur_order_id++; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
761 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
762 |
9297
add307f2e6ea
(svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium <rubidium@openttd.org>
parents:
9234
diff
changeset
|
763 InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
764 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
765 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
766 return CommandCost(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
767 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
768 |
6794
4449e9d10ee5
(svn r10033) -Feature [FS#760]: skip to the selected order in the order list when clicking on the "skip" button while pressing CTRL.
rubidium <rubidium@openttd.org>
parents:
6638
diff
changeset
|
769 /** Goto order of order-list. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
770 * @param tile unused |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6370
diff
changeset
|
771 * @param flags operation to perform |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
772 * @param p1 The ID of the vehicle which order is skipped |
6794
4449e9d10ee5
(svn r10033) -Feature [FS#760]: skip to the selected order in the order list when clicking on the "skip" button while pressing CTRL.
rubidium <rubidium@openttd.org>
parents:
6638
diff
changeset
|
773 * @param p2 the selected order to which we want to skip |
13067
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
774 * @param text unused |
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
775 * @return the cost of this operation or an error |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
776 */ |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11014
diff
changeset
|
777 CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
778 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
779 VehicleID veh_id = p1; |
6794
4449e9d10ee5
(svn r10033) -Feature [FS#760]: skip to the selected order in the order list when clicking on the "skip" button while pressing CTRL.
rubidium <rubidium@openttd.org>
parents:
6638
diff
changeset
|
780 VehicleOrderID sel_ord = p2; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
781 |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
782 Vehicle *v = Vehicle::GetIfValid(veh_id); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
783 |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
784 if (v == NULL || !CheckOwnership(v->owner) || sel_ord == v->cur_order_index || |
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
785 sel_ord >= v->GetNumOrders() || v->GetNumOrders() < 2) { |
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
786 return CMD_ERROR; |
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
787 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
788 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
789 if (flags & DC_EXEC) { |
6794
4449e9d10ee5
(svn r10033) -Feature [FS#760]: skip to the selected order in the order list when clicking on the "skip" button while pressing CTRL.
rubidium <rubidium@openttd.org>
parents:
6638
diff
changeset
|
790 v->cur_order_index = sel_ord; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
791 |
12114
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12082
diff
changeset
|
792 if (v->type == VEH_ROAD) ClearSlot(RoadVehicle::From(v)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
793 |
8843
1f412a20da48
(svn r12593) -Codechange: hide Order's flags in most of the code.
rubidium <rubidium@openttd.org>
parents:
8840
diff
changeset
|
794 if (v->current_order.IsType(OT_LOADING)) v->LeaveStation(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
795 |
12892
2245b86757b7
(svn r17384) -Fix [FS#2859]: remove all order window state changes out of the drawing routine and call them immediately when changes happen instead of on the next OnPaint. This prevents pressing buttons when they should've been already disabled.
rubidium <rubidium@openttd.org>
parents:
12804
diff
changeset
|
796 InvalidateVehicleOrder(v, -2); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
797 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
798 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
799 /* We have an aircraft/ship, they have a mini-schedule, so update them all */ |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
12892
diff
changeset
|
800 if (v->type == VEH_AIRCRAFT) SetWindowClassesDirty(WC_AIRCRAFT_LIST); |
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
12892
diff
changeset
|
801 if (v->type == VEH_SHIP) SetWindowClassesDirty(WC_SHIPS_LIST); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
802 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
803 return CommandCost(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
804 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
805 |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
806 /** |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
807 * Move an order inside the orderlist |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
808 * @param tile unused |
13067
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
809 * @param flags operation to perform |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
810 * @param p1 the ID of the vehicle |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
811 * @param p2 order to move and target |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
812 * bit 0-15 : the order to move |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
813 * bit 16-31 : the target order |
13067
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
814 * @param text unused |
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
815 * @return the cost of this operation or an error |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
816 * @note The target order will move one place down in the orderlist |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
817 * if you move the order upwards else it'll move it one place down |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
818 */ |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11014
diff
changeset
|
819 CommandCost CmdMoveOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
820 { |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
821 VehicleID veh = p1; |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
822 VehicleOrderID moving_order = GB(p2, 0, 16); |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
823 VehicleOrderID target_order = GB(p2, 16, 16); |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
824 |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
825 Vehicle *v = Vehicle::GetIfValid(veh); |
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
826 if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR; |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
827 |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
828 /* Don't make senseless movements */ |
10544
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
829 if (moving_order >= v->GetNumOrders() || target_order >= v->GetNumOrders() || |
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
830 moving_order == target_order || v->GetNumOrders() <= 1) |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
831 return CMD_ERROR; |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
832 |
11991
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11983
diff
changeset
|
833 Order *moving_one = v->GetOrder(moving_order); |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
834 /* Don't move an empty order */ |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
835 if (moving_one == NULL) return CMD_ERROR; |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
836 |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
837 if (flags & DC_EXEC) { |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
838 v->orders.list->MoveOrder(moving_order, target_order); |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
839 |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
840 /* Update shared list */ |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9937
diff
changeset
|
841 Vehicle *u = v->FirstShared(); |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
842 |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
843 DeleteOrderWarnings(u); |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
844 |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9937
diff
changeset
|
845 for (; u != NULL; u = u->NextShared()) { |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
846 /* Update the current order */ |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
847 if (u->cur_order_index == moving_order) { |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
848 u->cur_order_index = target_order; |
11866
1e159ef634d5
(svn r16260) -Codechange: Add Vehicle::IncrementOrderIndex() to deduplicate some code.
frosch <frosch@openttd.org>
parents:
11809
diff
changeset
|
849 } else if (u->cur_order_index > moving_order && u->cur_order_index <= target_order) { |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
850 u->cur_order_index--; |
11866
1e159ef634d5
(svn r16260) -Codechange: Add Vehicle::IncrementOrderIndex() to deduplicate some code.
frosch <frosch@openttd.org>
parents:
11809
diff
changeset
|
851 } else if (u->cur_order_index < moving_order && u->cur_order_index >= target_order) { |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
852 u->cur_order_index++; |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
853 } |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
854 |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
855 assert(v->orders.list == u->orders.list); |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
856 /* Update any possible open window of the vehicle */ |
10184
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
857 InvalidateVehicleOrder(u, moving_order | (target_order << 8)); |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
858 } |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
859 |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
860 /* As we move an order, the order to skip to will be 'wrong'. */ |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
861 Order *order; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
862 FOR_VEHICLE_ORDERS(v, order) { |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
863 if (order->IsType(OT_CONDITIONAL)) { |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
864 VehicleOrderID order_id = order->GetConditionSkipToOrder(); |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
865 if (order_id == moving_order) { |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
866 order_id = target_order; |
12705
6b046fd8da1a
(svn r17168) -Codechange: apply coding style to if and while statements
smatz <smatz@openttd.org>
parents:
12619
diff
changeset
|
867 } else if (order_id > moving_order && order_id <= target_order) { |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
868 order_id--; |
12705
6b046fd8da1a
(svn r17168) -Codechange: apply coding style to if and while statements
smatz <smatz@openttd.org>
parents:
12619
diff
changeset
|
869 } else if (order_id < moving_order && order_id >= target_order) { |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
870 order_id++; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
871 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
872 order->SetConditionSkipToOrder(order_id); |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
873 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
874 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
875 |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
876 /* Make sure to rebuild the whole list */ |
9297
add307f2e6ea
(svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium <rubidium@openttd.org>
parents:
9234
diff
changeset
|
877 InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 0); |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
878 } |
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
879 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
880 return CommandCost(); |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
881 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
882 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
883 /** Modify an order in the orderlist of a vehicle. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
884 * @param tile unused |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6370
diff
changeset
|
885 * @param flags operation to perform |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
886 * @param p1 various bitstuffed elements |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
887 * - p1 = (bit 0 - 15) - ID of the vehicle |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
888 * - p1 = (bit 16 - 31) - the selected order (if any). If the last order is given, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
889 * the order will be inserted before that one |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
890 * only the first 8 bits used currently (bit 16 - 23) (max 255) |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
891 * @param p2 various bitstuffed elements |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
892 * - p2 = (bit 0 - 3) - what data to modify (@see ModifyOrderFlags) |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
893 * - p2 = (bit 4 - 15) - the data to modify |
13067
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
894 * @param text unused |
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
895 * @return the cost of this operation or an error |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
896 */ |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11014
diff
changeset
|
897 CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
898 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
899 VehicleOrderID sel_ord = GB(p1, 16, 16); // XXX - automatically truncated to 8 bits. |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
900 VehicleID veh = GB(p1, 0, 16); |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
901 ModifyOrderFlags mof = (ModifyOrderFlags)GB(p2, 0, 4); |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
902 uint16 data = GB(p2, 4, 11); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
903 |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
904 if (mof >= MOF_END) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
905 |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
906 Vehicle *v = Vehicle::GetIfValid(veh); |
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
907 if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
908 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
909 /* Is it a valid order? */ |
10544
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
910 if (sel_ord >= v->GetNumOrders()) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
911 |
11991
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11983
diff
changeset
|
912 Order *order = v->GetOrder(sel_ord); |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
913 switch (order->GetType()) { |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
914 case OT_GOTO_STATION: |
12361
82830e1cd892
(svn r16785) -Codechange: make ships going to buoys use OT_GOTO_WAYPOINT too
rubidium <rubidium@openttd.org>
parents:
12228
diff
changeset
|
915 if (mof == MOF_COND_VARIABLE || mof == MOF_COND_COMPARATOR || mof == MOF_DEPOT_ACTION || mof == MOF_COND_VALUE) return CMD_ERROR; |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
916 break; |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
917 |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
918 case OT_GOTO_DEPOT: |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
919 if (mof != MOF_NON_STOP && mof != MOF_DEPOT_ACTION) return CMD_ERROR; |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
920 break; |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
921 |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
922 case OT_GOTO_WAYPOINT: |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
923 if (mof != MOF_NON_STOP) return CMD_ERROR; |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
924 break; |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
925 |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
926 case OT_CONDITIONAL: |
11680
e5e2c43d90df
(svn r16063) -Fix (r13752): MOF_COND_DESTINATION was not accepted by CmdModifyOrder(). (only used by AI)
frosch <frosch@openttd.org>
parents:
11657
diff
changeset
|
927 if (mof != MOF_COND_VARIABLE && mof != MOF_COND_COMPARATOR && mof != MOF_COND_VALUE && mof != MOF_COND_DESTINATION) return CMD_ERROR; |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
928 break; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
929 |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
930 default: |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
931 return CMD_ERROR; |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
932 } |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
933 |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
934 switch (mof) { |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
935 default: NOT_REACHED(); |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
936 |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
937 case MOF_NON_STOP: |
8919
f15d5f7bf51b
(svn r12689) -Feature: non-stop(or rather no non-stop) and via orders for road vehicles.
rubidium <rubidium@openttd.org>
parents:
8911
diff
changeset
|
938 if (v->type != VEH_TRAIN && v->type != VEH_ROAD) return CMD_ERROR; |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
939 if (data >= ONSF_END) return CMD_ERROR; |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
940 if (data == order->GetNonStopType()) return CMD_ERROR; |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
941 break; |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
942 |
11657
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
943 case MOF_STOP_LOCATION: |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
944 if (v->type != VEH_TRAIN) return CMD_ERROR; |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
945 if (data >= OSL_END) return CMD_ERROR; |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
946 break; |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
947 |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
948 case MOF_UNLOAD: |
8883
23eea6824c4b
(svn r12650) -Feature: ability to force a vehicle to not load at a station.
rubidium <rubidium@openttd.org>
parents:
8881
diff
changeset
|
949 if ((data & ~(OUFB_UNLOAD | OUFB_TRANSFER | OUFB_NO_UNLOAD)) != 0) return CMD_ERROR; |
23eea6824c4b
(svn r12650) -Feature: ability to force a vehicle to not load at a station.
rubidium <rubidium@openttd.org>
parents:
8881
diff
changeset
|
950 /* Unload and no-unload are mutual exclusive and so are transfer and no unload. */ |
23eea6824c4b
(svn r12650) -Feature: ability to force a vehicle to not load at a station.
rubidium <rubidium@openttd.org>
parents:
8881
diff
changeset
|
951 if (data != 0 && ((data & (OUFB_UNLOAD | OUFB_TRANSFER)) != 0) == ((data & OUFB_NO_UNLOAD) != 0)) return CMD_ERROR; |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
952 if (data == order->GetUnloadType()) return CMD_ERROR; |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
953 break; |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
954 |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
955 case MOF_LOAD: |
8883
23eea6824c4b
(svn r12650) -Feature: ability to force a vehicle to not load at a station.
rubidium <rubidium@openttd.org>
parents:
8881
diff
changeset
|
956 if (data > OLFB_NO_LOAD || data == 1) return CMD_ERROR; |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
957 if (data == order->GetLoadType()) return CMD_ERROR; |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
958 break; |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
959 |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
960 case MOF_DEPOT_ACTION: |
10285
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
961 if (data >= DA_END) return CMD_ERROR; |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
962 break; |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
963 |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
964 case MOF_COND_VARIABLE: |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
965 if (data >= OCV_END) return CMD_ERROR; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
966 break; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
967 |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
968 case MOF_COND_COMPARATOR: |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
969 if (data >= OCC_END) return CMD_ERROR; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
970 switch (order->GetConditionVariable()) { |
8903
d15e125c0b6a
(svn r12670) -Add: unconditional/always order 'jump/skip' variable.
rubidium <rubidium@openttd.org>
parents:
8901
diff
changeset
|
971 case OCV_UNCONDITIONALLY: return CMD_ERROR; |
d15e125c0b6a
(svn r12670) -Add: unconditional/always order 'jump/skip' variable.
rubidium <rubidium@openttd.org>
parents:
8901
diff
changeset
|
972 |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
973 case OCV_REQUIRES_SERVICE: |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
974 if (data != OCC_IS_TRUE && data != OCC_IS_FALSE) return CMD_ERROR; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
975 break; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
976 |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
977 default: |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
978 if (data == OCC_IS_TRUE || data == OCC_IS_FALSE) return CMD_ERROR; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
979 break; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
980 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
981 break; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
982 |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
983 case MOF_COND_VALUE: |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
984 switch (order->GetConditionVariable()) { |
8903
d15e125c0b6a
(svn r12670) -Add: unconditional/always order 'jump/skip' variable.
rubidium <rubidium@openttd.org>
parents:
8901
diff
changeset
|
985 case OCV_UNCONDITIONALLY: return CMD_ERROR; |
d15e125c0b6a
(svn r12670) -Add: unconditional/always order 'jump/skip' variable.
rubidium <rubidium@openttd.org>
parents:
8901
diff
changeset
|
986 |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
987 case OCV_LOAD_PERCENTAGE: |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
988 case OCV_RELIABILITY: |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
989 if (data > 100) return CMD_ERROR; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
990 break; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
991 |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
992 default: |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
993 if (data > 2047) return CMD_ERROR; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
994 break; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
995 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
996 break; |
9665
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
997 |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
998 case MOF_COND_DESTINATION: |
10544
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
999 if (data >= v->GetNumOrders()) return CMD_ERROR; |
9665
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1000 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1001 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1002 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1003 if (flags & DC_EXEC) { |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
1004 switch (mof) { |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
1005 case MOF_NON_STOP: |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
1006 order->SetNonStopType((OrderNonStopFlags)data); |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
1007 break; |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
1008 |
11657
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
1009 case MOF_STOP_LOCATION: |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
1010 order->SetStopLocation((OrderStopLocation)data); |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
1011 break; |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11090
diff
changeset
|
1012 |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
1013 case MOF_UNLOAD: |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
1014 order->SetUnloadType((OrderUnloadFlags)data); |
8885
2d7e1a978a1a
(svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium <rubidium@openttd.org>
parents:
8883
diff
changeset
|
1015 if ((data & OUFB_NO_UNLOAD) != 0 && (order->GetLoadType() & OLFB_NO_LOAD) != 0) { |
8883
23eea6824c4b
(svn r12650) -Feature: ability to force a vehicle to not load at a station.
rubidium <rubidium@openttd.org>
parents:
8881
diff
changeset
|
1016 order->SetLoadType((OrderLoadFlags)(order->GetLoadType() & ~OLFB_NO_LOAD)); |
23eea6824c4b
(svn r12650) -Feature: ability to force a vehicle to not load at a station.
rubidium <rubidium@openttd.org>
parents:
8881
diff
changeset
|
1017 } |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
1018 break; |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
1019 |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
1020 case MOF_LOAD: |
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
1021 order->SetLoadType((OrderLoadFlags)data); |
8885
2d7e1a978a1a
(svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium <rubidium@openttd.org>
parents:
8883
diff
changeset
|
1022 if ((data & OLFB_NO_LOAD) != 0 && (order->GetUnloadType() & OUFB_NO_UNLOAD) != 0) { |
2d7e1a978a1a
(svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium <rubidium@openttd.org>
parents:
8883
diff
changeset
|
1023 /* No load + no unload isn't compatible */ |
2d7e1a978a1a
(svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium <rubidium@openttd.org>
parents:
8883
diff
changeset
|
1024 order->SetUnloadType((OrderUnloadFlags)(order->GetUnloadType() & ~OUFB_NO_UNLOAD)); |
8883
23eea6824c4b
(svn r12650) -Feature: ability to force a vehicle to not load at a station.
rubidium <rubidium@openttd.org>
parents:
8881
diff
changeset
|
1025 } |
8845
bb04cb5677d8
(svn r12595) -Codechange: hide Order's flags in the last few cases.
rubidium <rubidium@openttd.org>
parents:
8843
diff
changeset
|
1026 break; |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
1027 |
10285
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1028 case MOF_DEPOT_ACTION: { |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1029 switch (data) { |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1030 case DA_ALWAYS_GO: |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1031 order->SetDepotOrderType((OrderDepotTypeFlags)(order->GetDepotOrderType() & ~ODTFB_SERVICE)); |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1032 order->SetDepotActionType((OrderDepotActionFlags)(order->GetDepotActionType() & ~ODATFB_HALT)); |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1033 break; |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1034 |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1035 case DA_SERVICE: |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1036 order->SetDepotOrderType((OrderDepotTypeFlags)(order->GetDepotOrderType() | ODTFB_SERVICE)); |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1037 order->SetDepotActionType((OrderDepotActionFlags)(order->GetDepotActionType() & ~ODATFB_HALT)); |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1038 break; |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1039 |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1040 case DA_STOP: |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1041 order->SetDepotOrderType((OrderDepotTypeFlags)(order->GetDepotOrderType() & ~ODTFB_SERVICE)); |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1042 order->SetDepotActionType((OrderDepotActionFlags)(order->GetDepotActionType() | ODATFB_HALT)); |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1043 break; |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1044 |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1045 default: |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1046 NOT_REACHED(); |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1047 } |
615db2678973
(svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10226
diff
changeset
|
1048 } break; |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
1049 |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1050 case MOF_COND_VARIABLE: { |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1051 order->SetConditionVariable((OrderConditionVariable)data); |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1052 |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1053 OrderConditionComparator occ = order->GetConditionComparator(); |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1054 switch (order->GetConditionVariable()) { |
8903
d15e125c0b6a
(svn r12670) -Add: unconditional/always order 'jump/skip' variable.
rubidium <rubidium@openttd.org>
parents:
8901
diff
changeset
|
1055 case OCV_UNCONDITIONALLY: |
d15e125c0b6a
(svn r12670) -Add: unconditional/always order 'jump/skip' variable.
rubidium <rubidium@openttd.org>
parents:
8901
diff
changeset
|
1056 order->SetConditionComparator(OCC_EQUALS); |
d15e125c0b6a
(svn r12670) -Add: unconditional/always order 'jump/skip' variable.
rubidium <rubidium@openttd.org>
parents:
8901
diff
changeset
|
1057 order->SetConditionValue(0); |
d15e125c0b6a
(svn r12670) -Add: unconditional/always order 'jump/skip' variable.
rubidium <rubidium@openttd.org>
parents:
8901
diff
changeset
|
1058 break; |
d15e125c0b6a
(svn r12670) -Add: unconditional/always order 'jump/skip' variable.
rubidium <rubidium@openttd.org>
parents:
8901
diff
changeset
|
1059 |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1060 case OCV_REQUIRES_SERVICE: |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1061 if (occ != OCC_IS_TRUE && occ != OCC_IS_FALSE) order->SetConditionComparator(OCC_IS_TRUE); |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1062 break; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1063 |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1064 case OCV_LOAD_PERCENTAGE: |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1065 case OCV_RELIABILITY: |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1066 if (order->GetConditionValue() > 100) order->SetConditionValue(100); |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1067 /* FALL THROUGH */ |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1068 default: |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1069 if (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) order->SetConditionComparator(OCC_EQUALS); |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1070 break; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1071 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1072 } break; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1073 |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1074 case MOF_COND_COMPARATOR: |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1075 order->SetConditionComparator((OrderConditionComparator)data); |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1076 break; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1077 |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1078 case MOF_COND_VALUE: |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1079 order->SetConditionValue(data); |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1080 break; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1081 |
9665
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1082 case MOF_COND_DESTINATION: |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1083 order->SetConditionSkipToOrder(data); |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1084 break; |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1085 |
8845
bb04cb5677d8
(svn r12595) -Codechange: hide Order's flags in the last few cases.
rubidium <rubidium@openttd.org>
parents:
8843
diff
changeset
|
1086 default: NOT_REACHED(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1087 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1088 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1089 /* Update the windows and full load flags, also for vehicles that share the same order list */ |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9937
diff
changeset
|
1090 Vehicle *u = v->FirstShared(); |
8869
202439e9e12c
(svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium <rubidium@openttd.org>
parents:
8866
diff
changeset
|
1091 DeleteOrderWarnings(u); |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9937
diff
changeset
|
1092 for (; u != NULL; u = u->NextShared()) { |
8872
32505929420d
(svn r12639) -Fix: order window was not marked dirty on changed orders.
rubidium <rubidium@openttd.org>
parents:
8869
diff
changeset
|
1093 /* Toggle u->current_order "Full load" flag if it changed. |
32505929420d
(svn r12639) -Fix: order window was not marked dirty on changed orders.
rubidium <rubidium@openttd.org>
parents:
8869
diff
changeset
|
1094 * However, as the same flag is used for depot orders, check |
32505929420d
(svn r12639) -Fix: order window was not marked dirty on changed orders.
rubidium <rubidium@openttd.org>
parents:
8869
diff
changeset
|
1095 * whether we are not going to a depot as there are three |
32505929420d
(svn r12639) -Fix: order window was not marked dirty on changed orders.
rubidium <rubidium@openttd.org>
parents:
8869
diff
changeset
|
1096 * cases where the full load flag can be active and only |
32505929420d
(svn r12639) -Fix: order window was not marked dirty on changed orders.
rubidium <rubidium@openttd.org>
parents:
8869
diff
changeset
|
1097 * one case where the flag is used for depot orders. In the |
32505929420d
(svn r12639) -Fix: order window was not marked dirty on changed orders.
rubidium <rubidium@openttd.org>
parents:
8869
diff
changeset
|
1098 * other cases for the OrderTypeByte the flags are not used, |
32505929420d
(svn r12639) -Fix: order window was not marked dirty on changed orders.
rubidium <rubidium@openttd.org>
parents:
8869
diff
changeset
|
1099 * so do not care and those orders should not be active |
32505929420d
(svn r12639) -Fix: order window was not marked dirty on changed orders.
rubidium <rubidium@openttd.org>
parents:
8869
diff
changeset
|
1100 * when this function is called. |
32505929420d
(svn r12639) -Fix: order window was not marked dirty on changed orders.
rubidium <rubidium@openttd.org>
parents:
8869
diff
changeset
|
1101 */ |
32505929420d
(svn r12639) -Fix: order window was not marked dirty on changed orders.
rubidium <rubidium@openttd.org>
parents:
8869
diff
changeset
|
1102 if (sel_ord == u->cur_order_index && |
32505929420d
(svn r12639) -Fix: order window was not marked dirty on changed orders.
rubidium <rubidium@openttd.org>
parents:
8869
diff
changeset
|
1103 (u->current_order.IsType(OT_GOTO_STATION) || u->current_order.IsType(OT_LOADING)) && |
32505929420d
(svn r12639) -Fix: order window was not marked dirty on changed orders.
rubidium <rubidium@openttd.org>
parents:
8869
diff
changeset
|
1104 u->current_order.GetLoadType() != order->GetLoadType()) { |
32505929420d
(svn r12639) -Fix: order window was not marked dirty on changed orders.
rubidium <rubidium@openttd.org>
parents:
8869
diff
changeset
|
1105 u->current_order.SetLoadType(order->GetLoadType()); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1106 } |
12892
2245b86757b7
(svn r17384) -Fix [FS#2859]: remove all order window state changes out of the drawing routine and call them immediately when changes happen instead of on the next OnPaint. This prevents pressing buttons when they should've been already disabled.
rubidium <rubidium@openttd.org>
parents:
12804
diff
changeset
|
1107 InvalidateVehicleOrder(u, -2); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1108 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1109 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1110 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
1111 return CommandCost(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1112 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1113 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1114 /** Clone/share/copy an order-list of an other vehicle. |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6370
diff
changeset
|
1115 * @param tile unused |
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6370
diff
changeset
|
1116 * @param flags operation to perform |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1117 * @param p1 various bitstuffed elements |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1118 * - p1 = (bit 0-15) - destination vehicle to clone orders to (p1 & 0xFFFF) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1119 * - p1 = (bit 16-31) - source vehicle to clone orders from, if any (none for CO_UNSHARE) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1120 * @param p2 mode of cloning: CO_SHARE, CO_COPY, or CO_UNSHARE |
13067
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1121 * @param text unused |
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1122 * @return the cost of this operation or an error |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1123 */ |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11014
diff
changeset
|
1124 CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1125 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1126 VehicleID veh_src = GB(p1, 16, 16); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1127 VehicleID veh_dst = GB(p1, 0, 16); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1128 |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
1129 Vehicle *dst = Vehicle::GetIfValid(veh_dst); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1130 |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
1131 if (dst == NULL || !CheckOwnership(dst->owner)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1132 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1133 switch (p2) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1134 case CO_SHARE: { |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
1135 Vehicle *src = Vehicle::GetIfValid(veh_src); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1136 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1137 /* Sanity checks */ |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
1138 if (src == NULL || !CheckOwnership(src->owner) || dst->type != src->type || dst == src) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1139 return CMD_ERROR; |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
1140 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1141 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1142 /* Trucks can't share orders with busses (and visa versa) */ |
13851
06143488a65f
(svn r18380) -Fix (r9301): One could not share orders between buses carrying different cargos.
frosch <frosch@openttd.org>
parents:
13679
diff
changeset
|
1143 if (src->type == VEH_ROAD && IsCargoInClass(src->cargo_type, CC_PASSENGERS) != IsCargoInClass(dst->cargo_type, CC_PASSENGERS)) { |
06143488a65f
(svn r18380) -Fix (r9301): One could not share orders between buses carrying different cargos.
frosch <frosch@openttd.org>
parents:
13679
diff
changeset
|
1144 return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1145 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1146 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1147 /* Is the vehicle already in the shared list? */ |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9937
diff
changeset
|
1148 if (src->FirstShared() == dst->FirstShared()) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1149 |
10652
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
1150 const Order *order; |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
1151 |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
1152 FOR_VEHICLE_ORDERS(src, order) { |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
1153 if (OrderGoesToStation(dst, order) && |
11922
0a4b63f3f3c3
(svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents:
11866
diff
changeset
|
1154 !CanVehicleUseStation(dst, Station::Get(order->GetDestination()))) { |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11719
diff
changeset
|
1155 return_cmd_error(STR_ERROR_CAN_T_COPY_SHARE_ORDER); |
10652
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
1156 } |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
1157 } |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
1158 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1159 if (flags & DC_EXEC) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1160 /* If the destination vehicle had a OrderList, destroy it */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1161 DeleteVehicleOrders(dst); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1162 |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1163 dst->orders.list = src->orders.list; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1164 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1165 /* Link this vehicle in the shared-list */ |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9937
diff
changeset
|
1166 dst->AddToShared(src); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1167 |
10184
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
1168 InvalidateVehicleOrder(dst, -1); |
12892
2245b86757b7
(svn r17384) -Fix [FS#2859]: remove all order window state changes out of the drawing routine and call them immediately when changes happen instead of on the next OnPaint. This prevents pressing buttons when they should've been already disabled.
rubidium <rubidium@openttd.org>
parents:
12804
diff
changeset
|
1169 InvalidateVehicleOrder(src, -2); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1170 |
9297
add307f2e6ea
(svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium <rubidium@openttd.org>
parents:
9234
diff
changeset
|
1171 InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1172 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1173 } break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1174 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1175 case CO_COPY: { |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
1176 Vehicle *src = Vehicle::GetIfValid(veh_src); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1177 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1178 /* Sanity checks */ |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
1179 if (src == NULL || !CheckOwnership(src->owner) || dst->type != src->type || dst == src) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1180 return CMD_ERROR; |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
1181 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1182 |
10652
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
1183 /* Trucks can't copy all the orders from busses (and visa versa), |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
1184 * and neither can helicopters and aircarft. */ |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
1185 const Order *order; |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
1186 FOR_VEHICLE_ORDERS(src, order) { |
42a789858c6c
(svn r14954) -Fix [FS#1890]: sharing/cloning/inserting of orders that the/a vehicle (in the shared list) can't go to (wrong station type etc)
rubidium <rubidium@openttd.org>
parents:
10650
diff
changeset
|
1187 if (OrderGoesToStation(dst, order) && |
11922
0a4b63f3f3c3
(svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents:
11866
diff
changeset
|
1188 !CanVehicleUseStation(dst, Station::Get(order->GetDestination()))) { |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11719
diff
changeset
|
1189 return_cmd_error(STR_ERROR_CAN_T_COPY_SHARE_ORDER); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1190 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1191 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1192 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1193 /* make sure there are orders available */ |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
1194 int delta = dst->IsOrderListShared() ? src->GetNumOrders() + 1 : src->GetNumOrders() - dst->GetNumOrders(); |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1195 if (!Order::CanAllocateItem(delta) || |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1196 ((dst->orders.list == NULL || dst->IsOrderListShared()) && !OrderList::CanAllocateItem())) { |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11719
diff
changeset
|
1197 return_cmd_error(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS); |
10304
575039101d7c
(svn r14547) -Fix: order pool seemed to look full when it was not as it only checked whether it was possible to allocate a new block of pool items instead of checking for free pool items.
rubidium <rubidium@openttd.org>
parents:
10285
diff
changeset
|
1198 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1199 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1200 if (flags & DC_EXEC) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1201 const Order *order; |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1202 Order *first = NULL; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1203 Order **order_dst; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1204 |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1205 /* If the destination vehicle had an order list, destroy the chain but keep the OrderList */ |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1206 DeleteVehicleOrders(dst, true); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1207 |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1208 order_dst = &first; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1209 FOR_VEHICLE_ORDERS(src, order) { |
7391
1b2a34c4f7fa
(svn r10760) -Codechange: make the order struct use the pool item class as super class.
rubidium <rubidium@openttd.org>
parents:
7049
diff
changeset
|
1210 *order_dst = new Order(); |
8835
e8296a8dbe93
(svn r12583) -Codechange: make AssignOrder a class function of order.
rubidium <rubidium@openttd.org>
parents:
8834
diff
changeset
|
1211 (*order_dst)->AssignOrder(*order); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1212 order_dst = &(*order_dst)->next; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1213 } |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
1214 if (dst->orders.list == NULL) { |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
1215 dst->orders.list = new OrderList(first, dst); |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
1216 } else { |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1217 assert(dst->orders.list->GetFirstOrder() == NULL); |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
1218 assert(!dst->orders.list->IsShared()); |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
1219 delete dst->orders.list; |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
1220 dst->orders.list = new OrderList(first, dst); |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1221 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1222 |
10184
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
1223 InvalidateVehicleOrder(dst, -1); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1224 |
9297
add307f2e6ea
(svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium <rubidium@openttd.org>
parents:
9234
diff
changeset
|
1225 InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1226 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1227 } break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1228 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1229 case CO_UNSHARE: return DecloneOrder(dst, flags); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1230 default: return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1231 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1232 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
1233 return CommandCost(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1234 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1235 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1236 /** Add/remove refit orders from an order |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1237 * @param tile Not used |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6370
diff
changeset
|
1238 * @param flags operation to perform |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1239 * @param p1 VehicleIndex of the vehicle having the order |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1240 * @param p2 bitmask |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1241 * - bit 0-7 CargoID |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1242 * - bit 8-15 Cargo subtype |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1243 * - bit 16-23 number of order to modify |
13067
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1244 * @param text unused |
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1245 * @return the cost of this operation or an error |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1246 */ |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11014
diff
changeset
|
1247 CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1248 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1249 VehicleID veh = GB(p1, 0, 16); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1250 VehicleOrderID order_number = GB(p2, 16, 8); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1251 CargoID cargo = GB(p2, 0, 8); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1252 byte subtype = GB(p2, 8, 8); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1253 |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
1254 const Vehicle *v = Vehicle::GetIfValid(veh); |
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
1255 if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1256 |
11991
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11983
diff
changeset
|
1257 Order *order = v->GetOrder(order_number); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1258 if (order == NULL) return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1259 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1260 if (flags & DC_EXEC) { |
8838
db9c6b0c9f07
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium <rubidium@openttd.org>
parents:
8836
diff
changeset
|
1261 order->SetRefit(cargo, subtype); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1262 |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9937
diff
changeset
|
1263 for (Vehicle *u = v->FirstShared(); u != NULL; u = u->NextShared()) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1264 /* Update any possible open window of the vehicle */ |
12892
2245b86757b7
(svn r17384) -Fix [FS#2859]: remove all order window state changes out of the drawing routine and call them immediately when changes happen instead of on the next OnPaint. This prevents pressing buttons when they should've been already disabled.
rubidium <rubidium@openttd.org>
parents:
12804
diff
changeset
|
1265 InvalidateVehicleOrder(u, -2); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1266 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1267 /* If the vehicle already got the current depot set as current order, then update current order as well */ |
12082
d092f17a921d
(svn r16491) -Codechange: Added parentheses around bitwise operators for code style.
alberth <alberth@openttd.org>
parents:
12068
diff
changeset
|
1268 if (u->cur_order_index == order_number && (u->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) { |
8838
db9c6b0c9f07
(svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium <rubidium@openttd.org>
parents:
8836
diff
changeset
|
1269 u->current_order.SetRefit(cargo, subtype); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1270 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1271 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1272 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1273 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
1274 return CommandCost(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1275 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1276 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1277 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1278 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1279 * Backup a vehicle order-list, so you can replace a vehicle |
10015
e2bd06791742
(svn r14174) -Fix: since now, we are 'losing' things, not 'loosing'
smatz <smatz@openttd.org>
parents:
9978
diff
changeset
|
1280 * without losing the order-list |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1281 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1282 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1283 void BackupVehicleOrders(const Vehicle *v, BackuppedOrders *bak) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1284 { |
7653
e6f32e659811
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents:
7401
diff
changeset
|
1285 /* Make sure we always have freed the stuff */ |
e6f32e659811
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents:
7401
diff
changeset
|
1286 free(bak->order); |
e6f32e659811
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents:
7401
diff
changeset
|
1287 bak->order = NULL; |
8258
6017c5ebeb7e
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents:
8254
diff
changeset
|
1288 free(bak->name); |
6017c5ebeb7e
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents:
8254
diff
changeset
|
1289 bak->name = NULL; |
7653
e6f32e659811
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents:
7401
diff
changeset
|
1290 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1291 /* Save general info */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1292 bak->orderindex = v->cur_order_index; |
8650
2fa51e7b4d1f
(svn r12296) -Fix [FS#1549]: restore timetable from backupped orders and add group ID to the backup
glx <glx@openttd.org>
parents:
8551
diff
changeset
|
1293 bak->group = v->group_id; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1294 bak->service_interval = v->service_interval; |
8258
6017c5ebeb7e
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents:
8254
diff
changeset
|
1295 if (v->name != NULL) bak->name = strdup(v->name); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1296 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1297 /* If we have shared orders, store it on a special way */ |
8469
066d7c3ca93d
(svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas <belugas@openttd.org>
parents:
8373
diff
changeset
|
1298 if (v->IsOrderListShared()) { |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9937
diff
changeset
|
1299 const Vehicle *u = (v->FirstShared() == v) ? v->NextShared() : v->FirstShared(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1300 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1301 bak->clone = u->index; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1302 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1303 /* Else copy the orders */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1304 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1305 /* We do not have shared orders */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1306 bak->clone = INVALID_VEHICLE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1307 |
7653
e6f32e659811
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents:
7401
diff
changeset
|
1308 |
e6f32e659811
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents:
7401
diff
changeset
|
1309 /* Count the number of orders */ |
e6f32e659811
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents:
7401
diff
changeset
|
1310 uint cnt = 0; |
e6f32e659811
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents:
7401
diff
changeset
|
1311 const Order *order; |
e6f32e659811
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents:
7401
diff
changeset
|
1312 FOR_VEHICLE_ORDERS(v, order) cnt++; |
e6f32e659811
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents:
7401
diff
changeset
|
1313 |
e6f32e659811
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents:
7401
diff
changeset
|
1314 /* Allocate memory for the orders plus an end-of-orders marker */ |
e6f32e659811
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents:
7401
diff
changeset
|
1315 bak->order = MallocT<Order>(cnt + 1); |
e6f32e659811
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents:
7401
diff
changeset
|
1316 |
e6f32e659811
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents:
7401
diff
changeset
|
1317 Order *dest = bak->order; |
e6f32e659811
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents:
7401
diff
changeset
|
1318 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1319 /* Copy the orders */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1320 FOR_VEHICLE_ORDERS(v, order) { |
9061
888b60158039
(svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni <bjarni@openttd.org>
parents:
9043
diff
changeset
|
1321 memcpy(dest, order, sizeof(Order)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1322 dest++; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1323 } |
6263
715aa17970ab
(svn r9072) -Codechange: [Orders] added methods to orders to free them and check if they are in use
bjarni <bjarni@openttd.org>
parents:
6259
diff
changeset
|
1324 /* End the list with an empty order */ |
715aa17970ab
(svn r9072) -Codechange: [Orders] added methods to orders to free them and check if they are in use
bjarni <bjarni@openttd.org>
parents:
6259
diff
changeset
|
1325 dest->Free(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1326 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1327 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1328 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1329 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1330 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1331 * Restore vehicle orders that are backupped via BackupVehicleOrders |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1332 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1333 */ |
7653
e6f32e659811
(svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents:
7401
diff
changeset
|
1334 void RestoreVehicleOrders(const Vehicle *v, const BackuppedOrders *bak) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1335 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1336 /* If we have a custom name, process that */ |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10488
diff
changeset
|
1337 if (bak->name != NULL) DoCommandP(0, v->index, 0, CMD_RENAME_VEHICLE, NULL, bak->name); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1338 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1339 /* If we had shared orders, recover that */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1340 if (bak->clone != INVALID_VEHICLE) { |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10488
diff
changeset
|
1341 DoCommandP(0, v->index | (bak->clone << 16), CO_SHARE, CMD_CLONE_ORDER); |
7820
5f3f31875341
(svn r11370) -Fix [FS1384]: manually replacing a vehicle with shared orders makes it lose it's order index and service interval. Patch by jthill.
rubidium <rubidium@openttd.org>
parents:
7683
diff
changeset
|
1342 } else { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1343 |
7820
5f3f31875341
(svn r11370) -Fix [FS1384]: manually replacing a vehicle with shared orders makes it lose it's order index and service interval. Patch by jthill.
rubidium <rubidium@openttd.org>
parents:
7683
diff
changeset
|
1344 /* CMD_NO_TEST_IF_IN_NETWORK is used here, because CMD_INSERT_ORDER checks if the |
5f3f31875341
(svn r11370) -Fix [FS1384]: manually replacing a vehicle with shared orders makes it lose it's order index and service interval. Patch by jthill.
rubidium <rubidium@openttd.org>
parents:
7683
diff
changeset
|
1345 * order number is one more than the current amount of orders, and because |
5f3f31875341
(svn r11370) -Fix [FS1384]: manually replacing a vehicle with shared orders makes it lose it's order index and service interval. Patch by jthill.
rubidium <rubidium@openttd.org>
parents:
7683
diff
changeset
|
1346 * in network the commands are queued before send, the second insert always |
5f3f31875341
(svn r11370) -Fix [FS1384]: manually replacing a vehicle with shared orders makes it lose it's order index and service interval. Patch by jthill.
rubidium <rubidium@openttd.org>
parents:
7683
diff
changeset
|
1347 * fails in test mode. By bypassing the test-mode, that no longer is a problem. */ |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
1348 for (uint i = 0; !bak->order[i].IsType(OT_NOTHING); i++) { |
9665
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1349 Order o = bak->order[i]; |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1350 /* Conditional orders need to have their destination to be valid on insertion. */ |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1351 if (o.IsType(OT_CONDITIONAL)) o.SetConditionSkipToOrder(0); |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1352 |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10488
diff
changeset
|
1353 if (!DoCommandP(0, v->index + (i << 16), o.Pack(), |
8650
2fa51e7b4d1f
(svn r12296) -Fix [FS#1549]: restore timetable from backupped orders and add group ID to the backup
glx <glx@openttd.org>
parents:
8551
diff
changeset
|
1354 CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK)) { |
7820
5f3f31875341
(svn r11370) -Fix [FS1384]: manually replacing a vehicle with shared orders makes it lose it's order index and service interval. Patch by jthill.
rubidium <rubidium@openttd.org>
parents:
7683
diff
changeset
|
1355 break; |
8650
2fa51e7b4d1f
(svn r12296) -Fix [FS#1549]: restore timetable from backupped orders and add group ID to the backup
glx <glx@openttd.org>
parents:
8551
diff
changeset
|
1356 } |
2fa51e7b4d1f
(svn r12296) -Fix [FS#1549]: restore timetable from backupped orders and add group ID to the backup
glx <glx@openttd.org>
parents:
8551
diff
changeset
|
1357 |
8679
68be52eef668
(svn r12345) -Fix [FS#1828](r12296): don't try to restore backupped timetable when timetabling is disabled
glx <glx@openttd.org>
parents:
8650
diff
changeset
|
1358 /* Copy timetable if enabled */ |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9390
diff
changeset
|
1359 if (_settings_game.order.timetabling && !DoCommandP(0, v->index | (i << 16) | (1 << 25), |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10488
diff
changeset
|
1360 o.wait_time << 16 | o.travel_time, |
8650
2fa51e7b4d1f
(svn r12296) -Fix [FS#1549]: restore timetable from backupped orders and add group ID to the backup
glx <glx@openttd.org>
parents:
8551
diff
changeset
|
1361 CMD_CHANGE_TIMETABLE | CMD_NO_TEST_IF_IN_NETWORK)) { |
9665
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1362 break; |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1363 } |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1364 } |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1365 |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1366 /* Fix the conditional orders' destination. */ |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
1367 for (uint i = 0; !bak->order[i].IsType(OT_NOTHING); i++) { |
9665
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1368 if (!bak->order[i].IsType(OT_CONDITIONAL)) continue; |
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1369 |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10488
diff
changeset
|
1370 if (!DoCommandP(0, v->index + (i << 16), MOF_LOAD | (bak->order[i].GetConditionSkipToOrder() << 4), |
9665
294a2fc5d425
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
rubidium <rubidium@openttd.org>
parents:
9641
diff
changeset
|
1371 CMD_MODIFY_ORDER | CMD_NO_TEST_IF_IN_NETWORK)) { |
8650
2fa51e7b4d1f
(svn r12296) -Fix [FS#1549]: restore timetable from backupped orders and add group ID to the backup
glx <glx@openttd.org>
parents:
8551
diff
changeset
|
1372 break; |
2fa51e7b4d1f
(svn r12296) -Fix [FS#1549]: restore timetable from backupped orders and add group ID to the backup
glx <glx@openttd.org>
parents:
8551
diff
changeset
|
1373 } |
7820
5f3f31875341
(svn r11370) -Fix [FS1384]: manually replacing a vehicle with shared orders makes it lose it's order index and service interval. Patch by jthill.
rubidium <rubidium@openttd.org>
parents:
7683
diff
changeset
|
1374 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1375 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1376 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1377 /* Restore vehicle order-index and service interval */ |
13175
3f4cc2986131
(svn r17682) -Codechange: remove erroneous space before some commas
rubidium <rubidium@openttd.org>
parents:
13070
diff
changeset
|
1378 DoCommandP(0, v->index, bak->orderindex | (bak->service_interval << 16), CMD_RESTORE_ORDER_INDEX); |
8650
2fa51e7b4d1f
(svn r12296) -Fix [FS#1549]: restore timetable from backupped orders and add group ID to the backup
glx <glx@openttd.org>
parents:
8551
diff
changeset
|
1379 |
2fa51e7b4d1f
(svn r12296) -Fix [FS#1549]: restore timetable from backupped orders and add group ID to the backup
glx <glx@openttd.org>
parents:
8551
diff
changeset
|
1380 /* Restore vehicle group */ |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10488
diff
changeset
|
1381 DoCommandP(0, bak->group, v->index, CMD_ADD_VEHICLE_GROUP); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1382 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1383 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1384 /** Restore the current order-index of a vehicle and sets service-interval. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1385 * @param tile unused |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6370
diff
changeset
|
1386 * @param flags operation to perform |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1387 * @param p1 the ID of the vehicle |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1388 * @param p2 various bistuffed elements |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1389 * - p2 = (bit 0-15) - current order-index (p2 & 0xFFFF) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1390 * - p2 = (bit 16-31) - service interval (p2 >> 16) |
13067
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1391 * @param text unused |
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
13034
diff
changeset
|
1392 * @return the cost of this operation or an error |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1393 * @todo Unfortunately you cannot safely restore the unitnumber or the old vehicle |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1394 * as far as I can see. We can store it in BackuppedOrders, and restore it, but |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1395 * but we have no way of seeing it has been tampered with or not, as we have no |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1396 * legit way of knowing what that ID was.@n |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1397 * If we do want to backup/restore it, just add UnitID uid to BackuppedOrders, and |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1398 * restore it as parameter 'y' (ugly hack I know) for example. "v->unitnumber = y;" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1399 */ |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11014
diff
changeset
|
1400 CommandCost CmdRestoreOrderIndex(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1401 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1402 VehicleOrderID cur_ord = GB(p2, 0, 16); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1403 uint16 serv_int = GB(p2, 16, 16); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1404 |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
1405 Vehicle *v = Vehicle::GetIfValid(p1); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1406 /* Check the vehicle type and ownership, and if the service interval and order are in range */ |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
1407 if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR; |
12032
2afeb10ae6ba
(svn r16439) -Change: Make the default vehicle servicing settings company-based settings, so in a multiplayer game everyone can change them.
yexo <yexo@openttd.org>
parents:
12010
diff
changeset
|
1408 if (serv_int != GetServiceIntervalClamped(serv_int, v->owner) || cur_ord >= v->GetNumOrders()) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1409 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1410 if (flags & DC_EXEC) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1411 v->cur_order_index = cur_ord; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1412 v->service_interval = serv_int; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1413 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1414 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
1415 return CommandCost(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1416 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1417 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1418 |
10647
592ae9307430
(svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents:
10582
diff
changeset
|
1419 static TileIndex GetStationTileForVehicle(const Vehicle *v, const Station *st) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1420 { |
10650
92ff04e7b1d9
(svn r14952) -Codechange: unify the "can vehicle go to station" tests
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
1421 if (!CanVehicleUseStation(v, st)) return INVALID_TILE; |
92ff04e7b1d9
(svn r14952) -Codechange: unify the "can vehicle go to station" tests
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
1422 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1423 switch (v->type) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1424 default: NOT_REACHED(); |
12510
3e976121ced2
(svn r16947) -Codechange: use TileArea instead of train_tile, trainst_w and trainst_h.
rubidium <rubidium@openttd.org>
parents:
12503
diff
changeset
|
1425 case VEH_TRAIN: return st->train_station.tile; |
10650
92ff04e7b1d9
(svn r14952) -Codechange: unify the "can vehicle go to station" tests
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
1426 case VEH_AIRCRAFT: return st->airport_tile; |
6259
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
1427 case VEH_SHIP: return st->dock_tile; |
12114
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12082
diff
changeset
|
1428 case VEH_ROAD: return st->GetPrimaryRoadStop(RoadVehicle::From(v))->xy; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1429 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1430 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1431 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1432 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1433 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1434 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1435 * Check the orders of a vehicle, to see if there are invalid orders and stuff |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1436 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1437 */ |
10647
592ae9307430
(svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents:
10582
diff
changeset
|
1438 void CheckOrders(const Vehicle *v) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1439 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1440 /* Does the user wants us to check things? */ |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9390
diff
changeset
|
1441 if (_settings_client.gui.order_review_system == 0) return; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1442 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1443 /* Do nothing for crashed vehicles */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1444 if (v->vehstatus & VS_CRASHED) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1445 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1446 /* Do nothing for stopped vehicles if setting is '1' */ |
12082
d092f17a921d
(svn r16491) -Codechange: Added parentheses around bitwise operators for code style.
alberth <alberth@openttd.org>
parents:
12068
diff
changeset
|
1447 if (_settings_client.gui.order_review_system == 1 && (v->vehstatus & VS_STOPPED)) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1448 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1449 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1450 /* do nothing we we're not the first vehicle in a share-chain */ |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9937
diff
changeset
|
1451 if (v->FirstShared() != v) return; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1452 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1453 /* Only check every 20 days, so that we don't flood the message log */ |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10184
diff
changeset
|
1454 if (v->owner == _local_company && v->day_counter % 20 == 0) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1455 int n_st, problem_type = -1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1456 const Order *order; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1457 int message = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1458 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1459 /* Check the order list */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1460 n_st = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1461 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1462 FOR_VEHICLE_ORDERS(v, order) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1463 /* Dummy order? */ |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
1464 if (order->IsType(OT_DUMMY)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1465 problem_type = 1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1466 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1467 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1468 /* Does station have a load-bay for this vehicle? */ |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
1469 if (order->IsType(OT_GOTO_STATION)) { |
11922
0a4b63f3f3c3
(svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents:
11866
diff
changeset
|
1470 const Station *st = Station::Get(order->GetDestination()); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1471 TileIndex required_tile = GetStationTileForVehicle(v, st); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1472 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1473 n_st++; |
10488
a9ecb9be9814
(svn r14743) -Codechange: use INVALID_TILE to indicate station doesn't have queried facility (or station/roadstop is invalid) instead of 0 (Yexo)
smatz <smatz@openttd.org>
parents:
10365
diff
changeset
|
1474 if (required_tile == INVALID_TILE) problem_type = 3; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1475 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1476 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1477 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1478 /* Check if the last and the first order are the same */ |
10544
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1479 if (v->GetNumOrders() > 1) { |
11991
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11983
diff
changeset
|
1480 const Order *last = v->GetLastOrder(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1481 |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1482 if (v->orders.list->GetFirstOrder()->Equals(*last)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1483 problem_type = 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1484 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1485 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1486 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1487 /* Do we only have 1 station in our order list? */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1488 if (n_st < 2 && problem_type == -1) problem_type = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1489 |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1490 #ifndef NDEBUG |
11014
1a4a901b1a95
(svn r15354) -Fix (r14803): first shared of a vehicle could be NULL making it impossible to (share-)clone the vehicle.
rubidium <rubidium@openttd.org>
parents:
10993
diff
changeset
|
1491 if (v->orders.list != NULL) v->orders.list->DebugCheckSanity(); |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1492 #endif |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1493 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1494 /* We don't have a problem */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1495 if (problem_type < 0) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1496 |
12619
2f530108f787
(svn r17062) -Change: unify the naming of some 125 strings
rubidium <rubidium@openttd.org>
parents:
12538
diff
changeset
|
1497 message = STR_NEWS_VEHICLE_HAS_TOO_FEW_ORDERS + problem_type; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1498 //DEBUG(misc, 3, "Triggered News Item for vehicle %d", v->index); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1499 |
10574
bf4424d086f0
(svn r14831) -Codechange: use {VEHICLE} instead of Train/Ship/Road veh/Aircraft/{STRING} {COMMA} in lang files (part by Swallow)
smatz <smatz@openttd.org>
parents:
10573
diff
changeset
|
1500 SetDParam(0, v->index); |
12010
d0bf08a7c260
(svn r16416) -Fix [FS#2912]: Rework deleting of news when referenced vehicles/stations/industries are deleted.
frosch <frosch@openttd.org>
parents:
11991
diff
changeset
|
1501 AddVehicleNewsItem( |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1502 message, |
9234
02827bf3dc03
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium <rubidium@openttd.org>
parents:
9111
diff
changeset
|
1503 NS_ADVICE, |
12010
d0bf08a7c260
(svn r16416) -Fix [FS#2912]: Rework deleting of news when referenced vehicles/stations/industries are deleted.
frosch <frosch@openttd.org>
parents:
11991
diff
changeset
|
1504 v->index |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1505 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1506 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1507 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1508 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1509 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1510 * Removes an order from all vehicles. Triggers when, say, a station is removed. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1511 * @param type The type of the order (OT_GOTO_[STATION|DEPOT|WAYPOINT]). |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1512 * @param destination The destination. Can be a StationID, DepotID or WaypointID. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1513 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1514 void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1515 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1516 Vehicle *v; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1517 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1518 /* Aircraft have StationIDs for depot orders and never use DepotIDs |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1519 * This fact is handled specially below |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1520 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1521 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1522 /* Go through all vehicles */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1523 FOR_ALL_VEHICLES(v) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1524 Order *order; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1525 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1526 order = &v->current_order; |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
1527 if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) ? OT_GOTO_STATION : order->GetType()) == type && |
8840
c3d2f0eb69a1
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium <rubidium@openttd.org>
parents:
8839
diff
changeset
|
1528 v->current_order.GetDestination() == destination) { |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
1529 order->MakeDummy(); |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
12892
diff
changeset
|
1530 SetWindowDirty(WC_VEHICLE_VIEW, v->index); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1531 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1532 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1533 /* Clear the order from the order-list */ |
10184
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
1534 int id = -1; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1535 FOR_VEHICLE_ORDERS(v, order) { |
10184
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
1536 id++; |
10019
9b57f8222853
(svn r14178) -Fix [FS#2256]: Do not evaluate GetDestination() for go-to-nearest-depot-orders.
frosch <frosch@openttd.org>
parents:
10015
diff
changeset
|
1537 if (order->IsType(OT_GOTO_DEPOT) && (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) continue; |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
1538 if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) ? OT_GOTO_STATION : order->GetType()) == type && |
8840
c3d2f0eb69a1
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium <rubidium@openttd.org>
parents:
8839
diff
changeset
|
1539 order->GetDestination() == destination) { |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
1540 order->MakeDummy(); |
10184
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
1541 for (const Vehicle *w = v->FirstShared(); w != NULL; w = w->NextShared()) { |
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
1542 /* In GUI, simulate by removing the order and adding it back */ |
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
1543 InvalidateVehicleOrder(w, id | (INVALID_VEH_ORDER_ID << 8)); |
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
1544 InvalidateVehicleOrder(w, (INVALID_VEH_ORDER_ID << 8) | id); |
fbd1b77a2509
(svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz <smatz@openttd.org>
parents:
10151
diff
changeset
|
1545 } |
10020
516f3198d980
(svn r14179) -Fix (r1): RemoveOrderFromAllVehicles() did not mark enough windows dirty.
frosch <frosch@openttd.org>
parents:
10019
diff
changeset
|
1546 } |
516f3198d980
(svn r14179) -Fix (r1): RemoveOrderFromAllVehicles() did not mark enough windows dirty.
frosch <frosch@openttd.org>
parents:
10019
diff
changeset
|
1547 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1548 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1549 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1550 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1551 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1552 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1553 * Checks if a vehicle has a GOTO_DEPOT in his order list |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1554 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1555 * @return True if this is true (lol ;)) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1556 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1557 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1558 bool VehicleHasDepotOrders(const Vehicle *v) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1559 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1560 const Order *order; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1561 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1562 FOR_VEHICLE_ORDERS(v, order) { |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
1563 if (order->IsType(OT_GOTO_DEPOT)) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1564 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1565 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1566 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1567 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1568 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1569 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1570 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1571 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1572 * Delete all orders from a vehicle |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1573 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1574 */ |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1575 void DeleteVehicleOrders(Vehicle *v, bool keep_orderlist) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1576 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1577 DeleteOrderWarnings(v); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1578 |
8469
066d7c3ca93d
(svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas <belugas@openttd.org>
parents:
8373
diff
changeset
|
1579 if (v->IsOrderListShared()) { |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9937
diff
changeset
|
1580 /* Remove ourself from the shared order list. */ |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9937
diff
changeset
|
1581 v->RemoveFromShared(); |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1582 v->orders.list = NULL; |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1583 } else if (v->orders.list != NULL) { |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9937
diff
changeset
|
1584 /* Remove the orders */ |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1585 v->orders.list->FreeChain(keep_orderlist); |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1586 if (!keep_orderlist) v->orders.list = NULL; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1587 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1588 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1589 |
12032
2afeb10ae6ba
(svn r16439) -Change: Make the default vehicle servicing settings company-based settings, so in a multiplayer game everyone can change them.
yexo <yexo@openttd.org>
parents:
12010
diff
changeset
|
1590 uint16 GetServiceIntervalClamped(uint interval, CompanyID company_id) |
8211
165064de4629
(svn r11774) -Change: do not include variables.h in a header when it is not needed.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
1591 { |
12032
2afeb10ae6ba
(svn r16439) -Change: Make the default vehicle servicing settings company-based settings, so in a multiplayer game everyone can change them.
yexo <yexo@openttd.org>
parents:
12010
diff
changeset
|
1592 return (Company::Get(company_id)->settings.vehicle.servint_ispercent) ? Clamp(interval, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : Clamp(interval, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS); |
8211
165064de4629
(svn r11774) -Change: do not include variables.h in a header when it is not needed.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
1593 } |
165064de4629
(svn r11774) -Change: do not include variables.h in a header when it is not needed.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
1594 |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1595 /** |
8830
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1596 * |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1597 * Check if a vehicle has any valid orders |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1598 * |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1599 * @return false if there are no valid orders |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1600 * |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1601 */ |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1602 static bool CheckForValidOrders(const Vehicle *v) |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1603 { |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1604 const Order *order; |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1605 |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
1606 FOR_VEHICLE_ORDERS(v, order) if (!order->IsType(OT_DUMMY)) return true; |
8830
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1607 |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1608 return false; |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1609 } |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1610 |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1611 /** |
8900
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1612 * Compare the variable and value based on the given comparator. |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1613 */ |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1614 static bool OrderConditionCompare(OrderConditionComparator occ, int variable, int value) |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1615 { |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1616 switch (occ) { |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1617 case OCC_EQUALS: return variable == value; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1618 case OCC_NOT_EQUALS: return variable != value; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1619 case OCC_LESS_THAN: return variable < value; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1620 case OCC_LESS_EQUALS: return variable <= value; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1621 case OCC_MORE_THAN: return variable > value; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1622 case OCC_MORE_EQUALS: return variable >= value; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1623 case OCC_IS_TRUE: return variable != 0; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1624 case OCC_IS_FALSE: return variable == 0; |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1625 default: NOT_REACHED(); |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1626 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1627 } |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1628 |
a12b2ec504da
(svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium <rubidium@openttd.org>
parents:
8894
diff
changeset
|
1629 /** |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1630 * Process a conditional order and determine the next order. |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1631 * @param order the order the vehicle currently has |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1632 * @param v the vehicle to update |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1633 * @return index of next order to jump to, or INVALID_VEH_ORDER_ID to use the next order |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1634 */ |
9807
5c6328db0312
(svn r13949) -Codechange [YAPP]: Declare the functions for processing conditional orders as non-static. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9666
diff
changeset
|
1635 VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v) |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1636 { |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1637 if (order->GetType() != OT_CONDITIONAL) return INVALID_VEH_ORDER_ID; |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1638 |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1639 bool skip_order = false; |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1640 OrderConditionComparator occ = order->GetConditionComparator(); |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1641 uint16 value = order->GetConditionValue(); |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1642 |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1643 switch (order->GetConditionVariable()) { |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1644 case OCV_LOAD_PERCENTAGE: skip_order = OrderConditionCompare(occ, CalcPercentVehicleFilled(v, NULL), value); break; |
12804
bcc8ad6501c5
(svn r17292) -Codechange: use unified ToPercent() function to convert fract numbers to percents
smatz <smatz@openttd.org>
parents:
12778
diff
changeset
|
1645 case OCV_RELIABILITY: skip_order = OrderConditionCompare(occ, ToPercent16(v->reliability), value); break; |
10969
208ba3fba382
(svn r15308) -Codechange: Deduplicate km-ish/h -> mph conversions.
frosch <frosch@openttd.org>
parents:
10960
diff
changeset
|
1646 case OCV_MAX_SPEED: skip_order = OrderConditionCompare(occ, v->GetDisplayMaxSpeed() * 10 / 16, value); break; |
10744
0118ca646690
(svn r15077) -Codechange: enumify DAYS_IN_YEAR and DAYS_IN_LEAP_YEAR
smatz <smatz@openttd.org>
parents:
10679
diff
changeset
|
1647 case OCV_AGE: skip_order = OrderConditionCompare(occ, v->age / DAYS_IN_LEAP_YEAR, value); break; |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1648 case OCV_REQUIRES_SERVICE: skip_order = OrderConditionCompare(occ, v->NeedsServicing(), value); break; |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1649 case OCV_UNCONDITIONALLY: skip_order = true; break; |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1650 default: NOT_REACHED(); |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1651 } |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1652 |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1653 return skip_order ? order->GetConditionSkipToOrder() : (VehicleOrderID)INVALID_VEH_ORDER_ID; |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1654 } |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1655 |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1656 /** |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1657 * Update the vehicle's destination tile from an order. |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1658 * @param order the order the vehicle currently has |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1659 * @param v the vehicle to update |
13070
1c4c4ae8d716
(svn r17570) -Fix: a number of Doxygen warnings about missing parameters, which were sometimes missing and sometimes just typos
rubidium <rubidium@openttd.org>
parents:
13067
diff
changeset
|
1660 * @param conditional_depth the depth (amount of steps) to go with conditional orders. This to prevent infinite loops. |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1661 */ |
9807
5c6328db0312
(svn r13949) -Codechange [YAPP]: Declare the functions for processing conditional orders as non-static. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9666
diff
changeset
|
1662 bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth) |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1663 { |
12377
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1664 if (conditional_depth > v->GetNumOrders()) return false; |
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1665 |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1666 switch (order->GetType()) { |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1667 case OT_GOTO_STATION: |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1668 v->dest_tile = v->GetOrderStationLocation(order->GetDestination()); |
12377
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1669 return true; |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1670 |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1671 case OT_GOTO_DEPOT: |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1672 if (v->current_order.GetDepotActionType() & ODATFB_NEAREST_DEPOT) { |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1673 /* We need to search for the nearest depot (hangar). */ |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1674 TileIndex location; |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1675 DestinationID destination; |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1676 bool reverse; |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1677 |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1678 if (v->FindClosestDepot(&location, &destination, &reverse)) { |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1679 v->dest_tile = location; |
11809
57fd0a8c36cb
(svn r16199) -Codechange: Pass OrderNonStopFlags also to MakeGoToDepotOrder().
frosch <frosch@openttd.org>
parents:
11730
diff
changeset
|
1680 v->current_order.MakeGoToDepot(destination, v->current_order.GetDepotOrderType(), v->current_order.GetNonStopType(), (OrderDepotActionFlags)(v->current_order.GetDepotActionType() & ~ODATFB_NEAREST_DEPOT), v->current_order.GetRefitCargo(), v->current_order.GetRefitSubtype()); |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1681 |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1682 /* If there is no depot in front, reverse automatically (trains only) */ |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1683 if (v->type == VEH_TRAIN && reverse) DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION); |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1684 |
11982
9add5306a01e
(svn r16388) -Codechange: move u.air to Aircraft
rubidium <rubidium@openttd.org>
parents:
11981
diff
changeset
|
1685 if (v->type == VEH_AIRCRAFT) { |
12114
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12082
diff
changeset
|
1686 Aircraft *a = Aircraft::From(v); |
11982
9add5306a01e
(svn r16388) -Codechange: move u.air to Aircraft
rubidium <rubidium@openttd.org>
parents:
11981
diff
changeset
|
1687 if (a->state == FLYING && a->targetairport != destination) { |
9add5306a01e
(svn r16388) -Codechange: move u.air to Aircraft
rubidium <rubidium@openttd.org>
parents:
11981
diff
changeset
|
1688 /* The aircraft is now heading for a different hangar than the next in the orders */ |
9add5306a01e
(svn r16388) -Codechange: move u.air to Aircraft
rubidium <rubidium@openttd.org>
parents:
11981
diff
changeset
|
1689 extern void AircraftNextAirportPos_and_Order(Aircraft *a); |
9add5306a01e
(svn r16388) -Codechange: move u.air to Aircraft
rubidium <rubidium@openttd.org>
parents:
11981
diff
changeset
|
1690 AircraftNextAirportPos_and_Order(a); |
9add5306a01e
(svn r16388) -Codechange: move u.air to Aircraft
rubidium <rubidium@openttd.org>
parents:
11981
diff
changeset
|
1691 } |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1692 } |
12377
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1693 return true; |
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1694 } |
12050
2330a45bc659
(svn r16457) -Fix [FS#2925]: skipping a 'nearest depot order' because none could be found could cause multiple orders to get skipped
rubidium <rubidium@openttd.org>
parents:
12032
diff
changeset
|
1695 |
12377
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1696 UpdateVehicleTimetable(v, true); |
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1697 v->IncrementOrderIndex(); |
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1698 } else if ((order->GetDepotOrderType() & ODTFB_SERVICE) && !v->NeedsServicing()) { |
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1699 UpdateVehicleTimetable(v, true); |
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1700 v->IncrementOrderIndex(); |
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1701 } else { |
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1702 if (v->type != VEH_AIRCRAFT) { |
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1703 v->dest_tile = Depot::Get(order->GetDestination())->xy; |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1704 } |
12377
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1705 return true; |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1706 } |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1707 break; |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1708 |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1709 case OT_GOTO_WAYPOINT: |
12503
9da198c570da
(svn r16940) -Codechange: make the pathfinders behave the same when finding waypoints or stations, i.e. don't force exactly one destination tile for a waypoint
rubidium <rubidium@openttd.org>
parents:
12475
diff
changeset
|
1710 v->dest_tile = Waypoint::Get(order->GetDestination())->xy; |
12377
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1711 return true; |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1712 |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1713 case OT_CONDITIONAL: { |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1714 VehicleOrderID next_order = ProcessConditionalOrder(order, v); |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1715 if (next_order != INVALID_VEH_ORDER_ID) { |
9641
d6df5044bb40
(svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium <rubidium@openttd.org>
parents:
9609
diff
changeset
|
1716 UpdateVehicleTimetable(v, false); |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1717 v->cur_order_index = next_order; |
11991
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11983
diff
changeset
|
1718 v->current_order_time += v->GetOrder(next_order)->travel_time; |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1719 } else { |
9641
d6df5044bb40
(svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium <rubidium@openttd.org>
parents:
9609
diff
changeset
|
1720 UpdateVehicleTimetable(v, true); |
11866
1e159ef634d5
(svn r16260) -Codechange: Add Vehicle::IncrementOrderIndex() to deduplicate some code.
frosch <frosch@openttd.org>
parents:
11809
diff
changeset
|
1721 v->IncrementOrderIndex(); |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1722 } |
12377
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1723 break; |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1724 } |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1725 |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1726 default: |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1727 v->dest_tile = 0; |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1728 return false; |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1729 } |
12377
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1730 |
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1731 assert(v->cur_order_index < v->GetNumOrders()); |
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1732 |
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1733 /* Get the current order */ |
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1734 order = v->GetOrder(v->cur_order_index); |
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1735 v->current_order = *order; |
0762b2672bc9
(svn r16802) -Fix [FS#3031]: service orders didn't behave like conditional orders; if a train doesn't need service it didn't completely skip the order, it would first send the vehicle towards the depot and would then realise it doesn't need to go there making it possible that the vehicle leaves that station on the wrong side.
rubidium <rubidium@openttd.org>
parents:
12361
diff
changeset
|
1736 return UpdateOrderDest(v, order, conditional_depth + 1); |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1737 } |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1738 |
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1739 /** |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1740 * Handle the orders of a vehicle and determine the next place |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1741 * to go to if needed. |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1742 * @param v the vehicle to do this for. |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1743 * @return true *if* the vehicle is eligible for reversing |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1744 * (basically only when leaving a station). |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1745 */ |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1746 bool ProcessOrders(Vehicle *v) |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1747 { |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
1748 switch (v->current_order.GetType()) { |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1749 case OT_GOTO_DEPOT: |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1750 /* Let a depot order in the orderlist interrupt. */ |
8853
02787d6f3834
(svn r12615) -Codechange: rename some enums related to depot orders to make it more clear that they are no loading/unloading flags. Also add more type strictness.
rubidium <rubidium@openttd.org>
parents:
8851
diff
changeset
|
1751 if (!(v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) return false; |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1752 break; |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1753 |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1754 case OT_LOADING: |
8830
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1755 return false; |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1756 |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1757 case OT_LEAVESTATION: |
8830
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1758 if (v->type != VEH_AIRCRAFT) return false; |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1759 break; |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1760 |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1761 default: break; |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1762 } |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1763 |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1764 /** |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1765 * Reversing because of order change is allowed only just after leaving a |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1766 * station (and the difficulty setting to allowed, of course) |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1767 * this can be detected because only after OT_LEAVESTATION, current_order |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1768 * will be reset to nothing. (That also happens if no order, but in that case |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1769 * it won't hit the point in code where may_reverse is checked) |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1770 */ |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
1771 bool may_reverse = v->current_order.IsType(OT_NOTHING); |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1772 |
8848
066a8010467f
(svn r12600) -Codechange: make GetNonStopType return a more augmented type; not is there a non-stop order but the kind of non-stop order, so one doesn't need to check _patches.new_nonstop type everywhere.
rubidium <rubidium@openttd.org>
parents:
8847
diff
changeset
|
1773 /* Check if we've reached a non-stop station.. */ |
12503
9da198c570da
(svn r16940) -Codechange: make the pathfinders behave the same when finding waypoints or stations, i.e. don't force exactly one destination tile for a waypoint
rubidium <rubidium@openttd.org>
parents:
12475
diff
changeset
|
1774 if (((v->current_order.IsType(OT_GOTO_STATION) && (v->current_order.GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)) || v->current_order.IsType(OT_GOTO_WAYPOINT)) && |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1775 IsTileType(v->tile, MP_STATION) && |
8840
c3d2f0eb69a1
(svn r12588) -Codechange: do not access the destination of an order directly.
rubidium <rubidium@openttd.org>
parents:
8839
diff
changeset
|
1776 v->current_order.GetDestination() == GetStationIndex(v->tile)) { |
12503
9da198c570da
(svn r16940) -Codechange: make the pathfinders behave the same when finding waypoints or stations, i.e. don't force exactly one destination tile for a waypoint
rubidium <rubidium@openttd.org>
parents:
12475
diff
changeset
|
1777 if (v->current_order.IsType(OT_GOTO_STATION)) v->last_station_visited = v->current_order.GetDestination(); |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1778 UpdateVehicleTimetable(v, true); |
11866
1e159ef634d5
(svn r16260) -Codechange: Add Vehicle::IncrementOrderIndex() to deduplicate some code.
frosch <frosch@openttd.org>
parents:
11809
diff
changeset
|
1779 v->IncrementOrderIndex(); |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1780 } |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1781 |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1782 /* Get the current order */ |
10544
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1783 if (v->cur_order_index >= v->GetNumOrders()) v->cur_order_index = 0; |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1784 |
11991
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11983
diff
changeset
|
1785 const Order *order = v->GetOrder(v->cur_order_index); |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1786 |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1787 /* If no order, do nothing. */ |
8836
890a77315801
(svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents:
8835
diff
changeset
|
1788 if (order == NULL || (v->type == VEH_AIRCRAFT && order->IsType(OT_DUMMY) && !CheckForValidOrders(v))) { |
8830
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1789 if (v->type == VEH_AIRCRAFT) { |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1790 /* Aircraft do something vastly different here, so handle separately */ |
11981
cf1aad9b971c
(svn r16387) -Codechange: use Aircraft instead of Vehicle where appropriate
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
1791 extern void HandleMissingAircraftOrders(Aircraft *v); |
12114
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12082
diff
changeset
|
1792 HandleMissingAircraftOrders(Aircraft::From(v)); |
8830
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1793 return false; |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1794 } |
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1795 |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1796 v->current_order.Free(); |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1797 v->dest_tile = 0; |
12114
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12082
diff
changeset
|
1798 if (v->type == VEH_ROAD) ClearSlot(RoadVehicle::From(v)); |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1799 return false; |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1800 } |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1801 |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1802 /* If it is unchanged, keep it. */ |
8911
72fcd1140679
(svn r12681) -Fix [FS#1921]: aircraft stopping mid-air.
rubidium <rubidium@openttd.org>
parents:
8909
diff
changeset
|
1803 if (order->Equals(v->current_order) && (v->type == VEH_AIRCRAFT || v->dest_tile != 0) && |
11922
0a4b63f3f3c3
(svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents:
11866
diff
changeset
|
1804 (v->type != VEH_SHIP || !order->IsType(OT_GOTO_STATION) || Station::Get(order->GetDestination())->dock_tile != INVALID_TILE)) { |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1805 return false; |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1806 } |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1807 |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1808 /* Otherwise set it, and determine the destination tile. */ |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1809 v->current_order = *order; |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1810 |
12892
2245b86757b7
(svn r17384) -Fix [FS#2859]: remove all order window state changes out of the drawing routine and call them immediately when changes happen instead of on the next OnPaint. This prevents pressing buttons when they should've been already disabled.
rubidium <rubidium@openttd.org>
parents:
12804
diff
changeset
|
1811 InvalidateVehicleOrder(v, -2); |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1812 switch (v->type) { |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1813 default: |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1814 NOT_REACHED(); |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1815 |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1816 case VEH_ROAD: |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1817 case VEH_TRAIN: |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1818 break; |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1819 |
8830
981a95f3204d
(svn r12578) -Codechange: merge the aircrafts ProcessOrder too into the 'unified' ProcessOrder.
rubidium <rubidium@openttd.org>
parents:
8827
diff
changeset
|
1820 case VEH_AIRCRAFT: |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1821 case VEH_SHIP: |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
12892
diff
changeset
|
1822 SetWindowClassesDirty(GetWindowClassForVehicleType(v->type)); |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1823 break; |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1824 } |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1825 |
9440
8400f3760306
(svn r13358) -Codechange: split next order determination and conditional order processing functionality from the order handling. Patch based on work by michi_cc.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1826 return UpdateOrderDest(v, order) && may_reverse; |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
1827 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1828 |
8832
870ff040ec3e
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium <rubidium@openttd.org>
parents:
8830
diff
changeset
|
1829 /** |
870ff040ec3e
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium <rubidium@openttd.org>
parents:
8830
diff
changeset
|
1830 * Check whether the given vehicle should stop at the given station |
870ff040ec3e
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium <rubidium@openttd.org>
parents:
8830
diff
changeset
|
1831 * based on this order and the non-stop settings. |
870ff040ec3e
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium <rubidium@openttd.org>
parents:
8830
diff
changeset
|
1832 * @param v the vehicle that might be stopping. |
870ff040ec3e
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium <rubidium@openttd.org>
parents:
8830
diff
changeset
|
1833 * @param station the station to stop at. |
870ff040ec3e
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium <rubidium@openttd.org>
parents:
8830
diff
changeset
|
1834 * @return true if the vehicle should stop. |
870ff040ec3e
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium <rubidium@openttd.org>
parents:
8830
diff
changeset
|
1835 */ |
870ff040ec3e
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium <rubidium@openttd.org>
parents:
8830
diff
changeset
|
1836 bool Order::ShouldStopAtStation(const Vehicle *v, StationID station) const |
870ff040ec3e
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium <rubidium@openttd.org>
parents:
8830
diff
changeset
|
1837 { |
8941
3b0ffce16526
(svn r12716) -Fix: Do not compare StationIDs with DepotIDs or WaypointIDs.
frosch <frosch@openttd.org>
parents:
8926
diff
changeset
|
1838 bool is_dest_station = this->IsType(OT_GOTO_STATION) && this->dest == station; |
8832
870ff040ec3e
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium <rubidium@openttd.org>
parents:
8830
diff
changeset
|
1839 return |
9076
80b7a6d19efc
(svn r12935) -Fix [FS#1975]: vehicles forget their manual depot order when stopping at a station. Now we just pass through the station without stopping when a vehicle has been given a depot order.
rubidium <rubidium@openttd.org>
parents:
9061
diff
changeset
|
1840 (!this->IsType(OT_GOTO_DEPOT) || (this->GetDepotOrderType() & ODTFB_PART_OF_ORDERS) != 0) && |
8832
870ff040ec3e
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium <rubidium@openttd.org>
parents:
8830
diff
changeset
|
1841 v->last_station_visited != station && // Do stop only when we've not just been there |
8848
066a8010467f
(svn r12600) -Codechange: make GetNonStopType return a more augmented type; not is there a non-stop order but the kind of non-stop order, so one doesn't need to check _patches.new_nonstop type everywhere.
rubidium <rubidium@openttd.org>
parents:
8847
diff
changeset
|
1842 /* Finally do stop when there is no non-stop flag set for this type of station. */ |
8941
3b0ffce16526
(svn r12716) -Fix: Do not compare StationIDs with DepotIDs or WaypointIDs.
frosch <frosch@openttd.org>
parents:
8926
diff
changeset
|
1843 !(this->GetNonStopType() & (is_dest_station ? ONSF_NO_STOP_AT_DESTINATION_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS)); |
8832
870ff040ec3e
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium <rubidium@openttd.org>
parents:
8830
diff
changeset
|
1844 } |
870ff040ec3e
(svn r12580) -Codechange: merge some logical related to non-stop orders.
rubidium <rubidium@openttd.org>
parents:
8830
diff
changeset
|
1845 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6071
diff
changeset
|
1846 void InitializeOrders() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1847 { |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
1848 _order_pool.CleanPool(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1849 |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
1850 _orderlist_pool.CleanPool(); |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
1851 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1852 _backup_orders_tile = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1853 } |