Skip to content

Commit

Permalink
CGAME: const + reduced scope
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerhardy committed Jul 27, 2024
1 parent 01a6fe5 commit 5b7dc3a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion code/cgame/cg_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ void CG_ShaderStateChanged(void);
// cg_playerstate.c
//
void CG_Respawn(void);
void CG_TransitionPlayerState(playerState_t *ps, playerState_t *ops);
void CG_TransitionPlayerState(const playerState_t *ps, playerState_t *ops);
void CG_ToggleSpawnProtection(int entNum, qboolean state);

//
Expand Down
6 changes: 3 additions & 3 deletions code/cgame/cg_playerstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void CG_Respawn(void) {
CG_CheckPlayerstateEvents
==============
*/
static void CG_CheckPlayerstateEvents(playerState_t *ps, playerState_t *ops) {
static void CG_CheckPlayerstateEvents(const playerState_t *ps, playerState_t *ops) {
int i;
int event;
centity_t *cent;
Expand Down Expand Up @@ -252,7 +252,7 @@ static void CG_PushReward(sfxHandle_t sfx, qhandle_t shader, int rewardCount) {
CG_CheckLocalSounds
==================
*/
static void CG_CheckLocalSounds(playerState_t *ps, playerState_t *ops) {
static void CG_CheckLocalSounds(const playerState_t *ps, playerState_t *ops) {
qboolean reward = qfalse;

// don't play the sounds if the player just changed teams
Expand Down Expand Up @@ -452,7 +452,7 @@ static void CG_CheckLocalSounds(playerState_t *ps, playerState_t *ops) {
CG_TransitionPlayerState
===============
*/
void CG_TransitionPlayerState(playerState_t *ps, playerState_t *ops) {
void CG_TransitionPlayerState(const playerState_t *ps, playerState_t *ops) {
// check for changing follow mode
if (ps->clientNum != ops->clientNum) {
cg.thisFrameTeleport = qtrue;
Expand Down
13 changes: 6 additions & 7 deletions code/cgame/cg_scoreboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,12 @@ Draw the normal in-game scoreboard
qboolean CG_DrawOldScoreboard(void) {
int x, y, i;
float fade;
float *fadeColor;
const float *fadeColor;
int maxClients;
int lineHeight;
int topBorderSize, bottomBorderSize;
int scoreLineSpace, maxScoreLinesPerTeam[TEAM_NUM_TEAMS];
const score_t *score;
char buf[32];

// don't draw anything if the menu or console is up
if (cg_paused.integer) {
Expand Down Expand Up @@ -406,11 +405,11 @@ qboolean CG_DrawOldScoreboard(void) {
fade = *fadeColor;
}

CG_DrawPic(0, 0, 640, 496, cgs.media.scoreboardBG);
CG_DrawPic(0, 0, SCREEN_WIDTH, 496, cgs.media.scoreboardBG);

// fragged by ... line
if (cg.killerName[0]) {
char *s = va(S_COLOR_BLACK "Fragged by %s", cg.killerName);
const char *s = va(S_COLOR_BLACK "Fragged by %s", cg.killerName);
int w = (CG_DrawStrlen(s) * BIGCHAR_WIDTH);
x = ((SCREEN_WIDTH - w) / 2);
y = (SB_TOP - 56);
Expand All @@ -421,7 +420,7 @@ qboolean CG_DrawOldScoreboard(void) {
// current rank
if (cgs.gametype < GT_TEAM) {
if (cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR) {
char *s;
const char *s;
int w;
if (cgs.gametype == GT_LPS) {
int ownLives = cg.snap->ps.stats[STAT_LIVESLEFT];
Expand All @@ -448,7 +447,7 @@ qboolean CG_DrawOldScoreboard(void) {
CG_DrawStringExt(x, y, s, fadeColor, qfalse, qfalse, FONT_BIG, 0);
}
} else {
char *s;
const char *s;
int w;
// FIXME: Use some sort of team_t define/enum
if (cg.teamScores[0] == cg.teamScores[1]) {
Expand Down Expand Up @@ -552,7 +551,6 @@ qboolean CG_DrawOldScoreboard(void) {
averageTeamLines = (linesLeft / numTeams);

if ((!teamDone[i]) && (cg.scoreTeamCount[i] <= averageTeamLines)) {

maxScoreLinesPerTeam[i] = cg.scoreTeamCount[i];
teamDone[i] = qtrue;
linesLeft -= cg.scoreTeamCount[i];
Expand Down Expand Up @@ -633,6 +631,7 @@ qboolean CG_DrawOldScoreboard(void) {
if (score != NULL) {
const clientInfo_t *ci = &cgs.clientinfo[score->client];
if (ci->team != TEAM_SPECTATOR) {
char buf[32];
CG_DrawMedals(62.0f, (float)SB_TOP + 216.0f, score);

// draw accuracy rate
Expand Down
11 changes: 4 additions & 7 deletions code/cgame/cg_snapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ All other times will use CG_TransitionSnapshot instead.
*/
static void CG_SetInitialSnapshot(snapshot_t *snap) {
int i;
centity_t *cent;
entityState_t *state;

cg.snap = snap;

Expand All @@ -98,8 +96,8 @@ static void CG_SetInitialSnapshot(snapshot_t *snap) {
CG_Respawn();

for (i = 0; i < cg.snap->numEntities; i++) {
state = &cg.snap->entities[i];
cent = &cg_entities[state->number];
const entityState_t *state = &cg.snap->entities[i];
centity_t *cent = &cg_entities[state->number];

memcpy(&cent->currentState, state, sizeof(entityState_t));
// cent->currentState = *state;
Expand All @@ -121,7 +119,6 @@ The transition point from snap to nextSnap has passed
===================
*/
static void CG_TransitionSnapshot(void) {
centity_t *cent;
snapshot_t *oldFrame;
int i;

Expand All @@ -141,7 +138,7 @@ static void CG_TransitionSnapshot(void) {

// clear the currentValid flag for all entities in the existing snapshot
for (i = 0; i < cg.snap->numEntities; i++) {
cent = &cg_entities[cg.snap->entities[i].number];
centity_t *cent = &cg_entities[cg.snap->entities[i].number];
cent->currentValid = qfalse;
}

Expand All @@ -153,7 +150,7 @@ static void CG_TransitionSnapshot(void) {
cg_entities[cg.snap->ps.clientNum].interpolate = qfalse;

for (i = 0; i < cg.snap->numEntities; i++) {
cent = &cg_entities[cg.snap->entities[i].number];
centity_t *cent = &cg_entities[cg.snap->entities[i].number];
CG_TransitionEntity(cent);

// remember time of snapshot this entity was last updated in
Expand Down

0 comments on commit 5b7dc3a

Please sign in to comment.