comparison src/ship_cmd.cpp @ 7502:2250b8ea9466 draft

(svn r11017) -Codechange: unify determining whether a vehicle needs/can be service a little more.
author rubidium <rubidium@openttd.org>
date Fri, 31 Aug 2007 17:13:39 +0000
parents f538c635385c
children b8e1d03b1e83
comparison
equal deleted inserted replaced
7501:a99f8ea26c2a 7502:2250b8ea9466
138 return best_depot; 138 return best_depot;
139 } 139 }
140 140
141 static void CheckIfShipNeedsService(Vehicle *v) 141 static void CheckIfShipNeedsService(Vehicle *v)
142 { 142 {
143 const Depot* depot; 143 if (_patches.servint_ships == 0 || !VehicleNeedsService(v)) return;
144
145 if (_patches.servint_ships == 0) return;
146 if (!VehicleNeedsService(v)) return;
147 if (v->vehstatus & VS_STOPPED) return;
148
149 if (v->current_order.type == OT_GOTO_DEPOT &&
150 v->current_order.flags & OF_HALT_IN_DEPOT)
151 return;
152
153 if (_patches.gotodepot && VehicleHasDepotOrders(v)) return;
154
155 if (v->IsInDepot()) { 144 if (v->IsInDepot()) {
156 VehicleServiceInDepot(v); 145 VehicleServiceInDepot(v);
157 return; 146 return;
158 } 147 }
159 148
160 depot = FindClosestShipDepot(v); 149 const Depot *depot = FindClosestShipDepot(v);
161 150
162 if (depot == NULL || DistanceManhattan(v->tile, depot->xy) > 12) { 151 if (depot == NULL || DistanceManhattan(v->tile, depot->xy) > 12) {
163 if (v->current_order.type == OT_GOTO_DEPOT) { 152 if (v->current_order.type == OT_GOTO_DEPOT) {
164 v->current_order.type = OT_DUMMY; 153 v->current_order.type = OT_DUMMY;
165 v->current_order.flags = 0; 154 v->current_order.flags = 0;
166 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); 155 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
167 } 156 }
168 return; 157 return;
169 } 158 }
170 159
171 if (v->current_order.type == OT_LOADING) v->LeaveStation();
172 v->current_order.type = OT_GOTO_DEPOT; 160 v->current_order.type = OT_GOTO_DEPOT;
173 v->current_order.flags = OF_NON_STOP; 161 v->current_order.flags = OF_NON_STOP;
174 v->current_order.dest = depot->index; 162 v->current_order.dest = depot->index;
175 v->dest_tile = depot->xy; 163 v->dest_tile = depot->xy;
176 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); 164 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);