Re: [Warzone-dev] a minor fix
The Watermelon schreef: On 6/22/07, Giel van Schijndel [EMAIL PROTECTED] wrote: The Watermelon schreef: a minor fix to avoid excessive harmless asserts by projectile validity check macro when using memory debugger like MSVC when debugging. I assume the problem you're trying to fix with this patch is that psAttacker = NULL at some times, and dereferencing this to retrieve -psSource and -psDest results in a segmentation fault? PS the first portion of your patch is whitespace only, this was quite annoying in reviewing your patch. yes it's a potential crash,though psAttacker should never be NULL,unless you fire a projectile with a script function.I think I forgot to include the changes which actually reduce the assert spam... Well this patch would actually prevent a segfault if a NULL pointer ever made it through that codepath. not sure what you mean by 'the first portion of your patch is whitespace only'. I mean this part: - psObj-airTarget= (UBYTE)( ( psTarget != NULL - psTarget-type == OBJ_DROID - vtolDroid((DROID*)psTarget) ) || - ( psTarget == NULL - (SDWORD)tarZ map_Height(tarX,tarY) ) ); + psObj-airTarget= (UBYTE)( (psTarget != NULL + psTarget-type == OBJ_DROID + vtolDroid((DROID*)psTarget)) || + (psTarget == NULL + (SDWORD)tarZ map_Height(tarX,tarY)) ); It adds a few tabs, removes some spaces and that's it. -- Giel signature.asc Description: OpenPGP digital signature ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev
[Warzone-dev] a minor fix
a minor fix to avoid excessive harmless asserts by projectile validity check macro when using memory debugger like MSVC when debugging. Index: src/projectile.c === --- src/projectile.c(revision 1555) +++ src/projectile.c(working copy) @@ -377,18 +377,26 @@ psObj-born = gameTime; psObj-player = (UBYTE)player; psObj-bVisible = FALSE; - psObj-airTarget= (UBYTE)( ( psTarget != NULL - psTarget-type == OBJ_DROID - vtolDroid((DROID*)psTarget) ) || - ( psTarget == NULL - (SDWORD)tarZ map_Height(tarX,tarY) ) ); + psObj-airTarget= (UBYTE)( (psTarget != NULL + psTarget-type == OBJ_DROID + vtolDroid((DROID*)psTarget)) || + (psTarget == NULL + (SDWORD)tarZ map_Height(tarX,tarY)) ); //Watermelon:use the source of the source of psObj :) (psAttacker is a projectile) if (bPenetrate) { - psObj-psSource = ((PROJ_OBJECT *)psAttacker)-psSource; - psObj-psDamaged = ((PROJ_OBJECT *)psAttacker)-psDest; - ((PROJ_OBJECT *)psAttacker)-state = PROJ_IMPACT; + if (psAttacker) + { + psObj-psSource = ((PROJ_OBJECT *)psAttacker)-psSource; + psObj-psDamaged = ((PROJ_OBJECT *)psAttacker)-psDest; + ((PROJ_OBJECT *)psAttacker)-state = PROJ_IMPACT; + } + else + { + psObj-psSource = NULL; + psObj-psDamaged = NULL; + } } else { ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev
Re: [Warzone-dev] a minor fix
The Watermelon schreef: a minor fix to avoid excessive harmless asserts by projectile validity check macro when using memory debugger like MSVC when debugging. I assume the problem you're trying to fix with this patch is that psAttacker = NULL at some times, and dereferencing this to retrieve -psSource and -psDest results in a segmentation fault? PS the first portion of your patch is whitespace only, this was quite annoying in reviewing your patch. -- Giel signature.asc Description: OpenPGP digital signature ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev