本文整理汇总了C++中Cbuf_Execute函数的典型用法代码示例。如果您正苦于以下问题:C++ Cbuf_Execute函数的具体用法?C++ Cbuf_Execute怎么用?C++ Cbuf_Execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Cbuf_Execute函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Com_ExecuteCfg
void Com_ExecuteCfg(void)
{
Cbuf_ExecuteText(EXEC_NOW, "exec default.cfg\n");
Cbuf_Execute(); // Always execute after exec to prevent text buffer overflowing
if(!Com_SafeMode())
{
// skip the q3config.cfg and autoexec.cfg if "safe" is on the command line
Cbuf_ExecuteText(EXEC_NOW, "exec " Q3CONFIG_NAME "\n");
Cbuf_Execute();
Cbuf_ExecuteText(EXEC_NOW, "exec autoexec_sp.cfg\n");
Cbuf_Execute();
}
}
示例2: Sys_AddDefaultConfig
void Sys_AddDefaultConfig(void)
{
FILE *fp;
struct stat st;
size_t len, r;
fp = fopen(SYS_SITE_CFG, "r");
if (!fp) {
return;
}
if (fstat(fileno(fp), &st) == 0) {
len = st.st_size;
if (len >= cmd_buffer.maxsize) {
len = cmd_buffer.maxsize - 1;
}
r = fread(cmd_buffer.text, 1, len, fp);
cmd_buffer.text[r] = 0;
cmd_buffer.cursize = COM_Compress(cmd_buffer.text);
}
fclose(fp);
if (cmd_buffer.cursize) {
Com_Printf("Execing %s\n", SYS_SITE_CFG);
Cbuf_Execute(&cmd_buffer);
}
}
示例3: ControlsResetDefaultsFunc
static void ControlsResetDefaultsFunc (void *unused)
{
Cbuf_AddText ("exec default.cfg\n");
Cbuf_Execute ();
ControlsSetMenuItemValues ();
}
示例4: _Host_Frame
/*
==================
Host_Frame
Runs all active servers
==================
*/
void _Host_Frame (float time)
{
if (setjmp (host_abortserver))
return; // something bad happened, or the server disconnected
// keep the random time dependent
rand ();
// decide the simulation time
if (!Host_FilterTime (time))
return; // don't run too fast, or packets will flood out
// get new key events
Sys_SendKeyEvents ();
// process console commands
Cbuf_Execute ();
NET_Poll();
// check for commands typed to the host
Host_GetConsoleCommands ();
if (sv.active)
Host_ServerFrame ();
}
示例5: Cbuf_ExecuteText
/*
============
Cbuf_ExecuteText
============
*/
void Cbuf_ExecuteText(int exec_when, const char *text)
{
switch (exec_when)
{
case EXEC_NOW:
if (text && strlen(text) > 0)
{
Com_DPrintf(S_COLOR_YELLOW "EXEC_NOW %s\n", text);
Cmd_ExecuteString(text);
}
else
{
Com_DPrintf(S_COLOR_YELLOW "EXEC_NOW %s\n", cmd_text.data);
Cbuf_Execute();
}
break;
case EXEC_INSERT:
Cbuf_InsertText(text);
break;
case EXEC_APPEND:
Cbuf_AddText(text);
break;
default:
Com_Error(ERR_FATAL, "Cbuf_ExecuteText: bad exec_when");
}
}
示例6: Cbuf_AddText
void CServerRemoteAccess::SetValue(const char *variable, const char *value)
{
FileHandle_t f;
struct cvar_s *var;
if (!Q_stricmp(variable, "map"))
{
Cbuf_AddText("changelevel ");
Cbuf_AddText((char*)value);
Cbuf_AddText("\n");
Cbuf_Execute();
}
else if (!Q_stricmp(variable, "mapcycle"))
{
f = FS_Open(mapcyclefile.string, "wt");
if (!f)
{
Con_Printf("Couldn't write to read-only file %s, using file _dev_mapcycle.txt instead.\n", mapcyclefile.string);
Cvar_DirectSet(&mapcyclefile, "_temp_mapcycle.txt");
f = FS_Open(mapcyclefile.string, "wt");
}
if (f)
{
FS_Write(value, Q_strlen(value) + 1, 1, f);
FS_Close(f);
}
}
else
{
var = Cvar_FindVar(variable);
if (var)
Cvar_DirectSet(var, value);
}
}
示例7: SAV_GameLoad_f
/**
* @brief Console command to load a savegame
* @sa SAV_GameLoad
*/
static void SAV_GameLoad_f (void)
{
const char *error = NULL;
/* get argument */
if (Cmd_Argc() < 2) {
Com_Printf("Usage: %s <filename>\n", Cmd_Argv(0));
return;
}
/* Check if savegame exists */
if (FS_CheckFile("save/%s.%s", Cmd_Argv(1), SAVEGAME_EXTENSION) <= 0) {
Com_Printf("savegame file '%s' doesn't exist or an empty file\n", Cmd_Argv(1));
return;
}
Com_DPrintf(DEBUG_CLIENT, "load file '%s'\n", Cmd_Argv(1));
/* load and go to map */
if (!SAV_GameLoad(Cmd_Argv(1), &error)) {
Cbuf_Execute(); /* wipe outstanding campaign commands */
cgi->UI_Popup(_("Error"), "%s\n%s", _("Error loading game."), error ? error : "");
Cmd_ExecuteString("game_exit");
}
}
示例8: Com_AddLateCommands
/*
=================
Com_AddLateCommands
Adds command line parameters as script statements
Commands lead with a + and continue until another +
Returns qtrue if any late commands were added, which
will keep the demoloop from immediately starting
Assumes +set commands are already filtered out
=================
*/
static qboolean Com_AddLateCommands(void)
{
int i;
char *s;
qboolean ret = qfalse;
for (i = 1; i < com_argc; i++) {
s = com_argv[i];
if (!s) {
continue;
}
if (*s == '+') {
if (ret) {
Cbuf_AddText(&cmd_buffer, "\n");
}
s++;
} else if (ret) {
Cbuf_AddText(&cmd_buffer, " ");
}
Cbuf_AddText(&cmd_buffer, s);
ret = qtrue;
}
if (ret) {
Cbuf_AddText(&cmd_buffer, "\n");
Cbuf_Execute(&cmd_buffer);
}
return ret;
}
示例9: SV_Init
/*
====================
SV_Init
====================
*/
void SV_Init (void)
{
Sys_Printf ("Host_Init\n");
Memory_Init (host_parms->membase, host_parms->memsize);
Cbuf_Init ();
Cmd_Init ();
COM_Init ();
FS_Init ();
PR_Init ();
Mod_Init ();
SV_InitNet ();
SV_InitLocal ();
Pmove_Init ();
Hunk_AllocName (0, "-HOST_HUNKLEVEL-");
host_hunklevel = Hunk_LowMark ();
Cbuf_InsertText ("exec server.cfg\n");
Cbuf_Execute ();
// unlock the early-set cvars after init
Cvar_UnlockAll ();
host_initialized = true;
Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
Con_Printf ("%4.1f megabyte heap\n", host_parms->memsize/(1024*1024.0));
Con_Printf ("======== HexenWorld Initialized ========\n");
// process command line arguments
Cmd_StuffCmds_f ();
Cbuf_Execute ();
// if a map wasn't specified on the command line, spawn demo1.map
if (sv.state == ss_dead)
Cmd_ExecuteString ("map demo1", src_command);
if (sv.state == ss_dead)
SV_Error ("Couldn't spawn a server");
}
示例10: SV_Frame
/*
==================
SV_Frame
==================
*/
void SV_Frame (float time)
{
static double start, end;
start = Sys_DoubleTime ();
svs.stats.idle += start - end;
// keep the random time dependent
rand ();
// decide the simulation time
realtime += time;
sv.time += time;
// check timeouts
SV_CheckTimeouts ();
// toggle the log buffer if full
SV_CheckLog ();
// move autonomous things around if enough time has passed
SV_Physics ();
// get packets
SV_ReadPackets ();
// check for commands typed to the host
SV_GetConsoleCommands ();
// process console commands
Cbuf_Execute ();
SV_CheckVars ();
// send messages back to the clients that had packets read this frame
SV_SendClientMessages ();
// send a heartbeat to the master if needed
Master_Heartbeat ();
// collect timing statistics
end = Sys_DoubleTime ();
svs.stats.active += end-start;
if (++svs.stats.count == STATFRAMES)
{
svs.stats.latched_active = svs.stats.active;
svs.stats.latched_idle = svs.stats.idle;
svs.stats.latched_packets = svs.stats.packets;
svs.stats.active = 0;
svs.stats.idle = 0;
svs.stats.packets = 0;
svs.stats.count = 0;
}
}
示例11: Com_AddConfigFile
void Com_AddConfigFile(const char *name, unsigned flags)
{
qerror_t ret;
ret = Cmd_ExecuteFile(name, flags);
if (ret == Q_ERR_SUCCESS) {
Cbuf_Execute(&cmd_buffer);
} else if (ret != Q_ERR_NOENT) {
Com_WPrintf("Couldn't exec %s: %s\n", name, Q_ErrorString(ret));
}
}
示例12: Host_Quit
void Host_Quit (void)
{
// execute user's trigger
TP_ExecTrigger ("f_exit");
Cbuf_Execute();
// save config (conditional)
Config_QuitSave();
// turn off
Host_Shutdown ();
Sys_Quit ();
}
示例13: Cbuf_AddText
//-----------------------------------------------------------------------------
// Purpose: Sets a cvar or value
//-----------------------------------------------------------------------------
void CServerRemoteAccess::SetValue(const char *variable, const char *value)
{
// check for special types
if (!stricmp(variable, "map"))
{
// push a map change command
Cbuf_AddText( va( "changelevel %s\n", value ) );
Cbuf_Execute();
}
else if (!stricmp(variable, "mapcycle"))
{
// write out a new mapcycle file
ConVarRef mapcycle( "mapcyclefile" );
if ( mapcycle.IsValid() )
{
FileHandle_t f = g_pFileSystem->Open(mapcycle.GetString(), "wt");
if (!f)
{
// mapcycle file probably read only, fall pack to temporary file
Msg("Couldn't write to read-only file %s, using file _temp_mapcycle.txt instead.\n", mapcycle.GetString());
mapcycle.SetValue("_temp_mapcycle.txt" );
f = g_pFileSystem->Open(mapcycle.GetString(), "wt");
if (!f)
{
return;
}
}
g_pFileSystem->Write(value, Q_strlen(value) + 1, f);
g_pFileSystem->Close(f);
}
}
else
{
// Stick the cvar set in the command string, so client notification, replication, etc happens
Cbuf_AddText( va("%s %s", variable, value) );
Cbuf_AddText("\n");
Cbuf_Execute();
}
}
示例14: CL_UserInputFrame
/*
* CL_UserInputFrame
*/
void CL_UserInputFrame( void )
{
// let the mouse activate or deactivate
IN_Frame();
// get new key events
Sys_SendKeyEvents();
// get new key events from mice or external controllers
IN_Commands();
// process console commands
Cbuf_Execute();
}
示例15: CL_NextDemo
/*
==================
CL_NextDemo
Called when a demo or cinematic finishes
If the "nextdemo" cvar is set, that command will be issued
==================
*/
void CL_NextDemo( void ) {
char v[MAX_STRING_CHARS];
Q_strncpyz( v, Cvar_VariableString ("nextdemo"), sizeof(v) );
v[MAX_STRING_CHARS-1] = 0;
Com_DPrintf("CL_NextDemo: %s\n", v );
if (!v[0]) {
return;
}
Cvar_Set ("nextdemo","");
Cbuf_AddText (v);
Cbuf_AddText ("\n");
Cbuf_Execute();
}