/* ================= UI_PlayerSetup_SetConfig ================= */ static void UI_PlayerSetup_SetConfig( void ) { CVAR_SET_STRING( "name", uiPlayerSetup.name.buffer ); CVAR_SET_STRING( "model", uiPlayerSetup.currentModel ); CVAR_SET_FLOAT( "topcolor", (int)(uiPlayerSetup.topColor.curValue * 255 )); CVAR_SET_FLOAT( "bottomcolor", (int)(uiPlayerSetup.bottomColor.curValue * 255 )); CVAR_SET_FLOAT( "cl_himodels", uiPlayerSetup.hiModels.enabled ); CVAR_SET_FLOAT( "ui_showmodels", uiPlayerSetup.showModels.enabled ); }
/* ================= UI_VidOptions_UpdateConfig ================= */ static void UI_VidOptions_UpdateConfig( void ) { CVAR_SET_FLOAT( "viewsize", RemapVal( uiVidOptions.screenSize.curValue, 0.0f, 1.0f, 30.0f, 120.0f )); CVAR_SET_FLOAT( "r_flaresize", (uiVidOptions.glareReduction.curValue * 200.0f ) + 100.0f ); CVAR_SET_FLOAT( "r_fastsky", uiVidOptions.fastSky.enabled ); CVAR_SET_FLOAT( "host_allow_materials", uiVidOptions.hiTextures.enabled ); if( CVAR_GET_FLOAT( "gl_ignorehwgamma" )) PIC_SetGamma( uiVidOptions.hTestImage, RemapVal( uiVidOptions.gammaIntensity.curValue, 0.0f, 1.0f, 1.8f, 7.0f )); else CVAR_SET_FLOAT( "gamma", RemapVal( uiVidOptions.gammaIntensity.curValue, 0.0f, 1.0f, 0.5f, 2.3f )); }
/* ================= UI_GameOptions_UpdateConfig ================= */ static void UI_GameOptions_UpdateConfig( void ) { static char fpsText[8]; sprintf( fpsText, "%.f", uiGameOptions.maxFPS.curValue ); uiGameOptions.maxFPS.generic.name = fpsText; CVAR_SET_FLOAT( "hand", uiGameOptions.hand.enabled ); CVAR_SET_FLOAT( "sv_allow_download", uiGameOptions.allowDownload.enabled ); CVAR_SET_FLOAT( "fps_max", uiGameOptions.maxFPS.curValue ); CVAR_SET_FLOAT( "cl_run", uiGameOptions.alwaysRun.enabled ); }
/* ================= UI_Main_NewGame ================= */ static void UI_Main_NewGame( void ) { if( CVAR_GET_FLOAT( "host_serverstate" ) && CVAR_GET_FLOAT( "maxplayers" ) > 1 ) HOST_ENDGAME( "end of the game" ); CVAR_SET_FLOAT( "skill", 1.0f ); CVAR_SET_FLOAT( "deathmatch", 0.0f ); CVAR_SET_FLOAT( "teamplay", 0.0f ); CVAR_SET_FLOAT( "pausable", 1.0f ); // singleplayer is always allowing pause CVAR_SET_FLOAT( "coop", 0.0f ); BACKGROUND_TRACK( NULL, NULL ); CLIENT_COMMAND( FALSE, "newgame\n" ); }
// determines whether we have enough players for a round bool CBaseRoundRules::CheckForRoundStart() { // - determine number of players present and future CountPlayersOnTeamFuture(true); // - assess whether we have enough players for a round // - return depending on situation // ben notes : m_iTeamRespawning as must be set only once m_iClassRespawning as is set // ben notes : or we will get players who aren't ready counted here if((GetNumOfBritishPlayers() > UNDEFINED) && (GetNumOfAmericanPlayers() > UNDEFINED)) { // -- force a full restart if we are waiting for players if(GetRoundState() == ROUND_WAITING_FOR_PLAYERS) { // --- set restart round CVAR_SET_FLOAT("sv_restartround", 1.0); // ---message clients tellin them this // TODO: Add in messaging function } return true; } else { return false; } }
void CvarManager::SetCvarMax(CvarInfo* info, bool set, float value, int pluginId) { info->bound.hasMax = set; info->bound.maxPluginId = pluginId; if (set) { // Detour is disabled on map change. if (m_HookDetour) { m_HookDetour->EnableDetour(); } info->bound.maxVal = value; // Current value is already in the allowed range. if (info->var->value <= value) { return; } // Update if needed. CVAR_SET_FLOAT(info->var->name, value); } }
/* ================= UI_InternetGames_Callback ================= */ static void UI_InternetGames_Callback( void *self, int event ) { menuCommon_s *item = (menuCommon_s *)self; if( event != QM_ACTIVATED ) return; switch( item->id ) { case ID_JOINGAME: if( CL_IsActive( )) UI_PromptDialog(); else UI_InternetGames_JoinGame(); break; case ID_CREATEGAME: CVAR_SET_FLOAT( "public", 1.0f ); UI_CreateGame_Menu(); break; case ID_GAMEINFO: // UNDONE: not implemented break; case ID_REFRESH: UI_RefreshInternetServerList(); break; case ID_DONE: UI_PopMenu(); break; case ID_YES: UI_InternetGames_JoinGame(); break; case ID_NO: UI_PromptDialog(); break; } }
/* ================= UI_GameOptions_UpdateConfig ================= */ static void UI_GameOptions_UpdateConfig( void ) { static char fpsText[8]; static char maxpacketText[8]; sprintf( fpsText, "%.f", uiGameOptions.maxFPS.curValue ); uiGameOptions.maxFPS.generic.name = fpsText; if( uiGameOptions.maxPacket.curValue >= 1500 ) { sprintf( maxpacketText, "default" ); // even do not send it to server CVAR_SET_FLOAT( "cl_maxpacket", 40000 ); } else { sprintf( maxpacketText, "%.f", uiGameOptions.maxPacket.curValue ); CVAR_SET_FLOAT( "cl_maxpacket", uiGameOptions.maxPacket.curValue ); } uiGameOptions.maxPacket.generic.name = maxpacketText; CVAR_SET_FLOAT( "hand", uiGameOptions.hand.enabled ); CVAR_SET_FLOAT( "sv_allow_download", uiGameOptions.allowDownload.enabled ); CVAR_SET_FLOAT( "fps_max", uiGameOptions.maxFPS.curValue ); CVAR_SET_FLOAT( "cl_run", uiGameOptions.alwaysRun.enabled ); CVAR_SET_FLOAT( "android_sleep", uiGameOptions.android_sleep.enabled ); }
int CHud :: MsgFunc_RoomType( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pszName, iSize, pbuf ); CVAR_SET_FLOAT( "room_type", (float)READ_BYTE( )); END_READ(); return 1; }
void FFA_Disable() { // unpatch! DoUnPatch(&g_takedmg_patches); DoUnPatch(&g_pkilled_patches); g_ffa_state = false; //we don't care about efficiency here CVAR_SET_FLOAT("mp_friendlyfire", g_last_ff_set); CVAR_SET_STRING("mp_freeforall", "0"); MF_ExecuteForward(g_StateChange, CSDM_FFA_DISABLE); }
/* ================= UI_GamePad_SetConfig ================= */ static void UI_GamePad_SetConfig( void ) { float side, forward, pitch, yaw; char binding[7] = { 0 }; side = uiGamePad.side.curValue; if( uiGamePad.invSide.enabled ) side *= -1; forward = uiGamePad.forward.curValue; if( uiGamePad.invFwd.enabled ) forward *= -1; pitch = uiGamePad.pitch.curValue; if( uiGamePad.invPitch.enabled ) pitch *= -1; yaw = uiGamePad.yaw.curValue; if( uiGamePad.invYaw.enabled ) yaw *= -1; for( int i = 0; i < 6; i++ ) { switch( (int)uiGamePad.axisBind[i].curValue ) { case JOY_AXIS_SIDE: binding[i] = 's'; break; case JOY_AXIS_FWD: binding[i] = 'f'; break; case JOY_AXIS_PITCH: binding[i] = 'p'; break; case JOY_AXIS_YAW: binding[i] = 'y'; break; case JOY_AXIS_RT: binding[i] = 'r'; break; case JOY_AXIS_LT: binding[i] = 'l'; break; default: binding[i] = '0'; break; } } CVAR_SET_FLOAT( "joy_side", side ); CVAR_SET_FLOAT( "joy_forward", forward ); CVAR_SET_FLOAT( "joy_pitch", pitch ); CVAR_SET_FLOAT( "joy_yaw", yaw ); CVAR_SET_STRING( "joy_axis_binding", binding ); }
void FFA_Enable() { // patch! DoPatch(&g_takedmg_patches); DoPatch(&g_pkilled_patches); g_ffa_state = true; //we don't care about efficiency here g_last_ff_set = CVAR_GET_FLOAT("mp_friendlyfire"); CVAR_SET_FLOAT("mp_friendlyfire", 1.0f); CVAR_SET_STRING("mp_freeforall", "1"); MF_ExecuteForward(g_StateChange, CSDM_FFA_ENABLE); }
static int setServerVariable(lua_State* inState) { // Get variable name const char* theVariableName = lua_tostring(inState, 1); if(theVariableName) { float theValue = lua_tonumber(inState, 2); CVAR_SET_FLOAT(theVariableName, theValue); } return 0; }
void log_init(const char *cvarname) { CVAR_REGISTER(&init_plugin_debug); // Since metamod replaces our cvar_t structure with a structure local // to metamod when we call CVAR_REGISTER, we have to get the address of // the new struct if we expect to be able to read/write directly to // the cvar struct. plugin_debug=CVAR_GET_POINTER(cvarname); // Since we haven't read server.cfg yet, allow debug logging (level 3) // to be enabled with the "+developer" cmdline option. if((int) CVAR_GET_FLOAT("developer") != 0) CVAR_SET_FLOAT(cvarname, 3); }
static void UI_TouchOptions_SetConfig( void ) { static char gridText[8]; snprintf( gridText, 8, "%.f", uiTouchOptions.gridsize.curValue ); uiTouchOptions.gridsize.generic.name = gridText; CVAR_SET_FLOAT( "touch_grid_enable", uiTouchOptions.grid.enabled ); CVAR_SET_FLOAT( "touch_grid_count", uiTouchOptions.gridsize.curValue ); CVAR_SET_FLOAT( "touch_yaw", RemapVal( uiTouchOptions.lookX.curValue, 0.0f, 1.0f, 50.0f, 500.0f )); CVAR_SET_FLOAT( "touch_pitch", RemapVal( uiTouchOptions.lookY.curValue, 0.0f, 1.0f, 50.0f, 500.0f )); CVAR_SET_FLOAT( "touch_sidezone", ( 2.0 / uiTouchOptions.moveX.curValue ) / 100 ); CVAR_SET_FLOAT( "touch_forwardzone", ( 2.0 / uiTouchOptions.moveX.curValue ) / 100 ); CVAR_SET_FLOAT( "touch_enable", uiTouchOptions.enable.enabled ); CVAR_SET_FLOAT( "m_ignore", uiTouchOptions.nomouse.enabled ); }
/* ================= UI_PlayerSetup_SetConfig ================= */ static void UI_PlayerSetup_SetConfig( void ) { CVAR_SET_STRING( "name", uiPlayerSetup.name.buffer ); char curColor[CS_SIZE]; int i = uiPlayerSetup.crosshairColor.curValue; snprintf( curColor, CS_SIZE, "%i %i %i", g_iCrosshairAvailColors[i][0], g_iCrosshairAvailColors[i][1], g_iCrosshairAvailColors[i][2] ); CVAR_SET_STRING( "cl_crosshair_color", curColor ); CVAR_SET_STRING( "cl_crosshair_size", uiPlayerSetup.crosshairSize.generic.name ); CVAR_SET_FLOAT( "cl_crosshair_translucent", uiPlayerSetup.crosshairTranslucent.enabled ); }
/* ================= UI_GameOptions_DiscardChanges ================= */ static void UI_GameOptions_DiscardChanges( void ) { CVAR_SET_FLOAT( "hand", uiGameInitial.hand ); CVAR_SET_FLOAT( "sv_allow_download", uiGameInitial.allowDownload ); CVAR_SET_FLOAT( "fps_max", uiGameInitial.maxFPS ); CVAR_SET_FLOAT( "cl_run", uiGameInitial.alwaysRun ); CVAR_SET_FLOAT( "cl_maxpacket", uiGameInitial.maxPacket ); CVAR_SET_FLOAT( "android_sleep", uiGameInitial.android_sleep ); }
/* ================= UI_CreateGame_Begin ================= */ static void UI_CreateGame_Begin( void ) { if( !MAP_IS_VALID( uiCreateGame.mapName[uiCreateGame.mapsList.curItem] )) return; // bad map if( CVAR_GET_FLOAT( "host_serverstate" ) && CVAR_GET_FLOAT( "maxplayers" ) == 1 ) HOST_ENDGAME( "end of the game" ); CVAR_SET_FLOAT( "deathmatch", 1.0f ); // start deathmatch as default CVAR_SET_FLOAT( "maxplayers", atoi( uiCreateGame.maxClients.buffer )); CVAR_SET_STRING( "hostname", uiCreateGame.hostName.buffer ); CVAR_SET_STRING( "defaultmap", uiCreateGame.mapName[uiCreateGame.mapsList.curItem] ); CVAR_SET_FLOAT( "hltv", uiCreateGame.hltv.enabled ); // all done, start server if( uiCreateGame.dedicatedServer.enabled ) { HOST_WRITECONFIG ( CVAR_GET_STRING( "servercfgfile" )); char cmd[128]; sprintf( cmd, "#%s", gMenu.m_gameinfo.gamefolder ); // NOTE: dedicated server will be executed "defaultmap" // from engine after restarting HOST_CHANGEGAME( cmd, "Starting dedicated server...\n" ); } else { HOST_WRITECONFIG ( CVAR_GET_STRING( "lservercfgfile" )); char cmd[128]; sprintf( cmd, "exec %s\nmap %s\n", CVAR_GET_STRING( "lservercfgfile" ), CVAR_GET_STRING( "defaultmap" )); CLIENT_COMMAND( FALSE, cmd ); } }
/* ================= R_Bloom_InitEffectTexture ================= */ static void R_Bloom_InitEffectTexture( void ) { int limit; if( r_bloom_sample_size->value < 32.0f ) CVAR_SET_FLOAT( "r_bloom_sample_size", 32.0f ); // make sure bloom size doesn't have stupid values limit = min( r_bloom_sample_size->value, min( screen_texture_width, screen_texture_height )); if( GL_Support( R_ARB_TEXTURE_NPOT_EXT )) { BLOOM_SIZE = limit; } else { // make sure bloom size is a power of 2 for( BLOOM_SIZE = 32; (BLOOM_SIZE<<1) <= limit; BLOOM_SIZE <<= 1 ); } if( BLOOM_SIZE != r_bloom_sample_size->value ) CVAR_SET_FLOAT( "r_bloom_sample_size", BLOOM_SIZE ); r_bloomeffecttexture = CREATE_TEXTURE( "*bloomeffecttexture", BLOOM_SIZE, BLOOM_SIZE, NULL, TF_IMAGE ); }
/* ================= R_Bloom_InitTextures ================= */ static void R_Bloom_InitTextures( void ) { if( GL_Support( R_ARB_TEXTURE_NPOT_EXT )) { screen_texture_width = glState.width; screen_texture_height = glState.height; } else { // find closer power of 2 to screen size for( screen_texture_width = 1; screen_texture_width < glState.width; screen_texture_width <<= 1 ); for( screen_texture_height = 1; screen_texture_height < glState.height; screen_texture_height <<= 1 ); } // disable blooms if we can't handle a texture of that size if( screen_texture_width > glConfig.max_2d_texture_size || screen_texture_height > glConfig.max_2d_texture_size ) { screen_texture_width = screen_texture_height = 0; CVAR_SET_FLOAT( "r_bloom", 0.0f ); ALERT( at_warning, "'R_InitBloomScreenTexture' too high resolution for light bloom, effect disabled\n" ); return; } r_bloomscreentexture = CREATE_TEXTURE( "*bloomscreentexture", screen_texture_width, screen_texture_height, NULL, TF_IMAGE ); // validate bloom size and init the bloom effect texture R_Bloom_InitEffectTexture(); // if screensize is more than 2x the bloom effect texture, set up for stepped downsampling r_bloomdownsamplingtexture = 0; r_screendownsamplingtexture_size = 0; if(( glState.width > (BLOOM_SIZE * 2) || glState.height > (BLOOM_SIZE * 2)) && !r_bloom_fast_sample->value ) { r_screendownsamplingtexture_size = (int)( BLOOM_SIZE * 2 ); r_bloomdownsamplingtexture = CREATE_TEXTURE( "*bloomdownsampletexture", r_screendownsamplingtexture_size, r_screendownsamplingtexture_size, NULL, TF_IMAGE ); } // init the screen backup texture if( r_screendownsamplingtexture_size ) R_Bloom_InitBackUpTexture( r_screendownsamplingtexture_size, r_screendownsamplingtexture_size ); else R_Bloom_InitBackUpTexture( BLOOM_SIZE, BLOOM_SIZE ); }
// setWeather(weather) SQInteger CServerNatives::ForceWind(SQVM * pVM) { SQFloat fWind; sq_getfloat(pVM, 2, &fWind); if(fWind != CVAR_GET_INTEGER("wind")) { CVAR_SET_FLOAT("wind", (float)fWind); CBitStream bsSend; bsSend.Write((float)fWind); g_pNetworkManager->RPC(RPC_ScriptingForceWind, &bsSend, PRIORITY_HIGH, RELIABILITY_RELIABLE_ORDERED, INVALID_ENTITY_ID, true); sq_pushbool(pVM, true); return 1; } sq_pushbool(pVM, false); return 1; }
/* ================= UI_NewGame_StartGame ================= */ static void UI_NewGame_StartGame( float skill ) { if( CVAR_GET_FLOAT( "host_serverstate" ) && CVAR_GET_FLOAT( "maxplayers" ) > 1 ) HOST_ENDGAME( "end of the game" ); CVAR_SET_FLOAT( "skill", skill ); CVAR_SET_FLOAT( "deathmatch", 0.0f ); CVAR_SET_FLOAT( "teamplay", 0.0f ); CVAR_SET_FLOAT( "pausable", 1.0f ); // singleplayer is always allowing pause CVAR_SET_FLOAT( "maxplayers", 1.0f ); CVAR_SET_FLOAT( "coop", 0.0f ); CLIENT_COMMAND( FALSE, "newgame\n" ); }
void CWorld :: Precache( void ) { g_pLastSpawn = NULL; CVAR_SET_STRING("sv_gravity", "800"); // 67ft/sec CVAR_SET_STRING("sv_stepsize", "18"); CVAR_SET_STRING("room_type", "0"); // clear DSP // Create all the arenas for (int i = 0; i < MAX_ARENAS; i++) { g_pArenaList[i] = GetClassPtr( ( CDiscArena *)NULL ); g_pArenaList[i]->Spawn(); } // Set up game rules if (g_pGameRules) { delete g_pGameRules; } g_pGameRules = InstallGameRules( ); //!!!UNDONE why is there so much Spawn code in the Precache function? I'll just keep it here ///!!!LATER - do we want a sound ent in deathmatch? (sjb) //pSoundEnt = CBaseEntity::Create( "soundent", g_vecZero, g_vecZero, edict() ); pSoundEnt = GetClassPtr( ( CSoundEnt *)NULL ); pSoundEnt->Spawn(); if ( !pSoundEnt ) { ALERT ( at_console, "**COULD NOT CREATE SOUNDENT**\n" ); } InitBodyQue(); // init sentence group playback stuff from sentences.txt. // ok to call this multiple times, calls after first are ignored. SENTENCEG_Init(); // init texture type array from materials.txt TEXTURETYPE_Init(); // the area based ambient sounds MUST be the first precache_sounds // player precaches W_Precache (); // get weapon precaches ClientPrecache(); // sounds used from C physics code PRECACHE_SOUND("common/null.wav"); // clears sound channels PRECACHE_SOUND( "items/suitchargeok1.wav" );//!!! temporary sound for respawning weapons. PRECACHE_SOUND( "items/gunpickup2.wav" );// player picks up a gun. PRECACHE_SOUND( "common/bodydrop3.wav" );// dead bodies hitting the ground (animation events) PRECACHE_SOUND( "common/bodydrop4.wav" ); PRECACHE_SOUND( "r_tele1.wav" ); // respawn sound PRECACHE_SOUND( "scream1.wav" ); // falling scream sound PRECACHE_SOUND( "scream2.wav" ); // falling scream sound PRECACHE_SOUND( "scream3.wav" ); // falling scream sound PRECACHE_SOUND( "decap.wav" ); // decapitation sound PRECACHE_SOUND( "shatter.wav" ); // freeze decapitation sound PRECACHE_MODEL( "models/head.mdl" ); // head g_Language = (int)CVAR_GET_FLOAT( "sv_language" ); if ( g_Language == LANGUAGE_GERMAN ) { PRECACHE_MODEL( "models/germangibs.mdl" ); } else { PRECACHE_MODEL( "models/hgibs.mdl" ); PRECACHE_MODEL( "models/agibs.mdl" ); } PRECACHE_SOUND ("weapons/ric1.wav"); PRECACHE_SOUND ("weapons/ric2.wav"); PRECACHE_SOUND ("weapons/ric3.wav"); PRECACHE_SOUND ("weapons/ric4.wav"); PRECACHE_SOUND ("weapons/ric5.wav"); // // Setup light animation tables. 'a' is total darkness, 'z' is maxbright. // // 0 normal LIGHT_STYLE(0, "m"); // 1 FLICKER (first variety) LIGHT_STYLE(1, "mmnmmommommnonmmonqnmmo"); // 2 SLOW STRONG PULSE LIGHT_STYLE(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"); // 3 CANDLE (first variety) LIGHT_STYLE(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg"); // 4 FAST STROBE LIGHT_STYLE(4, "mamamamamama"); // 5 GENTLE PULSE 1 LIGHT_STYLE(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj"); // 6 FLICKER (second variety) LIGHT_STYLE(6, "nmonqnmomnmomomno"); // 7 CANDLE (second variety) LIGHT_STYLE(7, "mmmaaaabcdefgmmmmaaaammmaamm"); // 8 CANDLE (third variety) LIGHT_STYLE(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"); // 9 SLOW STROBE (fourth variety) LIGHT_STYLE(9, "aaaaaaaazzzzzzzz"); // 10 FLUORESCENT FLICKER LIGHT_STYLE(10, "mmamammmmammamamaaamammma"); // 11 SLOW PULSE NOT FADE TO BLACK LIGHT_STYLE(11, "abcdefghijklmnopqrrqponmlkjihgfedcba"); // 12 UNDERWATER LIGHT MUTATION // this light only distorts the lightmap - no contribution // is made to the brightness of affected surfaces LIGHT_STYLE(12, "mmnnmmnnnmmnn"); // styles 32-62 are assigned by the light program for switchable lights // 63 testing LIGHT_STYLE(63, "a"); for ( i = 0; i < ARRAYSIZE(gDecals); i++ ) gDecals[i].index = DECAL_INDEX( gDecals[i].name ); // init the WorldGraph. WorldGraph.InitGraph(); // make sure the .NOD file is newer than the .BSP file. if ( !WorldGraph.CheckNODFile ( ( char * )STRING( gpGlobals->mapname ) ) ) {// NOD file is not present, or is older than the BSP file. WorldGraph.AllocNodes (); } else {// Load the node graph for this level if ( !WorldGraph.FLoadGraph ( (char *)STRING( gpGlobals->mapname ) ) ) {// couldn't load, so alloc and prepare to build a graph. ALERT ( at_console, "*Error opening .NOD file\n" ); WorldGraph.AllocNodes (); } else { ALERT ( at_console, "\n*Graph Loaded!\n" ); } } if ( pev->speed > 0 ) CVAR_SET_FLOAT( "sv_zmax", pev->speed ); else CVAR_SET_FLOAT( "sv_zmax", 4096 ); if ( pev->netname ) { ALERT( at_aiconsole, "Chapter title: %s\n", STRING(pev->netname) ); CBaseEntity *pEntity = CBaseEntity::Create( "env_message", g_vecZero, g_vecZero, NULL ); if ( pEntity ) { pEntity->SetThink( SUB_CallUseToggle ); pEntity->pev->message = pev->netname; pev->netname = 0; pEntity->pev->nextthink = gpGlobals->time + 0.3; pEntity->pev->spawnflags = SF_MESSAGE_ONCE; } } if ( pev->spawnflags & SF_WORLD_DARK ) CVAR_SET_FLOAT( "v_dark", 1.0 ); else CVAR_SET_FLOAT( "v_dark", 0.0 ); if ( pev->spawnflags & SF_WORLD_TITLE ) gDisplayTitle = TRUE; // display the game title if this key is set else gDisplayTitle = FALSE; if ( pev->spawnflags & SF_WORLD_FORCETEAM ) { CVAR_SET_FLOAT( "mp_defaultteam", 1 ); } else { CVAR_SET_FLOAT( "mp_defaultteam", 0 ); } // Discwar if ( g_iPlayersPerTeam < 1 ) g_iPlayersPerTeam = CVAR_GET_FLOAT("rc_playersperteam"); }
/* ================= UI_VidModes_UpdateConfig ================= */ static void UI_VidOptions_UpdateConfig( void ) { CVAR_SET_FLOAT( "gl_swapInterval", uiVidModes.vsync.enabled ); }
/* ================= UI_VidModes_SetConfig ================= */ static void UI_VidOptions_SetConfig( void ) { CVAR_SET_FLOAT( "vid_mode", uiVidModes.vidList.curItem ); CVAR_SET_FLOAT( "fullscreen", !uiVidModes.windowed.enabled ); CVAR_SET_FLOAT( "gl_swapInterval", uiVidModes.vsync.enabled ); }
/* ================= UI_VidModes_UpdateConfig ================= */ static void UI_VidOptions_UpdateConfig( void ) { CVAR_SET_FLOAT( "r_allow_software", uiVidModes.software.enabled ); }
/* ================= UI_VidModes_SetConfig ================= */ static void UI_VidOptions_SetConfig( void ) { CVAR_SET_FLOAT( "vid_mode", uiVidModes.vidList.curItem ); CVAR_SET_FLOAT( "fullscreen", !uiVidModes.windowed.enabled ); CVAR_SET_FLOAT( "r_allow_software", uiVidModes.software.enabled ); }
// // Just to ignore the "wad" field. // void CWorld :: KeyValue( KeyValueData *pkvd ) { if ( FStrEq(pkvd->szKeyName, "skyname") ) { // Sent over net now. CVAR_SET_STRING( "sv_skyname", pkvd->szValue ); pkvd->fHandled = TRUE; } else if ( FStrEq(pkvd->szKeyName, "sounds") ) { gpGlobals->cdAudioTrack = atoi(pkvd->szValue); pkvd->fHandled = TRUE; } else if ( FStrEq(pkvd->szKeyName, "WaveHeight") ) { // Sent over net now. pev->scale = atof(pkvd->szValue) * (1.0/8.0); pkvd->fHandled = TRUE; CVAR_SET_FLOAT( "sv_wateramp", pev->scale ); } else if ( FStrEq(pkvd->szKeyName, "MaxRange") ) { pev->speed = atof(pkvd->szValue); pkvd->fHandled = TRUE; } else if ( FStrEq(pkvd->szKeyName, "chaptertitle") ) { pev->netname = ALLOC_STRING(pkvd->szValue); pkvd->fHandled = TRUE; } else if ( FStrEq(pkvd->szKeyName, "startdark") ) { // UNDONE: This is a gross hack!!! The CVAR is NOT sent over the client/sever link // but it will work for single player int flag = atoi(pkvd->szValue); pkvd->fHandled = TRUE; if ( flag ) pev->spawnflags |= SF_WORLD_DARK; } else if ( FStrEq(pkvd->szKeyName, "newunit") ) { // Single player only. Clear save directory if set if ( atoi(pkvd->szValue) ) CVAR_SET_FLOAT( "sv_newunit", 1 ); pkvd->fHandled = TRUE; } else if ( FStrEq(pkvd->szKeyName, "gametitle") ) { if ( atoi(pkvd->szValue) ) pev->spawnflags |= SF_WORLD_TITLE; pkvd->fHandled = TRUE; } else if ( FStrEq(pkvd->szKeyName, "mapteams") ) { pev->team = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else if ( FStrEq(pkvd->szKeyName, "defaultteam") ) { if ( atoi(pkvd->szValue) ) { pev->spawnflags |= SF_WORLD_FORCETEAM; } pkvd->fHandled = TRUE; } // Discwar else if ( FStrEq(pkvd->szKeyName, "playersperteam") ) { g_iPlayersPerTeam = atoi(pkvd->szValue); pkvd->fHandled = TRUE; } else if ( FStrEq(pkvd->szKeyName, "no_arena") ) { if ( atoi(pkvd->szValue) ) m_iArenaOff = TRUE; pkvd->fHandled = TRUE; } else CBaseEntity::KeyValue( pkvd ); }
/* <36ace2> ../cstrike/dlls/bot/cs_bot_manager.cpp:484 */ void CCSBotManager::__MAKE_VHOOK(ServerCommand)(const char *pcmd) { if (!m_bServerActive || !UTIL_IsGame("czero")) return; char buffer[400]; const char *msg = CMD_ARGV(1); if (FStrEq(pcmd, "bot_about")) { Q_sprintf(buffer, "\n--------------------------------------------------------------------------\nThe Official Counter-Strike Bot V%d.%02d\nCreated by Michael S. Booth\nWeb: www.turtlerockstudios.com\\csbot\nE-mail: [email protected]\n--------------------------------------------------------------------------\n\n", CSBOT_VERSION_MAJOR, CSBOT_VERSION_MINOR); CONSOLE_ECHO(buffer); HintMessageToAllPlayers(buffer); } else if (FStrEq(pcmd, "bot_add")) { BotAddCommand(BOT_TEAM_ANY); } else if (FStrEq(pcmd, "bot_add_t")) { BotAddCommand(BOT_TEAM_T); } else if (FStrEq(pcmd, "bot_add_ct")) { BotAddCommand(BOT_TEAM_CT); } else if (FStrEq(pcmd, "bot_kill")) { bool killThemAll; if (CMD_ARGC() == 1 || FStrEq(msg, "all")) killThemAll = true; else killThemAll = false; for (int iIndex = 1; iIndex <= gpGlobals->maxClients; iIndex++) { CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(iIndex); if (pPlayer == NULL) continue; if (FNullEnt(pPlayer->pev)) continue; const char *name = STRING(pPlayer->pev->netname); if (FStrEq(name, "")) continue; if (pPlayer->IsBot()) { if (killThemAll || FStrEq(name, msg)) { pPlayer->TakeDamage(pPlayer->pev, pPlayer->pev, 9999.9f, DMG_CRUSH); } } } } else if (FStrEq(pcmd, "bot_kick")) { bool kickThemAll; if (CMD_ARGC() == 1 || FStrEq(msg, "all")) kickThemAll = true; else kickThemAll = false; for (int iIndex = 1; iIndex <= gpGlobals->maxClients; iIndex++) { CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(iIndex); if (pPlayer == NULL) continue; if (FNullEnt(pPlayer->pev)) continue; const char *name = STRING(pPlayer->pev->netname); if (FStrEq(name, "")) continue; if (pPlayer->IsBot()) { if (kickThemAll || FStrEq(name, msg)) { SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", name)); CVAR_SET_FLOAT("bot_quota", cv_bot_quota.value - 1); } } } if (kickThemAll || cv_bot_quota.value < 0.0f) { CVAR_SET_FLOAT("bot_quota", 0); } } else if (FStrEq(pcmd, "bot_knives_only")) { CVAR_SET_FLOAT("bot_allow_pistols", 0); CVAR_SET_FLOAT("bot_allow_shotguns", 0); CVAR_SET_FLOAT("bot_allow_sub_machine_guns", 0); CVAR_SET_FLOAT("bot_allow_rifles", 0); CVAR_SET_FLOAT("bot_allow_machine_guns", 0); CVAR_SET_FLOAT("bot_allow_grenades", 0); CVAR_SET_FLOAT("bot_allow_snipers", 0); CVAR_SET_FLOAT("bot_allow_shield", 0); } else if (FStrEq(pcmd, "bot_pistols_only")) { CVAR_SET_FLOAT("bot_allow_pistols", 1); CVAR_SET_FLOAT("bot_allow_shotguns", 0); CVAR_SET_FLOAT("bot_allow_sub_machine_guns", 0); CVAR_SET_FLOAT("bot_allow_rifles", 0); CVAR_SET_FLOAT("bot_allow_machine_guns", 0); CVAR_SET_FLOAT("bot_allow_grenades", 0); CVAR_SET_FLOAT("bot_allow_snipers", 0); CVAR_SET_FLOAT("bot_allow_shield", 0); } else if (FStrEq(pcmd, "bot_snipers_only")) { CVAR_SET_FLOAT("bot_allow_pistols", 1); CVAR_SET_FLOAT("bot_allow_shotguns", 0); CVAR_SET_FLOAT("bot_allow_sub_machine_guns", 0); CVAR_SET_FLOAT("bot_allow_rifles", 0); CVAR_SET_FLOAT("bot_allow_machine_guns", 0); CVAR_SET_FLOAT("bot_allow_grenades", 0); CVAR_SET_FLOAT("bot_allow_snipers", 1); CVAR_SET_FLOAT("bot_allow_shield", 0); } else if (FStrEq(pcmd, "bot_all_weapons")) { CVAR_SET_FLOAT("bot_allow_pistols", 1); CVAR_SET_FLOAT("bot_allow_shotguns", 1); CVAR_SET_FLOAT("bot_allow_sub_machine_guns", 1); CVAR_SET_FLOAT("bot_allow_rifles", 1); CVAR_SET_FLOAT("bot_allow_machine_guns", 1); CVAR_SET_FLOAT("bot_allow_grenades", 1); CVAR_SET_FLOAT("bot_allow_snipers", 1); CVAR_SET_FLOAT("bot_allow_shield", 1); } else if (FStrEq(pcmd, "entity_dump")) { PrintAllEntities(); } else if (FStrEq(pcmd, "bot_nav_delete")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_DELETE; } else if (FStrEq(pcmd, "bot_nav_split")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_SPLIT; } else if (FStrEq(pcmd, "bot_nav_merge")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_MERGE; } else if (FStrEq(pcmd, "bot_nav_mark")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_MARK; } else if (FStrEq(pcmd, "bot_nav_begin_area")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_BEGIN_AREA; } else if (FStrEq(pcmd, "bot_nav_end_area")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_END_AREA; } else if (FStrEq(pcmd, "bot_nav_connect")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_CONNECT; } else if (FStrEq(pcmd, "bot_nav_disconnect")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_DISCONNECT; } else if (FStrEq(pcmd, "bot_nav_splice")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_SPLICE; } else if (FStrEq(pcmd, "bot_nav_crouch")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_ATTRIB_CROUCH; } else if (FStrEq(pcmd, "bot_nav_jump")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_ATTRIB_JUMP; } else if (FStrEq(pcmd, "bot_nav_precise")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_ATTRIB_PRECISE; } else if (FStrEq(pcmd, "bot_nav_no_jump")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_ATTRIB_NO_JUMP; } else if (FStrEq(pcmd, "bot_nav_analyze")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_isAnalysisRequested) = true; } else if (FStrEq(pcmd, "bot_nav_strip")) { StripNavigationAreas();// TODO: reverse me } else if (FStrEq(pcmd, "bot_nav_save")) { GET_GAME_DIR(buffer); buffer[ Q_strlen(buffer) ] = '\\'; Q_strcat(buffer, CBotManager::GetNavMapFilename()); if (SaveNavigationMap(buffer))// TODO: reverse me CONSOLE_ECHO("Navigation map '%s' saved.\n", buffer); else CONSOLE_ECHO("ERROR: Cannot save navigation map '%s'.\n", buffer); } else if (FStrEq(pcmd, "bot_nav_load")) { ValidateMapData(); } else if (FStrEq(pcmd, "bot_nav_use_place")) { if (CMD_ARGC() == 1) { int i = 0; const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); for (BotPhraseList::const_iterator iter = placeList->begin(); iter != placeList->end(); ++iter, i++) { if ((*iter)->GetID() == GetNavPlace()) CONSOLE_ECHO("--> %-26s", (*iter)->GetName()); else CONSOLE_ECHO("%-30s", (*iter)->GetName()); if (!(i % 3)) CONSOLE_ECHO("\n"); } CONSOLE_ECHO("\n"); } else { const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); const BotPhrase *found = NULL; bool isAmbiguous = false; for (BotPhraseList::const_iterator iter = placeList->begin(); iter != placeList->end(); ++iter) { if (!Q_strnicmp((*iter)->GetName(), msg, Q_strlen(msg))) { if (!Q_strcmp((*iter)->GetName(), msg)) { found = (*iter); break; } if (found != NULL) isAmbiguous = true; else found = (*iter); } } if (isAmbiguous) { CONSOLE_ECHO("Ambiguous\n"); return; } if (found != NULL) { CONSOLE_ECHO("Current place set to '%s'\n", found->GetName()); m_navPlace = found->GetID(); } } } else if (FStrEq(pcmd, "bot_nav_toggle_place_mode")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_TOGGLE_PLACE_MODE; } else if (FStrEq(pcmd, "bot_nav_place_floodfill")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_PLACE_FLOODFILL; } else if (FStrEq(pcmd, "bot_nav_place_pick")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_PLACE_PICK; } else if (FStrEq(pcmd, "bot_nav_toggle_place_painting")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_TOGGLE_PLACE_PAINTING; } else if (FStrEq(pcmd, "bot_goto_mark")) { // tell the first bot we find to go to our marked area CNavArea *area = GetMarkedArea();// TODO: reverse me if (area != NULL) { CBaseEntity *pEntity = NULL; while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")) != NULL) { if (!pEntity->IsPlayer()) continue; if ((pEntity->pev->flags & FL_DORMANT) == FL_DORMANT) continue; CBasePlayer *playerOrBot = GetClassPtr((CBasePlayer *)pEntity->pev); if (playerOrBot->IsBot()) { CCSBot *bot = reinterpret_cast<CCSBot *>(playerOrBot); bot->MoveTo(&area->m_center, FASTEST_ROUTE);// TODO: reverse me return; } } } } else if (FStrEq(pcmd, "bot_memory_usage")) { CONSOLE_ECHO("Memory usage:\n"); CONSOLE_ECHO(" %d bytes per bot\b", sizeof(CCSBot)); CONSOLE_ECHO(" %d Navigation Areas @ %d bytes each = %d bytes\n", TheNavAreaGrid.GetNavAreaCount(), sizeof(CNavArea), TheNavAreaGrid.GetNavAreaCount() * sizeof(CNavArea)); CONSOLE_ECHO(" %d Hiding Spots @ %d bytes each = %d bytes\n", TheHidingSpotList.size(), sizeof(HidingSpot), sizeof(HidingSpot) * TheHidingSpotList.size()); unsigned int encounterMem = 0; for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) { CNavArea *area = (*iter); for (SpotEncounterList::iterator siter = area->m_spotEncounterList.begin(); siter != area->m_spotEncounterList.end(); ++siter) { // TODO: Fix me, this is crashed in HOOK_GAMEDLL SpotEncounter se = (*siter); encounterMem += sizeof(SpotEncounter); encounterMem += sizeof(SpotOrder) * se.spotList.size(); } } CONSOLE_ECHO(" Encounter Spot data = %d bytes\n", encounterMem); } else if (FStrEq(pcmd, "bot_nav_mark_unnamed")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_MARK_UNNAMED; } else if (FStrEq(pcmd, "bot_nav_warp")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_WARP_TO_MARK; } else if (FStrEq(pcmd, "bot_nav_corner_select")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_SELECT_CORNER; } else if (FStrEq(pcmd, "bot_nav_corner_raise")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_RAISE_CORNER; } else if (FStrEq(pcmd, "bot_nav_corner_lower")) { IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_LOWER_CORNER; } else if (FStrEq(pcmd, "bot_nav_check_consistency")) { if (CMD_ARGC() != 2) { CONSOLE_ECHO("usage: bot_nav_check_consistency <filename>\n"); return; } SanityCheckNavigationMap(msg);// TODO: reverse me } }
/* <36c3c2> ../cstrike/dlls/bot/cs_bot_manager.cpp:903 */ NOBODY bool CCSBotManager::BotAddCommand(BotProfileTeamType team, bool isFromConsole) { if (IMPLEMENT_ARRAY(m_isLearningMap) || ENG_CHECK_PARM("-nobots", NULL)) return false; const BotProfile *profile = NULL; if (!isFromConsole || CMD_ARGC() < 2) { if (team == BOT_TEAM_ANY) { // if team not specified, check cv_bot_join_team cvar for preference if (!Q_stricmp(cv_bot_join_team.string, "T")) team = BOT_TEAM_T; else if (!Q_stricmp(cv_bot_join_team.string, "CT")) team = BOT_TEAM_CT; else { TeamName defaultTeam = SelectDefaultTeam(); if (defaultTeam == TERRORIST) team = BOT_TEAM_T; else if (defaultTeam == CT) team = BOT_TEAM_CT; } } // try to add a bot by name profile = TheBotProfiles->GetRandomProfile(GetDifficultyLevel(), team); if (profile == NULL) { CONSOLE_ECHO("All bot profiles at this difficulty level are in use.\n"); return true; } } else { // in career, ignore humans bool ignoreHumans = false; CHalfLifeMultiplay *mp = g_pGameRules; if (mp && mp->IsCareer()) ignoreHumans = true; if (UTIL_IsNameTaken(CMD_ARGV(1), ignoreHumans)) { CONSOLE_ECHO("Error - %s is already in the game.\n", CMD_ARGV(1)); return true; } profile = TheBotProfiles->GetProfile(CMD_ARGV(1), team); if (profile == NULL) { CONSOLE_ECHO("Error - no profile for '%s' exists.\n", CMD_ARGV(1)); return true; } } // create the bot if (CCSBotManager::AddBot(profile, team)) // TODO: Reverse me { if (isFromConsole) { // increase the bot quota to account for manually added bot CVAR_SET_FLOAT("bot_quota", cv_bot_quota.value + 1); } } return true; }