src/ai/api/ai_town.cpp
branchnoai
changeset 10869 4fdb11e1b599
parent 10865 c4b3ddd2e9da
equal deleted inserted replaced
10867:5de2923d6e59 10869:4fdb11e1b599
   164 	EnforcePrecondition(false, IsValidTown(town_id));
   164 	EnforcePrecondition(false, IsValidTown(town_id));
   165 	EnforcePrecondition(false, IsActionAvailable(town_id, town_action));
   165 	EnforcePrecondition(false, IsActionAvailable(town_id, town_action));
   166 
   166 
   167 	return AIObject::DoCommand(::GetTown(town_id)->xy, town_id, town_action, CMD_DO_TOWN_ACTION);
   167 	return AIObject::DoCommand(::GetTown(town_id)->xy, town_id, town_action, CMD_DO_TOWN_ACTION);
   168 }
   168 }
       
   169 
       
   170 /* static */ AITown::TownRating AITown::GetRating(TownID town_id, AICompany::CompanyID company_id)
       
   171 {
       
   172 	if (!IsValidTown(town_id)) return INVALID_TOWN_RATING;
       
   173 	AICompany::CompanyID company = AICompany::ResolveCompanyID(company_id);
       
   174 	if (company == AICompany::INVALID_COMPANY) return INVALID_TOWN_RATING;
       
   175 
       
   176 	const Town *t = ::GetTown(town_id);
       
   177 	if (!HasBit(t->have_ratings, company)) return TOWN_RATING_NONE;
       
   178 	return max(TOWN_RATING_APPALLING, (TownRating)((t->ratings[company] / 200) + 3));
       
   179 }