From 398aeff770842c160640ca390161680400a3d961 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sun, 30 Nov 2014 18:06:36 +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, 6 insertions(+), 7 deletions(-) diff --git a/src/g_cmds.c b/src/g_cmds.c index 237b12a..83ed603 100644 --- a/src/g_cmds.c +++ b/src/g_cmds.c @@ -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; } diff --git a/src/savegame/tables/gamefunc_decs.h b/src/savegame/tables/gamefunc_decs.h index bf8832c..23bcab6 100644 --- a/src/savegame/tables/gamefunc_decs.h +++ b/src/savegame/tables/gamefunc_decs.h @@ -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 ) ; diff --git a/src/savegame/tables/gamefunc_list.h b/src/savegame/tables/gamefunc_list.h index b6c182e..7e8805c 100644 --- a/src/savegame/tables/gamefunc_list.h +++ b/src/savegame/tables/gamefunc_list.h @@ -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},