Skip to content

Commit

Permalink
GAME: extracted into function
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerhardy committed Nov 11, 2023
1 parent c65721f commit e6971b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions code/game/g_team.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,12 @@ static qboolean Team_FlagDefendOrProtectBonus(const gentity_t *targ, gentity_t *
return qfalse;
}

static void G_ResetLastHurtCarrier(gentity_t *ent) {
playerTeamState_t *teamState = &ent->client->pers.teamState;
teamState->lasthurtcarrier = 0;
teamState->lasthurtcarrierId = -1;
}

/**
* @brief Checks if the attacker is eligible for getting a defense bonus for killing the victim
*/
Expand Down Expand Up @@ -477,7 +483,7 @@ Note that bonuses are not cumulative. You get one, they are in importance
order.
================
*/
void Team_FragBonuses(const gentity_t *victim, gentity_t *attacker) {
void Team_FragBonuses(gentity_t *victim, gentity_t *attacker) {
int i;
int flag_pw, enemy_flag_pw;
int otherteam;
Expand Down Expand Up @@ -519,7 +525,7 @@ void Team_FragBonuses(const gentity_t *victim, gentity_t *attacker) {
for (i = 0; i < g_maxclients.integer; i++) {
gentity_t *ent = g_entities + i;
if (ent->inuse && ent->client->sess.sessionTeam == otherteam)
ent->client->pers.teamState.lasthurtcarrier = 0;
G_ResetLastHurtCarrier(ent);
}
return;
}
Expand All @@ -540,7 +546,7 @@ void Team_FragBonuses(const gentity_t *victim, gentity_t *attacker) {
for (i = 0; i < g_maxclients.integer; i++) {
gentity_t *ent = g_entities + i;
if (ent->inuse && ent->client->sess.sessionTeam == otherteam)
ent->client->pers.teamState.lasthurtcarrier = 0;
G_ResetLastHurtCarrier(ent);
}
return;
}
Expand All @@ -553,7 +559,7 @@ void Team_FragBonuses(const gentity_t *victim, gentity_t *attacker) {
AddScore(attacker, victim->r.currentOrigin, CTF_CARRIER_DANGER_PROTECT_BONUS, SCORE_BONUS_CARRIER_PROTECT_S);

attacker->client->pers.teamState.carrierdefense++;
victim->client->pers.teamState.lasthurtcarrier = 0;
G_ResetLastHurtCarrier(victim);

attacker->client->ps.persistant[PERS_PADHERO_COUNT]++;
// add the sprite over the player's head
Expand Down
2 changes: 1 addition & 1 deletion code/game/g_team.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const char *TeamColorString(int team);
void AddTeamScore(const vec3_t origin, int team, int score, char *reason);

void Team_DroppedFlagThink(gentity_t *ent);
void Team_FragBonuses(const gentity_t *victim, gentity_t *attacker);
void Team_FragBonuses(gentity_t *victim, gentity_t *attacker);
void Team_CheckHurtCarrier(const gentity_t *victim, gentity_t *attacker);
void Team_InitGame(void);
void Team_ReturnFlag(int team);
Expand Down

0 comments on commit e6971b2

Please sign in to comment.