From 150c521e13e8ec13f133a52f69430975d9cb20db Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sun, 30 Nov 2014 17:55:38 +0100 Subject: [PATCH] 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. --- src/g_cmds.c | 11 +++++------ src/savegame/tables/gamefunc_decs.h | 1 - src/savegame/tables/gamefunc_list.h | 1 - 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/g_cmds.c b/src/g_cmds.c index 493a423..c37e41b 100644 --- a/src/g_cmds.c +++ b/src/g_cmds.c @@ -8,11 +8,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; @@ -59,10 +58,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; } diff --git a/src/savegame/tables/gamefunc_decs.h b/src/savegame/tables/gamefunc_decs.h index c414d09..b291404 100644 --- a/src/savegame/tables/gamefunc_decs.h +++ b/src/savegame/tables/gamefunc_decs.h @@ -1204,7 +1204,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 ) ; diff --git a/src/savegame/tables/gamefunc_list.h b/src/savegame/tables/gamefunc_list.h index e0dbf88..eba91d5 100644 --- a/src/savegame/tables/gamefunc_list.h +++ b/src/savegame/tables/gamefunc_list.h @@ -1204,7 +1204,6 @@ {"SelectPrevItem", (byte *)SelectPrevItem}, {"SelectNextItem", (byte *)SelectNextItem}, {"OnSameTeam", (byte *)OnSameTeam}, -{"ClientTeam", (byte *)ClientTeam}, {"GetChaseTarget", (byte *)GetChaseTarget}, {"ChasePrev", (byte *)ChasePrev}, {"ChaseNext", (byte *)ChaseNext},