void vote_check_elect () { gedict_t *p; if( !get_votes_req( OV_ELECT, true ) ) { for( p = world; (p = find_client( p )); ) if ( p->v.elect_type != etNone ) break; if ( !p ) { // nor admin nor captain found - probably bug AbortElect(); return; } if( !(p->ct == ctSpec && match_in_progress) ) if( is_elected(p, etAdmin) ) // s: election was admin election BecomeAdmin(p, AF_ADMIN); if( !match_in_progress ) if( is_elected(p, etCaptain) ) // s: election was captain election BecomeCaptain(p); AbortElect(); return; } }
//////////////// // GlobalParams: // self /////////////// void SpectatorDisconnect() { gedict_t *p; if ( self->k_accepted ) { for ( p = world; (p = ( match_in_progress == 2 && !cvar("k_ann") ) ? find_spc( p ) : find_client( p )); ) G_sprint( p, PRINT_HIGH, "Spectator %s left the game\n", self->s.v.netname ); } // s: added conditional function call here if( self->v.elect_type != etNone ) { if ( match_in_progress != 2 ) G_bprint(2, "Election aborted\n"); AbortElect(); } if ( self->wizard ) { ent_remove( self->wizard ); self->wizard = NULL; } if( self->k_kicking ) ExitKick( self ); self->s.v.classname = ""; // Cenobite, so we clear out any specs as they leave self->k_accepted = 0; self->ct = ctNone; }
void ElectThink() { G_bprint(2, "The voting has timed out.\n" "Election aborted\n"); self->s.v.nextthink = -1; AbortElect(); }
void VoteAdmin() { gedict_t *p; int till; gedict_t *electguard; // Can't allow election and code entering for the same person at the same time if( self->k_adminc ) { G_sprint(self, 2, "Finish entering the code first\n"); return; } if( is_adm( self ) ) { G_sprint(self, 2, "You are already an admin\n"); return; } if( is_elected( self, etAdmin ) ) { G_bprint(2, "%s %s!\n", self->netname, redtext("aborts election")); AbortElect(); return; } // Only one election per server because otherwise we wouldn't know how to count // "yes"s or "no"s if( get_votes( OV_ELECT ) ) { G_sprint(self, 2, "An election is already in progress\n"); return; } if( !cvar( "k_admins" ) ) { G_sprint(self, 2, "%s on this server!\n", redtext("NO admins")); return; } // Check if voteadmin is allowed if( !cvar( "k_allowvoteadmin" ) ) { G_sprint(self, 2, "Admin election is not allowed on this server\n"); return; } if( (till = Q_rint( self->v.elect_block_till - g_globalvars.time)) > 0 ) { G_sprint(self, 2, "Wait %d second%s!\n", till, count_s(till) ); return; } if( self->ct == ctSpec && match_in_progress ) return; G_bprint(2, "%s has %s rights!\n", self->netname, redtext("requested admin")); for( p = world; (p = find_client( p )); ) if ( p != self && p->ct == ctPlayer ) G_sprint(p, 2, "Type %s in console to approve\n", redtext("yes")); G_sprint(self, 2, "Type %s to abort election\n", redtext("elect")); // announce the election self->v.elect = 1; self->v.elect_type = etAdmin; electguard = spawn(); // Check the 1 minute timeout for election electguard->s.v.owner = EDICT_TO_PROG( world ); electguard->classname = "electguard"; electguard->think = ( func_t ) ElectThink; electguard->s.v.nextthink = g_globalvars.time + 60; }