这篇教程C++ Com_ServerState函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中Com_ServerState函数的典型用法代码示例。如果您正苦于以下问题:C++ Com_ServerState函数的具体用法?C++ Com_ServerState怎么用?C++ Com_ServerState使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了Com_ServerState函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: CL_Connect_fvoid CL_Connect_f(void){ char *server; if (Cmd_Argc() != 2) { Com_Printf("usage: connect <server>/n"); return; } if (Com_ServerState()) { /* if running a local server, kill it and reissue note: this is connect with the save game system */ SV_Shutdown("Server quit/n", false); } else { CL_Disconnect(); } server = Cmd_Argv(1); NET_Config(true); /* allow remote */ CL_Disconnect(); cls.state = ca_connecting; Q_strlcpy(cls.servername, server, sizeof(cls.servername)); cls.connect_time = -99999; /* HACK: CL_CheckForResend() will fire immediately */}
开发者ID:greck2908,项目名称:qengine,代码行数:27,
示例2: SV_FindIndex/** * @brief Search the index in the config strings relative to a given start * @param name The value of the config string to search the index for * @param start The relative start point for the search * @param max The max. searched entries in the config string before giving up * @param create if @c true the value will get written into the config strings (appended) * @return @c 0 if not found */static unsigned int SV_FindIndex (const char *name, int start, int max, qboolean create){ int i; if (!name || !name[0]) return 0; for (i = 1; i < max && SV_GetConfigString(start + i)[0] != '/0'; i++) { const char *configString = SV_GetConfigString(start + i); if (Q_streq(configString, name)) return i; } if (!create) return 0; if (i == max) Com_Error(ERR_DROP, "*Index: overflow '%s' start: %i, max: %i", name, start, max); SV_SetConfigString(start + i, name); if (Com_ServerState() != ss_loading) { /* send the update to everyone */ struct dbuffer *msg = new_dbuffer(); NET_WriteByte(msg, svc_configstring); NET_WriteShort(msg, start + i); NET_WriteString(msg, name); SV_Multicast(~0, msg); } return i;}
开发者ID:chrisglass,项目名称:ufoai,代码行数:39,
示例3: Cvar_FixCheatVars/** * @brief Reset cheat cvar values to default * @sa CL_SendCommand */void Cvar_FixCheatVars (void){ if (!(Com_ServerState() && !Cvar_GetInteger("sv_cheats"))) return; for (cvar_t* var = cvarVars; var; var = var->next) { if (!(var->flags & CVAR_CHEAT)) continue; if (!var->defaultString) { Com_Printf("Cheat cvars: Cvar %s has no default value/n", var->name); continue; } if (Q_streq(var->string, var->defaultString)) continue; /* also remove the oldString value here */ Mem_Free(var->oldString); var->oldString = nullptr; Mem_Free(var->string); var->string = Mem_PoolStrDup(var->defaultString, com_cvarSysPool, 0); var->value = atof(var->string); var->integer = atoi(var->string); Com_Printf("'%s' is a cheat cvar - activate sv_cheats to use it./n", var->name); }}
开发者ID:drone-pl,项目名称:ufoai,代码行数:32,
示例4: CL_Disconnect/** * @brief Sets the @c cls.state to @c ca_disconnected and informs the server * @sa CL_Drop * @note Goes from a connected state to disconnected state * Sends a disconnect message to the server * This is also called on @c Com_Error, so it shouldn't cause any errors */void CL_Disconnect (void){ if (cls.state < ca_connecting) return; Com_Printf("Disconnecting.../n"); /* send a disconnect message to the server */ if (!Com_ServerState()) { dbuffer msg; NET_WriteByte(&msg, clc_stringcmd); NET_WriteString(&msg, NET_STATE_DISCONNECT "/n"); NET_WriteMsg(cls.netStream, msg); /* make sure, that this is send */ NET_Wait(0); } NET_StreamFinished(cls.netStream); cls.netStream = nullptr; CL_ClearState(); S_Stop(); R_ShutdownModels(false); R_FreeWorldImages(); CL_SetClientState(ca_disconnected); CL_ClearBattlescapeEvents(); GAME_EndBattlescape();}
开发者ID:Astrocoderguy,项目名称:ufoai,代码行数:38,
示例5: SCR_SetLoadingBackground/** * @brief Updates needed cvar for loading screens * @param[in] mapString The mapstring of the map that is currently loaded * @note If @c mapString is NULL the @c sv_mapname cvar is used * @return The loading/background pic path */static const image_t* SCR_SetLoadingBackground (const char *mapString){ const char *mapname; image_t* image; if (!mapString || Com_ServerState()) mapname = Cvar_GetString("sv_mapname"); else { mapname = mapString; Cvar_Set("sv_mapname", mapString); } /* we will try to load the random map shots by just removing the + from the beginning */ if (mapname[0] == '+') mapname++; image = R_FindImage(va("pics/maps/loading/%s", mapname), it_worldrelated); if (image == r_noTexture) image = R_FindImage("pics/maps/loading/default", it_pic); /* strip away the pics/ part */ Cvar_Set("mn_mappicbig", image->name + 5); return image;}
开发者ID:ptitSeb,项目名称:UFO--AI-OpenPandora,代码行数:31,
示例6: M_PushMenuvoid M_PushMenu ( menuframework_s *menu ){ int i; if (Cvar_VariableIntValue ("maxclients") == 1 && Com_ServerState () && !cl_paused->integer) Cvar_Set ("paused", "1"); // if this menu is already present, drop back to that level // to avoid stacking menus by hotkeys for( i=0 ; i<m_menudepth ; i++ ) { if( m_layers[i] == menu ) { break; } } if (i == m_menudepth) { if (m_menudepth >= MAX_MENU_DEPTH) Com_Error (ERR_FATAL, "M_PushMenu: MAX_MENU_DEPTH"); m_layers[m_menudepth++] = menu; } else { m_menudepth = i+1; } m_active = menu; m_entersound = true; cls.key_dest = key_menu;}
开发者ID:chrisnew,项目名称:quake2,代码行数:32,
示例7: CL_RequestNextDownload/** * @brief * @note Called after precache was sent from the server * @sa SV_Configstrings_f * @sa CL_Precache_f */void CL_RequestNextDownload (void){ if (cls.state != ca_connected) { Com_Printf("CL_RequestNextDownload: Not connected (%i)/n", cls.state); return; } /* Use the map data from the server */ cl.mapTiles = SV_GetMapTiles(); cl.mapData = SV_GetMapData(); /* as a multiplayer client we have to load the map here and * check the compatibility with the server */ if (!Com_ServerState() && !CL_CanMultiplayerStart()) return; CL_ViewLoadMedia(); dbuffer msg(7); /* send begin */ /* this will activate the render process (see client state ca_active) */ NET_WriteByte(&msg, clc_stringcmd); /* see CL_StartGame */ NET_WriteString(&msg, NET_STATE_BEGIN "/n"); NET_WriteMsg(cls.netStream, msg); cls.waitingForStart = CL_Milliseconds(); S_MumbleLink();}
开发者ID:Astrocoderguy,项目名称:ufoai,代码行数:36,
示例8: CL_Connect_f/*================CL_Connect_f================*/void CL_Connect_f (void){ char *server; if (Cmd_Argc() != 2) { Com_Printf ("usage: connect <server>/n"); return; } if (Com_ServerState ()) { // if running a local server, kill it and reissue SV_Shutdown (va("Server quit/n", msg), false); } else { CL_Disconnect (); } server = Cmd_Argv (1); NET_Config (true); // allow remote CL_Disconnect (); cls.state = ca_connecting; strncpy (cls.servername, server, sizeof(cls.servername)-1); cls.connect_time = -99999; // CL_CheckForResend() will fire immediately}
开发者ID:jacqueskrige,项目名称:uqe-quake2,代码行数:35,
示例9: StartServerActionFuncvoid StartServerActionFunc (void *self){ char startmap[1024]; float timelimit; float fraglimit; float maxclients; char *spot; strcpy (startmap, strchr (mapnames[s_startmap_list.curvalue], '/n') + 1); maxclients = (float)strtod(s_maxclients_field.buffer, (char **)NULL); timelimit = (float)strtod(s_timelimit_field.buffer, (char **)NULL); fraglimit = (float)strtod(s_fraglimit_field.buffer, (char **)NULL); Cvar_SetValue ("maxclients", Q_Clamp (0, maxclients, maxclients)); Cvar_SetValue ("timelimit", Q_Clamp (0, timelimit, timelimit)); Cvar_SetValue ("fraglimit", Q_Clamp (0, fraglimit, fraglimit)); Cvar_Set ("hostname", s_hostname_field.buffer); Cvar_SetValue ("deathmatch", (float)!s_rules_box.curvalue); Cvar_SetValue ("coop", (float)s_rules_box.curvalue); spot = NULL; // coop spawns if (s_rules_box.curvalue == 1) { if (Q_stricmp (startmap, "bunk1") == 0) spot = "start"; else if (Q_stricmp (startmap, "mintro") == 0) spot = "start"; else if (Q_stricmp (startmap, "fact1") == 0) spot = "start"; else if (Q_stricmp (startmap, "power1") == 0) spot = "pstart"; else if (Q_stricmp (startmap, "biggun") == 0) spot = "bstart"; else if (Q_stricmp (startmap, "hangar1") == 0) spot = "unitstart"; else if (Q_stricmp (startmap, "city1") == 0) spot = "unitstart"; else if (Q_stricmp (startmap, "boss1") == 0) spot = "bosstart"; } if (spot) { if (Com_ServerState()) Cbuf_AddText ("disconnect/n"); Cbuf_AddText (va ("gamemap /"*%s$%s/"/n", startmap, spot)); } else { Cbuf_AddText (va ("map %s/n", startmap)); } M_ForceMenuOff ();}
开发者ID:raynorpat,项目名称:cake,代码行数:59,
示例10: CL_ParseServerData/*==================CL_ParseServerData==================*/void CL_ParseServerData(void){ extern cvar_t * fs_gamedirvar; char * str; int i; Com_DPrintf("Serverdata packet received./n"); // // wipe the client_state_t struct // CL_ClearState(); cls.state = ca_connected; // parse protocol version number i = MSG_ReadLong(&net_message); cls.serverProtocol = i; // BIG HACK to let demos from release work with the 3.0x patch!!! if (Com_ServerState() && PROTOCOL_VERSION == 34) { } else if (i != PROTOCOL_VERSION) { Com_Error(ERR_DROP, "Server returned version %i, not %i", i, PROTOCOL_VERSION); } cl.servercount = MSG_ReadLong(&net_message); cl.attractloop = MSG_ReadByte(&net_message); // game directory str = MSG_ReadString(&net_message); strncpy(cl.gamedir, str, sizeof(cl.gamedir) - 1); // set gamedir if ((*str && (!fs_gamedirvar->string || !*fs_gamedirvar->string || strcmp(fs_gamedirvar->string, str))) || (!*str && (fs_gamedirvar->string || *fs_gamedirvar->string))) Cvar_Set("game", str); // parse player entity number cl.playernum = MSG_ReadShort(&net_message); // get the full level name str = MSG_ReadString(&net_message); if (cl.playernum == -1) { // playing a cinematic or showing a pic, not a level SCR_PlayCinematic(str); } else { // separate the printfs so the server message can have a color Com_Printf("/n/n/35/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/37/n/n"); Com_Printf("%c%s/n", 2, str); // need to prep refresh at next opportunity cl.refresh_prepped = false; }}
开发者ID:glampert,项目名称:quake2-for-ps2,代码行数:63,
示例11: M_Menu_SaveGame_fvoid M_Menu_SaveGame_f (void){ if (!Com_ServerState()) return; // not playing a game SaveGame_MenuInit(); M_PushMenu( &s_savegame_menu ); Create_Savestrings ();}
开发者ID:chrisnew,项目名称:quake2,代码行数:9,
示例12: LegacyProtocol/*==================LegacyProtocolA utility function that determinesif parsing of old protocol should be used.==================*/qboolean LegacyProtocol (void){ //if (dedicated->value) // Server always uses new protocol // return false; if ( (Com_ServerState() && cls.serverProtocol <= OLD_PROTOCOL_VERSION) || (cls.serverProtocol == OLD_PROTOCOL_VERSION) ) return true; return false;}
开发者ID:postfix,项目名称:quake2vr,代码行数:16,
示例13: CL_Pause_f/*==================CL_Pause_f==================*/void CL_Pause_f (void){ // never pause in multiplayer if (Cvar_VariableValue ("maxclients") > 1 || !Com_ServerState ()) { Cvar_SetValue ("paused", 0); return; } Cvar_SetValue ("paused", !cl_paused->value);}
开发者ID:jacqueskrige,项目名称:uqe-quake2,代码行数:16,
示例14: CL_OnBattlescape/** * @brief Check whether we are in a tactical mission as server or as client. But this * only means that we are able to render the map - not that the game is running (the * team can still be missing - see @c CL_BattlescapeRunning) * @note handles multiplayer and singleplayer * @sa CL_BattlescapeRunning * @return true when we are in battlefield */bool CL_OnBattlescape (void){ /* server_state is set to zero (ss_dead) on every battlefield shutdown */ if (Com_ServerState()) return true; /* server */ /* client */ if (cls.state >= ca_connected) return true; return false;}
开发者ID:Qazzian,项目名称:ufoai_suspend,代码行数:20,
示例15: UI_ForceMenuOff/*=================UI_ForceMenuOff=================*/void UI_ForceMenuOff (void){ // Knightmare- added Psychospaz's mouse support UI_RefreshCursorLink(); m_drawfunc = 0; m_keyfunc = 0; cls.key_dest = key_game; m_menudepth = 0; Key_ClearStates (); if (!cls.consoleActive && Cvar_VariableValue ("maxclients") == 1 && Com_ServerState()) // Knightmare added Cvar_Set ("paused", "0");}
开发者ID:Kiln707,项目名称:KMQuake2,代码行数:17,
示例16: CL_CheckForResend/* * Resend a connect message if the last one has timed out */voidCL_CheckForResend(void){ netadr_t adr; /* if the local server is running and we aren't just connect */ if ((cls.state == ca_disconnected) && Com_ServerState()) { cls.state = ca_connecting; Q_strlcpy(cls.servername, "localhost", sizeof(cls.servername)); /* we don't need a challenge on the localhost */ CL_SendConnectPacket(); return; } /* resend if we haven't gotten a reply yet */ if (cls.state != ca_connecting) { return; } if (cls.realtime - cls.connect_time < 3000) { return; } if (!NET_StringToAdr(cls.servername, &adr)) { Com_Printf("Bad server address/n"); cls.state = ca_disconnected; return; } if (adr.port == 0) { adr.port = BigShort(PORT_SERVER); } cls.connect_time = cls.realtime; Com_Printf("Connecting to %s.../n", cls.servername); Netchan_OutOfBandPrint(NS_CLIENT, adr, "getchallenge/n");}
开发者ID:Jenco420,项目名称:yquake2,代码行数:47,
示例17: CL_SendCommand/** * @sa CL_Frame */static void CL_SendCommand (void){ /* get new key events */ IN_SendKeyEvents(); /* process console commands */ Cbuf_Execute(); /* send intentions now */ CL_SendChangedUserinfos(); /* fix any cheating cvars */ Cvar_FixCheatVars(); switch (cls.state) { case ca_disconnected: /* if the local server is running and we aren't connected then connect */ if (Com_ServerState()) { cls.servername[0] = '/0'; cls.serverport[0] = '/0'; CL_SetClientState(ca_connecting); return; } break; case ca_connecting: if (CL_Milliseconds() - cls.connectTime > cl_connecttimeout->integer) { if (GAME_IsMultiplayer()) Com_Error(ERR_DROP, "Server is not reachable"); } break; case ca_connected: if (cls.waitingForStart) { if (CL_Milliseconds() - cls.waitingForStart > cl_connecttimeout->integer) { Com_Error(ERR_DROP, "Server aborted connection - the server didn't response in %is. You can try to increase the cvar cl_connecttimeout", cl_connecttimeout->integer / 1000); } else { SCR_DrawLoading(100); } } break; default: break; }}
开发者ID:Astrocoderguy,项目名称:ufoai,代码行数:47,
示例18: SV_ExecuteUserCommand/** * @sa SV_ExecuteClientMessage */static void SV_ExecuteUserCommand (client_t * cl, const char *s){ const ucmd_t *u; Cmd_TokenizeString(s, qfalse); for (u = ucmds; u->name; u++) if (Q_streq(Cmd_Argv(0), u->name)) { Com_DPrintf(DEBUG_SERVER, "SV_ExecuteUserCommand: %s/n", s); u->func(cl); return; } if (Com_ServerState() == ss_game) { Com_DPrintf(DEBUG_SERVER, "SV_ExecuteUserCommand: client command: %s/n", s); TH_MutexLock(svs.serverMutex); svs.ge->ClientCommand(cl->player); TH_MutexUnlock(svs.serverMutex); }}
开发者ID:kevlund,项目名称:ufoai,代码行数:23,
示例19: CL_GridRecalcRoutingstatic void CL_GridRecalcRouting (const le_t* le){ /* We ALWAYS check against a model, even if it isn't in use. * An unused model is NOT included in the inline list, so it doesn't get * traced against. */ if (!le->model1 || le->inlineModelName[0] != '*') return; if (Com_ServerState()) return; const cBspModel_t* model = CM_InlineModel(cl.mapTiles, le->inlineModelName); if (!model) { return; } AABB absBox(model->cbmBox); absBox.shift(model->origin); GridBox rerouteBox(absBox); Grid_RecalcRouting(cl.mapTiles, cl.mapData->routing, le->inlineModelName, rerouteBox, cl.leInlineModelList);}
开发者ID:yason,项目名称:ufoai,代码行数:21,
示例20: CL_CheckForResend/*=================CL_CheckForResendResend a connect message if the last one has timed out=================*/void CL_CheckForResend (void){ netadr_t adr; // if the local server is running and we aren't // then connect if (cls.state == ca_disconnected && Com_ServerState() ) { cls.state = ca_connecting; strncpy (cls.servername, "localhost", sizeof(cls.servername)-1); // we don't need a challenge on the localhost CL_SendConnectPacket (); return;// cls.connect_time = -99999; // CL_CheckForResend() will fire immediately } // resend if we haven't gotten a reply yet if (cls.state != ca_connecting) return; if (cls.realtime - cls.connect_time < 3000) return; if (!NET_StringToAdr (cls.servername, &adr)) { Com_Printf ("Bad server address/n"); cls.state = ca_disconnected; return; } if (adr.port == 0) adr.port = BigShort (PORT_SERVER); cls.connect_time = cls.realtime; // for retransmit requests Com_Printf ("Connecting to %s.../n", cls.servername); Netchan_OutOfBandPrint (NS_CLIENT, adr, "getchallenge/n");}
开发者ID:jacqueskrige,项目名称:uqe-quake2,代码行数:45,
示例21: SV_Configstring/** * @sa CL_ParseConfigString */static void SV_Configstring (int index, const char *fmt, ...){ char val[MAX_TOKEN_CHARS * MAX_TILESTRINGS]; va_list argptr; if (index < 0 || index >= MAX_CONFIGSTRINGS) Com_Error(ERR_DROP, "configstring: bad index %i", index); va_start(argptr, fmt); Q_vsnprintf(val, sizeof(val), fmt, argptr); va_end(argptr); SV_SetConfigString(index, val); if (Com_ServerState() != ss_loading) { /* send the update to everyone */ struct dbuffer *msg = new_dbuffer(); NET_WriteByte(msg, svc_configstring); NET_WriteShort(msg, index); NET_WriteString(msg, val); /* send to all clients */ SV_Multicast(~0, msg); }}
开发者ID:chrisglass,项目名称:ufoai,代码行数:27,
示例22: SV_New_f/** * @brief Sends the first message from the server to a connected client. * This will be sent on the initial connection and upon each server load. * Client reads via CL_ParseServerData in cl_parse.c * @sa CL_Reconnect_f * @sa CL_ConnectionlessPacket */static void SV_New_f (client_t *cl){ Com_DPrintf(DEBUG_SERVER, "New() from %s/n", cl->name); if (cl->state != cs_connected) { if (cl->state == cs_spawning) { /* client typed 'reconnect/new' while connecting. */ Com_Printf("SV_New_f: client typed 'reconnect/new' while connecting/n"); SV_ClientCommand(cl, "/ndisconnect/nreconnect/n"); SV_DropClient(cl, ""); } else Com_DPrintf(DEBUG_SERVER, "WARNING: Illegal 'new' from %s, client state %d. This shouldn't happen.../n", cl->name, cl->state); return; } /* client state to prevent multiple new from causing high cpu / overflows. */ SV_SetClientState(cl, cs_spawning); /* serverdata needs to go over for all types of servers * to make sure the protocol is right, and to set the gamedir */ /* send the serverdata */ { const int playernum = cl - SV_GetClient(0); struct dbuffer *msg = new_dbuffer(); NET_WriteByte(msg, svc_serverdata); NET_WriteLong(msg, PROTOCOL_VERSION); NET_WriteShort(msg, playernum); /* send full levelname */ NET_WriteString(msg, SV_GetConfigString(CS_NAME)); NET_WriteMsg(cl->stream, msg); } /* game server */ if (Com_ServerState() == ss_game) { int i; for (i = 0; i < MAX_CONFIGSTRINGS; i++) { const char *configString; /* CS_TILES and CS_POSITIONS can stretch over multiple configstrings, * so don't send the middle parts again. */ if (i > CS_TILES && i < CS_POSITIONS) continue; if (i > CS_POSITIONS && i < CS_MODELS) continue; configString = SV_GetConfigString(i); if (configString[0] != '/0') { struct dbuffer *msg = new_dbuffer(); Com_DPrintf(DEBUG_SERVER, "sending configstring %d: %s/n", i, configString); NET_WriteByte(msg, svc_configstring); NET_WriteShort(msg, i); NET_WriteString(msg, configString); /* enqueue and free msg */ NET_WriteMsg(cl->stream, msg); } } } SV_ClientCommand(cl, "precache/n");}
开发者ID:kevlund,项目名称:ufoai,代码行数:70,
示例23: CL_ParseServerDatavoidCL_ParseServerData(void){ extern cvar_t *fs_gamedirvar; char *str; int i; Com_DPrintf("Serverdata packet received./n"); /* wipe the client_state_t struct */ CL_ClearState(); cls.state = ca_connected; /* parse protocol version number */ i = MSG_ReadLong(&net_message); cls.serverProtocol = i; /* another demo hack */ if (Com_ServerState() && (PROTOCOL_VERSION == 34)) { } else if (i != PROTOCOL_VERSION) { Com_Error(ERR_DROP, "Server returned version %i, not %i", i, PROTOCOL_VERSION); } cl.servercount = MSG_ReadLong(&net_message); cl.attractloop = MSG_ReadByte(&net_message); /* game directory */ str = MSG_ReadString(&net_message); Q_strlcpy(cl.gamedir, str, sizeof(cl.gamedir)); /* set gamedir */ if ((*str && (!fs_gamedirvar->string || !*fs_gamedirvar->string || strcmp(fs_gamedirvar->string, str))) || (!*str && (fs_gamedirvar->string || *fs_gamedirvar->string))) { Cvar_Set("game", str); } /* parse player entity number */ cl.playernum = MSG_ReadShort(&net_message); /* get the full level name */ str = MSG_ReadString(&net_message); if (cl.playernum == -1) { /* playing a cinematic or showing a pic, not a level */ SCR_PlayCinematic(str); } else { /* seperate the printfs so the server * message can have a color */ Com_Printf("/n/n/35/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/36/37/n/n"); Com_Printf("%c%s/n", 2, str); /* need to prep refresh at next oportunity */ cl.refresh_prepped = false; }}
开发者ID:Clever-Boy,项目名称:yquake2,代码行数:64,
示例24: Q_assert/*============Cvar_Set2============*/static cvar_t *Cvar_Set2 (const char *var_name, const char *value, qboolean force){ cvar_t *var; char *old_string; Q_assert (var_name != NULL); Q_assert (value != NULL); if (var_name[0] == '$' && !force) { Com_Printf ("%s is write protected./n", LOG_GENERAL, var_name); return NULL; } var = Cvar_FindVar (var_name); if (!var) { // create it return Cvar_Get (var_name, value, 0); } if (var->flags & (CVAR_USERINFO | CVAR_SERVERINFO)) { if (!Cvar_InfoValidate (value)) { Com_Printf("invalid info cvar value/n", LOG_GENERAL); return var; } } if (!force) {#ifdef _DEBUG if (var->flags & CVAR_NOSET && !Cvar_IntValue ("developer"))#else if (var->flags & CVAR_NOSET)#endif { Com_Printf ("%s is write protected./n", LOG_GENERAL, var_name); return var; } if (var->flags & CVAR_LATCH) { if (var->latched_string) { if (strcmp(value, var->latched_string) == 0) return var; Z_Free (var->latched_string); } else { if (strcmp(value, var->string) == 0) return var; } if (Com_ServerState()) { Com_Printf ("%s will be changed for next map./n", LOG_GENERAL, var_name); var->latched_string = CopyString(value, TAGMALLOC_CVAR); } else { //memleak fix, thanks Maniac- Z_Free (var->string); var->string = CopyString(value, TAGMALLOC_CVAR); var->value = (float)atof (var->string); var->intvalue = (int)var->value; //r1: fix 0 case if (!var->intvalue && FLOAT_NE_ZERO(var->value)) var->intvalue = 1; if (!strcmp(var->name, "game")) { FS_SetGamedir (var->string); if (!Cvar_IntValue ("dedicated")) FS_ExecConfig ("autoexec.cfg"); } } return var; } } else { if (var->latched_string) { Z_Free (var->latched_string); var->latched_string = NULL; } } if (!strcmp(value, var->string)) return var; // not changed old_string = var->string;//.........这里部分代码省略.........
开发者ID:turol,项目名称:webquake2,代码行数:101,
示例25: Cvar_Set2/** * @brief Sets a cvar values * Handles write protection and latched cvars as expected * @param[in] varName Which cvar * @param[in] value Set the cvar to the value specified by 'value' * @param[in] force Force the update of the cvar */static cvar_t* Cvar_Set2 (const char* varName, const char* value, bool force){ cvar_t* var; if (!value) return nullptr; var = Cvar_FindVar(varName); /* create it */ if (!var) return Cvar_GetOrCreate(varName, value); if (var->flags & (CVAR_USERINFO | CVAR_SERVERINFO)) { if (!Cvar_InfoValidate(value)) { Com_Printf("invalid info cvar value '%s' of cvar '%s'/n", value, varName); return var; } } if (!force) { if (var->flags & CVAR_NOSET) { Com_Printf("%s is write protected./n", varName); return var; }#ifndef DEBUG if (var->flags & CVAR_DEVELOPER) { Com_Printf("%s is a developer cvar./n", varName); return var; }#endif if (var->flags & CVAR_LATCH) { if (var->latchedString) { if (Q_streq(value, var->latchedString)) return var; Mem_Free(var->latchedString); var->latchedString = nullptr; } else { if (Q_streq(value, var->string)) return var; } /* if we are running a server */ if (Com_ServerState()) { Com_Printf("%s will be changed for next game./n", varName); var->latchedString = Mem_PoolStrDup(value, com_cvarSysPool, 0); } else { Mem_Free(var->oldString); var->oldString = var->string; var->string = Mem_PoolStrDup(value, com_cvarSysPool, 0); var->value = atof(var->string); var->integer = atoi(var->string); } if (var->check && var->check(var)) Com_Printf("Invalid value for cvar %s/n", varName); return var; } } else { Mem_Free(var->latchedString); var->latchedString = nullptr; } if (Q_streq(value, var->string)) return var; /* not changed */ if (var->flags & CVAR_R_MASK) Com_SetRenderModified(true); Mem_Free(var->oldString); /* free the old value string */ var->oldString = var->string; var->modified = true; if (var->flags & CVAR_USERINFO) Com_SetUserinfoModified(true); /* transmit at next opportunity */ var->string = Mem_PoolStrDup(value, com_cvarSysPool, 0); var->value = atof(var->string); var->integer = atoi(var->string); if (var->check && var->check(var)) { Com_Printf("Invalid value for cvar %s/n", varName); return var; } Cvar_ExecuteChangeListener(var); return var;}
开发者ID:drone-pl,项目名称:ufoai,代码行数:97,
示例26: Cmd_Exec_f/*===============Cmd_Exec_f===============*/void Cmd_Exec_f (void){ const char *path; char *f, *p; int len; char f2[COMMAND_BUFFER_SIZE+2]; if (Cmd_Argc () != 2) { Com_Printf ("exec <filename> : execute a config file/n", LOG_GENERAL); return; } path = Cmd_Argv(1); //r1: normalize while ((p = strchr (path, '//')) != NULL) p[0] = '/'; //r1: deny traversing outside the q2 directory p = strstr (path, "../"); if (p) { p += 3; if (strstr (p, "../")) { Com_Printf ("WARNING: Illegal config path '%s'/n", LOG_GENERAL, path); return; } } //r1: sanity check length first so people don't exec pak0.pak and eat 300MB ram len = FS_LoadFile (path, NULL); if (len > COMMAND_BUFFER_SIZE - 2) { Com_Printf ("WARNING: %s exceeds maximum config file length/n", LOG_GENERAL, Cmd_Argv(1)); len = COMMAND_BUFFER_SIZE - 2; } len = FS_LoadFile (path, (void **)&f); if (!f || len <= 0) { //ugly hack to avoid printing missing config errors before startup finishes if (q2_initialized) Com_Printf ("couldn't exec %s/n", LOG_GENERAL, path); return; }#ifndef DEDICATED_ONLY if (Com_ServerState())#endif Com_Printf ("execing %s/n", LOG_GENERAL, path);#ifndef DEDICATED_ONLY else Com_DPrintf ("execing %s/n",path);#endif // the file doesn't have a trailing 0, so we need to copy it off //f2 = Z_TagMalloc(len+2, TAGMALLOC_CMDBUFF); //f2 = alloca (len+2); memcpy (f2, f, len); //r1: fix for "no trailing newline = 'u or s'" bug. f2[len] = '/n'; f2[len+1] = 0; if ((p = strchr(f2, '/r')) != NULL && *(p+1) != '/n') Com_Printf ("WARNING: Raw //r found in config file %s/n", LOG_GENERAL|LOG_WARNING, path); Cbuf_InsertText (f2); //Z_Free (f2); FS_FreeFile (f);}
开发者ID:Slipyx,项目名称:r1q2,代码行数:79,
示例27: Cvar_FindVar/*============Cvar_Set2============*/cvar_t *Cvar_Set2 (char *var_name, char *value, qboolean force){ cvar_t *var; var = Cvar_FindVar (var_name); if (!var) { // create it return Cvar_Get (var_name, value, 0); } if (var->flags & (CVAR_USERINFO | CVAR_SERVERINFO)) { if (!Cvar_InfoValidate (value)) { Com_Printf("invalid info cvar value/n"); return var; } } if (!force) { if (var->flags & CVAR_NOSET) { Com_Printf ("%s is write protected./n", var_name); return var; } if (var->flags & CVAR_LATCH) { if (var->latched_string) { if (strcmp(value, var->latched_string) == 0) return var; Z_Free (var->latched_string); } else { if (strcmp(value, var->string) == 0) return var; } if (Com_ServerState()) { Com_Printf ("%s will be changed for next game./n", var_name); var->latched_string = CopyString(value); } else { var->string = CopyString(value); var->value = atof (var->string); if (!strcmp(var->name, "game")) { FS_SetGame(var->string); FS_ExecAutoexec (); } } return var; } } else { if (var->latched_string) { Z_Free (var->latched_string); var->latched_string = NULL; } } if (!strcmp(value, var->string)) return var; // not changed var->modified = true; if (var->flags & CVAR_USERINFO) userinfo_modified = true; // transmit at next oportunity Z_Free (var->string); // free the old value string var->string = CopyString(value); var->value = atof (var->string); return var;}
开发者ID:weimingtom,项目名称:quakesdl2,代码行数:88,
注:本文中的Com_ServerState函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ Com_Warn函数代码示例 C++ Com_RealTime函数代码示例 |