Beispiel #1
0
// { votecoop
void vote_check_coop ()
{
	int veto;

	if ( ( deathmatch && match_in_progress ) || intermission_running || match_over )
		return;

	if ( !get_votes( OV_COOP ) )
		return;

	veto = is_admins_vote( OV_COOP );

	if( veto || !get_votes_req( OV_COOP, true ) )
	{
		vote_clear( OV_COOP );

		// toggle coop mode
		cvar_fset( "coop", coop = !cvar("coop") );
		// set appropriate deathmatch
		cvar_fset( "deathmatch", deathmatch = !coop );

		if ( veto )
			G_bprint( 2, "%s\n", redtext(va("Coop mode %s by admin veto", OnOff(cvar("coop")))) );
		else
			G_bprint( 2, "%s\n", redtext(va("Coop mode %s by majority vote", OnOff(cvar("coop")))) );

		// and reload map
		if ( cvar("k_bloodfest") )
			changelevel( coop ? g_globalvars.mapname : cvar_string( "k_defmap" ) );
		else
			changelevel( coop ? "start" : g_globalvars.mapname );
			
		return;
	}
}
Beispiel #2
0
void vote_check_antilag ()
{
	int veto;

	if ( match_in_progress || intermission_running || match_over )
		return;

	if ( !get_votes( OV_ANTILAG ) )
		return;

	veto = is_admins_vote( OV_ANTILAG );

	if( veto || !get_votes_req( OV_ANTILAG, true ) )
	{
		vote_clear( OV_ANTILAG );

		// toggle antilag mode.
		trap_cvar_set_float( "sv_antilag", (float)(cvar( "sv_antilag" ) ? 0 : 2));

		if ( veto )
			G_bprint(2, "%s\n", redtext(va("Antilag mode %s by admin veto", OnOff(2 == cvar("sv_antilag")))));
		else
			G_bprint(2, "%s\n", redtext(va("Antilag mode %s by majority vote", OnOff(2 == cvar("sv_antilag")))));

		return;
	}
}
Beispiel #3
0
// !!! do not confuse rpickup and pickup
void vote_check_pickup ()
{
	gedict_t *p;
	int veto;

	if ( match_in_progress || k_captains )
		return;

	if ( !get_votes( OV_PICKUP ) )
		return;

	veto = is_admins_vote( OV_PICKUP );

	if( veto || !get_votes_req( OV_PICKUP, true ) ) {
		vote_clear( OV_PICKUP );

		if ( veto )
			G_bprint(2, "console: admin veto for pickup\n");
		else
			G_bprint(2, "console: a pickup game it is then\n");

		for( p = world;	(p = find_plr( p )); ) {

			stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO,
						"break\n"
						"color 0\n"
						"team \"\"\n"
						"skin base\n");
		}

		return;
	}
}
Beispiel #4
0
Datei: vote.c Projekt: deurk/ktx
void vote_check_teamoverlay ()
{
	int veto;

	if ( match_in_progress || intermission_running || match_over )
		return;

	if ( !get_votes( OV_TEAMOVERLAY ) )
		return;

	veto = is_admins_vote( OV_TEAMOVERLAY );

	if( veto || !get_votes_req( OV_TEAMOVERLAY, true ) )
	{
		vote_clear( OV_TEAMOVERLAY );

		// Toggle teamoverlay.
		cvar_fset("k_teamoverlay", !cvar("k_teamoverlay"));

		if ( veto )
			G_bprint(2, "%s\n", redtext(va("Teamoverlay %s by admin veto", OnOff(cvar("k_teamoverlay")))));
		else
			G_bprint(2, "%s\n", redtext(va("Teamoverlay %s by majority vote", OnOff(cvar("k_teamoverlay")))));

		return;
	}
}
Beispiel #5
0
// !!! do not confuse rpickup and pickup
void vote_check_rpickup ()
{
	float frnd;
    int i, tn, pl_cnt, pl_idx;
	gedict_t *p;
	int veto;

	if ( match_in_progress || k_captains )
		return;

	if ( !get_votes( OV_RPICKUP ) )
		return;

   	// Firstly obtain the number of players we have in total on server
   	pl_cnt = CountPlayers();

	if ( pl_cnt < 4 )
		return;

	veto = is_admins_vote( OV_RPICKUP );

	if( veto || !get_votes_req( OV_RPICKUP, true ) ) {
		vote_clear( OV_RPICKUP );

		for( p = world; (p = find_plr( p )); )
			p->k_teamnumber = 0;

		for( tn = 1; pl_cnt > 0; pl_cnt-- ) {
			frnd = g_random(); // bound is macros - so u _can't_ put g_random inside bound
			pl_idx = bound(0, (int)( frnd * pl_cnt ), pl_cnt-1 ); // select random player between 0 and pl_cnt

			for( i = 0, p = world; (p = find_plr( p )); ) {
				if ( p->k_teamnumber )
					continue;

				if ( i == pl_idx ) {
					p->k_teamnumber = tn;
					tn = (tn == 1 ? 2 : 1); // next random player will be in other team

            		if( p->k_teamnumber == 1 )
                		stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "break\ncolor  4\nskin \"\"\nteam red\n");
            		else
                		stuffcmd_flags(p, STUFFCMD_IGNOREINDEMO, "break\ncolor 13\nskin \"\"\nteam blue\n");

					break;
				}

				i++;
			}
		}

		if ( veto )
			G_bprint(2, "console: admin veto for %s\n", redtext("random pickup"));
		else
    		G_bprint(2, "console: %s game it is then\n", redtext("random pickup"));

		return;
	}
}
Beispiel #6
0
void vote_check_break ()
{
	if ( !match_in_progress || intermission_running || match_over )
		return;

	if( !get_votes_req( OV_BREAK, true ) ) {
		vote_clear( OV_BREAK );

		G_bprint(2, "%s\n", redtext("Match stopped by majority vote"));

		EndMatch( 1 );

		return;
	}
}
Beispiel #7
0
void vote_check_nospecs ()
{
	int veto;

	if ( match_in_progress || intermission_running || match_over )
		return;

	if ( !get_votes( OV_NOSPECS ) )
		return;

	veto = is_admins_vote( OV_NOSPECS );

	if( veto || !get_votes_req( OV_NOSPECS, true ) )
	{
		vote_clear( OV_NOSPECS );

		// set no specs mode
		cvar_fset("_k_nospecs", !cvar("_k_nospecs"));

		if ( veto )
			G_bprint(2, "%s\n", redtext(va("No spectators mode %s by admin veto", OnOff(cvar("_k_nospecs")))));
		else
			G_bprint(2, "%s\n", redtext(va("No spectators mode %s by majority vote", OnOff(cvar("_k_nospecs")))));

		// kick specs
		if ( cvar("_k_nospecs") )
		{
			gedict_t *spec;

			for ( spec = world; (spec = find_spc( spec )); )
			{
				if ( VIP( spec ) & ALLOWED_NOSPECS_VIPS )
					continue; // don't kick this VIP
    
				if ( is_real_adm(spec) )
					continue; // don't kick real admin
    
				stuffcmd(spec, "disconnect\n");  // FIXME: stupid way
			}
		}

		return;
	}
}
Beispiel #8
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 );
}
Beispiel #9
0
void vote_check_map ()
{
	int   vt_req = get_votes_req( OV_MAP, true );
	char  *m  = "";

	if ( maps_voted_idx < 0 || strnull( m = GetMapName(maps_voted[maps_voted_idx].map_id) ) )
		return;

	if ( !k_matchLess )
	if ( match_in_progress )
		return;

	if ( maps_voted[maps_voted_idx].admins )
		G_bprint(2, "%s\n", redtext("Admin veto"));
	else if( !vt_req  )
		G_bprint(2, "%s votes for mapchange.\n", redtext("Majority"));
	else
		return;

	vote_clear( OV_MAP );

	changelevel( m );
}