src/ai/api/ai_industry.cpp
author rubidium
Sat, 14 Apr 2007 20:38:10 +0000
branchnoai
changeset 9594 5009a30f320a
parent 9497 f6678533ccba
child 9649 bc8c06513f5b
permissions -rw-r--r--
(svn r9627) [NoAI] -Fix: let the squirrel export script export all needed (and a few more) types of references to structs and classes.
/* $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();
}

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

char *AIIndustry::GetName(IndustryID industry_id)
{
	if (!this->IsValidIndustry(industry_id)) return NULL;
	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)
{
	if (!this->IsValidIndustry(industry_id)) return INVALID_TILE;
	const Industry *i = ::GetIndustry(industry_id);
	return i->xy;
}