src/ai/api/ai_industry.cpp
author truelight
Sun, 18 Mar 2007 18:02:27 +0000
branchnoai
changeset 9452 4c5eedbc3ba9
parent 9430 9e0a193b2bec
child 9459 73300438e505
permissions -rw-r--r--
(svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
DoCommand no longer returns the cost, it returns a bool.
Costs are available via this Accounting class.
/* $Id$ */

/** @file ai_industry.cpp handles the query-related of the AIIndustry class */

#include "ai_industry.hpp"
#include "../../industry.h"
#include "../../strings.h"
#include "../../variables.h" /* For SetDParam */
#include "table/strings.h"

IndustryID AIIndustry::GetMaxIndustryID()
{
	return ::GetMaxIndustryIndex();
}

int32 AIIndustry::GetIndustryCount()
{
	return ::GetNumIndustries();
}

bool AIIndustry::IsValidIndustry(IndustryID industry_id)
{
	return ::IsValidIndustryID(industry_id);
}

char *AIIndustry::GetName(IndustryID industry_id)
{
	static const int len = 64;
	char *industry_name = MallocT<char>(len);

	SetDParam(0, industry_id);
	GetString(industry_name, STR_INDUSTRY, &industry_name[len - 1]);

	return industry_name;
}

TileIndex AIIndustry::GetLocation(IndustryID industry_id)
{
	const Industry *i = ::GetIndustry(industry_id);
	return i->xy;
}