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).
This commit is contained in:
Daniel Gibson 2014-11-30 18:02:32 +01:00
parent ca84136e65
commit e2b397d92c

View file

@ -27,11 +27,10 @@
#include "header/local.h"
#include "monster/player.h"
char *
ClientTeam(edict_t *ent)
static char *
ClientTeam(edict_t *ent, char* value)
{
char *p;
static char value[512];
value[0] = 0;
@ -68,10 +67,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;
}