示例#1
0
// *** Load public settings for current mode ***
int G_Pub_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd)
{
	// Vote request (vote is being initiated)
	if (arg)
	{
		if (trap_Argc() > 2)
		{
			G_refPrintf(ent, "Usage: ^3%s %s%s\n", ((fRefereeCmd) ? "\\ref" : "\\callvote"), arg, aVoteInfo[dwVoteIndex].pszVoteHelp);
			return(G_INVALID);
		}
		else if (vote_allow_pub.integer <= 0 && ent && !ent->client->sess.referee)
		{
			G_voteDisableMessage(ent, arg);
			return(G_INVALID);
		}

		// Vote action (vote has passed)
	}
	else
	{
		// Load in pub settings for current gametype
		G_configSet(g_gametype.integer, qfalse);
		AP("cp \"Public Settings Loaded!\n\"");
	}

	return(G_OK);
}
示例#2
0
int G_Config_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd)
{
	// Vote request (vote is being initiated)
	if (arg)
	{
		if (trap_Argc() > 3)
		{
			G_refPrintf(ent, "Usage: ^3%s %s%s\n", ((fRefereeCmd) ? "\\ref" : "\\callvote"), arg, aVoteInfo[dwVoteIndex].pszVoteHelp);
			G_PrintConfigs(ent);
			return G_INVALID;
		}
		else if (vote_allow_config.integer <= 0 && ent && !ent->client->sess.referee)
		{
			G_voteDisableMessage(ent, arg);
			return G_INVALID;
		}
		else if (arg2 == NULL || strlen(arg2) < 1)
		{
			G_PrintConfigs(ent);
			return G_INVALID;
		}
		Com_sprintf(level.voteInfo.vote_value, VOTE_MAXSTRING, "%s", arg2);
	}
	else // Vote action (vote has passed)
	{
		// Load in comp settings for current gametype
		if (G_configSet(level.voteInfo.vote_value))
		{
			AP("cpm \"Competition Settings Loaded!\n\"");
		}
	}

	return G_OK;
}
示例#3
0
void CC_loadconfig(void)
{
	char scriptName[MAX_QPATH];

	if (trap_Argc() != 2)
	{
		G_Printf("usage: loadConfig <config name>\n");
		return;
	}

	trap_Argv(1, scriptName, sizeof(scriptName));

	trap_SetConfigstring(CS_CONFIGNAME, "");
	memset(&level.config, 0, sizeof(config_t));
	G_configSet(scriptName);
}
示例#4
0
文件: g_match.c 项目: morsik/warpig
// Setting initialization
void G_loadMatchGame(void)
{
	unsigned int    i, dwBlueOffset, dwRedOffset;
	unsigned int    aRandomValues[MAX_REINFSEEDS];
	char            strReinfSeeds[MAX_STRING_CHARS];


	if (server_autoconfig.integer > 0 && (!(z_serverflags.integer & ZSF_COMP) || level.newSession))
	{
		G_configSet(g_gametype.integer, (server_autoconfig.integer == 1));
		trap_Cvar_Set("z_serverflags", va("%d", z_serverflags.integer | ZSF_COMP));
	}

	G_Printf("Setting MOTD...\n");
	trap_SetConfigstring(CS_CUSTMOTD + 0, server_motd0.string);
	trap_SetConfigstring(CS_CUSTMOTD + 1, server_motd1.string);
	trap_SetConfigstring(CS_CUSTMOTD + 2, server_motd2.string);
	trap_SetConfigstring(CS_CUSTMOTD + 3, server_motd3.string);
	trap_SetConfigstring(CS_CUSTMOTD + 4, server_motd4.string);
	trap_SetConfigstring(CS_CUSTMOTD + 5, server_motd5.string);

	// Voting flags
	G_voteFlags();

	// Set version info for demoplayback compatibility
//  trap_SetConfigstring(CS_OSPVERSION, va("%s", G_BASEVERSION));   // Add more tokens as needed

	// Set up the random reinforcement seeds for both teams and send to clients
	dwBlueOffset = rand() % MAX_REINFSEEDS;
	dwRedOffset = rand() % MAX_REINFSEEDS;
	strcpy(strReinfSeeds, va("%d %d", (dwBlueOffset << REINF_BLUEDELT) + (rand() % (1 << REINF_BLUEDELT)),
	                         (dwRedOffset << REINF_REDDELT) + (rand() % (1 << REINF_REDDELT))));

	for (i = 0; i < MAX_REINFSEEDS; i++)
	{
		aRandomValues[i] = (rand() % REINF_RANGE) * aReinfSeeds[i];
		strcat(strReinfSeeds, va(" %d", aRandomValues[i]));
	}

	level.dwBlueReinfOffset = 1000 * aRandomValues[dwBlueOffset] / aReinfSeeds[dwBlueOffset];
	level.dwRedReinfOffset = 1000 * aRandomValues[dwRedOffset] / aReinfSeeds[dwRedOffset];

	trap_SetConfigstring(CS_REINFSEEDS, strReinfSeeds);
}
示例#5
0
qboolean ConsoleCommand(void)
{
	char cmd[MAX_TOKEN_CHARS];

	trap_Argv(0, cmd, sizeof(cmd));

#ifdef FEATURE_LUA
	if (!Q_stricmp(cmd, "lua_status"))
	{
		G_LuaStatus(NULL);
		return qtrue;
	}
	if (Q_stricmp(cmd, "lua_api") == 0)
	{
		G_LuaStackDump();
		return qtrue;
	}
	// *LUA* API callbacks
	if (G_LuaHook_ConsoleCommand(cmd))
	{
		return qtrue;
	}
#endif
	if (Q_stricmp(cmd, "entitylist") == 0)
	{
		Svcmd_EntityList_f();
		return qtrue;
	}
	if (Q_stricmp(cmd, "csinfo") == 0)
	{
		Svcmd_CSInfo_f();
		return qtrue;
	}
	if (Q_stricmp(cmd, "forceteam") == 0)
	{
		Svcmd_ForceTeam_f();
		return qtrue;
	}
	if (Q_stricmp(cmd, "game_memory") == 0)
	{
		Svcmd_GameMem_f();
		return qtrue;
	}
	if (Q_stricmp(cmd, "addip") == 0)
	{
		Svcmd_AddIP_f();
		return qtrue;
	}
	if (Q_stricmp(cmd, "removeip") == 0)
	{
		Svcmd_RemoveIP_f();
		return qtrue;
	}
	if (Q_stricmp(cmd, "listip") == 0)
	{
		trap_SendConsoleCommand(EXEC_INSERT, "g_banIPs\n");
		return qtrue;
	}
	if (Q_stricmp(cmd, "listmaxlivesip") == 0)
	{
		PrintMaxLivesGUID();
		return qtrue;
	}
	if (Q_stricmp(cmd, "start_match") == 0)
	{
		Svcmd_StartMatch_f();
		return qtrue;
	}
	if (Q_stricmp(cmd, "reset_match") == 0)
	{
		Svcmd_ResetMatch_f(qtrue, qtrue);
		return qtrue;
	}
	if (Q_stricmp(cmd, "swap_teams") == 0)
	{
		Svcmd_SwapTeams_f();
		return qtrue;
	}
	if (Q_stricmp(cmd, "shuffle_teams") == 0)
	{
		Svcmd_ShuffleTeams_f(qtrue);
		return qtrue;
	}
	if (Q_stricmp(cmd, "shuffle_teams_norestart") == 0)
	{
		Svcmd_ShuffleTeams_f(qfalse);
		return qtrue;
	}
	if (Q_stricmp(cmd, "makeReferee") == 0)
	{
		G_MakeReferee();
		return qtrue;
	}
	if (Q_stricmp(cmd, "removeReferee") == 0)
	{
		G_RemoveReferee();
		return qtrue;
	}
	if (Q_stricmp(cmd, "mute") == 0)
	{
		G_MuteClient();
		return qtrue;
	}
	if (Q_stricmp(cmd, "unmute") == 0)
	{
		G_UnMuteClient();
		return qtrue;
	}
	if (Q_stricmp(cmd, "ban") == 0)
	{
		G_PlayerBan();
		return qtrue;
	}
	if (Q_stricmp(cmd, "campaign") == 0)
	{
		Svcmd_Campaign_f();
		return qtrue;
	}
	if (Q_stricmp(cmd, "listcampaigns") == 0)
	{
		Svcmd_ListCampaigns_f();
		return qtrue;
	}
	if (Q_stricmp(cmd, "revive") == 0)
	{
		trap_Argv(1, cmd, sizeof(cmd));
		Svcmd_RevivePlayer(cmd);
		return qtrue;
	}
	// moved from engine
	if (!Q_stricmp(cmd, "kick"))
	{
		Svcmd_Kick_f();
		return qtrue;
	}
	if (!Q_stricmp(cmd, "clientkick"))
	{
		Svcmd_KickNum_f();
		return qtrue;
	}
#ifdef FEATURE_OMNIBOT
	if (!Q_stricmp(cmd, "bot"))
	{
		Bot_Interface_ConsoleCommand();
		return qtrue;
	}
#endif
	if (!Q_stricmp(cmd, "cp"))
	{
		trap_SendServerCommand(-1, va("cp \"%s\"", Q_AddCR(ConcatArgs(1))));
		return qtrue;
	}
	if (!Q_stricmp(cmd, "reloadConfig"))
	{
		trap_SetConfigstring(CS_CONFIGNAME, "");
		memset(&level.config, 0, sizeof(config_t));
		G_configSet(g_customConfig.string);

		return qtrue;
	}
	if (!Q_stricmp(cmd, "loadConfig"))
	{
		CC_loadconfig();
		return qtrue;
	}
	if (!Q_stricmp(cmd, "sv_cvarempty"))
	{
		memset(level.svCvars, 0, sizeof(level.svCvars));
		level.svCvarsCount = 0;
		G_UpdateSvCvars();
		return qtrue;
	}
	if (!Q_stricmp(cmd, "sv_cvar"))
	{
		CC_svcvar();
		return qtrue;
	}
	if (!Q_stricmp(cmd, "playsound") || !Q_stricmp(cmd, "playsound_env"))
	{
		G_PlaySound_Cmd();
		return qtrue;
	}
	//if (g_cheats.integer)
	//{
	if (!Q_stricmp(cmd, "gib"))
	{
		Svcmd_Gib();
		return qtrue;
	}
	if (!Q_stricmp(cmd, "die"))
	{
		Svcmd_Die();
		return qtrue;
	}
	if (!Q_stricmp(cmd, "freeze"))
	{
		Svcmd_Freeze();
		return qtrue;
	}
	if (!Q_stricmp(cmd, "unfreeze"))
	{
		Svcmd_Unfreeze();
		return qtrue;
	}
	if (!Q_stricmp(cmd, "burn"))
	{
		Svcmd_Burn();
		return qtrue;
	}
	if (!Q_stricmp(cmd, "pip"))
	{
		Svcmd_Pip();
		return qtrue;
	}
	if (!Q_stricmp(cmd, "throw"))
	{
		Svcmd_Fling(1);
		return qtrue;
	}
	//}

	if (g_dedicated.integer)
	{
		// FIXME
		// this 'say' condition is never reached?!
		if (!Q_stricmp(cmd, "say"))
		{
			trap_SendServerCommand(-1, va("cpm \"server: %s\n\"", Q_AddCR(ConcatArgs(1))));
			return qtrue;
		}
		// added for rcon/Lua chat
		if (!Q_stricmp(cmd, "chat"))
		{
			trap_SendServerCommand(-1, va("chat \"console: %s\"", Q_AddCR(ConcatArgs(1))));
			return qtrue;
		}

		// console also gets ref commands
		if (!level.fLocalHost && Q_stricmp(cmd, "ref") == 0)
		{
			//G_refCommandCheck expects the next argument (warn, pause, lock,..)
			trap_Argv(1, cmd, sizeof(cmd));
			if (!G_refCommandCheck(NULL, cmd))
			{
				G_refHelp_cmd(NULL);
			}
			return qtrue;
		}

		// everything else will also be printed as a say command
		//trap_SendServerCommand( -1, va("cpm \"server: %s\n\"", ConcatArgs(0) ) );

		// prints to the console instead now
		return qfalse;
	}

	return qfalse;
}