Skip to content
This repository has been archived by the owner on Oct 27, 2023. It is now read-only.

Commit

Permalink
Cleaned up client.cpp. PMove: More comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
WatIsDeze committed Mar 14, 2021
1 parent 60b9648 commit f2b0534
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 31 deletions.
35 changes: 23 additions & 12 deletions src/sharedgame/pmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,17 @@ static void PM_AirMove(void)



/*
=============
PM_CategorizePosition
=============
*/
//
//===============
// PM_CategorizePosition
//
// + Tests for whether the player is on-ground or not:
// - In case of the player its velocity being over 180, it will
// assume it is off ground, and not test any further.
// +
// -
//===============
//
static void PM_CategorizePosition(void)
{
vec3_t point;
Expand Down Expand Up @@ -723,11 +729,13 @@ static void PM_CategorizePosition(void)
}


/*
=============
PM_CheckJump
=============
*/
//
//===============
// PM_CheckJump
//
// Tests for whether we can jump. If so, set the appropriate velocity values.
//===============
//
static void PM_CheckJump(void)
{
if (pm->s.pm_flags & PMF_TIME_LAND) {
Expand Down Expand Up @@ -791,7 +799,7 @@ static void PM_CheckJump(void)
// - Whether to jump out of the water, or not.
//===============
//
static void PM_CheckSpecialMovement(void)
static void PM_CheckSpecialMovements(void)
{
vec3_t spot;
int cont;
Expand Down Expand Up @@ -1211,10 +1219,13 @@ void PMove(pmove_t* pmove, pmoveParams_t* params)
// set groundentity, watertype, and waterlevel
PM_CategorizePosition();

// Check for whether we're dead, if so, call PM_DeadMove. It will stop
// the player from keeping on moving forward.
if (pm->s.pm_type == PM_DEAD)
PM_DeadMove();

PM_CheckSpecialMovement();
// Check for special movements to execute.
PM_CheckSpecialMovements();

// drop timing counter
if (pm->s.pm_time) {
Expand Down
41 changes: 22 additions & 19 deletions src/svgame/player/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -987,52 +987,55 @@ void spectator_respawn(edict_t *ent)
{
int i, numspec;

// if the user wants to become a spectator, make sure he doesn't
// If the user wants to become a spectator, make sure he doesn't
// exceed max_spectators
if (ent->client->pers.spectator) {
// Test if the spectator password was correct, if not, error and return.
char *value = Info_ValueForKey(ent->client->pers.userinfo, "spectator");
if (*spectator_password->string &&
strcmp(spectator_password->string, "none") &&
strcmp(spectator_password->string, value)) {
// Report error message by centerprinting it to client.
gi.cprintf(ent, PRINT_HIGH, "Spectator password incorrect.\n");

// Enable spectator state.
ent->client->pers.spectator = qfalse;
// CLEANUP: Stuffcmd
//gi.WriteByte(svg_stufftext);
//gi.WriteString("spectator 0\n");
//gi.unicast(ent, qtrue);
// TODO: FIX STUFFCMD.

// Let the client go out of its spectator mode by using a stuffcmd.
gi.stuffcmd(ent, "spectator 0\n");
return;
}

// count spectators
// Count actual active spectators
for (i = 1, numspec = 0; i <= maxclients->value; i++)
if (g_edicts[i].inuse && g_edicts[i].client->pers.spectator)
numspec++;

if (numspec >= maxspectators->value) {
gi.cprintf(ent, PRINT_HIGH, "Server spectator limit is full.");
// Report error message by centerprinting it to client.
gi.cprintf(ent, PRINT_HIGH, "Server spectator limit is full.\n");

// Enable spectator state.
ent->client->pers.spectator = qfalse;
// reset his spectator var
//gi.WriteByte(svg_stufftext);
//gi.WriteString("spectator 0\n");
//gi.unicast(ent, qtrue);
// TODO: FIX STUFFCMD.

// Let the client go out of its spectator mode by using a stuffcmd.
gi.stuffcmd(ent, "spectator 0\n");
return;
}
} else {
// he was a spectator and wants to join the game
// he must have the right password
// He was a spectator and wants to join the game
// He must have the right password
// Test if the spectator password was correct, if not, error and return.
char *value = Info_ValueForKey(ent->client->pers.userinfo, "password");
if (*password->string && strcmp(password->string, "none") &&
strcmp(password->string, value)) {
// Report error message by centerprinting it to client.
gi.cprintf(ent, PRINT_HIGH, "Password incorrect.\n");

// Enable spectator state.
ent->client->pers.spectator = qtrue;
//gi.WriteByte(svg_stufftext);
//gi.WriteString("spectator 1\n");
//gi.unicast(ent, qtrue);
// TODO: FIX STUFFCMD.

// Let the client go in its spectator mode by using a stuffcmd.
gi.stuffcmd(ent, "spectator 1\n");
return;
}
Expand Down

0 comments on commit f2b0534

Please sign in to comment.