celestar@9895: /* $Id$ */ celestar@9895: celestar@9895: #include "stdafx.h" celestar@9895: #include "openttd.h" celestar@9895: #include "roadveh.h" celestar@9895: #include "ship.h" celestar@9895: #include "table/strings.h" celestar@9895: #include "functions.h" celestar@9895: #include "news.h" celestar@9895: #include "command.h" celestar@9895: #include "player.h" celestar@9895: #include "engine.h" celestar@9895: #include "debug.h" celestar@9895: #include "vehicle_gui.h" celestar@9895: #include "depot.h" celestar@9895: #include "train.h" celestar@9895: #include "aircraft.h" celestar@9895: #include "cargotype.h" celestar@9911: #include "group.h" celestar@9895: celestar@9895: celestar@9895: /* celestar@9895: * move the cargo from one engine to another if possible celestar@9895: */ celestar@9895: static void MoveVehicleCargo(Vehicle *dest, Vehicle *source) celestar@9895: { celestar@9895: Vehicle *v = dest; celestar@9895: int units_moved; celestar@9895: celestar@9895: do { celestar@9895: do { celestar@9895: if (source->cargo_type != dest->cargo_type) celestar@9895: continue; // cargo not compatible celestar@9895: celestar@9895: if (dest->cargo_count == dest->cargo_cap) celestar@9895: continue; // the destination vehicle is already full celestar@9895: celestar@9895: units_moved = min(source->cargo_count, dest->cargo_cap - dest->cargo_count); celestar@9895: source->cargo_count -= units_moved; celestar@9895: dest->cargo_count += units_moved; celestar@9895: dest->cargo_source = source->cargo_source; celestar@9895: celestar@9895: // copy the age of the cargo celestar@9895: dest->cargo_days = source->cargo_days; celestar@9895: dest->day_counter = source->day_counter; celestar@9895: dest->tick_counter = source->tick_counter; celestar@9895: celestar@9895: } while (source->cargo_count > 0 && (dest = dest->next) != NULL); celestar@9895: dest = v; celestar@9895: } while ((source = source->next) != NULL); celestar@9895: celestar@9895: /* celestar@9895: * The of the train will be incorrect at this moment. This is due celestar@9895: * to the fact that removing the old wagon updates the weight of celestar@9895: * the complete train, which is without the weight of cargo we just celestar@9895: * moved back into some (of the) new wagon(s). celestar@9895: */ celestar@9895: if (dest->type == VEH_TRAIN) TrainConsistChanged(dest->first); celestar@9895: } celestar@9895: celestar@9895: static bool VerifyAutoreplaceRefitForOrders(const Vehicle *v, const EngineID engine_type) celestar@9895: { celestar@9895: const Order *o; celestar@9895: const Vehicle *u; celestar@9895: celestar@9895: if (v->type == VEH_TRAIN) { celestar@9895: u = GetFirstVehicleInChain(v); celestar@9895: } else { celestar@9895: u = v; celestar@9895: } celestar@9895: celestar@9895: FOR_VEHICLE_ORDERS(u, o) { celestar@9895: if (!(o->refit_cargo < NUM_CARGO)) continue; celestar@9895: if (!CanRefitTo(v->engine_type, o->refit_cargo)) continue; celestar@9895: if (!CanRefitTo(engine_type, o->refit_cargo)) return false; celestar@9895: } celestar@9895: celestar@9895: return true; celestar@9895: } celestar@9895: celestar@9895: /** celestar@9895: * Function to find what type of cargo to refit to when autoreplacing celestar@9895: * @param *v Original vehicle, that is being replaced celestar@9895: * @param engine_type The EngineID of the vehicle that is being replaced to celestar@9895: * @return The cargo type to replace to celestar@9895: * CT_NO_REFIT is returned if no refit is needed celestar@9895: * CT_INVALID is returned when both old and new vehicle got cargo capacity and refitting the new one to the old one's cargo type isn't possible celestar@9895: */ celestar@9895: static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type) celestar@9895: { celestar@9910: CargoID new_cargo_type = GetEngineCargoType(engine_type); celestar@9895: celestar@9910: if (new_cargo_type == CT_INVALID) return CT_NO_REFIT; // Don't try to refit an engine with no cargo capacity celestar@9895: celestar@9895: if (v->cargo_type == new_cargo_type || CanRefitTo(engine_type, v->cargo_type)) { celestar@9895: if (VerifyAutoreplaceRefitForOrders(v, engine_type)) { celestar@9895: return v->cargo_type == new_cargo_type ? (CargoID)CT_NO_REFIT : v->cargo_type; celestar@9895: } else { celestar@9895: return CT_INVALID; celestar@9895: } celestar@9895: } celestar@9895: if (v->type != VEH_TRAIN) return CT_INVALID; // We can't refit the vehicle to carry the cargo we want celestar@9895: celestar@9895: /* Below this line it's safe to assume that the vehicle in question is a train */ celestar@9895: celestar@9895: if (v->cargo_cap != 0) return CT_INVALID; // trying to replace a vehicle with cargo capacity into another one with incompatible cargo type celestar@9895: celestar@9895: /* the old engine didn't have cargo capacity, but the new one does celestar@9895: * now we will figure out what cargo the train is carrying and refit to fit this */ celestar@9895: v = GetFirstVehicleInChain(v); celestar@9895: do { celestar@9895: if (v->cargo_cap == 0) continue; celestar@9895: /* Now we found a cargo type being carried on the train and we will see if it is possible to carry to this one */ celestar@9895: if (v->cargo_type == new_cargo_type) return CT_NO_REFIT; celestar@9895: if (CanRefitTo(engine_type, v->cargo_type)) return v->cargo_type; celestar@9910: } while ((v = v->next) != NULL); celestar@9895: return CT_NO_REFIT; // We failed to find a cargo type on the old vehicle and we will not refit the new one celestar@9895: } celestar@9895: celestar@9895: /* Replaces a vehicle (used to be called autorenew) celestar@9895: * This function is only called from MaybeReplaceVehicle() celestar@9895: * Must be called with _current_player set to the owner of the vehicle celestar@9895: * @param w Vehicle to replace celestar@9895: * @param flags is the flags to use when calling DoCommand(). Mainly DC_EXEC counts celestar@9895: * @return value is cost of the replacement or CMD_ERROR celestar@9895: */ celestar@9913: static CommandCost ReplaceVehicle(Vehicle **w, byte flags, int32 total_cost) celestar@9895: { celestar@9913: CommandCost cost; celestar@9913: CommandCost sell_value; celestar@9895: Vehicle *old_v = *w; celestar@9895: const Player *p = GetPlayer(old_v->owner); celestar@9895: EngineID new_engine_type; celestar@9895: const UnitID cached_unitnumber = old_v->unitnumber; celestar@9895: bool new_front = false; celestar@9895: Vehicle *new_v = NULL; celestar@9895: char vehicle_name[32]; celestar@9895: CargoID replacement_cargo_type; celestar@9895: celestar@9911: /* If the vehicle belongs to a group, check if the group is protected from the global autoreplace. celestar@9911: * If not, chek if an global auto replacement is defined */ celestar@9911: new_engine_type = (IsValidGroupID(old_v->group_id) && GetGroup(old_v->group_id)->replace_protection) ? celestar@9911: INVALID_ENGINE : celestar@9911: EngineReplacementForPlayer(p, old_v->engine_type, DEFAULT_GROUP); celestar@9911: celestar@9911: /* If we don't set new_egnine_type previously, we try to check if an autoreplacement was defined celestar@9911: * for the group and the engine_type of the vehicle */ celestar@9911: if (new_engine_type == INVALID_ENGINE && !IsDefaultGroupID(old_v->group_id)) { celestar@9911: new_engine_type = EngineReplacementForPlayer(p, old_v->engine_type, old_v->group_id); celestar@9911: } celestar@9911: celestar@9895: if (new_engine_type == INVALID_ENGINE) new_engine_type = old_v->engine_type; celestar@9895: celestar@9895: replacement_cargo_type = GetNewCargoTypeForReplace(old_v, new_engine_type); celestar@9895: celestar@9895: /* check if we can't refit to the needed type, so no replace takes place to prevent the vehicle from altering cargo type */ celestar@9895: if (replacement_cargo_type == CT_INVALID) return 0; celestar@9895: celestar@9895: sell_value = DoCommand(0, old_v->index, 0, DC_QUERY_COST, GetCmdSellVeh(old_v)); celestar@9895: celestar@9895: /* We give the player a loan of the same amount as the sell value. celestar@9895: * This is needed in case he needs the income from the sale to build the new vehicle. celestar@9895: * We take it back if building fails or when we really sell the old engine */ celestar@9895: SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); celestar@9895: SubtractMoneyFromPlayer(sell_value); celestar@9895: celestar@9895: cost = DoCommand(old_v->tile, new_engine_type, 3, flags, GetCmdBuildVeh(old_v)); celestar@9895: if (CmdFailed(cost)) { celestar@9895: SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); celestar@9895: SubtractMoneyFromPlayer(-sell_value); // Take back the money we just gave the player celestar@9895: return cost; celestar@9895: } celestar@9895: celestar@9912: if (replacement_cargo_type != CT_NO_REFIT) { celestar@9912: /* add refit cost */ celestar@9913: CommandCost refit_cost = GetRefitCost(new_engine_type); celestar@9912: if (old_v->type == VEH_TRAIN && IsMultiheaded(old_v)) refit_cost += refit_cost; // pay for both ends celestar@9912: cost += refit_cost; celestar@9912: } celestar@9895: celestar@9895: if (flags & DC_EXEC) { celestar@9895: new_v = GetVehicle(_new_vehicle_id); celestar@9895: *w = new_v; //we changed the vehicle, so MaybeReplaceVehicle needs to work on the new one. Now we tell it what the new one is celestar@9895: celestar@9895: /* refit if needed */ celestar@9895: if (replacement_cargo_type != CT_NO_REFIT) { celestar@9895: if (CmdFailed(DoCommand(0, new_v->index, replacement_cargo_type, DC_EXEC, GetCmdRefitVeh(new_v)))) { celestar@9895: /* Being here shows a failure, which most likely is in GetNewCargoTypeForReplace() or incorrect estimation costs */ celestar@9895: error("Autoreplace failed to refit. Replace engine %d to %d and refit to cargo %d", old_v->engine_type, new_v->engine_type, replacement_cargo_type); celestar@9895: } celestar@9895: } celestar@9895: celestar@9895: if (new_v->type == VEH_TRAIN && HASBIT(old_v->u.rail.flags, VRF_REVERSE_DIRECTION) && !IsMultiheaded(new_v) && !(new_v->next != NULL && IsArticulatedPart(new_v->next))) { celestar@9895: // we are autorenewing to a single engine, so we will turn it as the old one was turned as well celestar@9895: SETBIT(new_v->u.rail.flags, VRF_REVERSE_DIRECTION); celestar@9895: } celestar@9895: celestar@9895: if (old_v->type == VEH_TRAIN && !IsFrontEngine(old_v)) { celestar@9895: /* this is a railcar. We need to move the car into the train celestar@9895: * We add the new engine after the old one instead of replacing it. It will give the same result anyway when we celestar@9895: * sell the old engine in a moment celestar@9895: */ celestar@9912: /* Get the vehicle in front of the one we move out */ celestar@9912: Vehicle *front = GetPrevVehicleInChain(old_v); celestar@9912: /* If the vehicle in front is the rear end of a dualheaded engine, then we need to use the one in front of that one */ celestar@9912: if (IsMultiheaded(front) && !IsTrainEngine(front)) front = GetPrevVehicleInChain(front); celestar@9895: /* Now we move the old one out of the train */ celestar@9895: DoCommand(0, (INVALID_VEHICLE << 16) | old_v->index, 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); celestar@9912: /* Add the new vehicle */ celestar@9912: DoCommand(0, (front->index << 16) | new_v->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); celestar@9895: } else { celestar@9895: // copy/clone the orders celestar@9895: DoCommand(0, (old_v->index << 16) | new_v->index, IsOrderListShared(old_v) ? CO_SHARE : CO_COPY, DC_EXEC, CMD_CLONE_ORDER); celestar@9895: new_v->cur_order_index = old_v->cur_order_index; celestar@9895: ChangeVehicleViewWindow(old_v, new_v); celestar@9895: new_v->profit_this_year = old_v->profit_this_year; celestar@9895: new_v->profit_last_year = old_v->profit_last_year; celestar@9895: new_v->service_interval = old_v->service_interval; celestar@9911: DoCommand(0, old_v->group_id, new_v->index, flags, CMD_ADD_VEHICLE_GROUP); celestar@9895: new_front = true; celestar@9895: new_v->unitnumber = old_v->unitnumber; // use the same unit number celestar@9911: new_v->dest_tile = old_v->dest_tile; celestar@9895: celestar@9895: new_v->current_order = old_v->current_order; celestar@9895: if (old_v->type == VEH_TRAIN && GetNextVehicle(old_v) != NULL){ celestar@9895: Vehicle *temp_v = GetNextVehicle(old_v); celestar@9895: celestar@9895: // move the entire train to the new engine, excluding the old engine celestar@9895: if (IsMultiheaded(old_v) && temp_v == old_v->u.rail.other_multiheaded_part) { celestar@9895: // we got front and rear of a multiheaded engine right after each other. We should work with the next in line instead celestar@9895: temp_v = GetNextVehicle(temp_v); celestar@9895: } celestar@9895: celestar@9895: if (temp_v != NULL) { celestar@9895: DoCommand(0, (new_v->index << 16) | temp_v->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); celestar@9895: } celestar@9895: } celestar@9895: } celestar@9895: /* We are done setting up the new vehicle. Now we move the cargo from the old one to the new one */ celestar@9895: MoveVehicleCargo(new_v->type == VEH_TRAIN ? GetFirstVehicleInChain(new_v) : new_v, old_v); celestar@9895: celestar@9895: // Get the name of the old vehicle if it has a custom name. celestar@9895: if (!IsCustomName(old_v->string_id)) { celestar@9895: vehicle_name[0] = '\0'; celestar@9895: } else { celestar@9895: GetName(vehicle_name, old_v->string_id & 0x7FF, lastof(vehicle_name)); celestar@9895: } celestar@9895: } else { // flags & DC_EXEC not set celestar@9913: CommandCost tmp_move = 0; celestar@9912: if (old_v->type == VEH_TRAIN && IsFrontEngine(old_v) && old_v->next != NULL) { celestar@9912: /* Verify that the wagons can be placed on the engine in question. celestar@9912: * This is done by building an engine, test if the wagons can be added and then sell the test engine. */ celestar@9912: DoCommand(old_v->tile, new_engine_type, 3, DC_EXEC, GetCmdBuildVeh(old_v)); celestar@9912: Vehicle *temp = GetVehicle(_new_vehicle_id); celestar@9912: tmp_move = DoCommand(0, (temp->index << 16) | old_v->next->index, 1, 0, CMD_MOVE_RAIL_VEHICLE); celestar@9912: DoCommand(0, temp->index, 0, DC_EXEC, GetCmdSellVeh(old_v)); celestar@9912: } celestar@9912: celestar@9895: /* Ensure that the player will not end up having negative money while autoreplacing celestar@9895: * This is needed because the only other check is done after the income from selling the old vehicle is substracted from the cost */ celestar@9912: if (CmdFailed(tmp_move) || p->money64 < (cost + total_cost)) { celestar@9895: SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); celestar@9895: SubtractMoneyFromPlayer(-sell_value); // Pay back the loan celestar@9895: return CMD_ERROR; celestar@9895: } celestar@9895: } celestar@9895: celestar@9895: /* Take back the money we just gave the player just before building the vehicle celestar@9895: * The player will get the same amount now that the sale actually takes place */ celestar@9895: SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); celestar@9895: SubtractMoneyFromPlayer(-sell_value); celestar@9895: celestar@9895: /* sell the engine/ find out how much you get for the old engine (income is returned as negative cost) */ celestar@9895: cost += DoCommand(0, old_v->index, 0, flags, GetCmdSellVeh(old_v)); celestar@9895: celestar@9895: if (new_front) { celestar@9895: /* now we assign the old unitnumber to the new vehicle */ celestar@9895: new_v->unitnumber = cached_unitnumber; celestar@9895: } celestar@9895: celestar@9895: /* Transfer the name of the old vehicle */ celestar@9895: if ((flags & DC_EXEC) && vehicle_name[0] != '\0') { celestar@9895: _cmd_text = vehicle_name; celestar@9895: DoCommand(0, new_v->index, 0, DC_EXEC, CMD_NAME_VEHICLE); celestar@9895: } celestar@9895: celestar@9895: return cost; celestar@9895: } celestar@9895: celestar@9895: /** replaces a vehicle if it's set for autoreplace or is too old celestar@9895: * (used to be called autorenew) celestar@9895: * @param v The vehicle to replace celestar@9895: * if the vehicle is a train, v needs to be the front engine celestar@9895: * @param check Checks if the replace is valid. No action is done at all celestar@9895: * @param display_costs If set, a cost animation is shown (only if check is false) celestar@9895: * @return CMD_ERROR if something went wrong. Otherwise the price of the replace celestar@9895: */ celestar@9913: CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs) celestar@9895: { celestar@9895: Vehicle *w; celestar@9895: const Player *p = GetPlayer(v->owner); celestar@9895: byte flags = 0; celestar@9913: CommandCost cost, temp_cost = 0; celestar@9895: bool stopped; celestar@9895: celestar@9895: /* Remember the length in case we need to trim train later on celestar@9895: * If it's not a train, the value is unused celestar@9895: * round up to the length of the tiles used for the train instead of the train length instead celestar@9895: * Useful when newGRF uses custom length */ celestar@9895: uint16 old_total_length = (v->type == VEH_TRAIN ? celestar@9895: (v->u.rail.cached_total_length + TILE_SIZE - 1) / TILE_SIZE * TILE_SIZE : celestar@9895: -1 celestar@9895: ); celestar@9895: celestar@9895: celestar@9895: _current_player = v->owner; celestar@9895: celestar@9895: assert(IsPlayerBuildableVehicleType(v)); celestar@9895: celestar@9895: assert(v->vehstatus & VS_STOPPED); // the vehicle should have been stopped in VehicleEnteredDepotThisTick() if needed celestar@9895: celestar@9895: /* Remember the flag v->leave_depot_instantly because if we replace the vehicle, the vehicle holding this flag will be sold celestar@9895: * If it is set, then we only stopped the vehicle to replace it (if needed) and we will need to start it again. celestar@9895: * We also need to reset the flag since it should remain false except from when the vehicle enters a depot until autoreplace is handled in the same tick */ celestar@9895: stopped = v->leave_depot_instantly; celestar@9895: v->leave_depot_instantly = false; celestar@9895: celestar@9895: for (;;) { celestar@9895: cost = 0; celestar@9895: w = v; celestar@9895: do { celestar@9895: if (w->type == VEH_TRAIN && IsMultiheaded(w) && !IsTrainEngine(w)) { celestar@9895: /* we build the rear ends of multiheaded trains with the front ones */ celestar@9895: continue; celestar@9895: } celestar@9895: celestar@9895: // check if the vehicle should be replaced celestar@9895: if (!p->engine_renew || celestar@9895: w->age - w->max_age < (p->engine_renew_months * 30) || // replace if engine is too old celestar@9895: w->max_age == 0) { // rail cars got a max age of 0 celestar@9911: /* If the vehicle belongs to a group, check if the group is protected from the global autoreplace. celestar@9911: If not, chek if an global auto remplacement is defined */ celestar@9911: if (IsValidGroupID(w->group_id)) { celestar@9911: if (!EngineHasReplacementForPlayer(p, w->engine_type, w->group_id) && ( celestar@9911: GetGroup(w->group_id)->replace_protection || celestar@9911: !EngineHasReplacementForPlayer(p, w->engine_type, DEFAULT_GROUP))) { celestar@9911: continue; celestar@9911: } celestar@9911: } else if (!EngineHasReplacementForPlayer(p, w->engine_type, DEFAULT_GROUP)) { celestar@9895: continue; celestar@9911: } celestar@9895: } celestar@9895: celestar@9895: /* Now replace the vehicle */ celestar@9895: temp_cost = ReplaceVehicle(&w, flags, cost); celestar@9895: celestar@9912: if (CmdFailed(temp_cost)) break; // replace failed for some reason. Leave the vehicle alone celestar@9912: celestar@9895: if (flags & DC_EXEC && celestar@9895: (w->type != VEH_TRAIN || w->u.rail.first_engine == INVALID_ENGINE)) { celestar@9895: /* now we bought a new engine and sold the old one. We need to fix the celestar@9895: * pointers in order to avoid pointing to the old one for trains: these celestar@9895: * pointers should point to the front engine and not the cars celestar@9895: */ celestar@9895: v = w; celestar@9895: } celestar@9912: cost += temp_cost; celestar@9895: } while (w->type == VEH_TRAIN && (w = GetNextVehicle(w)) != NULL); celestar@9895: celestar@9895: if (!(flags & DC_EXEC) && (p->money64 < (int32)(cost + p->engine_renew_money) || cost == 0)) { celestar@9895: if (!check && p->money64 < (int32)(cost + p->engine_renew_money) && ( _local_player == v->owner ) && cost != 0) { celestar@9895: StringID message; celestar@9895: SetDParam(0, v->unitnumber); celestar@9895: switch (v->type) { celestar@9895: case VEH_TRAIN: message = STR_TRAIN_AUTORENEW_FAILED; break; celestar@9895: case VEH_ROAD: message = STR_ROADVEHICLE_AUTORENEW_FAILED; break; celestar@9895: case VEH_SHIP: message = STR_SHIP_AUTORENEW_FAILED; break; celestar@9895: case VEH_AIRCRAFT: message = STR_AIRCRAFT_AUTORENEW_FAILED; break; celestar@9895: // This should never happen celestar@9895: default: NOT_REACHED(); message = 0; break; celestar@9895: } celestar@9895: celestar@9895: AddNewsItem(message, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), v->index, 0); celestar@9895: } celestar@9895: if (stopped) v->vehstatus &= ~VS_STOPPED; celestar@9895: if (display_costs) _current_player = OWNER_NONE; celestar@9895: return CMD_ERROR; celestar@9895: } celestar@9895: celestar@9895: if (flags & DC_EXEC) { celestar@9895: break; // we are done replacing since the loop ran once with DC_EXEC celestar@9895: } else if (check) { celestar@9895: /* It's a test only and we know that we can do this celestar@9895: * NOTE: payment for wagon removal is NOT included in this price */ celestar@9895: return cost; celestar@9895: } celestar@9895: // now we redo the loop, but this time we actually do stuff since we know that we can do it celestar@9895: flags |= DC_EXEC; celestar@9895: } celestar@9895: celestar@9895: /* If setting is on to try not to exceed the old length of the train with the replacement */ celestar@9895: if (v->type == VEH_TRAIN && p->renew_keep_length) { celestar@9895: Vehicle *temp; celestar@9895: w = v; celestar@9895: celestar@9895: while (v->u.rail.cached_total_length > old_total_length) { celestar@9895: // the train is too long. We will remove cars one by one from the start of the train until it's short enough celestar@9895: while (w != NULL && RailVehInfo(w->engine_type)->railveh_type != RAILVEH_WAGON) { celestar@9895: w = GetNextVehicle(w); celestar@9895: } celestar@9895: if (w == NULL) { celestar@9895: // we failed to make the train short enough celestar@9895: SetDParam(0, v->unitnumber); celestar@9895: AddNewsItem(STR_TRAIN_TOO_LONG_AFTER_REPLACEMENT, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), v->index, 0); celestar@9895: break; celestar@9895: } celestar@9895: temp = w; celestar@9895: w = GetNextVehicle(w); celestar@9895: DoCommand(0, (INVALID_VEHICLE << 16) | temp->index, 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); celestar@9895: MoveVehicleCargo(v, temp); celestar@9895: cost += DoCommand(0, temp->index, 0, DC_EXEC, CMD_SELL_RAIL_WAGON); celestar@9895: } celestar@9895: } celestar@9895: celestar@9895: if (stopped) v->vehstatus &= ~VS_STOPPED; celestar@9895: if (display_costs) { celestar@9895: if (IsLocalPlayer()) ShowCostOrIncomeAnimation(v->x_pos, v->y_pos, v->z_pos, cost); celestar@9895: _current_player = OWNER_NONE; celestar@9895: } celestar@9895: return cost; celestar@9895: }