.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > SDK Programming discussions > Half-Life 1 SDK
Half-Life 1 SDK For developments focused around Half-Life (and its mods) Half-Life

Reply
 
Thread Tools
botmaaaaaaaaan!!!!!
Old
  (#1)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default botmaaaaaaaaan!!!!! - 20-03-2004

O knowledgeable guru, I need thy immense wisdom again...

... and especially your ability to check one thing or two in the Half-Life source code, if you don't mind

I've f*ckedup a metamod plugin, but completely, and as usuals I didn't make backups. That's because the error only occurs on some situations and I never noticed it before. But it's very reproductible indeed: the plugin is Count Floyd's POD-bot, and the crash occurs randomly although very often, only on "cs_" maps, i.e, maps with hostages. The error I get is:

NUM_FOR_EDICT: bad pointer.

Does this sound familiar to you ??
I scoured the source code again and again to no avail. I'm becoming desperate as I need this stupid error to be fixed quickly in order to make a release of this bot and move on to other things (mine, and the united bot thingy). And where I enrage is when I see that the engine exits gracefully with a nice MessageBox, and who says messagebox says no real crash, and who says no crash says NO BREAK IN THE FRIKKIN DEBUGGER !!! I don't give a foack about message boxes, I ONLY WISHED MY DEBUGGER WOULD KICK IN RIGHT AT THE ERROR !!!

If (and as I believe) that's impossible, could you have a look in the engine source code and tell me where are the main places where this error can occur ? I assume the bot is calling an engine function with a fucked parameter, but if I could narrow down my search and avoid checking one after the other the 5,000 engine function calls there are in this stupid bot source code I would be quite pleased. What does this error mean ? I thought it was related to INDEXENT() and ENTINDEX() where you would for example ask the engine for a pointer to an edict_t by number, and passing a number out of range, but I've quintuple-checked these two everywhere I could find them to no avail.

I'm clueless ! What does this error mean ? In which engine function(s) does it kick in ? Please don't tell me "everywhere", I would go mad, please :'(



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: botmaaaaaaaaan!!!!!
Old
  (#2)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default Re: botmaaaaaaaaan!!!!! - 20-03-2004

Try looking in the quake 1 source code, I did a quick google for NUM_FOR_EDICT and a few quake source files turned up.

[ Added ]

From looking around in the quake source, it looks like it is used by ENTINDEX( edict_t* ).
Everywhere I have looked so far uses NUM_FOR_EDICT to get the index of an entity, still looking though.

Last edited by Lazy; 20-03-2004 at 23:46..
  
Reply With Quote
Re: botmaaaaaaaaan!!!!!
Old
  (#3)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: botmaaaaaaaaan!!!!! - 21-03-2004

bah don't worry, I made a great fuss again for not very much ----> it's FIXED. w00h00h000000t!!!

Actually I spent hours on it, but the only method that works when all the other fails remain the trial and error: you comment out (/* like this */) half of the code, then compile the bot and see if it crashes. If it doesn't you uncomment half of what you'd commented and you try again. If it doesn't you uncomment half of it again, until you narrow down the bug.

The line that was causing the error was, believe it or not:
Code:
pPlayer = ThreatTab[i].pEntity;
pPlayer being edict_t *, pEntity idem, and i being NOT out of range. A perfectly valid line. Everything that was below that line was commented, but IF that line was NOT commented, the game crashed. Unbearable.

Anyhow I put it back because I've found the REAL problem elsewhere in this very function. Count Floyd has the very bad habit of declaring his variable names everywhere BUT where they should be declared.
Code:
void SomeFunction (edict_t *pPlayer) // first definition of pPlayer
{
   int i; // first definition of i
 
   for (i = 0; i < somevalue; i++)
   {
	  DoSomething ();
 
	  edict_t *pPlayer = INDEXENT (i); // new definition of pPlayer
 
	  // three pages later...
 
	  for (int index = 0; index < 32; index++)
	  {
		 // four other pages later...
 
		 int i = someOtherValue; // new definition of i
		 while (i > 0)
		 {
			edict_t *pPlayer = bots[i].pEdict; // new definition of pPlayer
			DoSomeStuffWithVariable (i--);
		 }
	  }
   }
}
there are things like that everywhere. Actually it's a miracle his bot worked so well for all that time... 9_9


Anyway I'm still interested in knowing what the NUM_FOR_EDICT(): bad pointer error means



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."

Last edited by Pierre-Marie Baty; 21-03-2004 at 02:45..
  
Reply With Quote
Re: botmaaaaaaaaan!!!!!
Old
  (#4)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default Re: botmaaaaaaaaan!!!!! - 21-03-2004

Code:
int NUM_FOR_EDICT(edict_t *e)
{
 int  b;
 
 b = (byte *)e - (byte *)sv.edicts;
 b = b / pr_edict_size;
 
 if (b < 0 || b >= sv.num_edicts)
  SV_Error ("NUM_FOR_EDICT: bad pointer");
 return b;
}


Looks like the error is made when the entity index is below zero or greater than the amount of entities in the game.

  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com