Files
@ r11789:1af8e5bdde25
Branch filter:
Location: cpp/openttd-patchpack/source/src/ai/api/ai_industrytype.cpp - annotation
r11789:1af8e5bdde25
4.2 KiB
text/x-c
(svn r16184) -Update: WebTranslator2 update to 2009-04-29 17:32:47
estonian - 6 changed by kristjans (6)
french - 10 fixed by glx (10)
polish - 17 fixed by xaxa (17)
simplified_chinese - 25 fixed, 6 changed by ww9980 (31)
estonian - 6 changed by kristjans (6)
french - 10 fixed by glx (10)
polish - 17 fixed by xaxa (17)
simplified_chinese - 25 fixed, 6 changed by ww9980 (31)
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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10790:a63d33c87344 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r11096:4cc781efea7a r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r11096:4cc781efea7a r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 r11535:0e469c567841 | /* $Id$ */
/** @file ai_industrytype.cpp Implementation of AIIndustryType. */
#include "ai_industrytype.hpp"
#include "ai_map.hpp"
#include "../../command_type.h"
#include "../../settings_type.h"
#include "../../strings_func.h"
#include "../../industry.h"
/* static */ bool AIIndustryType::IsValidIndustryType(IndustryType industry_type)
{
if (industry_type >= NUM_INDUSTRYTYPES) return false;
return ::GetIndustrySpec(industry_type)->enabled;
}
/* static */ bool AIIndustryType::IsRawIndustry(IndustryType industry_type)
{
if (!IsValidIndustryType(industry_type)) return false;
return ::GetIndustrySpec(industry_type)->IsRawIndustry();
}
/* static */ bool AIIndustryType::ProductionCanIncrease(IndustryType industry_type)
{
if (!IsValidIndustryType(industry_type)) return false;
if (_settings_game.game_creation.landscape != LT_TEMPERATE) return true;
return (::GetIndustrySpec(industry_type)->behaviour & INDUSTRYBEH_DONT_INCR_PROD) == 0;
}
/* static */ Money AIIndustryType::GetConstructionCost(IndustryType industry_type)
{
if (!IsValidIndustryType(industry_type)) return false;
return ::GetIndustrySpec(industry_type)->GetConstructionCost();
}
/* static */ char *AIIndustryType::GetName(IndustryType industry_type)
{
if (!IsValidIndustryType(industry_type)) return NULL;
static const int len = 64;
char *industrytype_name = MallocT<char>(len);
::GetString(industrytype_name, ::GetIndustrySpec(industry_type)->name, &industrytype_name[len - 1]);
return industrytype_name;
}
/* static */ AIList *AIIndustryType::GetProducedCargo(IndustryType industry_type)
{
if (!IsValidIndustryType(industry_type)) return NULL;
const IndustrySpec *ins = ::GetIndustrySpec(industry_type);
AIList *list = new AIList();
for (size_t i = 0; i < lengthof(ins->produced_cargo); i++) {
if (ins->produced_cargo[i] != CT_INVALID) list->AddItem(ins->produced_cargo[i], 0);
}
return list;
}
/* static */ AIList *AIIndustryType::GetAcceptedCargo(IndustryType industry_type)
{
if (!IsValidIndustryType(industry_type)) return NULL;
const IndustrySpec *ins = ::GetIndustrySpec(industry_type);
AIList *list = new AIList();
for (size_t i = 0; i < lengthof(ins->accepts_cargo); i++) {
if (ins->accepts_cargo[i] != CT_INVALID) list->AddItem(ins->accepts_cargo[i], 0);
}
return list;
}
/* static */ bool AIIndustryType::CanBuildIndustry(IndustryType industry_type)
{
if (!IsValidIndustryType(industry_type)) return false;
if (!::GetIndustrySpec(industry_type)->IsRawIndustry()) return true;
/* raw_industry_construction == 1 means "Build as other industries" */
return _settings_game.construction.raw_industry_construction == 1;
}
/* static */ bool AIIndustryType::CanProspectIndustry(IndustryType industry_type)
{
if (!IsValidIndustryType(industry_type)) return false;
if (!::GetIndustrySpec(industry_type)->IsRawIndustry()) return false;
/* raw_industry_construction == 2 means "prospect" */
return _settings_game.construction.raw_industry_construction == 2;
}
/* static */ bool AIIndustryType::BuildIndustry(IndustryType industry_type, TileIndex tile)
{
EnforcePrecondition(false, CanBuildIndustry(industry_type));
EnforcePrecondition(false, AIMap::IsValidTile(tile));
uint32 seed = ::InteractiveRandom();
return AIObject::DoCommand(tile, (::InteractiveRandomRange(::GetIndustrySpec(industry_type)->num_table) << 16) | industry_type, seed, CMD_BUILD_INDUSTRY);
}
/* static */ bool AIIndustryType::ProspectIndustry(IndustryType industry_type)
{
EnforcePrecondition(false, CanProspectIndustry(industry_type));
uint32 seed = ::InteractiveRandom();
return AIObject::DoCommand(0, industry_type, seed, CMD_BUILD_INDUSTRY);
}
/* static */ bool AIIndustryType::IsBuiltOnWater(IndustryType industry_type)
{
if (!IsValidIndustryType(industry_type)) return false;
return (::GetIndustrySpec(industry_type)->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0;
}
/* static */ bool AIIndustryType::HasHeliport(IndustryType industry_type)
{
if (!IsValidIndustryType(industry_type)) return false;
return (::GetIndustrySpec(industry_type)->behaviour & INDUSTRYBEH_AI_AIRSHIP_ROUTES) != 0;
}
/* static */ bool AIIndustryType::HasDock(IndustryType industry_type)
{
if (!IsValidIndustryType(industry_type)) return false;
return (::GetIndustrySpec(industry_type)->behaviour & INDUSTRYBEH_AI_AIRSHIP_ROUTES) != 0;
}
|