Skip to content

Commit

Permalink
Rewritten pause game stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
TriForceX committed Mar 22, 2021
1 parent b052311 commit a11faf5
Show file tree
Hide file tree
Showing 24 changed files with 481 additions and 205 deletions.
20 changes: 19 additions & 1 deletion assets/client/strip/jkmod_ingame.sp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION 1
ID 137
REFERENCE JKINGAME
COUNT 1
COUNT 3
INDEX 0
{
REFERENCE RACE_TIME
Expand All @@ -11,3 +11,21 @@ INDEX 0
TEXT_LANGUAGE6 "Time"
TEXT_LANGUAGE8 "Tiempo"
}
INDEX 1
{
REFERENCE PAUSE_GAME
TEXT_LANGUAGE1 "Game paused"
TEXT_LANGUAGE2 "Jeu en pause"
TEXT_LANGUAGE3 "Spiel pausiert"
TEXT_LANGUAGE6 "Game paused"
TEXT_LANGUAGE8 "Juego pausado"
}
INDEX 2
{
REFERENCE PAUSE_GAME_SEC
TEXT_LANGUAGE1 "Resume in %i"
TEXT_LANGUAGE2 "Reprise dans %i"
TEXT_LANGUAGE3 "Wieder aufnehmen %i"
TEXT_LANGUAGE6 "Resume in %i"
TEXT_LANGUAGE8 "Reanudando en %i"
}
2 changes: 2 additions & 0 deletions code/cgame/cg_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -3610,6 +3610,8 @@ static void CG_DrawWarmup( void ) {
// int cw;
const char *s;

if (cgs.jkmodCvar.pauseTime > cg.snap->serverTime) return; // Tr!Force: [Pause] Don't draw warmup

sec = cg.warmup;
if ( !sec ) {
return;
Expand Down
2 changes: 2 additions & 0 deletions code/cgame/cg_servercmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ void CG_UpdateConfigString( int num, qboolean init )
case CS_MVSDK:
MV_LoadSettings( str );
break;
case CS_PAUSE: // Tr!Force: [Pause] Get server pause time
cgs.jkmodCvar.pauseTime = atoi(str);
default:
break;
}
Expand Down
8 changes: 0 additions & 8 deletions code/game/bg_pmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -3647,14 +3647,6 @@ static void PM_Weapon( void )
if ( pm->cmd.buttons & BUTTON_USE_HOLDABLE ) {
if ( ! ( pm->ps->pm_flags & PMF_USE_ITEM_HELD ) ) {

#ifdef JK2_GAME
// Tr!Force: [Pause] Don't allow
if (jkcvar_pauseGame.integer)
{
return;
}
#endif

if (!pm->ps->stats[STAT_HOLDABLE_ITEM])
{
return;
Expand Down
2 changes: 2 additions & 0 deletions code/game/bg_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
#define CS_CLIENT_DUELWINNER 29 // current duel round winner - needed for printing at top of scoreboard
#define CS_CLIENT_DUELISTS 30 // client numbers for both current duelists. Needed for a number of client-side things.

#define CS_PAUSE 31 // Tr!Force: [Pause] Set config string

// these are also in be_aas_def.h - argh (rjr)
#define CS_MODELS 32
#define CS_SOUNDS (CS_MODELS+MAX_MODELS)
Expand Down
29 changes: 13 additions & 16 deletions code/game/g_active.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,9 +1080,16 @@ void BaseJK2_ClientThink_real( gentity_t *ent ) { // Tr!Force: [BaseJK2] Client
return;
}

// Tr!Force: [Pause] Check pause think
if (level.jkmodLevel.pauseTime > level.time)
{
JKMod_PauseClientThink(ent);
return;
}

if (ent && ent->client && (ent->client->ps.eFlags & EF_INVULNERABLE))
{
if (ent->client->invulnerableTimer <= level.time && !jkcvar_pauseGame.integer) // Tr!Force: [Pause] Don't allow
if (ent->client->invulnerableTimer <= level.time)
{
ent->client->ps.eFlags &= ~EF_INVULNERABLE;
}
Expand Down Expand Up @@ -1132,11 +1139,6 @@ void BaseJK2_ClientThink_real( gentity_t *ent ) { // Tr!Force: [BaseJK2] Client
client->ps.basespeed = g_speed.value;
}

if (jkcvar_pauseGame.integer) // Tr!Force: [Pause] Don't allow viewangles also
{
client->ps.pm_type = PM_SPINTERMISSION;
}

if (ent->client->ps.duelInProgress)
{
gentity_t *duelAgainst = &g_entities[ent->client->ps.duelIndex];
Expand Down Expand Up @@ -1543,7 +1545,7 @@ void BaseJK2_ClientThink_real( gentity_t *ent ) { // Tr!Force: [BaseJK2] Client
break;
case GENCMD_USE_SEEKER:
if ( (ent->client->ps.stats[STAT_HOLDABLE_ITEMS] & (1 << HI_SEEKER)) &&
G_ItemUsable(&ent->client->ps, HI_SEEKER) && !jkcvar_pauseGame.integer ) // Tr!Force: [Pause] Don't allow
G_ItemUsable(&ent->client->ps, HI_SEEKER) )
{
ItemUse_Seeker(ent);
G_AddEvent(ent, EV_USE_ITEM0+HI_SEEKER, 0);
Expand All @@ -1552,7 +1554,7 @@ void BaseJK2_ClientThink_real( gentity_t *ent ) { // Tr!Force: [BaseJK2] Client
break;
case GENCMD_USE_FIELD:
if ( (ent->client->ps.stats[STAT_HOLDABLE_ITEMS] & (1 << HI_SHIELD)) &&
G_ItemUsable(&ent->client->ps, HI_SHIELD) && !jkcvar_pauseGame.integer ) // Tr!Force: [Pause] Don't allow
G_ItemUsable(&ent->client->ps, HI_SHIELD) )
{
ItemUse_Shield(ent);
G_AddEvent(ent, EV_USE_ITEM0+HI_SHIELD, 0);
Expand All @@ -1561,7 +1563,7 @@ void BaseJK2_ClientThink_real( gentity_t *ent ) { // Tr!Force: [BaseJK2] Client
break;
case GENCMD_USE_BACTA:
if ( (ent->client->ps.stats[STAT_HOLDABLE_ITEMS] & (1 << HI_MEDPAC)) &&
G_ItemUsable(&ent->client->ps, HI_MEDPAC) /*&& !jkcvar_pauseGame.integer*/ ) // Tr!Force: [Pause] Don't allow ?
G_ItemUsable(&ent->client->ps, HI_MEDPAC) )
{
ItemUse_MedPack(ent);
G_AddEvent(ent, EV_USE_ITEM0+HI_MEDPAC, 0);
Expand Down Expand Up @@ -1600,7 +1602,7 @@ void BaseJK2_ClientThink_real( gentity_t *ent ) { // Tr!Force: [BaseJK2] Client
break;
case GENCMD_USE_SENTRY:
if ( (ent->client->ps.stats[STAT_HOLDABLE_ITEMS] & (1 << HI_SENTRY_GUN)) &&
G_ItemUsable(&ent->client->ps, HI_SENTRY_GUN) && !jkcvar_pauseGame.integer ) // Tr!Force: [Pause] Don't allow
G_ItemUsable(&ent->client->ps, HI_SENTRY_GUN) )
{
ItemUse_Sentry(ent);
G_AddEvent(ent, EV_USE_ITEM0+HI_SENTRY_GUN, 0);
Expand Down Expand Up @@ -1787,11 +1789,6 @@ void G_CheckClientTimeouts ( gentity_t *ent )
return;
}

if ( jkcvar_pauseGame.integer ) // Tr!Force: [Pause] Don't allow
{
return;
}

// Already a spectator, no need to boot them to spectator
if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR )
{
Expand Down Expand Up @@ -1823,7 +1820,7 @@ void ClientThink( int clientNum ) {
// phone jack if they don't get any for a while
ent->client->lastCmdTime = level.time;

if ( !(ent->r.svFlags & SVF_BOT) && !g_synchronousClients.integer || jkcvar_pauseGame.integer ) { // Tr!Force: [Pause] Don't allow
if ( !(ent->r.svFlags & SVF_BOT) && !g_synchronousClients.integer ) {
ClientThink_real( ent );
}
}
Expand Down
16 changes: 8 additions & 8 deletions code/game/g_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void ThrowSaberToAttacker(gentity_t *self, gentity_t *attacker)
VectorCopy(ent->s.origin2, ent->s.pos.trBase);
VectorCopy(ent->s.origin2, ent->s.origin);
VectorCopy(ent->s.origin2, ent->r.currentOrigin);
ent->pos2[0] = 0;
ent->jkmodEnt.time1/*pos2[0]*/ = 0; // Tr!Force: [Pause] Think time
trap_LinkEntity(ent);
return;
}
Expand Down Expand Up @@ -173,21 +173,21 @@ void JMSaberThink(gentity_t *ent)
ent->s.eType = ET_MISSILE;
ent->enemy = NULL;

ent->pos2[0] = 1;
ent->pos2[1] = 0; //respawn next think
// ent->pos2[0] = 1; // Tr!Force: [Pause] Skip this
ent->jkmodEnt.time1/*pos2[1]*/ = 0; //respawn next think // Tr!Force: [Pause] Think time
trap_LinkEntity(ent);
}
else
{
ent->pos2[1] = level.time + JMSABER_RESPAWN_TIME;
ent->jkmodEnt.time1/*pos2[1]*/ = level.time + JMSABER_RESPAWN_TIME; // Tr!Force: [Pause] Think time
}
}
else if (ent->pos2[0] && ent->pos2[1] < level.time)
else if (ent->jkmodEnt.time1/*pos2[0]*/ && ent->jkmodEnt.time1/*pos2[1]*/ < level.time) // Tr!Force: [Pause] Think time
{
VectorCopy(ent->s.origin2, ent->s.pos.trBase);
VectorCopy(ent->s.origin2, ent->s.origin);
VectorCopy(ent->s.origin2, ent->r.currentOrigin);
ent->pos2[0] = 0;
ent->jkmodEnt.time1/*pos2[0]*/ = 0; // Tr!Force: [Pause] Think time
trap_LinkEntity(ent);
}

Expand Down Expand Up @@ -263,8 +263,8 @@ void JMSaberTouch(gentity_t *self, gentity_t *other, trace_t *trace)
i++;
}

self->pos2[0] = 1;
self->pos2[1] = level.time + JMSABER_RESPAWN_TIME;
// self->pos2[0] = 1; // Tr!Force: [Pause] Skip this
self->jkmodEnt.time1/*pos2[1]*/ = level.time + JMSABER_RESPAWN_TIME; // Tr!Force: [Pause] Think time

self->s.modelindex = 0;
self->s.eFlags |= EF_NODRAW;
Expand Down
17 changes: 7 additions & 10 deletions code/game/g_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,6 @@ void Cmd_Kill_f( gentity_t *ent ) {
if (ent->health <= 0) {
return;
}
if (jkcvar_pauseGame.integer) // Tr!Force: [Pause] Don't allow kill command
{
trap_SendServerCommand(ent - g_entities, va("print \"You can't kill yourself during pause mode\n\""));
return;
}
if (ent->client->ps.stats[JK_DIMENSION] == DIMENSION_RACE) // Tr!Force: [Dimensions] Don't kill, respawn
{
trap_UnlinkEntity(ent);
Expand Down Expand Up @@ -734,6 +729,13 @@ void SetTeam( gentity_t *ent, char *s ) {
team = TEAM_SPECTATOR;
}

// Tr!Force: [Pause] Don't allow
if (level.jkmodLevel.pauseTime > level.time)
{
trap_SendServerCommand(ent - g_entities, "cp \"You can't change team during pause mode\n\"");
return;
}

//
// decide if we will allow the change
//
Expand Down Expand Up @@ -2157,11 +2159,6 @@ void Cmd_ToggleSaber_f(gentity_t *ent)
return;
}

if (jkcvar_pauseGame.integer) // Tr!Force: [Pause] Don't allow toggle saber
{
return;
}

// if (ent->client->ps.duelInProgress && !ent->client->ps.saberHolstered)
// {
// return;
Expand Down
6 changes: 3 additions & 3 deletions code/game/g_combat.c
Original file line number Diff line number Diff line change
Expand Up @@ -2373,7 +2373,7 @@ void LimbTouch( gentity_t *self, gentity_t *other, trace_t *trace )

void LimbThink( gentity_t *ent )
{
if (ent->speed < level.time)
if (ent->jkmodEnt.time1/*speed*/ < level.time) // Tr!Force: [Pause] Think time
{
ent->think = G_FreeEntity;
ent->nextthink = level.time;
Expand All @@ -2382,7 +2382,7 @@ void LimbThink( gentity_t *ent )

if (ent->s.pos.trType != TR_GRAVITY)
{
int addamt = (ent->speed - level.time);
int addamt = (ent->jkmodEnt.time1/*ent->speed*/ - level.time); // Tr!Force: [Pause] Think time

if (addamt > 5000)
{
Expand Down Expand Up @@ -2633,7 +2633,7 @@ void G_Dismember( gentity_t *ent, vec3_t point, int limbType, float limbRollBase
VectorCopy( newPoint, limb->s.pos.trBase );
limb->think = LimbThink;
limb->touch = LimbTouch;
limb->speed = level.time + Q_irand(4000, 8000);
limb->jkmodEnt.time1/*speed*/ = level.time + Q_irand(4000, 8000); // Tr!Force: [Pause] Think time
limb->nextthink = level.time + FRAMETIME;

//need size, contents, clipmask
Expand Down
14 changes: 4 additions & 10 deletions code/game/g_items.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ void pas_think( gentity_t *ent )
return;
}

if ((ent->bolt_LLeg+TURRET_LIFETIME) < level.time)
if ((ent->jkmodEnt.time1/*bolt_LLeg*/+TURRET_LIFETIME) < level.time) // Tr!Force: [Pause] Think time
{
G_Sound( ent, CHAN_BODY, G_SoundIndex( "sound/chars/turret/shutdown.wav" ));
ent->s.bolt2 = ENTITYNUM_NONE;
Expand Down Expand Up @@ -1026,7 +1026,7 @@ void ItemUse_Sentry( gentity_t *ent )

sentry->bolt_Head = 1000;

sentry->bolt_LLeg = level.time;
sentry->jkmodEnt.time1/*bolt_LLeg*/ = level.time; // Tr!Force: [Pause] Think time

sentry->noDamageTeam = ent->client->sess.sessionTeam;

Expand Down Expand Up @@ -2139,10 +2139,7 @@ void G_RunItem( gentity_t *ent ) {

if ( ent->s.pos.trType == TR_STATIONARY ) {
// check think function
if (!jkcvar_pauseGame.integer) // Tr!Force: [Pause] Don't allow
{
G_RunThink( ent );
}
G_RunThink( ent );
return;
}

Expand All @@ -2167,10 +2164,7 @@ void G_RunItem( gentity_t *ent ) {
trap_LinkEntity( ent ); // FIXME: avoid this for stationary?

// check think function
if (!jkcvar_pauseGame.integer) // Tr!Force: [Pause] Don't allow
{
G_RunThink( ent );
}
G_RunThink( ent );

if ( tr.fraction == 1 ) {
return;
Expand Down
13 changes: 7 additions & 6 deletions code/game/g_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2055,7 +2055,7 @@ void CheckExitRules( void ) {
}
}

if ( g_timelimit.integer && !level.warmupTime && !jkcvar_pauseGame.integer ) { // Tr!Force: [Pause] Don't allow
if ( g_timelimit.integer && !level.warmupTime ) {
if ( level.time - level.startTime >= g_timelimit.integer*60000 ) {
// trap_SendServerCommand( -1, "print \"Timelimit hit.\n\"");
trap_SendServerCommand( -1, va("print \"%s.\n\"",G_GetStripEdString("SVINGAME", "TIMELIMIT_HIT")));
Expand Down Expand Up @@ -2535,11 +2535,6 @@ Runs thinking code for this frame if necessary
void G_RunThink (gentity_t *ent) {
float thinktime;

if (jkcvar_pauseGame.integer) // Tr!Force; [Pause] Don't allow
{
return;
}

thinktime = ent->nextthink;
if (thinktime <= 0) {
return;
Expand Down Expand Up @@ -2644,6 +2639,12 @@ void G_RunFrame( int levelTime ) {

g_TimeSinceLastFrame = (level.time - g_LastFrameTime);

// Tr!Force: [Pause] Check paused frame
if (JKMod_PauseFrameCheck(levelTime)) {
JKMod_PauseFrameRun();
return;
}

// get any cvar changes
G_UpdateCvars();

Expand Down
Loading

0 comments on commit a11faf5

Please sign in to comment.