Skip to content

Commit

Permalink
MATCHLESS: cleanup, trade off a bit more math to lose a few variables…
Browse files Browse the repository at this point in the history
… in our struct
  • Loading branch information
ciscon authored and deurk committed May 12, 2020
1 parent 4ac98b4 commit 90326c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
2 changes: 0 additions & 2 deletions include/progs.h
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,6 @@ typedef struct gedict_s {
float dmg;
float lip;
float attack_finished;
float attack_finished_last;
int attack_idle_time; // keep track of last time client fired weapon in matchless
float pain_finished;

float invincible_finished;
Expand Down
27 changes: 11 additions & 16 deletions src/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,31 +475,26 @@ void CheckOvertime()
void TimerThink ()
{
gedict_t *p;
int idle_time;

//if in matchless mode, check that the user hasn't exceeded k_matchless_max_idle_time
if ( k_matchLess && CountPlayers() && match_in_progress && k_matchLess_idle_time){
for( p = world; (p = find_client( p )); )
{
if( p->attack_finished != p->attack_finished_last ) {
p->attack_finished_last = p->attack_finished;
p->attack_idle_time = 0;
} else {
if( p->attack_idle_time > k_matchLess_idle_time ){
G_sprint(p, 2, "You were forced to reconnect as spectator by exceeding the maximum idle time of %i seconds.\n", k_matchLess_idle_time);
stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "spectator 1\n");
if ( !strnull( ezinfokey(p, "Qizmo") ) )
stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "say ,:dis\nwait;wait;wait; say ,:reconnect\n");
else
stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "disconnect\nwait;wait;reconnect\n");
} else if ( p->attack_idle_time == k_matchLess_idle_warn ) {
G_sprint(p, 2, "\x87%s You will be forced to spectate if you do not fire within %i seconds!\n", redtext( "WARNING:" ), (k_matchLess_idle_time-k_matchLess_idle_warn));
}
p->attack_idle_time++;
idle_time=(int)(g_globalvars.time-p->attack_finished);
if( idle_time > k_matchLess_idle_time ){
G_sprint(p, 2, "You were forced to reconnect as spectator by exceeding the maximum idle time of %i seconds.\n", k_matchLess_idle_time);
stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "spectator 1\n");
if ( !strnull( ezinfokey(p, "Qizmo") ) )
stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "say ,:dis\nwait;wait;wait; say ,:reconnect\n");
else
stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "disconnect\nwait;wait;reconnect\n");
} else if ( idle_time == k_matchLess_idle_warn ) {
G_sprint(p, 2, "\x87%s You will be forced to spectate if you do not fire within %i seconds!\n", redtext( "WARNING:" ), (k_matchLess_idle_time-k_matchLess_idle_warn));
}
}
}


if( !k_matchLess && !CountPlayers() ) {
EndMatch( 1 );
return;
Expand Down

0 comments on commit 90326c5

Please sign in to comment.