tron@2186: /* $Id$ */ tron@2186: truelight@0: #include "stdafx.h" Darkvater@1891: #include "openttd.h" tron@3959: #include "roadveh.h" tron@3961: #include "ship.h" truelight@0: #include "news.h" rubidium@8750: #include "player_func.h" truelight@0: #include "engine.h" celestar@1601: #include "debug.h" matthijs@1752: #include "vehicle_gui.h" matthijs@1758: #include "depot.h" bjarni@2676: #include "train.h" bjarni@4662: #include "aircraft.h" peter1138@6439: #include "cargotype.h" rubidium@7139: #include "group.h" smatz@8560: #include "order.h" rubidium@8610: #include "strings_func.h" rubidium@8612: #include "command_func.h" rubidium@8640: #include "vehicle_func.h" rubidium@8627: #include "functions.h" rubidium@8707: #include "variables.h" rubidium@8708: #include "autoreplace_func.h" bjarni@8859: #include "articulated_vehicles.h" bjarni@2244: rubidium@8760: #include "table/strings.h" rubidium@8760: bjarni@9124: bjarni@2599: /* bjarni@2599: * move the cargo from one engine to another if possible bjarni@2599: */ bjarni@2599: static void MoveVehicleCargo(Vehicle *dest, Vehicle *source) bjarni@2599: { bjarni@2599: Vehicle *v = dest; bjarni@2599: bjarni@2599: do { bjarni@2599: do { bjarni@2599: if (source->cargo_type != dest->cargo_type) rubidium@4434: continue; // cargo not compatible bjarni@2599: rubidium@7506: if (dest->cargo.Count() == dest->cargo_cap) rubidium@4434: continue; // the destination vehicle is already full bjarni@2599: rubidium@7506: uint units_moved = min(source->cargo.Count(), dest->cargo_cap - dest->cargo.Count()); rubidium@7506: source->cargo.MoveTo(&dest->cargo, units_moved); bjarni@2599: bjarni@2599: // copy the age of the cargo bjarni@2599: dest->day_counter = source->day_counter; bjarni@2599: dest->tick_counter = source->tick_counter; bjarni@2599: rubidium@7988: } while (source->cargo.Count() > 0 && (dest = dest->Next()) != NULL); bjarni@2599: dest = v; rubidium@7988: } while ((source = source->Next()) != NULL); rubidium@5944: rubidium@5944: /* rubidium@5944: * The of the train will be incorrect at this moment. This is due rubidium@5944: * to the fact that removing the old wagon updates the weight of rubidium@5944: * the complete train, which is without the weight of cargo we just rubidium@5944: * moved back into some (of the) new wagon(s). rubidium@5944: */ rubidium@7993: if (dest->type == VEH_TRAIN) TrainConsistChanged(dest->First()); bjarni@2599: } bjarni@2599: bjarni@4741: static bool VerifyAutoreplaceRefitForOrders(const Vehicle *v, const EngineID engine_type) bjarni@4741: { bjarni@4741: const Order *o; bjarni@4741: const Vehicle *u; bjarni@4741: rubidium@6585: if (v->type == VEH_TRAIN) { rubidium@7993: u = v->First(); bjarni@4741: } else { bjarni@4741: u = v; bjarni@4741: } bjarni@4741: bjarni@4741: FOR_VEHICLE_ORDERS(u, o) { bjarni@4782: if (!(o->refit_cargo < NUM_CARGO)) continue; bjarni@4741: if (!CanRefitTo(v->engine_type, o->refit_cargo)) continue; bjarni@4741: if (!CanRefitTo(engine_type, o->refit_cargo)) return false; bjarni@4741: } bjarni@4741: bjarni@4741: return true; bjarni@4741: } bjarni@4741: bjarni@4554: /** bjarni@4554: * Function to find what type of cargo to refit to when autoreplacing bjarni@4554: * @param *v Original vehicle, that is being replaced bjarni@4554: * @param engine_type The EngineID of the vehicle that is being replaced to bjarni@4554: * @return The cargo type to replace to bjarni@4554: * CT_NO_REFIT is returned if no refit is needed bjarni@4554: * 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 bjarni@4554: */ bjarni@4554: static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type) bjarni@4554: { bjarni@7001: CargoID new_cargo_type = GetEngineCargoType(engine_type); bjarni@4554: bjarni@7001: if (new_cargo_type == CT_INVALID) return CT_NO_REFIT; // Don't try to refit an engine with no cargo capacity bjarni@4554: bjarni@8858: if (v->cargo_cap != 0 && (v->cargo_type == new_cargo_type || CanRefitTo(engine_type, v->cargo_type))) { bjarni@4741: if (VerifyAutoreplaceRefitForOrders(v, engine_type)) { rubidium@5838: return v->cargo_type == new_cargo_type ? (CargoID)CT_NO_REFIT : v->cargo_type; bjarni@4741: } else { bjarni@4741: return CT_INVALID; bjarni@4741: } bjarni@4741: } rubidium@6585: if (v->type != VEH_TRAIN) return CT_INVALID; // We can't refit the vehicle to carry the cargo we want bjarni@4554: bjarni@4554: /* Below this line it's safe to assume that the vehicle in question is a train */ bjarni@4554: bjarni@4554: if (v->cargo_cap != 0) return CT_INVALID; // trying to replace a vehicle with cargo capacity into another one with incompatible cargo type bjarni@4554: bjarni@4554: /* the old engine didn't have cargo capacity, but the new one does bjarni@4554: * now we will figure out what cargo the train is carrying and refit to fit this */ rubidium@7993: v = v->First(); bjarni@4554: do { bjarni@4554: if (v->cargo_cap == 0) continue; bjarni@4554: /* Now we found a cargo type being carried on the train and we will see if it is possible to carry to this one */ bjarni@4554: if (v->cargo_type == new_cargo_type) return CT_NO_REFIT; bjarni@4554: if (CanRefitTo(engine_type, v->cargo_type)) return v->cargo_type; rubidium@7988: } while ((v = v->Next()) != NULL); bjarni@4554: return CT_NO_REFIT; // We failed to find a cargo type on the old vehicle and we will not refit the new one bjarni@4554: } bjarni@4554: bjarni@2552: /* Replaces a vehicle (used to be called autorenew) tron@2639: * This function is only called from MaybeReplaceVehicle() bjarni@2552: * Must be called with _current_player set to the owner of the vehicle bjarni@2552: * @param w Vehicle to replace bjarni@2552: * @param flags is the flags to use when calling DoCommand(). Mainly DC_EXEC counts tron@2639: * @return value is cost of the replacement or CMD_ERROR bjarni@2552: */ rubidium@7486: static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost) bjarni@2552: { rubidium@7439: CommandCost cost; rubidium@7439: CommandCost sell_value; bjarni@2599: Vehicle *old_v = *w; bjarni@2552: const Player *p = GetPlayer(old_v->owner); bjarni@2552: EngineID new_engine_type; bjarni@2552: const UnitID cached_unitnumber = old_v->unitnumber; bjarni@2552: bool new_front = false; bjarni@2552: Vehicle *new_v = NULL; peter1138@8754: char *vehicle_name = NULL; bjarni@4554: CargoID replacement_cargo_type; bjarni@2552: frosch@9176: /* Check if there is a autoreplacement set for the vehicle */ frosch@9176: new_engine_type = EngineReplacementForPlayer(p, old_v->engine_type, old_v->group_id); frosch@9176: /* if not, just renew to the same type */ rubidium@7146: if (new_engine_type == INVALID_ENGINE) new_engine_type = old_v->engine_type; rubidium@7146: bjarni@4554: replacement_cargo_type = GetNewCargoTypeForReplace(old_v, new_engine_type); bjarni@4554: bjarni@4554: /* check if we can't refit to the needed type, so no replace takes place to prevent the vehicle from altering cargo type */ rubidium@7446: if (replacement_cargo_type == CT_INVALID) return CommandCost(); bjarni@4554: bjarni@6043: sell_value = DoCommand(0, old_v->index, 0, DC_QUERY_COST, GetCmdSellVeh(old_v)); bjarni@4728: bjarni@4728: /* We give the player a loan of the same amount as the sell value. bjarni@4728: * This is needed in case he needs the income from the sale to build the new vehicle. bjarni@4728: * We take it back if building fails or when we really sell the old engine */ bjarni@4728: SubtractMoneyFromPlayer(sell_value); bjarni@4728: bjarni@6043: cost = DoCommand(old_v->tile, new_engine_type, 3, flags, GetCmdBuildVeh(old_v)); bjarni@4728: if (CmdFailed(cost)) { rubidium@7446: /* Take back the money we just gave the player */ rubidium@7446: sell_value.MultiplyCost(-1); rubidium@7446: SubtractMoneyFromPlayer(sell_value); bjarni@4728: return cost; bjarni@4728: } bjarni@2552: bjarni@7242: if (replacement_cargo_type != CT_NO_REFIT) { bjarni@7242: /* add refit cost */ rubidium@7439: CommandCost refit_cost = GetRefitCost(new_engine_type); bjarni@8859: if (old_v->type == VEH_TRAIN && RailVehInfo(new_engine_type)->railveh_type == RAILVEH_MULTIHEAD) { bjarni@8859: /* Since it's a dualheaded engine we have to pay once more because the rear end is being refitted too. */ bjarni@8859: refit_cost.AddCost(refit_cost); bjarni@8859: } rubidium@7446: cost.AddCost(refit_cost); bjarni@7242: } bjarni@4554: bjarni@2552: if (flags & DC_EXEC) { bjarni@2564: new_v = GetVehicle(_new_vehicle_id); rubidium@4434: *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 bjarni@2552: bjarni@2552: /* refit if needed */ bjarni@4554: if (replacement_cargo_type != CT_NO_REFIT) { bjarni@6043: if (CmdFailed(DoCommand(0, new_v->index, replacement_cargo_type, DC_EXEC, GetCmdRefitVeh(new_v)))) { bjarni@4613: /* Being here shows a failure, which most likely is in GetNewCargoTypeForReplace() or incorrect estimation costs */ bjarni@4613: 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); bjarni@4611: } bjarni@2552: } bjarni@4611: skidd13@8424: 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()))) { bjarni@3896: // we are autorenewing to a single engine, so we will turn it as the old one was turned as well skidd13@8427: SetBit(new_v->u.rail.flags, VRF_REVERSE_DIRECTION); bjarni@3896: } bjarni@2552: rubidium@6585: if (old_v->type == VEH_TRAIN && !IsFrontEngine(old_v)) { bjarni@2552: /* this is a railcar. We need to move the car into the train bjarni@2552: * We add the new engine after the old one instead of replacing it. It will give the same result anyway when we bjarni@2552: * sell the old engine in a moment bjarni@2552: */ bjarni@7231: /* Get the vehicle in front of the one we move out */ rubidium@7993: Vehicle *front = old_v->Previous(); bjarni@7231: /* 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 */ bjarni@8022: if (IsRearDualheaded(front)) front = front->Previous(); bjarni@2678: /* Now we move the old one out of the train */ tron@3491: DoCommand(0, (INVALID_VEHICLE << 16) | old_v->index, 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); bjarni@7202: /* Add the new vehicle */ bjarni@7202: DoCommand(0, (front->index << 16) | new_v->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); bjarni@2552: } else { bjarni@2552: // copy/clone the orders belugas@8965: DoCommand(0, (old_v->index << 16) | new_v->index, old_v->IsOrderListShared() ? CO_SHARE : CO_COPY, DC_EXEC, CMD_CLONE_ORDER); bjarni@2552: new_v->cur_order_index = old_v->cur_order_index; bjarni@2552: ChangeVehicleViewWindow(old_v, new_v); bjarni@2575: new_v->profit_this_year = old_v->profit_this_year; bjarni@2575: new_v->profit_last_year = old_v->profit_last_year; bjarni@3679: new_v->service_interval = old_v->service_interval; rubidium@7143: DoCommand(0, old_v->group_id, new_v->index, flags, CMD_ADD_VEHICLE_GROUP); bjarni@2552: new_front = true; rubidium@4434: new_v->unitnumber = old_v->unitnumber; // use the same unit number bjarni@7047: new_v->dest_tile = old_v->dest_tile; bjarni@2552: bjarni@2552: new_v->current_order = old_v->current_order; rubidium@6585: if (old_v->type == VEH_TRAIN && GetNextVehicle(old_v) != NULL){ bjarni@2842: Vehicle *temp_v = GetNextVehicle(old_v); bjarni@2842: bjarni@2842: // move the entire train to the new engine, excluding the old engine bjarni@2842: if (IsMultiheaded(old_v) && temp_v == old_v->u.rail.other_multiheaded_part) { bjarni@2842: // we got front and rear of a multiheaded engine right after each other. We should work with the next in line instead bjarni@2842: temp_v = GetNextVehicle(temp_v); bjarni@2842: } bjarni@2842: bjarni@2842: if (temp_v != NULL) { tron@3491: DoCommand(0, (new_v->index << 16) | temp_v->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); bjarni@2681: } bjarni@2552: } bjarni@2552: } bjarni@2678: /* We are done setting up the new vehicle. Now we move the cargo from the old one to the new one */ rubidium@7993: MoveVehicleCargo(new_v->type == VEH_TRAIN ? new_v->First() : new_v, old_v); peter1138@2716: peter1138@2716: // Get the name of the old vehicle if it has a custom name. peter1138@8754: if (old_v->name != NULL) vehicle_name = strdup(old_v->name); bjarni@4554: } else { // flags & DC_EXEC not set rubidium@7446: CommandCost tmp_move; bjarni@8020: bjarni@8020: if (old_v->type == VEH_TRAIN && IsFrontEngine(old_v)) { bjarni@8023: Vehicle *next_veh = GetNextUnit(old_v); // don't try to move the rear multiheaded engine or articulated parts bjarni@8020: if (next_veh != NULL) { bjarni@8020: /* Verify that the wagons can be placed on the engine in question. bjarni@8020: * This is done by building an engine, test if the wagons can be added and then sell the test engine. */ bjarni@8020: DoCommand(old_v->tile, new_engine_type, 3, DC_EXEC, GetCmdBuildVeh(old_v)); bjarni@8020: Vehicle *temp = GetVehicle(_new_vehicle_id); bjarni@8020: tmp_move = DoCommand(0, (temp->index << 16) | next_veh->index, 1, 0, CMD_MOVE_RAIL_VEHICLE); bjarni@8020: DoCommand(0, temp->index, 0, DC_EXEC, GetCmdSellVeh(old_v)); bjarni@8020: } bjarni@7296: } bjarni@7296: bjarni@4554: /* Ensure that the player will not end up having negative money while autoreplacing bjarni@4554: * This is needed because the only other check is done after the income from selling the old vehicle is substracted from the cost */ rubidium@7448: if (CmdFailed(tmp_move) || p->player_money < (cost.GetCost() + total_cost)) { rubidium@7446: /* Pay back the loan */ rubidium@7446: sell_value.MultiplyCost(-1); rubidium@7446: SubtractMoneyFromPlayer(sell_value); bjarni@4728: return CMD_ERROR; bjarni@4728: } bjarni@2552: } bjarni@2552: bjarni@4728: /* Take back the money we just gave the player just before building the vehicle bjarni@4728: * The player will get the same amount now that the sale actually takes place */ rubidium@7446: sell_value.MultiplyCost(-1); rubidium@7446: SubtractMoneyFromPlayer(sell_value); bjarni@4728: bjarni@4554: /* sell the engine/ find out how much you get for the old engine (income is returned as negative cost) */ rubidium@7446: cost.AddCost(DoCommand(0, old_v->index, 0, flags, GetCmdSellVeh(old_v))); bjarni@2552: bjarni@2552: if (new_front) { bjarni@4554: /* now we assign the old unitnumber to the new vehicle */ bjarni@2552: new_v->unitnumber = cached_unitnumber; bjarni@2552: } bjarni@2552: bjarni@4554: /* Transfer the name of the old vehicle */ peter1138@8754: if ((flags & DC_EXEC) && vehicle_name != NULL) { peter1138@2716: _cmd_text = vehicle_name; tron@3491: DoCommand(0, new_v->index, 0, DC_EXEC, CMD_NAME_VEHICLE); peter1138@8754: free(vehicle_name); peter1138@2716: } peter1138@2716: bjarni@2552: return cost; bjarni@2552: } bjarni@2552: tron@2639: /** replaces a vehicle if it's set for autoreplace or is too old tron@2639: * (used to be called autorenew) tron@2639: * @param v The vehicle to replace rubidium@4434: * if the vehicle is a train, v needs to be the front engine bjarni@4662: * @param check Checks if the replace is valid. No action is done at all bjarni@4662: * @param display_costs If set, a cost animation is shown (only if check is false) bjarni@4662: * @return CMD_ERROR if something went wrong. Otherwise the price of the replace tron@2639: */ rubidium@7439: CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs) bjarni@2552: { bjarni@2552: Vehicle *w; bjarni@2552: const Player *p = GetPlayer(v->owner); bjarni@2552: byte flags = 0; rubidium@7446: CommandCost cost, temp_cost; bjarni@5937: bool stopped; tron@2805: tron@2805: /* Remember the length in case we need to trim train later on bjarni@3175: * If it's not a train, the value is unused bjarni@3175: * round up to the length of the tiles used for the train instead of the train length instead bjarni@3175: * Useful when newGRF uses custom length */ rubidium@6585: uint16 old_total_length = (v->type == VEH_TRAIN ? celestar@3422: (v->u.rail.cached_total_length + TILE_SIZE - 1) / TILE_SIZE * TILE_SIZE : celestar@3422: -1 celestar@3422: ); bjarni@3175: bjarni@2552: bjarni@2552: _current_player = v->owner; bjarni@2552: bjarni@6045: assert(IsPlayerBuildableVehicleType(v)); bjarni@2579: rubidium@4434: assert(v->vehstatus & VS_STOPPED); // the vehicle should have been stopped in VehicleEnteredDepotThisTick() if needed bjarni@2590: bjarni@5937: /* Remember the flag v->leave_depot_instantly because if we replace the vehicle, the vehicle holding this flag will be sold bjarni@5937: * If it is set, then we only stopped the vehicle to replace it (if needed) and we will need to start it again. bjarni@5937: * 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 */ bjarni@5937: stopped = v->leave_depot_instantly; bjarni@5937: v->leave_depot_instantly = false; bjarni@2552: tron@2639: for (;;) { rubidium@8726: cost = CommandCost(EXPENSES_NEW_VEHICLES); bjarni@2552: w = v; bjarni@2552: do { bjarni@8022: if (w->type == VEH_TRAIN && IsRearDualheaded(w)) { bjarni@2676: /* we build the rear ends of multiheaded trains with the front ones */ bjarni@2676: continue; bjarni@2676: } bjarni@2676: bjarni@2552: // check if the vehicle should be replaced bjarni@9124: if (!w->NeedsAutorenewing(p) || // replace if engine is too old tron@2639: w->max_age == 0) { // rail cars got a max age of 0 frosch@9176: if (!EngineHasReplacementForPlayer(p, w->engine_type, w->group_id)) continue; bjarni@2552: } bjarni@2552: bjarni@2552: /* Now replace the vehicle */ rubidium@7446: temp_cost = ReplaceVehicle(&w, flags, cost.GetCost()); bjarni@2552: bjarni@7296: if (CmdFailed(temp_cost)) break; // replace failed for some reason. Leave the vehicle alone bjarni@7296: tron@2639: if (flags & DC_EXEC && rubidium@6585: (w->type != VEH_TRAIN || w->u.rail.first_engine == INVALID_ENGINE)) { tron@2639: /* now we bought a new engine and sold the old one. We need to fix the tron@2639: * pointers in order to avoid pointing to the old one for trains: these tron@2639: * pointers should point to the front engine and not the cars tron@2639: */ bjarni@2552: v = w; bjarni@2552: } rubidium@7446: cost.AddCost(temp_cost); rubidium@6585: } while (w->type == VEH_TRAIN && (w = GetNextVehicle(w)) != NULL); bjarni@2552: rubidium@7448: if (!(flags & DC_EXEC) && (p->player_money < (cost.GetCost() + p->engine_renew_money) || cost.GetCost() == 0)) { rubidium@7448: if (!check && p->player_money < (cost.GetCost() + p->engine_renew_money) && ( _local_player == v->owner ) && cost.GetCost() != 0) { bjarni@2552: StringID message; bjarni@2552: SetDParam(0, v->unitnumber); bjarni@2552: switch (v->type) { rubidium@6585: case VEH_TRAIN: message = STR_TRAIN_AUTORENEW_FAILED; break; rubidium@6585: case VEH_ROAD: message = STR_ROADVEHICLE_AUTORENEW_FAILED; break; rubidium@6585: case VEH_SHIP: message = STR_SHIP_AUTORENEW_FAILED; break; rubidium@6585: case VEH_AIRCRAFT: message = STR_AIRCRAFT_AUTORENEW_FAILED; break; bjarni@2552: // This should never happen bjarni@2552: default: NOT_REACHED(); message = 0; break; bjarni@2552: } bjarni@2552: bjarni@2552: AddNewsItem(message, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), v->index, 0); bjarni@2552: } tron@2639: if (stopped) v->vehstatus &= ~VS_STOPPED; bjarni@4676: if (display_costs) _current_player = OWNER_NONE; bjarni@4662: return CMD_ERROR; bjarni@2552: } bjarni@2552: bjarni@2552: if (flags & DC_EXEC) { rubidium@4434: break; // we are done replacing since the loop ran once with DC_EXEC bjarni@4662: } else if (check) { bjarni@4662: /* It's a test only and we know that we can do this bjarni@4662: * NOTE: payment for wagon removal is NOT included in this price */ bjarni@4662: return cost; bjarni@2552: } bjarni@2552: // now we redo the loop, but this time we actually do stuff since we know that we can do it bjarni@2552: flags |= DC_EXEC; bjarni@2552: } bjarni@2552: tron@2805: /* If setting is on to try not to exceed the old length of the train with the replacement */ rubidium@6585: if (v->type == VEH_TRAIN && p->renew_keep_length) { bjarni@2617: Vehicle *temp; bjarni@2617: w = v; tron@2805: tron@2805: while (v->u.rail.cached_total_length > old_total_length) { bjarni@2617: // the train is too long. We will remove cars one by one from the start of the train until it's short enough belugas@6119: while (w != NULL && RailVehInfo(w->engine_type)->railveh_type != RAILVEH_WAGON) { bjarni@2617: w = GetNextVehicle(w); bjarni@2617: } bjarni@2617: if (w == NULL) { bjarni@2617: // we failed to make the train short enough bjarni@2617: SetDParam(0, v->unitnumber); bjarni@2617: AddNewsItem(STR_TRAIN_TOO_LONG_AFTER_REPLACEMENT, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), v->index, 0); bjarni@2617: break; bjarni@2617: } bjarni@2617: temp = w; bjarni@2617: w = GetNextVehicle(w); tron@3491: DoCommand(0, (INVALID_VEHICLE << 16) | temp->index, 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); bjarni@2678: MoveVehicleCargo(v, temp); rubidium@7446: cost.AddCost(DoCommand(0, temp->index, 0, DC_EXEC, CMD_SELL_RAIL_WAGON)); bjarni@2617: } bjarni@2617: } bjarni@2617: tron@2639: if (stopped) v->vehstatus &= ~VS_STOPPED; bjarni@4662: if (display_costs) { rubidium@7446: if (IsLocalPlayer()) ShowCostOrIncomeAnimation(v->x_pos, v->y_pos, v->z_pos, cost.GetCost()); bjarni@4662: _current_player = OWNER_NONE; bjarni@4662: } bjarni@4662: return cost; bjarni@2552: }