View Single Post
Re: Bug-NUM_FOR_EDICT Error: Bad Pointer
Old
  (#22)
sPlOrYgOn
<-- He did it.
 
sPlOrYgOn's Avatar
 
Status: Offline
Posts: 1,558
Join Date: Jan 2004
Location: Los Angeles, California, USA, North America, Earth, Solar System, Milky Way.
Default Re: Bug-NUM_FOR_EDICT Error: Bad Pointer - 11-05-2004

Quote:
Originally Posted by Whistler
This will only work if that is a bug in CS
calling ENTINDEX() or INDEXENT() in the bot plugin won't get here...
aww

on the good side...
I didn't know INDEXENT could cause it too
I was only checking ENTINDEX

[edit]
another good news might be that I might have found where it is being caused...
and it does have something to do with intense battles..
at least the dying part...
in BotClient.cpp I changed this:
Code:
void BotClient_CS_DeathMsg (void *p, int bot_index)
{
   // This message gets sent when someone got killed

   static int killer_index;
   static int victim_index;
   static edict_t *killer_edict;
   static bot_t *pBot;

   if (state == 0)
      killer_index = *(int *) p; // ENTINDEX() of killer
   else if (state == 1)
      victim_index = *(int *) p; // ENTINDEX() of victim
   else if (state == 2)
   {
      if ((killer_index != 0) && (killer_index != victim_index))
      {
         killer_edict = INDEXENT (killer_index);
         pBot = UTIL_GetBotPointer (killer_edict);

         // is this message about a bot who killed somebody ?
         if (pBot != NULL)
         {
            pBot->pLastVictim = INDEXENT (victim_index);
            pBot->f_shootatdead_time = gpGlobals->time + RANDOM_FLOAT (0.0, 2.0);
         }

         else // Did a human kill a Bot on his team ?
         {
            edict_t *victim_edict = INDEXENT (victim_index);
            pBot = UTIL_GetBotPointer (victim_edict);

            if (pBot != NULL)
               pBot->bDead = TRUE;
         }
      }
   }
}
to:
Code:
void BotClient_CS_DeathMsg (void *p, int bot_index)
{
   // This message gets sent when someone got killed

   static int killer_index;
   static int victim_index;
   static edict_t *killer_edict;
   static bot_t *pBot;

   if (state == 0)
      killer_index = *(int *) p; // ENTINDEX() of killer
   else if (state == 1)
      victim_index = *(int *) p; // ENTINDEX() of victim
   else if (state == 2)
   {
      // check if victim_index is zero...
      // it does it to killer_index so why not victim_index too?
      if ((killer_index != 0) && (victim_index != 0) && (killer_index != victim_index))
      {
         killer_edict = INDEXENT (killer_index);
         pBot = UTIL_GetBotPointer (killer_edict);

         // is this message about a bot who killed somebody ?
         if (pBot != NULL)
         {
            pBot->pLastVictim = INDEXENT (victim_index);
            pBot->f_shootatdead_time = gpGlobals->time + RANDOM_FLOAT (0.0, 2.0);
         }

         else // Did a human kill a Bot on his team ?
         {
            edict_t *victim_edict = INDEXENT (victim_index);
            pBot = UTIL_GetBotPointer (victim_edict);

            if (pBot != NULL)
               pBot->bDead = TRUE;
         }
      }
   }
}
and hopefully that will fix it..
[/edit

Last edited by sPlOrYgOn; 11-05-2004 at 01:47..