How do you save the event queue?

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
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

How do you save the event queue?

Post by Brumi »

I'm trying to implement save/load for SimpleAI and I'm stuck with saving the event queue. Now if the game is saved when the AI is busy, events waiting at the time will disappear and therefore won't be handled. So is there an easy way to solve this?
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: How do you save the event queue?

Post by Yexo »

I'm sorry I don't have to time to search through my own code now, but AdmiralAI does handle this case. Take a look at the save and load functions in main.nut. If I remember correctly it fetches all events to a local queue, when saving it saves that queue and when handling events it first adds all events to that internal queue before handling them.
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: How do you save the event queue?

Post by Brumi »

Thank you for your help, I will try something similar.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 5 guests