static void CG_ConfigStringModified( void ) { const char *str; int num; num = atoi( CG_Argv( 1 ) ); // get the gamestate from the client system, which will have the // new configstring already integrated cgi_GetGameState( &cgs.gameState ); // look up the individual string that was modified str = CG_ConfigString( num ); // do something with it if necessary if ( num == CS_MUSIC ) { CG_StartMusic(); } else if ( num == CS_SERVERINFO ) { CG_ParseServerinfo(); } else if ( num >= CS_MODELS && num < CS_MODELS+MAX_MODELS ) { cgs.model_draw[ num-CS_MODELS ] = cgi_R_RegisterModel( str ); } else if ( num >= CS_SOUNDS && num < CS_SOUNDS+MAX_MODELS ) { if ( str[0] != '*' ) { cgs.sound_precache[ num-CS_SOUNDS] = cgi_S_RegisterSound( str ); } } else if ( num >= CS_PLAYERS && num < CS_PLAYERS+MAX_CLIENTS ) { CG_NewClientinfo( num - CS_PLAYERS ); CG_RegisterClientModels( num - CS_PLAYERS ); } }
static void CG_ConfigStringModified( void ) { const char *str; int num; num = atoi( CG_Argv( 1 ) ); // get the gamestate from the client system, which will have the // new configstring already integrated cgi_GetGameState( &cgs.gameState ); // look up the individual string that was modified str = CG_ConfigString( num ); // do something with it if necessary if ( num == CS_ITEMS ) { int i; for ( i = 1 ; i < bg_numItems ; i++ ) { if ( str[ i ] == '1' ) { if (bg_itemlist[i].classname) { CG_RegisterItemSounds( i ); CG_RegisterItemVisuals( i ); } } } } else if ( num == CS_MUSIC ) { CG_StartMusic( qtrue ); } else if ( num == CS_SERVERINFO ) { CG_ParseServerinfo(); } else if ( num >= CS_MODELS && num < CS_MODELS+MAX_MODELS ) { cgs.model_draw[ num-CS_MODELS ] = cgi_R_RegisterModel( str ); // OutputDebugString(va("### CG_ConfigStringModified(): cgs.model_draw[%d] = \"%s\"\n",num-CS_MODELS,str)); // GHOUL2 Insert start } else if ( num >= CS_CHARSKINS && num < CS_CHARSKINS+MAX_CHARSKINS ) { cgs.skins[ num-CS_CHARSKINS ] = cgi_R_RegisterSkin( str ); // Ghoul2 Insert end } else if ( num >= CS_SOUNDS && num < CS_SOUNDS+MAX_SOUNDS ) { if ( str[0] != '*' ) { cgs.sound_precache[ num-CS_SOUNDS] = cgi_S_RegisterSound( str ); } } else if ( num >= CS_EFFECTS && num < CS_EFFECTS + MAX_FX ) { theFxScheduler.RegisterEffect( str ); } else if ( num >= CS_PLAYERS && num < CS_PLAYERS+MAX_CLIENTS ) { CG_NewClientinfo( num - CS_PLAYERS ); CG_RegisterClientModels( num - CS_PLAYERS ); } else if ( num >= CS_LIGHT_STYLES && num < CS_LIGHT_STYLES + (MAX_LIGHT_STYLES*3)) { CG_SetLightstyle(num - CS_LIGHT_STYLES); } else if ( num >= CS_WORLD_FX && num < CS_WORLD_FX + MAX_WORLD_FX ) { cgi_R_WorldEffectCommand( str ); } }
/* ================ CG_ConfigStringModified ================ */ static void CG_ConfigStringModified( void ) { const char* str; int num; num = atoi( CG_Argv( 1 ) ); // get the gamestate from the client system, which will have the // new configstring already integrated g_client->GetGameState( &cgs.gameState ); // look up the individual string that was modified str = CG_ConfigString( num ); // do something with it if necessary if ( num == CS_SERVERINFO ) { CG_ParseServerinfo(); } else if ( num == CS_WORLD_SKYMATERIAL ) { rf->setSkyMaterial( str ); } else if ( num == CS_WORLD_WATERLEVEL ) { rf->setWaterLevel( str ); } else if ( num == CS_WORLD_FARPLANE ) { cg.farPlane = atof( str ); } else if ( num >= CS_MODELS && num < CS_MODELS + MAX_MODELS ) { cgs.gameModels[ num - CS_MODELS ] = rf->registerModel( str ); } else if ( num >= CS_ANIMATIONS && num < CS_ANIMATIONS + MAX_ANIMATIONS ) { cgs.gameAnims[ num - CS_ANIMATIONS ] = rf->registerAnimation_getAPI( str ); } else if ( num >= CS_RAGDOLLDEFSS && num < CS_RAGDOLLDEFSS + MAX_RAGDOLLDEFS ) { cgs.gameAFs[ num - CS_RAGDOLLDEFSS ] = g_declMgr->registerAFDecl( str ); } else if ( num >= CS_COLLMODELS && num < CS_MODELS + MAX_MODELS ) { cgs.gameCollModels[ num - CS_COLLMODELS ] = cm->registerModel( str ); } else if ( num >= CS_SOUNDS && num < CS_SOUNDS + MAX_SOUNDS ) { // cgs.gameSounds[ num-CS_SOUNDS] = 0;//trap_S_RegisterSound( str, false ); } else if ( num >= CS_SKINS && num < CS_SKINS + MAX_SKINS ) { //cgs.gameSkins[ num-CS_SKINS] = rf->registerSkin(str); } else if ( num >= CS_MATERIALS && num < CS_MATERIALS + MAX_MATERIALS ) { cgs.gameMaterials[ num - CS_MATERIALS] = rf->registerMaterial( str ); } }
/* ================ CG_ConfigStringModified ================ */ static void CG_ConfigStringModified(void) { const char *str; int num; num = atoi(CG_Argv(1)); // get the gamestate from the client system, which will have the // new configstring already integrated trap_GetGameState(&cgs.gameState); // look up the individual string that was modified str = CG_ConfigString(num); // do something with it if necessary if(num == CS_MUSIC) { CG_StartMusic(); } else if(num == CS_SERVERINFO) { CG_ParseServerinfo(); } else if(num == CS_WARMUP) { CG_ParseWarmup(); } else if(num == CS_SCORES1) { cgs.scores1 = atoi(str); } else if(num == CS_SCORES2) { cgs.scores2 = atoi(str); } else if(num == CS_LEVEL_START_TIME) { cgs.levelStartTime = atoi(str); } else if(num == CS_VOTE_TIME) { cgs.voteTime = atoi(str); cgs.voteModified = qtrue; } else if(num == CS_VOTE_YES) { cgs.voteYes = atoi(str); cgs.voteModified = qtrue; } else if(num == CS_VOTE_NO) { cgs.voteNo = atoi(str); cgs.voteModified = qtrue; } else if(num == CS_VOTE_STRING) { Q_strncpyz(cgs.voteString, str, sizeof(cgs.voteString)); trap_S_StartLocalSound(cgs.media.voteNow, CHAN_ANNOUNCER); } else if(num >= CS_TEAMVOTE_TIME && num <= CS_TEAMVOTE_TIME + 1) { cgs.teamVoteTime[num - CS_TEAMVOTE_TIME] = atoi(str); cgs.teamVoteModified[num - CS_TEAMVOTE_TIME] = qtrue; } else if(num >= CS_TEAMVOTE_YES && num <= CS_TEAMVOTE_YES + 1) { cgs.teamVoteYes[num - CS_TEAMVOTE_YES] = atoi(str); cgs.teamVoteModified[num - CS_TEAMVOTE_YES] = qtrue; } else if(num >= CS_TEAMVOTE_NO && num <= CS_TEAMVOTE_NO + 1) { cgs.teamVoteNo[num - CS_TEAMVOTE_NO] = atoi(str); cgs.teamVoteModified[num - CS_TEAMVOTE_NO] = qtrue; } else if(num >= CS_TEAMVOTE_STRING && num <= CS_TEAMVOTE_STRING + 1) { Q_strncpyz(cgs.teamVoteString[num - CS_TEAMVOTE_STRING], str, sizeof(cgs.teamVoteString)); trap_S_StartLocalSound(cgs.media.voteNow, CHAN_ANNOUNCER); } else if(num == CS_INTERMISSION) { cg.intermissionStarted = atoi(str); } else if(num >= CS_MODELS && num < CS_MODELS + MAX_MODELS) { cgs.gameModels[num - CS_MODELS] = trap_R_RegisterModel(str, qtrue); } else if(num >= CS_SOUNDS && num < CS_SOUNDS + MAX_SOUNDS) { if(str[0] != '*') { // player specific sounds don't register here cgs.gameSounds[num - CS_SOUNDS] = trap_S_RegisterSound(str); } } else if(num >= CS_PLAYERS && num < CS_PLAYERS + MAX_CLIENTS) { CG_NewClientInfo(num - CS_PLAYERS); CG_BuildSpectatorString(); } else if(num == CS_FLAGSTATUS) { if(cgs.gametype == GT_CTF) { // format is rb where its red/blue, 0 is at base, 1 is taken, 2 is dropped cgs.redflag = str[0] - '0'; cgs.blueflag = str[1] - '0'; } else if(cgs.gametype == GT_1FCTF) { cgs.flagStatus = str[0] - '0'; } } else if(num == CS_SHADERSTATE) { CG_ShaderStateChanged(); } }
static void CG_ConfigStringModified( void ) { const char *str; int num; num = atoi( CG_Argv( 1 ) ); // get the gamestate from the client system, which will have the // new configstring already integrated trap->GetGameState( &cgs.gameState ); // look up the individual string that was modified str = CG_ConfigString( num ); // do something with it if necessary if ( num == CS_MUSIC ) { CG_StartMusic( qtrue ); } else if ( num == CS_SERVERINFO ) { CG_ParseServerinfo(); } else if ( num == CS_WARMUP ) { CG_ParseWarmup(); } else if ( num == CS_SCORES1 ) { cgs.scores1 = atoi( str ); } else if ( num == CS_SCORES2 ) { cgs.scores2 = atoi( str ); } else if ( num == CS_CLIENT_JEDIMASTER ) { cgs.jediMaster = atoi ( str ); } else if ( num == CS_CLIENT_DUELWINNER ) { cgs.duelWinner = atoi ( str ); } else if ( num == CS_CLIENT_DUELISTS ) { char buf[64]; int c = 0; int i = 0; while (str[i] && str[i] != '|') { buf[c] = str[i]; c++; i++; } buf[c] = 0; cgs.duelist1 = atoi ( buf ); c = 0; i++; while (str[i] && str[i] != '|') { buf[c] = str[i]; c++; i++; } buf[c] = 0; cgs.duelist2 = atoi ( buf ); if (str[i]) { c = 0; i++; while (str[i]) { buf[c] = str[i]; c++; i++; } buf[c] = 0; cgs.duelist3 = atoi(buf); } } else if ( num == CS_CLIENT_DUELHEALTHS ) { // nmckenzie: DUEL_HEALTH SetDuelistHealthsFromConfigString(str); } else if ( num == CS_LEVEL_START_TIME ) { cgs.levelStartTime = atoi( str ); } else if ( num == CS_VOTE_TIME ) { cgs.voteTime = atoi( str ); cgs.voteModified = qtrue; } else if ( num == CS_VOTE_YES ) { cgs.voteYes = atoi( str ); cgs.voteModified = qtrue; } else if ( num == CS_VOTE_NO ) { cgs.voteNo = atoi( str ); cgs.voteModified = qtrue; } else if ( num == CS_VOTE_STRING ) { Q_strncpyz( cgs.voteString, str, sizeof( cgs.voteString ) ); } else if ( num >= CS_TEAMVOTE_TIME && num <= CS_TEAMVOTE_TIME + 1) { cgs.teamVoteTime[num-CS_TEAMVOTE_TIME] = atoi( str ); cgs.teamVoteModified[num-CS_TEAMVOTE_TIME] = qtrue; } else if ( num >= CS_TEAMVOTE_YES && num <= CS_TEAMVOTE_YES + 1) { cgs.teamVoteYes[num-CS_TEAMVOTE_YES] = atoi( str ); cgs.teamVoteModified[num-CS_TEAMVOTE_YES] = qtrue; } else if ( num >= CS_TEAMVOTE_NO && num <= CS_TEAMVOTE_NO + 1) { cgs.teamVoteNo[num-CS_TEAMVOTE_NO] = atoi( str ); cgs.teamVoteModified[num-CS_TEAMVOTE_NO] = qtrue; } else if ( num >= CS_TEAMVOTE_STRING && num <= CS_TEAMVOTE_STRING + 1) { Q_strncpyz( cgs.teamVoteString[num-CS_TEAMVOTE_STRING], str, sizeof( cgs.teamVoteString ) ); } else if ( num == CS_INTERMISSION ) { cg.intermissionStarted = atoi( str ); } else if ( num >= CS_MODELS && num < CS_MODELS+MAX_MODELS ) { char modelName[MAX_QPATH]; strcpy(modelName, str); if (strstr(modelName, ".glm") || modelName[0] == '$') { //Check to see if it has a custom skin attached. CG_HandleAppendedSkin(modelName); CG_CacheG2AnimInfo(modelName); } if (modelName[0] != '$' && modelName[0] != '@') { //don't register vehicle names and saber names as models. cgs.gameModels[ num-CS_MODELS ] = trap->R_RegisterModel( modelName ); } else { cgs.gameModels[ num-CS_MODELS ] = 0; } // GHOUL2 Insert start /* } else if ( num >= CS_CHARSKINS && num < CS_CHARSKINS+MAX_CHARSKINS ) { cgs.skins[ num-CS_CHARSKINS ] = trap->R_RegisterSkin( str ); */ //rww - removed and replaced with CS_G2BONES // Ghoul2 Insert end } else if ( num >= CS_SOUNDS && num < CS_SOUNDS+MAX_SOUNDS ) { if ( str[0] != '*' ) { // player specific sounds don't register here cgs.gameSounds[ num-CS_SOUNDS] = trap->S_RegisterSound( str ); } else if (str[1] == '$') { //an NPC soundset CG_PrecacheNPCSounds(str); } } else if ( num >= CS_EFFECTS && num < CS_EFFECTS+MAX_FX ) { if (str[0] == '*') { //it's a special global weather effect CG_ParseWeatherEffect(str); cgs.gameEffects[ num-CS_EFFECTS] = 0; } else { cgs.gameEffects[ num-CS_EFFECTS] = trap->FX_RegisterEffect( str ); } } else if ( num >= CS_SIEGE_STATE && num < CS_SIEGE_STATE+1 ) { if (str[0]) { CG_ParseSiegeState(str); } } else if ( num >= CS_SIEGE_WINTEAM && num < CS_SIEGE_WINTEAM+1 ) { if (str[0]) { cg_siegeWinTeam = atoi(str); } } else if ( num >= CS_SIEGE_OBJECTIVES && num < CS_SIEGE_OBJECTIVES+1 ) { CG_ParseSiegeObjectiveStatus(str); } else if (num >= CS_SIEGE_TIMEOVERRIDE && num < CS_SIEGE_TIMEOVERRIDE+1) { cg_beatingSiegeTime = atoi(str); CG_SetSiegeTimerCvar ( cg_beatingSiegeTime ); } else if ( num >= CS_PLAYERS && num < CS_PLAYERS+MAX_CLIENTS ) { CG_NewClientInfo( num - CS_PLAYERS, qtrue); CG_BuildSpectatorString(); } else if ( num == CS_FLAGSTATUS ) { if( cgs.gametype == GT_CTF || cgs.gametype == GT_CTY ) { // format is rb where its red/blue, 0 is at base, 1 is taken, 2 is dropped int redflagId = str[0] - '0', blueflagId = str[1] - '0'; if ( redflagId >= 0 && redflagId < ARRAY_LEN( ctfFlagStatusRemap ) ) cgs.redflag = ctfFlagStatusRemap[redflagId]; if ( blueflagId >= 0 && blueflagId < ARRAY_LEN( ctfFlagStatusRemap ) ) cgs.blueflag = ctfFlagStatusRemap[blueflagId]; } } else if ( num == CS_SHADERSTATE ) { CG_ShaderStateChanged(); } else if ( num >= CS_LIGHT_STYLES && num < CS_LIGHT_STYLES + (MAX_LIGHT_STYLES * 3)) { CG_SetLightstyle(num - CS_LIGHT_STYLES); } }
static void CG_ConfigStringModified(void) { const char *str; int num; num = atoi(BG_Argv(1)); // get the gamestate from the client system, which will have the // new configstring already integrated trap_GetGameState(&cgs.gameState); // look up the individual string that was modified str = CG_ConfigString(num); // do something with it if necessary if (num == CS_SERVERINFO) { CG_ParseServerinfo(); } else if (num == CS_WARMUP) { CG_SetWarmup(atoi(str)); } else if (num == CS_SCORES1) { cgs.scores1 = atoi(str); } else if (num == CS_SCORES2) { cgs.scores2 = atoi(str); } else if (num == CS_LEVEL_START_TIME) { cgs.levelStartTime = atoi(str); } else if (num == CS_VOTE_TIME) { if (!strcmp(str, "failed")) { cgs.voteTime = 0; CG_Printf("Vote failed.\n"); CG_AddBufferedSound(cgs.media.voteFailed); } else if (!strcmp(str, "passed")) { cgs.voteTime = 0; CG_Printf("Vote passed.\n"); CG_AddBufferedSound(cgs.media.votePassed); } else if (*str) { cgs.voteTime = atoi(str); CG_Printf("Vote cast.\n"); CG_AddBufferedSound(cgs.media.voteNow); } } else if (num == CS_VOTE_YES) { cgs.voteYes = atoi(str); trap_S_StartLocalSound(cgs.media.talkSound, CHAN_LOCAL_SOUND); } else if (num == CS_VOTE_NO) { cgs.voteNo = atoi(str); trap_S_StartLocalSound(cgs.media.talkSound, CHAN_LOCAL_SOUND); } else if (num == CS_VOTE_STRING) { Q_strncpyz(cgs.voteString, str, sizeof(cgs.voteString)); } else if (num == CS_INTERMISSION) { cg.intermissionStarted = atoi(str); } else if (num >= CS_MODELS && num < CS_MODELS+MAX_MODELS) { cgs.gameModels[num-CS_MODELS] = trap_R_RegisterModel(str); } else if (num >= CS_SOUNDS && num < CS_SOUNDS+MAX_SOUNDS) { if (str[0] != '*') { // player specific sounds don't register here cgs.gameSounds[num-CS_SOUNDS] = trap_S_RegisterSound(str, qfalse); } } else if (num >= CS_PLAYERS && num < CS_PLAYERS+MAX_CLIENTS) { CG_NewClientInfo(num - CS_PLAYERS); } else if (num == CS_FLAGSTATUS) { // format is rb where its red/blue, 0 is at base, 1 is taken, 2 is dropped if (cgs.gametype == GT_CTF) { team_t team; team = cgs.clientinfo[cg.clientNum].team; if ((cgs.redflag == 1 && str[0] - '0' == 2 && team == TEAM_RED) || (cgs.blueflag == 1 && str[1] - '0' == 2 && team == TEAM_BLUE)) { CG_CenterPrint("^2The enemy dropped your flag"); } else if ((cgs.redflag == 1 && str[0] - '0' == 2 && team == TEAM_BLUE) || (cgs.blueflag == 1 && str[1] - '0' == 2 && team == TEAM_RED)) { CG_CenterPrint("^1You team dropped the flag"); } cgs.redflag = str[0] - '0'; cgs.blueflag = str[1] - '0'; } } else if (num == CS_SHADERSTATE) { CG_ShaderStateChanged(); } else if (num == CS_ROUND_START) { cg.countdownCount = -1; cgs.roundStartTime = atoi(str); } else if (num == CS_LIVING_COUNT) { int newRed, newBlue; newRed = atoi(COM_Parse((char **) &str)); newBlue = atoi(COM_Parse((char **) &str)); if (!cgs.warmup && cg.time >= cgs.roundStartTime) { team_t team; team = cg.snap->ps.persistant[PERS_TEAM]; if ((newRed == 1 && cgs.redLivingCount != 1 && team == TEAM_RED) || (newBlue == 1 && cgs.blueLivingCount != 1 && team == TEAM_BLUE)) { CG_CenterPrint("You are the last in your team"); } } cgs.redLivingCount = newRed; cgs.blueLivingCount = newBlue; } else if (num == CS_OVERTIME) { cgs.overtimeStart = atoi(str); trap_S_StartLocalSound(cgs.media.protectSound, CHAN_ANNOUNCER); CG_CenterPrint(va("^3OVERTIME^7 - %d seconds added", cgs.overtimeLimit)); } else if (num >= CS_RESPAWN_TIMERS && num < CS_RESPAWN_TIMERS + MAX_RESPAWN_TIMERS) { CG_ParseRespawnTimer(num - CS_RESPAWN_TIMERS, str); } else if (num == CS_PAUSE_START) { cgs.pauseStart = atoi(str); if (cgs.pauseStart > 0) { trap_S_StartLocalSound(cgs.media.pauseSound, CHAN_LOCAL_SOUND); } } else if (num == CS_PAUSE_END) { cg.countdownCount = -1; cgs.pauseEnd = atoi(str); } else if (num == CS_PAUSE_TIME) { cgs.pauseTime = atoi(str); } }
/* ================= CG_Init Called after every level change or subsystem restart Will perform callbacks to make the loading info screen update. ================= */ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) { const char *s; // clear everything memset( &cgs, 0, sizeof( cgs ) ); memset( &cg, 0, sizeof( cg ) ); memset( cg_entities, 0, sizeof(cg_entities) ); memset( cg_weapons, 0, sizeof(cg_weapons) ); cg.clientNum = clientNum; cgs.processedSnapshotNum = serverMessageNum; cgs.serverCommandSequence = serverCommandSequence; // load a few needed things before we do any screen updates cgs.media.charsetShader = trap_R_RegisterShader( "interface/fonts/font0.png" ); cgs.media.whiteShader = trap_R_RegisterShader( "white" ); cgs.media.clearShader = trap_R_RegisterShader( "clear" ); cgs.media.charsetProp = trap_R_RegisterShaderNoMip( "interface/fonts/font1.png" ); cgs.media.charsetPropGlow = trap_R_RegisterShaderNoMip( "interface/fonts/font1Glow.png" ); cgs.media.charsetPropB = trap_R_RegisterShaderNoMip( "interface/fonts/font2.png" ); CG_RegisterCvars(); CG_InitConsoleCommands(); cg.weaponSelect = 1; // get the rendering configuration from the client system trap_GetGlconfig( &cgs.glconfig ); cgs.screenXScale = cgs.glconfig.vidWidth / 640.0; cgs.screenYScale = cgs.glconfig.vidHeight / 480.0; // get the gamestate from the client system trap_GetGameState( &cgs.gameState ); // check version s = CG_ConfigString( CS_PRODUCT_VERSION ); if ( strcmp( s, PRODUCT_VERSION ) ) { CG_Error( "Client/Server game mismatch: %s/%s", PRODUCT_VERSION, s ); } s = CG_ConfigString( CS_LEVEL_START_TIME ); cgs.levelStartTime = atoi( s ); CG_ParseServerinfo(); // load the new map CG_LoadingString( "collision map" ); trap_CM_LoadMap( cgs.mapname ); cg.loading = qtrue; // force players to load instead of defer CG_LoadingString( "sounds" ); CG_RegisterSounds(); CG_LoadingString( "graphics" ); CG_RegisterGraphics(); CG_LoadingString( "clients" ); CG_RegisterClients(); // if low on memory, some clients will be deferred cg.loading = qfalse; // future players will be deferred CG_InitLocalEntities(); // ADDING FOR ZEQ2 CG_FrameHist_Init(); CG_InitTrails(); CG_InitParticleSystems(); CG_InitBeamTables(); CG_InitRadarBlips(); // END ADDING CG_InitMarkPolys(); // remove the last loading update cg.infoScreenText[0] = 0; // Make sure we have update values (scores) CG_SetConfigValues(); CG_LoadingString( "" ); CG_ShaderStateChanged(); trap_S_ClearLoopingSounds( qtrue ); }
/* ================= CG_Init Called after every level change or subsystem restart Will perform callbacks to make the loading info screen update. ================= */ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) { const char *s; // clear everything memset( &cgs, 0, sizeof( cgs ) ); memset( &cg, 0, sizeof( cg ) ); memset( cg_entities, 0, sizeof(cg_entities) ); memset( cg_weapons, 0, sizeof(cg_weapons) ); memset( cg_items, 0, sizeof(cg_items) ); cg.clientNum = clientNum; cgs.processedSnapshotNum = serverMessageNum; cgs.serverCommandSequence = serverCommandSequence; // load a few needed things before we do any screen updates cgs.media.charsetShader = trap_R_RegisterShader( "gfx/2d/bigchars" ); cgs.media.whiteShader = trap_R_RegisterShader( "white" ); cgs.media.charsetProp = trap_R_RegisterShaderNoMip( "menu/art/font1_prop.tga" ); cgs.media.charsetPropGlow = trap_R_RegisterShaderNoMip( "menu/art/font1_prop_glo.tga" ); cgs.media.charsetPropB = trap_R_RegisterShaderNoMip( "menu/art/font2_prop.tga" ); CG_RegisterCvars(); CG_InitConsoleCommands(); cg.weaponSelect = WP_MACHINEGUN; cgs.redflag = cgs.blueflag = -1; // For compatibily, default to unset for cgs.flagStatus = -1; // old servers // get the rendering configuration from the client system trap_GetGlconfig( &cgs.glconfig ); cgs.screenXScale = cgs.glconfig.vidWidth / 640.0; cgs.screenYScale = cgs.glconfig.vidHeight / 480.0; // get the gamestate from the client system trap_GetGameState( &cgs.gameState ); // check version s = CG_ConfigString( CS_GAME_VERSION ); if ( strcmp( s, GAME_VERSION ) ) { CG_Error( "Client/Server game mismatch: %s/%s", GAME_VERSION, s ); } s = CG_ConfigString( CS_LEVEL_START_TIME ); cgs.levelStartTime = atoi( s ); CG_ParseServerinfo(); // load the new map CG_LoadingString( "collision map" ); trap_CM_LoadMap( cgs.mapname ); cg.loading = qtrue; // force players to load instead of defer CG_LoadingString( "sounds" ); CG_RegisterSounds(); CG_LoadingString( "graphics" ); CG_RegisterGraphics(); CG_LoadingString( "clients" ); CG_RegisterClients(); // if low on memory, some clients will be deferred cg.loading = qfalse; // future players will be deferred CG_InitLocalEntities(); CG_InitMarkPolys(); // remove the last loading update cg.infoScreenText[0] = 0; // Make sure we have update values (scores) CG_SetConfigValues(); CG_StartMusic(); CG_LoadingString( "" ); CG_ShaderStateChanged(); trap_S_ClearLoopingSounds( qtrue ); }
/* ================ CG_ConfigStringModified ================ */ static void CG_ConfigStringModified( void ) { const char *str; int num; num = atoi( CG_Argv( 1 ) ); // get the gamestate from the client system, which will have the // new configstring already integrated trap_GetGameState( &cgs.gameState ); // look up the individual string that was modified str = CG_ConfigString( num ); // do something with it if necessary if ( num == CS_MUSIC ) { CG_StartMusic(); } else if ( num == CS_SERVERINFO ) { CG_ParseServerinfo(); } else if ( num == CS_WARMUP ) { CG_ParseWarmup(); } else if ( num == CS_ALIEN_STAGES ) { stage_t oldAlienStage = cgs.alienStage; if ( str[ 0 ] ) { sscanf( str, "%d %d %d", &cgs.alienStage, &cgs.alienCredits, &cgs.alienNextStageThreshold ); if ( cgs.alienStage != oldAlienStage ) { CG_AnnounceAlienStageTransition( oldAlienStage, cgs.alienStage ); } } else { cgs.alienStage = cgs.alienCredits = cgs.alienNextStageThreshold = 0; } } else if ( num == CS_HUMAN_STAGES ) { stage_t oldHumanStage = cgs.humanStage; if ( str[ 0 ] ) { sscanf( str, "%d %d %d", &cgs.humanStage, &cgs.humanCredits, &cgs.humanNextStageThreshold ); if ( cgs.humanStage != oldHumanStage ) { CG_AnnounceHumanStageTransition( oldHumanStage, cgs.humanStage ); } } else { cgs.humanStage = cgs.humanCredits = cgs.humanNextStageThreshold = 0; } } else if ( num == CS_LEVEL_START_TIME ) { cgs.levelStartTime = atoi( str ); } else if ( num >= CS_VOTE_TIME && num < CS_VOTE_TIME + NUM_TEAMS ) { cgs.voteTime[ num - CS_VOTE_TIME ] = atoi( str ); cgs.voteModified[ num - CS_VOTE_TIME ] = qtrue; if ( num - CS_VOTE_TIME == TEAM_NONE ) { trap_Cvar_Set( "ui_voteActive", cgs.voteTime[ TEAM_NONE ] ? "1" : "0" ); } else if ( num - CS_VOTE_TIME == TEAM_ALIENS ) { trap_Cvar_Set( "ui_alienTeamVoteActive", cgs.voteTime[ TEAM_ALIENS ] ? "1" : "0" ); } else if ( num - CS_VOTE_TIME == TEAM_HUMANS ) { trap_Cvar_Set( "ui_humanTeamVoteActive", cgs.voteTime[ TEAM_HUMANS ] ? "1" : "0" ); } } else if ( num >= CS_VOTE_YES && num < CS_VOTE_YES + NUM_TEAMS ) { cgs.voteYes[ num - CS_VOTE_YES ] = atoi( str ); cgs.voteModified[ num - CS_VOTE_YES ] = qtrue; } else if ( num >= CS_VOTE_NO && num < CS_VOTE_NO + NUM_TEAMS ) { cgs.voteNo[ num - CS_VOTE_NO ] = atoi( str ); cgs.voteModified[ num - CS_VOTE_NO ] = qtrue; } else if ( num >= CS_VOTE_STRING && num < CS_VOTE_STRING + NUM_TEAMS ) { Q_strncpyz( cgs.voteString[ num - CS_VOTE_STRING ], str, sizeof( cgs.voteString[ num - CS_VOTE_STRING ] ) ); } else if ( num >= CS_VOTE_CALLER && num < CS_VOTE_CALLER + NUM_TEAMS ) { Q_strncpyz( cgs.voteCaller[ num - CS_VOTE_CALLER ], str, sizeof( cgs.voteCaller[ num - CS_VOTE_CALLER ] ) ); } else if ( num == CS_INTERMISSION ) { cg.intermissionStarted = atoi( str ); } else if ( num >= CS_MODELS && num < CS_MODELS + MAX_MODELS ) { cgs.gameModels[ num - CS_MODELS ] = trap_R_RegisterModel( str ); } else if ( num >= CS_SHADERS && num < CS_SHADERS + MAX_GAME_SHADERS ) { cgs.gameShaders[ num - CS_SHADERS ] = trap_R_RegisterShader( str ); } else if ( num >= CS_PARTICLE_SYSTEMS && num < CS_PARTICLE_SYSTEMS + MAX_GAME_PARTICLE_SYSTEMS ) { cgs.gameParticleSystems[ num - CS_PARTICLE_SYSTEMS ] = CG_RegisterParticleSystem( ( char * ) str ); } else if ( num >= CS_SOUNDS && num < CS_SOUNDS + MAX_SOUNDS ) { if ( str[ 0 ] != '*' ) { // player specific sounds don't register here cgs.gameSounds[ num - CS_SOUNDS ] = trap_S_RegisterSound( str, qfalse ); } } else if ( num >= CS_PLAYERS && num < CS_PLAYERS + MAX_CLIENTS ) { CG_NewClientInfo( num - CS_PLAYERS ); CG_BuildSpectatorString(); } else if ( num == CS_WINNER ) { trap_Cvar_Set( "ui_winner", str ); } else if ( num == CS_SHADERSTATE ) { CG_ShaderStateChanged(); } }
/* ================ CG_ConfigStringModified ================ */ static void CG_ConfigStringModified( void ) { const char *str; int num; num = atoi( CG_Argv( 1 ) ); // get the gamestate from the client system, which will have the // new configstring already integrated trap_GetGameState( &cgs.gameState ); // look up the individual string that was modified str = CG_ConfigString( num ); // do something with it if necessary if ( num == CS_MUSIC ) { CG_StartMusic( qtrue ); } else if ( num == CS_SERVERINFO ) { CG_ParseServerinfo(); } else if ( num == CS_WARMUP ) { CG_ParseWarmup(); } else if ( num == CS_SCORES1 ) { cgs.scores1 = atoi( str ); } else if ( num == CS_SCORES2 ) { cgs.scores2 = atoi( str ); } else if ( num == CS_CLIENT_JEDIMASTER ) { cgs.jediMaster = atoi ( str ); } else if ( num == CS_CLIENT_DUELWINNER ) { cgs.duelWinner = atoi ( str ); } else if ( num == CS_CLIENT_DUELISTS ) { char buf[64]; int c = 0; int i = 0; while (str[i] && str[i] != '|') { buf[c] = str[i]; c++; i++; } buf[c] = 0; cgs.duelist1 = atoi ( buf ); c = 0; i++; while (str[i]) { buf[c] = str[i]; c++; i++; } buf[c] = 0; cgs.duelist2 = atoi ( buf ); } else if ( num == CS_LEVEL_START_TIME ) { cgs.levelStartTime = atoi( str ); } else if ( num == CS_VOTE_TIME ) { cgs.voteTime = atoi( str ); cgs.voteModified = qtrue; } else if ( num == CS_VOTE_YES ) { cgs.voteYes = atoi( str ); cgs.voteModified = qtrue; } else if ( num == CS_VOTE_NO ) { cgs.voteNo = atoi( str ); cgs.voteModified = qtrue; } else if ( num == CS_VOTE_STRING ) { Q_strncpyz( cgs.voteString, str, sizeof( cgs.voteString ) ); } else if ( num >= CS_TEAMVOTE_TIME && num <= CS_TEAMVOTE_TIME + 1) { cgs.teamVoteTime[num-CS_TEAMVOTE_TIME] = atoi( str ); cgs.teamVoteModified[num-CS_TEAMVOTE_TIME] = qtrue; } else if ( num >= CS_TEAMVOTE_YES && num <= CS_TEAMVOTE_YES + 1) { cgs.teamVoteYes[num-CS_TEAMVOTE_YES] = atoi( str ); cgs.teamVoteModified[num-CS_TEAMVOTE_YES] = qtrue; } else if ( num >= CS_TEAMVOTE_NO && num <= CS_TEAMVOTE_NO + 1) { cgs.teamVoteNo[num-CS_TEAMVOTE_NO] = atoi( str ); cgs.teamVoteModified[num-CS_TEAMVOTE_NO] = qtrue; } else if ( num >= CS_TEAMVOTE_STRING && num <= CS_TEAMVOTE_STRING + 1) { Q_strncpyz( cgs.teamVoteString[num-CS_TEAMVOTE_STRING], str, sizeof( cgs.teamVoteString ) ); } else if ( num == CS_INTERMISSION ) { cg.intermissionStarted = atoi( str ); } else if ( num >= CS_MODELS && num < CS_MODELS+MAX_MODELS ) { cgs.gameModels[ num-CS_MODELS ] = trap_R_RegisterModel( str ); // GHOUL2 Insert start } else if ( num >= CS_CHARSKINS && num < CS_CHARSKINS+MAX_CHARSKINS ) { cgs.skins[ num-CS_CHARSKINS ] = trap_R_RegisterSkin( str ); // Ghoul2 Insert end } else if ( num >= CS_SOUNDS && num < CS_SOUNDS+MAX_SOUNDS ) { if ( str[0] != '*' ) { // player specific sounds don't register here cgs.gameSounds[ num-CS_SOUNDS] = trap_S_RegisterSound( str ); } } else if ( num >= CS_EFFECTS && num < CS_SOUNDS+MAX_SOUNDS ) { if ( str[0] != '*' ) { // player specific sounds don't register here cgs.gameEffects[ num-CS_EFFECTS] = trap_FX_RegisterEffect( str ); } } else if ( num >= CS_PLAYERS && num < CS_PLAYERS+MAX_CLIENTS ) { CG_NewClientInfo( num - CS_PLAYERS, qtrue); CG_BuildSpectatorString(); } else if ( num == CS_FLAGSTATUS ) { if( cgs.gametype == GT_CTF || cgs.gametype == GT_CTY ) { // format is rb where its red/blue, 0 is at base, 1 is taken, 2 is dropped cgs.redflag = str[0] - '0'; cgs.blueflag = str[1] - '0'; } } else if ( num == CS_SHADERSTATE ) { CG_ShaderStateChanged(); } else if ( num >= CS_LIGHT_STYLES && num < CS_LIGHT_STYLES + (MAX_LIGHT_STYLES * 3)) { CG_SetLightstyle(num - CS_LIGHT_STYLES); } }
/* ================= CG_Init Called after every level change or subsystem restart Will perform callbacks to make the loading info screen update. ================= */ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) { const char* s; // clear everything memset( &cgs, 0, sizeof( cgs ) ); memset( &cg, 0, sizeof( cg ) ); memset( cg_entities, 0, sizeof( cg_entities ) ); if ( g_loadingScreen ) // update loading screen (if its present) { g_loadingScreen->addLoadingString( "CG_Init: clientNum %i\n", clientNum ); } cg.clientNum = clientNum; cgs.processedSnapshotNum = serverMessageNum; cgs.serverCommandSequence = serverCommandSequence; // load a few needed things before we do any screen updates cgs.media.charsetShader = rf->registerMaterial( "gfx/2d/bigchars" ); cgs.media.whiteShader = rf->registerMaterial( "white" ); // init cgame console variables AUTOCVAR_RegisterAutoCvars(); CG_RegisterCvars(); // init console commands AUTOCMD_RegisterAutoConsoleCommands(); // get the rendering configuration from the client system cgs.screenXScale = rf->getWinWidth() / 640.0; cgs.screenYScale = rf->getWinHeight() / 480.0; // get the gamestate from the client system g_client->GetGameState( &cgs.gameState ); // check version s = CG_ConfigString( CS_GAME_VERSION ); if ( strcmp( s, GAME_VERSION ) ) { CG_Error( "Client/Server game mismatch: %s/%s", GAME_VERSION, s ); } s = CG_ConfigString( CS_LEVEL_START_TIME ); cgs.levelStartTime = atoi( s ); s = CG_ConfigString( CS_WORLD_SKYMATERIAL ); if ( s && s[0] ) { rf->setSkyMaterial( s ); } s = CG_ConfigString( CS_WORLD_WATERLEVEL ); if ( s && s[0] ) { rf->setWaterLevel( s ); } s = CG_ConfigString( CS_WORLD_FARPLANE ); if ( s && s[0] ) { cg.farPlane = atof( s ); } CG_ParseServerinfo(); // clear any references to old media rf->clearEntities(); //trap_R_ClearScene(); if ( g_loadingScreen ) // update loading screen (if its present) { g_loadingScreen->addLoadingString( "CG_Init: loading world map \"%s\"...", cgs.mapname ); } // load world map first so inline models are present when requested rf->loadWorldMap( cgs.mapname ); if ( g_loadingScreen ) // update loading screen (if its present) { g_loadingScreen->addLoadingString( "done.\n" ); } if ( g_loadingScreen ) // update loading screen (if its present) { g_loadingScreen->addLoadingString( "CG_Init: registering render models..." ); } u32 c_renderModelsLoaded = 0; for ( u32 i = 0; i < MAX_MODELS; i++ ) { const char* str = CG_ConfigString( CS_MODELS + i ); if ( str && str[0] ) { cgs.gameModels[i] = rf->registerModel( str ); c_renderModelsLoaded++; } } if ( g_loadingScreen ) // update loading screen (if its present) { g_loadingScreen->addLoadingString( " %i rModels\n", c_renderModelsLoaded ); g_loadingScreen->addLoadingString( "CG_Init: registering skins..." ); } u32 c_renderSkinsLoaded = 0; for ( u32 i = 0; i < MAX_SKINS; i++ ) { const char* str = CG_ConfigString( CS_SKINS + i ); if ( str && str[0] ) { //cgs.gameSkins[i] = rf->registerSkin(str); c_renderSkinsLoaded++; } } if ( g_loadingScreen ) // update loading screen (if its present) { g_loadingScreen->addLoadingString( " %i rSkins\n", c_renderSkinsLoaded ); g_loadingScreen->addLoadingString( "CG_Init: registering animations..." ); } u32 c_animationsLoaded = 0; for ( u32 i = 0; i < MAX_ANIMATIONS; i++ ) { const char* str = CG_ConfigString( CS_ANIMATIONS + i ); if ( str && str[0] ) { cgs.gameAnims[i] = rf->registerAnimation_getAPI( str ); c_animationsLoaded++; } } if ( g_loadingScreen ) // update loading screen (if its present) { g_loadingScreen->addLoadingString( " %i animations\n", c_animationsLoaded ); g_loadingScreen->addLoadingString( "CG_Init: registering articulated figures decls..." ); } u32 c_afsLoaded = 0; for ( u32 i = 0; i < MAX_RAGDOLLDEFS; i++ ) { const char* str = CG_ConfigString( CS_RAGDOLLDEFSS + i ); if ( str && str[0] ) { cgs.gameAFs[i] = g_declMgr->registerAFDecl( str ); c_afsLoaded++; } } if ( g_loadingScreen ) // update loading screen (if its present) { g_loadingScreen->addLoadingString( " %i AFs\n", c_afsLoaded ); g_loadingScreen->addLoadingString( "CG_Init: registering collision models..." ); } u32 c_collisionModelsLoaded = 0; for ( u32 i = 0; i < MAX_MODELS; i++ ) { const char* str = CG_ConfigString( CS_COLLMODELS + i ); if ( str && str[0] ) { cgs.gameCollModels[i] = cm->registerModel( str ); c_collisionModelsLoaded++; } } if ( g_loadingScreen ) // update loading screen (if its present) { g_loadingScreen->addLoadingString( " %i cmModels\n", c_collisionModelsLoaded ); g_loadingScreen->addLoadingString( "CG_Init: registering materials..." ); } u32 c_renderMaterialsLoaded = 0; for ( u32 i = 0; i < MAX_MATERIALS; i++ ) { const char* str = CG_ConfigString( CS_MATERIALS + i ); if ( str && str[0] ) { cgs.gameMaterials[i] = rf->registerMaterial( str ); c_renderMaterialsLoaded++; } } if ( g_loadingScreen ) // update loading screen (if its present) { g_loadingScreen->addLoadingString( " %i materials\n", c_renderMaterialsLoaded ); g_loadingScreen->addLoadingString( "CG_Init: registering sounds..." ); } u32 c_soundsLoaded = 0; for ( u32 i = 0; i < MAX_SOUNDS; i++ ) { const char* str = CG_ConfigString( CS_SOUNDS + i ); if ( str && str[0] ) { // cgs.gameSounds[i] = 0;//snd->registerSound(str); c_soundsLoaded++; } } if ( g_loadingScreen ) // update loading screen (if its present) { g_loadingScreen->addLoadingString( " %i sounds\n", c_soundsLoaded ); } // cg.loading = false; // future players will be deferred }
/* ================ CG_ConfigStringModified ================ */ static void CG_ConfigStringModified() { const char *str; int num; // update the config string state with the new data, keeping in sync // with the config strings in the engine. // The engine already checked the inputs num = atoi( CG_Argv( 1 ) ); cgs.gameState[num] = CG_Argv(2); // look up the individual string that was modified str = CG_ConfigString( num ); //CG_Printf("configstring modification %i: %s\n", num, str); // do something with it if necessary if ( num == CS_MUSIC ) { CG_StartMusic(); } else if ( num == CS_SERVERINFO ) { CG_ParseServerinfo(); } else if ( num == CS_WARMUP ) { CG_ParseWarmup(); } else if ( num == CS_LEVEL_START_TIME ) { cgs.levelStartTime = atoi( str ); } else if ( num >= CS_VOTE_TIME && num < CS_VOTE_TIME + NUM_TEAMS ) { cgs.voteTime[ num - CS_VOTE_TIME ] = atoi( str ); cgs.voteModified[ num - CS_VOTE_TIME ] = true; if ( num - CS_VOTE_TIME == TEAM_NONE ) { trap_Cvar_Set( "ui_voteActive", cgs.voteTime[ TEAM_NONE ] ? "1" : "0" ); } else if ( num - CS_VOTE_TIME == TEAM_ALIENS ) { trap_Cvar_Set( "ui_alienTeamVoteActive", cgs.voteTime[ TEAM_ALIENS ] ? "1" : "0" ); } else if ( num - CS_VOTE_TIME == TEAM_HUMANS ) { trap_Cvar_Set( "ui_humanTeamVoteActive", cgs.voteTime[ TEAM_HUMANS ] ? "1" : "0" ); } } else if ( num >= CS_VOTE_YES && num < CS_VOTE_YES + NUM_TEAMS ) { cgs.voteYes[ num - CS_VOTE_YES ] = atoi( str ); cgs.voteModified[ num - CS_VOTE_YES ] = true; } else if ( num >= CS_VOTE_NO && num < CS_VOTE_NO + NUM_TEAMS ) { cgs.voteNo[ num - CS_VOTE_NO ] = atoi( str ); cgs.voteModified[ num - CS_VOTE_NO ] = true; } else if ( num >= CS_VOTE_STRING && num < CS_VOTE_STRING + NUM_TEAMS ) { Q_strncpyz( cgs.voteString[ num - CS_VOTE_STRING ], str, sizeof( cgs.voteString[ num - CS_VOTE_STRING ] ) ); } else if ( num >= CS_VOTE_CALLER && num < CS_VOTE_CALLER + NUM_TEAMS ) { Q_strncpyz( cgs.voteCaller[ num - CS_VOTE_CALLER ], str, sizeof( cgs.voteCaller[ num - CS_VOTE_CALLER ] ) ); } else if ( num == CS_INTERMISSION ) { cg.intermissionStarted = atoi( str ); if ( cg.intermissionStarted ) { Rocket_ShowScoreboard( "scoreboard", true ); } } else if ( num >= CS_MODELS && num < CS_MODELS + MAX_MODELS ) { cgs.gameModels[ num - CS_MODELS ] = trap_R_RegisterModel( str ); } else if ( num >= CS_SHADERS && num < CS_SHADERS + MAX_GAME_SHADERS ) { cgs.gameShaders[ num - CS_SHADERS ] = trap_R_RegisterShader(str, RSF_DEFAULT); } else if ( num >= CS_GRADING_TEXTURES && num < CS_GRADING_TEXTURES + MAX_GRADING_TEXTURES ) { CG_RegisterGrading( num - CS_GRADING_TEXTURES, str ); } else if ( num >= CS_PARTICLE_SYSTEMS && num < CS_PARTICLE_SYSTEMS + MAX_GAME_PARTICLE_SYSTEMS ) { cgs.gameParticleSystems[ num - CS_PARTICLE_SYSTEMS ] = CG_RegisterParticleSystem( ( char * ) str ); } else if ( num >= CS_SOUNDS && num < CS_SOUNDS + MAX_SOUNDS ) { if ( str[ 0 ] != '*' ) { // player specific sounds don't register here cgs.gameSounds[ num - CS_SOUNDS ] = trap_S_RegisterSound( str, false ); } } else if ( num >= CS_PLAYERS && num < CS_PLAYERS + MAX_CLIENTS ) { CG_NewClientInfo( num - CS_PLAYERS ); CG_BuildSpectatorString(); } else if ( num == CS_WINNER ) { trap_Cvar_Set( "ui_winner", str ); } else if ( num == CS_SHADERSTATE ) { CG_ShaderStateChanged(); } }
/* ================ CG_ConfigStringModified ================ */ static void CG_ConfigStringModified( void ) { const char *str; int num; num = atoi( CG_Argv( 1 ) ); // get the gamestate from the client system, which will have the // new configstring already integrated trap_GetGameState( &cgs.gameState ); // look up the individual string that was modified str = CG_ConfigString( num ); // do something with it if necessary if ( num == CS_MUSIC ) { CG_StartMusic(); } else if ( num == CS_MUSIC_QUEUE ) { //----(SA) added CG_QueueMusic(); } else if ( num == CS_MISSIONSTATS ) { //----(SA) added CG_ParseMissionStats(); } else if ( num == CS_SERVERINFO ) { CG_ParseServerinfo(); } else if ( num == CS_WARMUP ) { CG_ParseWarmup(); } else if ( num == CS_SCORES1 ) { cgs.scores1 = atoi( str ); } else if ( num == CS_SCORES2 ) { cgs.scores2 = atoi( str ); } else if ( num == CS_LEVEL_START_TIME ) { cgs.levelStartTime = atoi( str ); } else if ( num == CS_VOTE_TIME ) { cgs.voteTime = atoi( str ); cgs.voteModified = qtrue; } else if ( num == CS_VOTE_YES ) { cgs.voteYes = atoi( str ); cgs.voteModified = qtrue; } else if ( num == CS_VOTE_NO ) { cgs.voteNo = atoi( str ); cgs.voteModified = qtrue; } else if ( num == CS_VOTE_STRING ) { Q_strncpyz( cgs.voteString, str, sizeof( cgs.voteString ) ); #if 0 trap_S_StartLocalSound( cgs.media.voteNow, CHAN_ANNOUNCER ); } else if ( num >= CS_TEAMVOTE_TIME && num <= CS_TEAMVOTE_TIME + 1 ) { cgs.teamVoteTime[num - CS_TEAMVOTE_TIME] = atoi( str ); cgs.teamVoteModified[num - CS_TEAMVOTE_TIME] = qtrue; } else if ( num >= CS_TEAMVOTE_YES && num <= CS_TEAMVOTE_YES + 1 ) { cgs.teamVoteYes[num - CS_TEAMVOTE_YES] = atoi( str ); cgs.teamVoteModified[num - CS_TEAMVOTE_YES] = qtrue; } else if ( num >= CS_TEAMVOTE_NO && num <= CS_TEAMVOTE_NO + 1 ) { cgs.teamVoteNo[num - CS_TEAMVOTE_NO] = atoi( str ); cgs.teamVoteModified[num - CS_TEAMVOTE_NO] = qtrue; } else if ( num >= CS_TEAMVOTE_STRING && num <= CS_TEAMVOTE_STRING + 1 ) { Q_strncpyz( cgs.teamVoteString[num - CS_TEAMVOTE_STRING], str, sizeof( cgs.teamVoteString ) ); trap_S_StartLocalSound( cgs.media.voteNow, CHAN_ANNOUNCER ); #endif } else if ( num == CS_INTERMISSION ) { cg.intermissionStarted = atoi( str ); } else if ( num == CS_SCREENFADE ) { CG_ParseScreenFade(); } else if ( num == CS_FOGVARS ) { CG_ParseFog(); } else if ( num >= CS_MODELS && num < CS_MODELS + MAX_MODELS ) { cgs.gameModels[ num - CS_MODELS ] = trap_R_RegisterModel( str ); } else if ( num >= CS_SOUNDS && num < CS_SOUNDS + MAX_MODELS ) { if ( str[0] != '*' ) { // player specific sounds don't register here // Ridah, register sound scripts seperately if ( !strstr( str, ".wav" ) ) { CG_SoundScriptPrecache( str ); } else { cgs.gameSounds[ num - CS_SOUNDS] = trap_S_RegisterSound( str ); } } } else if ( num >= CS_PLAYERS && num < CS_PLAYERS + MAX_CLIENTS ) { CG_NewClientInfo( num - CS_PLAYERS ); } // Rafael particle configstring else if ( num >= CS_PARTICLES && num < CS_PARTICLES + MAX_PARTICLES_AREAS ) { CG_NewParticleArea( num ); } //----(SA) have not reached this code yet so I don't know if I really need this here else if ( num >= CS_DLIGHTS && num < CS_DLIGHTS + MAX_DLIGHTS ) { CG_Printf( ">>>>>>>>>>>got configstring for dlight: %d\ntell Sherman!!!!!!!!!!", num - CS_DLIGHTS ); //----(SA) } else if ( num == CS_SHADERSTATE ) { CG_ShaderStateChanged(); } }
/* ================= CG_Init Called after every level change or subsystem restart Will perform callbacks to make the loading info screen update. ================= */ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum, int randomSeed ) { const char *s; // clear everything memset( &cgs, 0, sizeof( cgs ) ); memset( &cg, 0, sizeof( cg ) ); memset( cg_entities, 0, sizeof(cg_entities) ); srand( randomSeed ); cg.clientNum = clientNum; cgs.processedSnapshotNum = serverMessageNum; cgs.serverCommandSequence = serverCommandSequence; trap_R_RegisterFont( "facfont-20", 0, &cgs.media.facfont ); trap_R_RegisterFont( "verdana-14", 0, &cgs.media.verdana ); // load a few needed things before we do any screen updates // cgs.media.charsetShader = trap_R_RegisterShader( "gfx/2d/bigchars" ); cgs.media.whiteShader = trap_R_RegisterShader( "*white" ); // cgs.media.charsetProp = trap_R_RegisterShaderNoMip( "menu/art/font1_prop.tga" ); // cgs.media.charsetPropGlow = trap_R_RegisterShaderNoMip( "menu/art/font1_prop_glo.tga" ); // cgs.media.charsetPropB = trap_R_RegisterShaderNoMip( "menu/art/font2_prop.tga" ); cgs.media.blackShader = trap_R_RegisterShaderNoMip( "textures/mohmenu/black.tga" ); CG_RegisterCvars(); CG_InitConsoleCommands(); // get the rendering configuration from the client system trap_GetGlconfig( &cgs.glconfig ); cgs.screenXScale = cgs.glconfig.vidWidth / 640.0; cgs.screenYScale = cgs.glconfig.vidHeight / 480.0; // get the gamestate from the client system trap_GetGameState( &cgs.gameState ); // check version s = CG_ConfigString( CS_GAME_VERSION ); if ( strcmp( s, GAME_VERSION ) ) { CG_Error( "Client/Server game mismatch: %s/%s", GAME_VERSION, s ); } s = CG_ConfigString( CS_LEVEL_START_TIME ); cgs.levelStartTime = atoi( s ); CG_ParseServerinfo(); // load the new map CG_LoadingString( "collision map" ); trap_CM_LoadMap( cgs.mapname ); CG_LoadingString( "sounds" ); CG_RegisterSounds(); CG_LoadUbersound(); CG_LoadingString( "graphics" ); CG_RegisterGraphics(); CG_LoadingString( "clients" ); CG_RegisterClients(); // if low on memory, some clients will be deferred CG_InitLocalEntities(); CG_InitMarkPolys(); CG_InitEventSystem(); CG_InitBeams(); CG_InitRainEffect(); // remove the last loading update cg.infoScreenText[0] = 0; // Make sure we have update values (scores) CG_SetConfigValues(); CG_StartMusic(); CG_LoadingString( "" ); trap_S_ClearLoopingSounds( qtrue ); }
/* ================ CG_ConfigStringModified ================ */ static void CG_ConfigStringModified( void ) { const char *str; int num; num = atoi( CG_Argv( 1 ) ); // get the gamestate from the client system, which will have the // new configstring already integrated trap_GetGameState( &cgs.gameState ); // look up the individual string that was modified str = CG_ConfigString( num ); // do something with it if necessary if ( num == CS_MUSIC ) { CG_StartMusic(); } else if ( num == CS_SERVERINFO ) { CG_ParseServerinfo(); } else if ( num == CS_WARMUP ) { CG_ParseWarmup(); } else if ( num == CS_SCORES1 ) { cgs.scores1 = atoi( str ); } else if ( num == CS_SCORES2 ) { cgs.scores2 = atoi( str ); } else if ( num == CS_BUILDPOINTS ) { sscanf( str, "%d %d %d %d %d", &cgs.alienBuildPoints, &cgs.alienBuildPointsTotal, &cgs.humanBuildPoints, &cgs.humanBuildPointsTotal, &cgs.humanBuildPointsPowered ); } else if ( num == CS_STAGES ) { stage_t oldAlienStage = cgs.alienStage; stage_t oldHumanStage = cgs.humanStage; sscanf( str, "%d %d %d %d %d %d", &cgs.alienStage, &cgs.humanStage, &cgs.alienKills, &cgs.humanKills, &cgs.alienNextStageThreshold, &cgs.humanNextStageThreshold ); if ( cgs.alienStage != oldAlienStage ) { CG_AnnounceAlienStageTransistion( oldAlienStage, cgs.alienStage ); } if ( cgs.humanStage != oldHumanStage ) { CG_AnnounceHumanStageTransistion( oldHumanStage, cgs.humanStage ); } } else if ( num == CS_SPAWNS ) { sscanf( str, "%d %d", &cgs.numAlienSpawns, &cgs.numHumanSpawns ); } else if ( num == CS_LEVEL_START_TIME ) { cgs.levelStartTime = atoi( str ); } else if ( num == CS_VOTE_TIME ) { cgs.voteTime = atoi( str ); cgs.voteModified = qtrue; if ( cgs.voteTime ) { trap_Cvar_Set( "ui_voteActive", "1" ); } else { trap_Cvar_Set( "ui_voteActive", "0" ); } } else if ( num == CS_VOTE_YES ) { cgs.voteYes = atoi( str ); cgs.voteModified = qtrue; } else if ( num == CS_VOTE_NO ) { cgs.voteNo = atoi( str ); cgs.voteModified = qtrue; } else if ( num == CS_VOTE_STRING ) { Q_strncpyz( cgs.voteString, str, sizeof( cgs.voteString ) ); } else if ( num >= CS_TEAMVOTE_TIME && num <= CS_TEAMVOTE_TIME + 1 ) { int cs_offset = num - CS_TEAMVOTE_TIME; cgs.teamVoteTime[ cs_offset ] = atoi( str ); cgs.teamVoteModified[ cs_offset ] = qtrue; if ( cs_offset == 0 ) { if ( cgs.teamVoteTime[ cs_offset ] ) { trap_Cvar_Set( "ui_humanTeamVoteActive", "1" ); } else { trap_Cvar_Set( "ui_humanTeamVoteActive", "0" ); } } else if ( cs_offset == 1 ) { if ( cgs.teamVoteTime[ cs_offset ] ) { trap_Cvar_Set( "ui_alienTeamVoteActive", "1" ); } else { trap_Cvar_Set( "ui_alienTeamVoteActive", "0" ); } } } else if ( num >= CS_TEAMVOTE_YES && num <= CS_TEAMVOTE_YES + 1 ) { cgs.teamVoteYes[ num - CS_TEAMVOTE_YES ] = atoi( str ); cgs.teamVoteModified[ num - CS_TEAMVOTE_YES ] = qtrue; } else if ( num >= CS_TEAMVOTE_NO && num <= CS_TEAMVOTE_NO + 1 ) { cgs.teamVoteNo[ num - CS_TEAMVOTE_NO ] = atoi( str ); cgs.teamVoteModified[ num - CS_TEAMVOTE_NO ] = qtrue; } else if ( num >= CS_TEAMVOTE_STRING && num <= CS_TEAMVOTE_STRING + 1 ) { Q_strncpyz( cgs.teamVoteString[ num - CS_TEAMVOTE_STRING ], str, sizeof( cgs.teamVoteString ) ); } else if ( num == CS_INTERMISSION ) { cg.intermissionStarted = atoi( str ); } else if ( num >= CS_MODELS && num < CS_MODELS + MAX_MODELS ) { cgs.gameModels[ num - CS_MODELS ] = trap_R_RegisterModel( str ); } else if ( num >= CS_SHADERS && num < CS_SHADERS + MAX_GAME_SHADERS ) { cgs.gameShaders[ num - CS_SHADERS ] = trap_R_RegisterShader( str ); } else if ( num >= CS_PARTICLE_SYSTEMS && num < CS_PARTICLE_SYSTEMS + MAX_GAME_PARTICLE_SYSTEMS ) { cgs.gameParticleSystems[ num - CS_PARTICLE_SYSTEMS ] = CG_RegisterParticleSystem( ( char * ) str ); } else if ( num >= CS_SOUNDS && num < CS_SOUNDS + MAX_SOUNDS ) { if ( str[ 0 ] != '*' ) { // player specific sounds don't register here cgs.gameSounds[ num - CS_SOUNDS ] = trap_S_RegisterSound( str, qfalse ); } } else if ( num >= CS_PLAYERS && num < CS_PLAYERS + MAX_CLIENTS ) { CG_NewClientInfo( num - CS_PLAYERS ); CG_BuildSpectatorString(); } else if ( num == CS_FLAGSTATUS ) { } else if ( num == CS_SHADERSTATE ) { CG_ShaderStateChanged(); } }