src/ai/api/ai_town.cpp
branchnoai
changeset 9582 40f54a61bb17
parent 9497 f6678533ccba
child 9723 eee46cb39750
equal deleted inserted replaced
9581:398688c1a07a 9582:40f54a61bb17
    23 	return ::IsValidTownID(town_id);
    23 	return ::IsValidTownID(town_id);
    24 }
    24 }
    25 
    25 
    26 char *AITown::GetName(TownID town_id)
    26 char *AITown::GetName(TownID town_id)
    27 {
    27 {
    28 	if (!this->IsValidTown(town_id)) return NULL;
    28 	if (!AITown::IsValidTown(town_id)) return NULL;
    29 	static const int len = 64;
    29 	static const int len = 64;
    30 	char *town_name = MallocT<char>(len);
    30 	char *town_name = MallocT<char>(len);
    31 
    31 
    32 	SetDParam(0, town_id);
    32 	SetDParam(0, town_id);
    33 	GetString(town_name, STR_TOWN, &town_name[len - 1]);
    33 	GetString(town_name, STR_TOWN, &town_name[len - 1]);
    35 	return town_name;
    35 	return town_name;
    36 }
    36 }
    37 
    37 
    38 int32 AITown::GetPopulation(TownID town_id)
    38 int32 AITown::GetPopulation(TownID town_id)
    39 {
    39 {
    40 	if (!this->IsValidTown(town_id)) return 0;
    40 	if (!AITown::IsValidTown(town_id)) return 0;
    41 	const Town *t = ::GetTown(town_id);
    41 	const Town *t = ::GetTown(town_id);
    42 	return t->population;
    42 	return t->population;
    43 }
    43 }
    44 
    44 
    45 TileIndex AITown::GetLocation(TownID town_id)
    45 TileIndex AITown::GetLocation(TownID town_id)
    46 {
    46 {
    47 	if (!this->IsValidTown(town_id)) return INVALID_TILE;
    47 	if (!AITown::IsValidTown(town_id)) return INVALID_TILE;
    48 	const Town *t = ::GetTown(town_id);
    48 	const Town *t = ::GetTown(town_id);
    49 	return t->xy;
    49 	return t->xy;
    50 }
    50 }