Skip to content

Commit

Permalink
JANITORIAL: replaced magic constants
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerhardy committed Apr 8, 2022
1 parent 9619ae4 commit 45224d7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions code/cgame/cg_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2543,8 +2543,8 @@ static void CG_DrawEntityIcons(void) {
CG_DrawHealthstationIcon(cent);
break;
case ET_TELEPORT_TRIGGER:
// Magical constant is set for sprayroom teleporter in SP_trigger_teleport
if (0x23 == cent->currentState.generic1) {
// constant is set for sprayroom teleporter in SP_trigger_teleport
if (SPRAYROOM_CONSTANT == cent->currentState.generic1) {
CG_DrawSprayroomIcon(cent);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion code/cgame/cg_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ void CG_EntityEvent(centity_t *cent, vec3_t position) {
color[3] = 1.0f;

// Hit a spraywall
if (es->generic1 == 0x23) {
if (es->generic1 == SPRAYROOM_CONSTANT) {
logohandle = FindLogoForSpraying(ci);
Add_LogoToDrawList(es->pos.trBase, dir, logohandle, radius, ci);
} else {
Expand Down
5 changes: 2 additions & 3 deletions code/cgame/cg_predict.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,9 @@ static void CG_TouchTriggerPrediction(void) {
}

if (ent->eType == ET_TELEPORT_TRIGGER && (cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR ||
cg.snap->ps.ammo[WP_SPRAYPISTOL] || ent->generic1 != 0x23)) {
cg.snap->ps.ammo[WP_SPRAYPISTOL] || ent->generic1 != SPRAYROOM_CONSTANT)) {
// the hyperspace-effect is realy ugly ... and it can only be seen, if there are big lags or high ping
// cg.hyperspace = qtrue;

// cg.hyperspace = qtrue;
} else if (ent->eType == ET_PUSH_TRIGGER) {
BG_TouchJumpPad(&cg.predictedPlayerState, ent);
}
Expand Down
14 changes: 9 additions & 5 deletions code/game/g_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,11 @@ static void trigger_teleporter_touch(gentity_t *self, gentity_t *other, trace_t
TeleportPlayer(other, dest->s.origin, dest->s.angles);
}

/*QUAKED trigger_teleport (.5 .5 .5) ? SPECTATOR
#define TELEPORT_SPECTATORS_ONLY 1
#define TELEPORT_ENTER_SPRAYROOM 2
#define TELEPORT_LEAVE_SPRAYROOM 4

/*QUAKED trigger_teleport (.5 .5 .5) ? SPECTATORS_ONLY ENTER_SPRAYROOM LEAVE_SPRAYROOM
Allows client side prediction of teleportation events.
Must point at a target_position, which will be the teleport destination.
Expand All @@ -331,23 +335,23 @@ void SP_trigger_teleport(gentity_t *self) {

// unlike other triggers, we need to send this one to the client
// unless is a spectator trigger
if (self->spawnflags & 1) {
if (self->spawnflags & TELEPORT_SPECTATORS_ONLY) {
self->r.svFlags |= SVF_NOCLIENT;
} else {
self->r.svFlags &= ~SVF_NOCLIENT;
}

// Mark as sprayroom teleporter if ENTER_SPRAYROOM is set.
// Used for clientside prediction etc.
if (self->spawnflags & 0x2) {
self->s.generic1 = 0x23;
if (self->spawnflags & TELEPORT_ENTER_SPRAYROOM) {
self->s.generic1 = SPRAYROOM_CONSTANT;
self->s.origin2[0] = (self->r.absmin[0] + self->r.absmax[0]) * 0.5f;
self->s.origin2[1] = (self->r.absmin[1] + self->r.absmax[1]) * 0.5f;
self->s.origin2[2] = (self->r.absmin[2] + self->r.absmax[2]) * 0.5f;
level.sr_tele = self;
}

else if (self->spawnflags & 4) {
else if (self->spawnflags & TELEPORT_LEAVE_SPRAYROOM) {
level.sr_teleout = self;
}

Expand Down
2 changes: 1 addition & 1 deletion code/game/g_weapon.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ static void weapon_spraypistol_fire(gentity_t *ent) {

// Hit a spraywall
if (tr.entityNum != ENTITYNUM_WORLD) {
tent->s.generic1 = 0x23; // ungebrauchte vars tut man missbrauchen ;)
tent->s.generic1 = SPRAYROOM_CONSTANT;
}
}

Expand Down
2 changes: 2 additions & 0 deletions code/qcommon/q_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ typedef enum {
#define BLINK_DIVISOR 200
#define PULSE_DIVISOR 75

#define SPRAYROOM_CONSTANT 0x23

#define UI_LEFT 0x00000000 // default
#define UI_CENTER 0x00000001
#define UI_RIGHT 0x00000002
Expand Down

0 comments on commit 45224d7

Please sign in to comment.