GameMonkey Script

GameMonkey Script Forums
It is currently Thu Jan 24, 2019 4:02 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Function debug info.
PostPosted: Thu Jun 18, 2009 1:54 pm 
Offline

Joined: Fri Jan 14, 2005 2:28 am
Posts: 439
So I'm trying to get working the ability to essentially serialize the global table as much as possible. Part of this involves trying to serialize any functions that it comes across while walking the global table hierarchy.

As long as debug mode is enabled, it appears that source code information is maintained for scripts that are loaded, however I've run into an unexpected issue. Here's what I'm doing

Code:
const char *SourceCode = 0;
const char *SourceFile = 0;
_machine->GetSourceCode(fn->GetSourceId(),SourceCode,SourceFile);
if(SourceCode)
{
   //_file.WriteString(SourceCode);

   int FuncSourceLine = 0;

   int line;
   while((line = fn->GetFunctionSourceLine(FuncSourceLine++)) >= 0)
   {
      enum { BufferSize = 1024 };
      char buffer[BufferSize] = {};
      gmGetLineFromString(SourceCode, line, buffer, BufferSize);
      _file.WriteString(buffer);
      _file.WriteString("\n");
   }
}

// for reference

int gmFunctionObject::GetFunctionSourceLine(int a_relativeLine)
{
   if(m_debugInfo && m_debugInfo->m_lineInfo)
   {
      if(a_relativeLine < 0 || a_relativeLine >= m_debugInfo->m_lineInfoCount)
         return -1;

      return m_debugInfo->m_lineInfo[a_relativeLine].m_lineNumber;
   }
   return -1;
}


Using a function from my bot as a test case, this partially works, however the output is missing information.

Code:
global KickABotOnHeavyTeam = function()
{
   heavyteam = 0;
   heavyteamcount = 0;
   foreach ( team and tbl in Server.Team )
   {
      if(tbl.NumPlayers > heavyteamcount && tbl.NumBots > 0)
      {
         heavyteamcount = tbl.NumPlayers;
         heavyteam = team;
      }   
   }
   
   if(heavyteam != 0)
   {
      print("Kicking bot from team", heavyteam);
      KickBotFromTeam(heavyteam);
   }
};


And here is what my dump function outputs so far.
Code:
KickABotOnHeavyTeam =  = function(heavyteam,heavyteamcount,team,tbl)
{
   heavyteam = 0;
   heavyteamcount = 0;
   foreach ( team and tbl in Server.Team )
      if(tbl.NumPlayers > heavyteamcount && tbl.NumBots > 0)
         heavyteamcount = tbl.NumPlayers;
         heavyteam = team;
      if(tbl.NumPlayers > heavyteamcount && tbl.NumBots > 0)
   if(heavyteam != 0)
      print("Kicking bot from team", heavyteam);
      KickBotFromTeam(heavyteam);
   if(heavyteam != 0)

}


Not only is it missing any of the braces that denote the blocks, but it appears to be missing the entire last if() block. Any idea what's going in here? The lineinfocount of the functions is such that it can't possibly include all of the lines, so something is pruning them, or the information is being lost during script compilation.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group