API CHANGES of 14/2/2009 (All AIs are currently broken!)

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
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

API CHANGES of 14/2/2009 (All AIs are currently broken!)

Post by Yexo »

Today several api function were changed. For a complete list of changes, see http://vcs.openttd.org/svn/
The applied patches can be found on the wiki: http://wiki.openttd.org/wiki/index.php? ... ldid=30941
I'll give a short summary of the changes here.

The following functions were completely removed:
AIIndustry::GetProduction (use GetLastMonthProduction instead).
AICompany::GetCompanyName and AICompany::SetCompanyName (they've been marked deprecated for several months now, use GetName/SetName instead)
AITown::GetMaxTownID
AIEventVehicleCrashed::CloneCrashedVehicle This function was never implemented and is now removed from the api.
AIAirport::AirportAvailable (AIAirport::IsValidAirportType now only returns true for available airports)
AIBridge::GetYearAvailable (AIBridge::IsValidBridge now only returns true for available bridges)

The following functions were changes:
AIMarine::BuildWaterDepot now accepts a front_tile parameter instead of a bool is_vertical.
AIVehicle::MoveWagon is splitted in MoveWagon and MoveWagonChain
AIRoad::BuildRoadStation is splitted in BuildRoadStation and BuildDriveThroughRoadStation
All Build*Station functions were modified. The join_adjacent parameter has been changed to StationID station_id. Mapping from old to new values:
true -> AIStation::STATION_JOIN_ADJACENT
false -> AIStation::STATION_NEW
(impossible) -> A valid StationID (join that station, even if the tile is not next to it).
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: API CHANGES of 14/2/2009 (All AIs are currently broken!)

Post by fanioz »

Surely, the AIs broken :D
But the changes made is better I thought, :)
If I allowed to make a suggestion :
- AIError have a methode like ClearLastError() or ResetLastError(), that will prevent an error handler to catch again a handled error before, without "break;" statement
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
flowover
Engineer
Engineer
Posts: 61
Joined: 24 Jun 2008 05:51

Re: API CHANGES of 14/2/2009 (All AIs are currently broken!)

Post by flowover »

Until the game goes .7 i'm going to expect plenty of ai breaking in the nightly builds. It's good to see A LOT of action in this arena. The game has never been funner to play than with the many new ai's! I've always played alone in the past because they just build a huge mess for me to work around.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: API CHANGES of 14/2/2009 (All AIs are currently broken!)

Post by Yexo »

fanioz wrote:Surely, the AIs broken :D
But the changes made is better I thought, :)
If I allowed to make a suggestion :
- AIError have a methode like ClearLastError() or ResetLastError(), that will prevent an error handler to catch again a handled error before, without "break;" statement
The last error is reset at the moment you start executing a new command, that is, as soon as you call an api function that actually changes anything.
flowover wrote:Until the game goes .7 i'm going to expect plenty of ai breaking in the nightly builds. It's good to see A LOT of action in this arena. The game has never been funner to play than with the many new ai's! I've always played alone in the past because they just build a huge mess for me to work around.
Actually I hope this was the last batch of api changes before 0.7 comes out.
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: API CHANGES of 14/2/2009 (All AIs are currently broken!)

Post by Zutty »

Yexo wrote:The last error is reset at the moment you start executing a new command, that is, as soon as you call an api function that actually changes anything.
Sorry to hijack this thread but I find it a pain to debug when calling GetLastError() or GetLastErrorString() seems to clear the error. It would be nice if they could both be called for the same error without causing the error to be cleared, since at the moment I can't display the error string in the log window or in a sign without breaking my existing error handling blocks.

Maybe I'm doing it wrong though!
PathZilla - A networking AI - Now with tram support.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: API CHANGES of 14/2/2009 (All AIs are currently broken!)

Post by Rubidium »

After building the sign the error that will be returned by GetLastError* is any error caused while building the sign. GetLastError* itself doesn't reset the error; it's building the sign that does. Building a sign is equivalent to building a vehicle or road w.r.t. error handling.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 23 guests