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 18:06:36 +01:00
parent 3bcb10d734
commit 398aeff770
3 changed files with 6 additions and 7 deletions

View File

@ -1,10 +1,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;
@ -33,11 +33,12 @@ qboolean OnSameTeam (edict_t *ent1, edict_t *ent2)
if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS)))
return false;
strcpy (ent1Team, ClientTeam (ent1));
strcpy (ent2Team, ClientTeam (ent2));
ClientTeam (ent1, ent1Team);
ClientTeam (ent2, ent2Team);
if (strcmp(ent1Team, ent2Team) == 0)
if (ent1Team[1] != '\0' && strcmp(ent1Team, ent2Team) == 0)
return true;
return false;
}

View File

@ -1260,7 +1260,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 ai_run ( edict_t * self , float dist ) ;
extern qboolean ai_checkattack ( edict_t * self , float dist ) ;
extern void ai_fly_strafe ( edict_t * self , float dist ) ;

View File

@ -1260,7 +1260,6 @@
{"SelectPrevItem", (byte *)SelectPrevItem},
{"SelectNextItem", (byte *)SelectNextItem},
{"OnSameTeam", (byte *)OnSameTeam},
{"ClientTeam", (byte *)ClientTeam},
{"ai_run", (byte *)ai_run},
{"ai_checkattack", (byte *)ai_checkattack},
{"ai_fly_strafe", (byte *)ai_fly_strafe},