Thanks a lot for this quality feedback !
Quote:
Originally Posted by Whistler
Some bugs...
1. shield pickup.
else if (iPickType == PICKUP_SHIELD)
{
if ((pEdict->v.weapons & (1 << CS_WEAPON_ELITE)) || BotHasShield (pBot) || pBot->bIsVIP)
bCanPickup = FALSE;
else if (BotHasPrimaryWeapon (pBot))
{
if (!BotRateGroundWeapon (pBot, pent)) // BUG
bCanPickup = FALSE;
}
}
I have changed a little to the BotRateGroundWeapon function (mine returns bool, CF's returns int). In the original PODBot code it should be like this:
if (BotRateGroundWeapon(pBot, pent) <= 0))
|
Actually this doesn't matter much, since BotRateGroundWeapon() returns positive numbers only... There's nothing wrong in writing !BotRateGroundWeapon(), or is it ? Booleans are treated like unsigned chars by x86 compilers anyway.
Quote:
2. two crash bugs.
BotThink (bot.cpp):
if ((pBot->iStates & STATE_SUSPECTENEMY) && pBot->bWantsToFire)
{
int iTask = pBot->pTasks->iTask; // BUG
// Don't allow shooting through walls when camping
if (iTask == TASK_PAUSE || iTask == TASK_CAMP)
pBot->bWantsToFire = FALSE;
}
BUG: pBot->pTasks may be NULL sometimes.
in the original PB code: GetBotSafeTask(pBot)->iTask. or you can also check "if (pBot->pTasks)" manually. In my code I moved this code to LastEnemyShootable() function.
|
Right ! I missed this one... but hey, I can't just wait for ages for the code to crash at this very point in order to notice it

Looks like you've been luckier than me

I'll grep in the source for every occurence of "pTasks->" and replace them with BotGetSafeTask() when necessary. (*edit*: wow, there were a LOT of them actually ! you should check it out too, there are many more than just this place)
Quote:
SoundAttachToThreat (bot_sounds.cpp):
extern threat_t ThreatTab[32];
.......
iIndex = ENTINDEX (pEdict) - 1; // BUG
ThreatTab[iIndex].fHearingDistance = 800.0 * fVolume;
BUG: ENTINDEX(pEdict) - 1 sometimes may be "out of the range" and this will causes invalid memory access. So we had better change this as well....
(This might be what causes the hostage crash problem IMO)
Here is what I'm doing:
Vector vecPosition = pEdict->v.origin;
if (vecPosition == Vector(0, 0, 0))
vecPosition = VecBModelOrigin(pEdict);
int iIndex = ENTINDEX(pEdict) - 1;
if (iIndex < 0 || iIndex >= gpGlobals->maxClients)
iIndex = UTIL_GetNearestPlayerIndex(vecPosition);
// Hit/Fall Sound?
if (strncmp("player/bhit_flesh", pszSample, 17) == 0
|| strncmp("player/headshot", pszSample, 15) == 0)
{
// don't change iIndex here, and in any following code.....
ThreatTab[iIndex].fHearingDistance = 800.0 * fVolume;
ThreatTab[iIndex].fTimeSoundLasting = gpGlobals->time + 0.5;
ThreatTab[iIndex].vecSoundPosition = vecPosition;
}
|
Nice solution... Although I'm not sure it REALLY can crash... from my experience I noticed that all sounds that were emitted through pfnEmitSound() (and NOT pfnEmitAmbientSound()) are attached to a client. But of course, adding this check won't cost much. Thanks
Quote:
3. weapon selecting bug.
BotSelectBestWeapon (bot_combat.cpp):
iChosenWeaponIndex %= 24; // BUG
select_index = iChosenWeaponIndex;
You have added support to new weapons, yeah? like this weapons after 24 will never be selected You can change the 24 to "NUM_WEAPONS + 1"
Also it seems CF learnt BASIC first - he kept using abs() when he should use fabs() ;D
|
Haha, yet one more ! there are countless little bugs like that and it's a real pain to catch them all

and I'll have a look around and check for the fabs() issue too... Thanks for the hint !
Quote:
P.S. Thanks for your fix. Seems Valve has changed a lot from the initial release of CS 1.6..... I'll add them to my code. Thanks.
|
No problem, there are certainly a couple other bugs left, as you just proven me

But what is fixed, definitely is.
BTW, you know you can use the [ code ] and [ /code ] tags to post C code in the forums ?