Files
@ r14363:db29028f5824
Branch filter:
Location: cpp/openttd-patchpack/source/src/ai/api/ai_event_types.cpp - annotation
r14363:db29028f5824
2.9 KiB
text/x-c
(svn r18930) -Fix: [NoAI] Autoreplace is also valid for the default group.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | r10696:8dfe83e30d01 r10696:8dfe83e30d01 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r11756:1996f11774e0 r11403:ba31da6812eb r10696:8dfe83e30d01 r10960:e97ebf9cf99b r11403:ba31da6812eb r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10790:a63d33c87344 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r12844:8b5d0ee41491 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r13379:11e43d1e8cf7 r13379:11e43d1e8cf7 r13379:11e43d1e8cf7 r13379:11e43d1e8cf7 r13379:11e43d1e8cf7 r13379:11e43d1e8cf7 r13379:11e43d1e8cf7 r13379:11e43d1e8cf7 r13379:11e43d1e8cf7 r13379:11e43d1e8cf7 r13379:11e43d1e8cf7 r13379:11e43d1e8cf7 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r12844:8b5d0ee41491 r11350:df593340eca2 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r13211:4ba95564ba64 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r11350:df593340eca2 r11350:df593340eca2 r11403:ba31da6812eb r11350:df593340eca2 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r12844:8b5d0ee41491 r10969:8b8a9653d684 r10967:2c98940d6c64 r10967:2c98940d6c64 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r12844:8b5d0ee41491 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r12844:8b5d0ee41491 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r11756:1996f11774e0 r10696:8dfe83e30d01 r12844:8b5d0ee41491 r10769:860dac73eb3e r10769:860dac73eb3e r10769:860dac73eb3e r10769:860dac73eb3e r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r12844:8b5d0ee41491 r10696:8dfe83e30d01 r12845:8860291369ea r12845:8860291369ea r12845:8860291369ea r12845:8860291369ea r12845:8860291369ea | /* $Id$ */
/*
* This file is part of OpenTTD.
* 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.
* 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.
* 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/>.
*/
/** @file ai_event_types.cpp Implementation of all EventTypes. */
#include "ai_event_types.hpp"
#include "ai_vehicle.hpp"
#include "../../command_type.h"
#include "../../strings_func.h"
#include "../../settings_type.h"
#include "../../engine_base.h"
#include "../../articulated_vehicles.h"
#include "table/strings.h"
char *AIEventEnginePreview::GetName()
{
static const int len = 64;
char *engine_name = MallocT<char>(len);
::SetDParam(0, this->engine);
::GetString(engine_name, STR_ENGINE_NAME, &engine_name[len - 1]);
return engine_name;
}
CargoID AIEventEnginePreview::GetCargoType()
{
CargoArray cap = ::GetCapacityOfArticulatedParts(this->engine);
CargoID most_cargo = CT_INVALID;
uint amount = 0;
for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
if (cap[cid] > amount) {
amount = cap[cid];
most_cargo = cid;
}
}
return most_cargo;
}
int32 AIEventEnginePreview::GetCapacity()
{
const Engine *e = ::Engine::Get(this->engine);
switch (e->type) {
case VEH_ROAD:
case VEH_TRAIN: {
CargoArray capacities = GetCapacityOfArticulatedParts(this->engine);
for (CargoID c = 0; c < NUM_CARGO; c++) {
if (capacities[c] == 0) continue;
return capacities[c];
}
return -1;
} break;
case VEH_SHIP:
case VEH_AIRCRAFT:
return e->GetDisplayDefaultCapacity();
break;
default: NOT_REACHED();
}
}
int32 AIEventEnginePreview::GetMaxSpeed()
{
const Engine *e = ::Engine::Get(this->engine);
int32 max_speed = e->GetDisplayMaxSpeed(); // km-ish/h
if (e->type == VEH_AIRCRAFT) max_speed /= _settings_game.vehicle.plane_speed;
return max_speed;
}
Money AIEventEnginePreview::GetPrice()
{
return ::Engine::Get(this->engine)->GetCost();
}
Money AIEventEnginePreview::GetRunningCost()
{
return ::Engine::Get(this->engine)->GetRunningCost();
}
int32 AIEventEnginePreview::GetVehicleType()
{
switch (::Engine::Get(this->engine)->type) {
case VEH_ROAD: return AIVehicle::VT_ROAD;
case VEH_TRAIN: return AIVehicle::VT_RAIL;
case VEH_SHIP: return AIVehicle::VT_WATER;
case VEH_AIRCRAFT: return AIVehicle::VT_AIR;
default: NOT_REACHED();
}
}
bool AIEventEnginePreview::AcceptPreview()
{
return AIObject::DoCommand(0, this->engine, 0, CMD_WANT_ENGINE_PREVIEW);
}
bool AIEventCompanyAskMerger::AcceptMerger()
{
return AIObject::DoCommand(0, this->owner, 0, CMD_BUY_COMPANY);
}
|