--- a/src/ai/api/ai_town.cpp Sun Jun 08 15:32:10 2008 +0000
+++ b/src/ai/api/ai_town.cpp Sun Jun 08 19:35:16 2008 +0000
@@ -166,3 +166,14 @@
return AIObject::DoCommand(::GetTown(town_id)->xy, town_id, town_action, CMD_DO_TOWN_ACTION);
}
+
+/* static */ AITown::TownRating AITown::GetRating(TownID town_id, AICompany::CompanyID company_id)
+{
+ if (!IsValidTown(town_id)) return INVALID_TOWN_RATING;
+ AICompany::CompanyID company = AICompany::ResolveCompanyID(company_id);
+ if (company == AICompany::INVALID_COMPANY) return INVALID_TOWN_RATING;
+
+ const Town *t = ::GetTown(town_id);
+ if (!HasBit(t->have_ratings, company)) return TOWN_RATING_NONE;
+ return max(TOWN_RATING_APPALLING, (TownRating)((t->ratings[company] / 200) + 3));
+}