Skip to content
Permalink
Browse files

cgame: slight improvement in CG_GibPlayer

* Init newjunction variable at declaration instead of loop
* Assign bodyRefEnt only one time at declaration
* Break when a tag is not found instead of checking flag variable foundtag
* Reduce scope variables
  • Loading branch information...
Aranud committed Aug 13, 2019
1 parent 453d47b commit 881d001252febe741d5965910da78ce37b790052
Showing with 61 additions and 74 deletions.
  1. +61 −74 src/cgame/cg_effects.c
@@ -578,106 +578,93 @@ int CG_GetOriginForTag(centity_t *cent, refEntity_t *parent, const char *tagName
*/
void CG_GibPlayer(centity_t *cent, vec3_t playerOrigin, vec3_t gdir)
{
vec3_t origin;
trace_t trace;
clientInfo_t *ci;
bg_character_t *character;
vec4_t projection;
// BloodCloud
qboolean newjunction[MAXJUNCTIONS];
vec3_t junctionOrigin[MAXJUNCTIONS];
vec3_t axis[3];

static const char *JunctiongibTags[] =
if (cg_blood.integer && cg_bloodTime.integer)
{
// leg tag
"tag_footright",
"tag_footleft",
"tag_legright",
"tag_legleft",
vec3_t origin;
trace_t trace;
clientInfo_t *ci;
bg_character_t *character;
vec4_t projection;
// BloodCloud
qboolean newjunction[MAXJUNCTIONS] = { 0 };
vec3_t junctionOrigin[MAXJUNCTIONS];
vec3_t axis[3];

// torsotags
"tag_armright",
"tag_armleft",
vec4_t color;
vec3_t velocity, dir, angles;
refEntity_t *re = &cent->pe.bodyRefEnt;
int i, j, count = 0;
int tagIndex, gibIndex, junction;
int clientNum = cent->currentState.clientNum;

"tag_torso",
"tag_chest"
};
static const char *JunctiongibTags[] =
{
// leg tag
"tag_footright",
"tag_footleft",
"tag_legright",
"tag_legleft",

static const char *ConnectTags[] =
{
// legs tags
"tag_legright",
"tag_legleft",
"tag_torso",
"tag_torso",
// torsotags
"tag_armright",
"tag_armleft",

// torso tags
"tag_chest",
"tag_chest",
"tag_torso",
"tag_chest"
};

"tag_chest",
"tag_torso",
};
static const char *ConnectTags[] =
{
// legs tags
"tag_legright",
"tag_legleft",
"tag_torso",
"tag_torso",

static const char *gibTags[] =
{
// tags in the legs
"tag_footright",
"tag_footleft",
"tag_legright",
"tag_legleft",
"tag_torso",

// tags in the torso
"tag_chest",
"tag_armright",
"tag_armleft",
"tag_head",
NULL
};
// torso tags
"tag_chest",
"tag_chest",

if (cg_blood.integer && cg_bloodTime.integer)
{
vec4_t color;
vec3_t velocity, dir, angles;
refEntity_t *re;
int i, j, count = 0;
int tagIndex, gibIndex, junction;
int clientNum = cent->currentState.clientNum;
qboolean foundtag;
"tag_chest",
"tag_torso",
};

if (clientNum < 0 || clientNum >= MAX_CLIENTS)
static const char *gibTags[] =
{
CG_Error("Bad clientNum on player entity\n");
}
// tags in the legs
"tag_footright",
"tag_footleft",
"tag_legright",
"tag_legleft",
"tag_torso",

// tags in the torso
"tag_chest",
"tag_armright",
"tag_armleft",
"tag_head",
NULL
};

for (i = 0; i < MAXJUNCTIONS; i++)
if (clientNum < 0 || clientNum >= MAX_CLIENTS)
{
newjunction[i] = qfalse;
CG_Error("Bad clientNum on player entity\n");
}

ci = &cgs.clientinfo[clientNum];
character = CG_CharacterForClientinfo(ci, cent);

// fetch the various positions of the tag_gib*'s
// and spawn the gibs from the correct places (especially the head)
for (gibIndex = 0, count = 0, foundtag = qtrue; foundtag && gibIndex < MAX_GIB_MODELS && gibTags[gibIndex]; gibIndex++)
for (gibIndex = 0, count = 0; gibIndex < MAX_GIB_MODELS && gibTags[gibIndex]; gibIndex++)
{
re = 0;
foundtag = qfalse;

if (!character->gibModels[gibIndex])
{
continue;
break;
}

re = &cent->pe.bodyRefEnt;

for (tagIndex = 0; (tagIndex = CG_GetOriginForTag(cent, re, gibTags[gibIndex], tagIndex, origin, axis)) >= 0; count++, tagIndex++)
{
foundtag = qtrue;

VectorSubtract(origin, re->origin, dir);
VectorNormalize(dir);

0 comments on commit 881d001

Please sign in to comment.
You can’t perform that action at this time.