Page 1 of 1

Suggestion::AI Debug panel

Posted: 09 Mar 2009 03:37
by fanioz
Yesterday, I've made some misstype in my code. My AI doesn't do any progress without any info on AI Debug Panel. :(
And then, I tried to restart with ./openttd -d ai=5. Now the console said :

dbg: [ai] ERROR: HasNext() is invalid as Begin() is never called

for me, (maybe other too :?: ) it would be hard to find ( if there are tons of HasNext() statement arround your code :D ) in wich line of code is that error occured. And it looks like that this kind of error doesn't make the program stop, because the console now full-filled with the above error message.

So, the suggestion is :
1. the error message is included with the line number
2. the error message displayed in the debug panel

The misstyped code is similiar like this (error on line 5)

Code: Select all

local list = AIList();
for(local i = list.Begin(); list.HasNext(); i = list.Next()){
  //do some stuff
  local list2 = AIList();
  for(local i = list.Begin(); list2.HasNext(); i = list2.Next()){
    //do some stuff that make a further decission
   // as the looping is not give the actual value of .Next() , the decission is never made
  }
}
I'm using r15603, today I'll download r1647 and try with that.

And.. correct me if that was just because my miss understanding of squirrel/API :D
:bow: thanks

Re: Suggestion::AI Debug panel

Posted: 09 Mar 2009 15:44
by Yexo
Valid suggestion, I'll try to change the behavior, but it will require rewriting some code in AIAbstractList.

Re: Suggestion::AI Debug panel

Posted: 10 Mar 2009 05:25
by fanioz
Thanks, that sounds good :D