One entity shooting another should work even if friendly fire is off

In rogue's RHANGAR1 the turret didn't blow up the ceiling when friendly fire
was off, because in ClientTeam() both entities were set to "" (no team),
but OnSameTeam() just did a strcmp() instead of checking this special
case (no team).
We check this now and thus it works. Hooray.
I also refactored ClientTeam() to take the buffer instead of using a
static one and to be static (it's only called by OnSameTeam() anyway).

The savegame table entry for this function was invalid, but it doesn't
need to be saved anyway, so I just deleted it from the table.
This commit is contained in:
Daniel Gibson 2014-11-30 17:58:18 +01:00
parent 47634e64e8
commit 5e33152f6a
3 changed files with 5 additions and 8 deletions

View file

@ -27,11 +27,10 @@
#include "header/local.h"
#include "monster/misc/player.h"
char *
ClientTeam(edict_t *ent)
static char *
ClientTeam(edict_t *ent, char* value)
{
char *p;
static char value[512];
value[0] = 0;
@ -78,10 +77,10 @@ OnSameTeam(edict_t *ent1, edict_t *ent2)
return false;
}
strcpy(ent1Team, ClientTeam(ent1));
strcpy(ent2Team, ClientTeam(ent2));
ClientTeam(ent1, ent1Team);
ClientTeam(ent2, ent2Team);
if (strcmp(ent1Team, ent2Team) == 0)
if (ent1Team[0] != '\0' && strcmp(ent1Team, ent2Team) == 0)
{
return true;
}

View file

@ -1025,7 +1025,6 @@ extern void ValidateSelectedItem ( edict_t * ent ) ;
extern void SelectPrevItem ( edict_t * ent , int itflags ) ;
extern void SelectNextItem ( edict_t * ent , int itflags ) ;
extern qboolean OnSameTeam ( edict_t * ent1 , edict_t * ent2 ) ;
extern char * ClientTeam ( edict_t * ent ) ;
extern void GetChaseTarget ( edict_t * ent ) ;
extern void ChasePrev ( edict_t * ent ) ;
extern void ChaseNext ( edict_t * ent ) ;

View file

@ -1025,7 +1025,6 @@
{"SelectPrevItem", (byte *)SelectPrevItem},
{"SelectNextItem", (byte *)SelectNextItem},
{"OnSameTeam", (byte *)OnSameTeam},
{"ClientTeam", (byte *)ClientTeam},
{"GetChaseTarget", (byte *)GetChaseTarget},
{"ChasePrev", (byte *)ChasePrev},
{"ChaseNext", (byte *)ChaseNext},