Page 1 of 1
Important change to call/acall/pcall (2 juni 2009)
Posted: 01 Jun 2009 22:04
by Yexo
Because I assume not everyone reads the changelog:
(svn r16502) -Fix [FS#2935]: when an AI was suspended while in a function called (indirectly) via call/acall/pcall OpenTTD crashed. Fix this by disallowing AIs to be suspended while called via call/acall/pcall.
IMPORTANT FOR AI WRITERS: AIs can no longer call any DoCommand functions (change anything, build vehicles, etc.) in a function called (indirectly) via call/acall/pcall. Where possible, please rewrite your code so it doesn't use call/acall/pcall.
This change will also be in 0.7.1-RC3 and later. Please test your AIs using the latest nightly / 0.7.1-RC3 when it comes out and report all crashes. Thanks to fanioz for reporting this problem.
Re: Important change to call/acall/pcall (2 juni 2009)
Posted: 03 Jun 2009 09:47
by fanioz
I remembered sometimes ago there are thread about un-ability of AIList.Valuate() function to call DoCommand, and there is replacement that is made using ".call/.acall/.pcall" methode. Now, these methods is no longer could call a DoCommand

and we only can use a normal function with a little trick as shown by yexo.
==================
Forget it,
However, the program stability should be on the first place.
Thanks to yexo for fixing

(and Rubidium - who make me confident to report the bug

)
Re: Important change to call/acall/pcall (2 juni 2009)
Posted: 06 Jun 2009 12:17
by Zuu
Hmm, so then placing debug signs in valuators will not work anymore. And I see my PAXLink have become pretty broken due to this. Not sure how much to change though. But I think there is at least one DoCommand that is not a debug call in it.
Thanks for the notice though.
Re: Important change to call/acall/pcall (2 juni 2009)
Posted: 13 Jun 2009 15:21
by Bilbo
Zuu wrote:Hmm, so then placing debug signs in valuators will not work anymore.
Well, you can place debug signs into some array and then put contents of the array on the map once the valuator is finished
Re: Important change to call/acall/pcall (2 juni 2009)
Posted: 15 Jun 2009 10:48
by Yexo
Zuu wrote:Hmm, so then placing debug signs in valuators will not work anymore.
You can write a valuate replacement in squirrel without using call. I've attached the version I use in AdmiralAI.
Edit: now I have (.nut files are not allowed as attachment)
Re: Important change to call/acall/pcall (2 juni 2009)
Posted: 15 Jun 2009 13:02
by Roujin
Yexo wrote:I've attached the version I use in AdmiralAI.
No, you haven't.
Re: Important change to call/acall/pcall (2 juni 2009)
Posted: 15 Jun 2009 13:38
by fanioz
Found ...in : Admiral21.tar/utils/valuator.nut

Re: Important change to call/acall/pcall (2 juni 2009)
Posted: 14 Jul 2009 04:59
by Dustin
I noticed that the current release disallows commands even in test mode. That seems reasonable since it might be hard to know the difference in a callback. It would be nice to allow valuators to try operations in test mode, though. Unless of course this would also cause a crash...
Re: Important change to call/acall/pcall (2 juni 2009)
Posted: 14 Jul 2009 06:57
by Yexo
Dustin wrote:I noticed that the current release disallows commands even in test mode. That seems reasonable since it might be hard to know the difference in a callback. It would be nice to allow valuators to try operations in test mode, though. Unless of course this would also cause a crash...
Maybe not a crash, but it does give problems with suspending the AI. Since there are working replacements for call/acall/List::aluate written in squirrel I see no need to enable it.