Esempio n. 1
0
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;
	}
}
Esempio n. 2
0
int get_elect_type ()
{
	gedict_t *p;

	for( p = world; (p = find_client( p )); ) {
		if( is_elected(p, etAdmin) ) // elected admin
			return etAdmin;

		if( is_elected(p, etCaptain) ) // elected captain
			return etCaptain;
	}

	return etNone;
}
Esempio n. 3
0
// AbortElect is used to terminate the voting
// Important if player to be elected disconnects or levelchange happens
void AbortElect()
{
	gedict_t *p;

	for( p = world; (p = find_client( p )); ) {
		if ( p->v.elect_type != etNone ) {
			if ( is_elected(p, etCaptain) )
				k_captains = floor( k_captains );

			p->v.elect_type = etNone;
			p->v.elect_block_till = g_globalvars.time + 30; // block election for some time
		}
	}

	vote_clear( OV_ELECT ); // clear vote

// Kill timeout checker entity
	for( p = world; (p = find(p, FOFCLSN, "electguard")); ) 
		ent_remove( p );
}
Esempio n. 4
0
File: admin.c Progetto: deurk/ktx
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;
}
Esempio n. 5
0
File: admin.c Progetto: deurk/ktx
void ReqAdmin ()
{
    //  check for election
    if( is_elected(self, etAdmin) )
    {
        G_sprint(self, 2, "Abort %sion first\n", redtext("elect"));
        return;
    }

    if( is_adm( self ) )
    {
        G_bprint(2, "%s is no longer an %s\n", self->netname, redtext("admin"));

        if( self->k_kicking )
            ExitKick( self );

        self->k_admin = 0; // ok, remove all admin flags

		on_unadmin( self );

        return;
    }

    if( self->k_adminc )
	{
        G_sprint(self, 2, "%s code canceled\n", redtext("admin"));
    	self->k_adminc = 0;
		return;
	}

	if( !cvar( "k_admins" ) ) {
		G_sprint(self, 2, "%s on this server!\n", redtext("NO admins"));
		return;
	}

	if ( VIP_IsFlags( self, VIP_ADMIN ) ) // this VIP does't required pass
    {
		BecomeAdmin(self, AF_REAL_ADMIN);
		return;
    }
	
	// parse /admin <pass>
	if ( trap_CmdArgc() == 2 ) {
		char arg_2[1024];
		char *pass = cvar_string( "k_admincode" );
		int till = Q_rint(self->k_adm_lasttime + 5 - g_globalvars.time);

		if( self->k_adm_lasttime && till > 0  ) { // probably must help against brute force
			G_sprint(self, 2, "Wait %d second%s!\n", till, count_s(till) );
			return;
		}

		trap_CmdArgv( 1, arg_2, sizeof( arg_2 ) );

		if ( !strnull(pass) && strneq(pass, "none") && streq(arg_2, pass) )
			BecomeAdmin(self, AF_REAL_ADMIN);
		else {
            G_sprint(self, 2, "%s...\n", redtext("Access denied"));
			self->k_adm_lasttime = g_globalvars.time;
		}

		return;
	}

    self->k_adminc = 6;
    self->k_added  = 0;

    // You can now use numbers to enter code
    G_sprint(self, 2, "Use %s or %s to enter code\n", redtext("numbers"), redtext("impulses") );
}