Bug in NoAI API: AITown.GetTownRating

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Bug in NoAI API: AITown.GetTownRating

Post by Morloth »

Dear devs,

I think the AITown.GetTownRating returns the wrong town rating. It seems that when I check for:

Code: Select all

local companyID = AICompany.ResolveCompanyID(AICompany.COMPANY_SELF);
if (AITown.GetTownRating(town, companyID) == AITown.TOWN_RATING_GOOD) {
   ...
}
The code actually checks for AITown.TOWN_RATING_VERY_GOOD. So it seems that all the values assigned to the town ratings are 1 too high. The function in src/ai/api/ai_town.cpp should read:

Code: Select all

return max(TOWN_RATING_APPALLING, (TownRating)((t->ratings[company] / 200) + 4));
For instance, when the town's rating is 1, it should return TOWN_RATING_MEDIOCRE (4) but it returns TOWN_RATING_POOR (3).

Cheers,
Bram
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2848
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: Bug in NoAI API: AITown.GetTownRating

Post by ChillCore »

Fixed in r20103.
Thank you frosch.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 4 guests