/* =============== RE_Shutdown =============== */ void RE_Shutdown(qboolean destroyWindow) { Ren_Print("RE_Shutdown( %i )\n", destroyWindow); ri.Cmd_RemoveSystemCommand("imagelist"); ri.Cmd_RemoveSystemCommand("shaderlist"); ri.Cmd_RemoveSystemCommand("skinlist"); ri.Cmd_RemoveSystemCommand("modellist"); ri.Cmd_RemoveSystemCommand("modelist"); ri.Cmd_RemoveSystemCommand("screenshot"); ri.Cmd_RemoveSystemCommand("screenshotJPEG"); ri.Cmd_RemoveSystemCommand("gfxinfo"); ri.Cmd_RemoveSystemCommand("minimize"); ri.Cmd_RemoveSystemCommand("taginfo"); // keep a backup of the current images if possible // clean out any remaining unused media from the last backup R_PurgeCache(); if (r_cache->integer) { if (tr.registered) { if (destroyWindow) { R_IssuePendingRenderCommands(); R_DeleteTextures(); } else { // backup the current media R_BackupModels(); R_BackupShaders(); R_BackupImages(); } } } else if (tr.registered) { R_IssuePendingRenderCommands(); R_DeleteTextures(); } R_DoneFreeType(); R_ShutdownGamma(); // shut down platform specific OpenGL stuff if (destroyWindow) { R_DoGLimpShutdown(); // release the virtual memory R_Hunk_End(); R_FreeImageBuffer(); ri.Tag_Free(); // wipe all render alloc'd zone memory } tr.registered = qfalse; }
/* =============== RE_Shutdown =============== */ void RE_Shutdown( qboolean destroyWindow ) { ri.Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); ri.Cmd_RemoveCommand ("modellist"); ri.Cmd_RemoveCommand ("screenshotJPEG"); ri.Cmd_RemoveCommand ("screenshot"); ri.Cmd_RemoveCommand ("imagelist"); ri.Cmd_RemoveCommand ("shaderlist"); ri.Cmd_RemoveCommand ("skinlist"); ri.Cmd_RemoveCommand ("gfxinfo"); ri.Cmd_RemoveCommand("minimize"); ri.Cmd_RemoveCommand( "modelist" ); ri.Cmd_RemoveCommand( "shaderstate" ); if ( tr.registered ) { R_SyncRenderThread(); R_ShutdownCommandBuffers(); R_DeleteTextures(); } R_DoneFreeType(); // shut down platform specific OpenGL stuff if ( destroyWindow ) { GLimp_Shutdown(); } tr.registered = qfalse; }
/* =============== RE_Shutdown =============== */ void RE_Shutdown( qboolean destroyWindow ) { ri.Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); ri.Cmd_RemoveCommand ("modellist"); ri.Cmd_RemoveCommand ("screenshotJPEG"); ri.Cmd_RemoveCommand ("screenshot"); ri.Cmd_RemoveCommand ("imagelist"); ri.Cmd_RemoveCommand ("shaderlist"); ri.Cmd_RemoveCommand ("skinlist"); ri.Cmd_RemoveCommand ("gfxinfo"); ri.Cmd_RemoveCommand("minimize"); ri.Cmd_RemoveCommand( "modelist" ); ri.Cmd_RemoveCommand( "shaderstate" ); if ( tr.registered ) { R_IssuePendingRenderCommands(); R_DeleteTextures(); } R_DoneFreeType(); // shut down platform specific OpenGL stuff if ( destroyWindow ) { GLimp_Shutdown(); Com_Memset( &glConfig, 0, sizeof( glConfig ) ); Com_Memset( &glState, 0, sizeof( glState ) ); } tr.registered = qfalse; }
/* =============== RE_Shutdown =============== */ void RE_Shutdown( qboolean destroyWindow ) { //ri.Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); Com_VPrintf( "RE_Shutdown( %i )\n", destroyWindow ); ri.Cmd_RemoveCommand( "modelList" ); ri.Cmd_RemoveCommand( "screenShotJPEG" ); ri.Cmd_RemoveCommand( "screenShot" ); ri.Cmd_RemoveCommand( "imageList" ); ri.Cmd_RemoveCommand( "shaderList" ); ri.Cmd_RemoveCommand( "skinList" ); ri.Cmd_RemoveCommand( "gfxInfo" ); ri.Cmd_RemoveCommand( "minimize" ); ri.Cmd_RemoveCommand( "modeList" ); if ( tr.registered ) { R_SyncRenderThread(); R_ShutdownCommandBuffers(); #ifdef USE_RENDERER_GLSLFBO R_DeleteGlslShadersAndPrograms(); R_DeleteFramebufferObject(); #endif //USE_RENDERER_GLSLFBO R_DeleteTextures(); } R_DoneFreeType(); // shut down platform specific OpenGL stuff if ( destroyWindow ) { GLimp_Shutdown(); } tr.registered = qfalse; }
void RE_Shutdown( qboolean destroyWindow ) { ri.Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); ri.Cmd_RemoveCommand ("imagelist"); ri.Cmd_RemoveCommand ("shaderlist"); ri.Cmd_RemoveCommand ("skinlist"); ri.Cmd_RemoveCommand ("modellist"); ri.Cmd_RemoveCommand ("modelist" ); ri.Cmd_RemoveCommand ("screenshot"); ri.Cmd_RemoveCommand ("screenshot_tga"); ri.Cmd_RemoveCommand ("gfxinfo"); ri.Cmd_RemoveCommand ("r_fogDistance"); ri.Cmd_RemoveCommand ("r_fogColor"); ri.Cmd_RemoveCommand ("modelcacheinfo"); ri.Cmd_RemoveCommand ("imagecacheinfo"); R_ShutdownWorldEffects(); R_ShutdownFonts(); if ( tr.registered ) { R_SyncRenderThread(); R_ShutdownCommandBuffers(); if (destroyWindow) { R_DeleteTextures(); // only do this for vid_restart now, not during things like map load } } // shut down platform specific OpenGL stuff if ( destroyWindow ) { GLimp_Shutdown(); } tr.registered = qfalse; }
/* ===================== CL_Disconnect Called when a connection, or cinematic is being terminated. Goes from a connected state to either a menu state or a console state Sends a disconnect message to the server This is also called on Com_Error and Com_Quit, so it shouldn't cause any errors ===================== */ void CL_Disconnect( void ) { if ( !com_cl_running || !com_cl_running->integer ) { return; } #ifdef _XBOX Cvar_Set("r_norefresh", "0"); // Make sure to stop all rumbling! - Prevents bug when quitting game during rumble: extern void IN_KillRumbleScripts( void ); IN_KillRumbleScripts(); #endif if (cls.uiStarted) UI_SetActiveMenu( NULL,NULL ); SCR_StopCinematic (); S_ClearSoundBuffer(); #ifdef _XBOX // extern qboolean RE_RegisterImages_LevelLoadEnd(void); // RE_RegisterImages_LevelLoadEnd(); R_DeleteTextures(); #endif // send a disconnect message to the server // send it a few times in case one is dropped if ( cls.state >= CA_CONNECTED ) { CL_AddReliableCommand( "disconnect" ); CL_WritePacket(); CL_WritePacket(); CL_WritePacket(); } CL_ClearState (); CL_FreeReliableCommands(); extern void CL_FreeServerCommands(void); CL_FreeServerCommands(); memset( &clc, 0, sizeof( clc ) ); cls.state = CA_DISCONNECTED; // allow cheats locally Cvar_Set( "timescale", "1" );//jic we were skipping Cvar_Set( "skippingCinematic", "0" );//jic we were skipping }
// Delete textures from the front end via SMP const void *RB_Clean( const void *data, qboolean save ) { const swapBuffersCommand_t *cmd; cmd = (const swapBuffersCommand_t *)data; R_PurgeShaders( 9999999 ); R_PurgeBackupImages( 9999999 ); R_PurgeModels( 9999999 ); if ( save && r_cache->integer ){ R_BackupModels(); R_BackupShaders(); R_BackupImages(); } else { R_DeleteTextures(); } return (const void *)( cmd + 1 ); }
/* =============== RE_Shutdown =============== */ void RE_Shutdown( qboolean destroyWindow ) { ri.Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); ri.Cmd_RemoveCommand ("modellist"); ri.Cmd_RemoveCommand ("screenshotJPEG"); ri.Cmd_RemoveCommand ("screenshot"); ri.Cmd_RemoveCommand ("imagelist"); ri.Cmd_RemoveCommand ("shaderlist"); ri.Cmd_RemoveCommand ("skinlist"); ri.Cmd_RemoveCommand ("gfxinfo"); ri.Cmd_RemoveCommand ("modelist"); ri.Cmd_RemoveCommand ("shaderstate"); ri.Cmd_RemoveCommand ("r_we"); ri.Cmd_RemoveCommand ("modelcacheinfo"); ri.Cmd_RemoveCommand ("imagecacheinfo"); #ifndef DEDICATED R_ShutdownFonts(); if ( tr.registered ) { R_SyncRenderThread(); R_ShutdownCommandBuffers(); if (destroyWindow) { R_DeleteTextures(); // only do this for vid_restart now, not during things like map load } } // shut down platform specific OpenGL stuff if ( destroyWindow ) { GLimp_Shutdown(); } #endif //!DEDICATED tr.registered = qfalse; #ifdef G2_COLLISION_ENABLED if (G2VertSpaceServer) { delete G2VertSpaceServer; G2VertSpaceServer = 0; } #endif }
/* =============== RE_Shutdown =============== */ void RE_Shutdown( qboolean destroyWindow ) { ri.Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); ri.Cmd_RemoveCommand( "modellist" ); ri.Cmd_RemoveCommand( "screenshotJPEG" ); ri.Cmd_RemoveCommand( "screenshot" ); ri.Cmd_RemoveCommand( "imagelist" ); ri.Cmd_RemoveCommand( "shaderlist" ); ri.Cmd_RemoveCommand( "skinlist" ); ri.Cmd_RemoveCommand( "gfxinfo" ); ri.Cmd_RemoveCommand("minimize"); ri.Cmd_RemoveCommand( "modelist" ); ri.Cmd_RemoveCommand( "shaderstate" ); ri.Cmd_RemoveCommand( "taginfo" ); // Ridah ri.Cmd_RemoveCommand( "cropimages" ); // done. if ( tr.registered ) { R_IssuePendingRenderCommands(); R_DeleteTextures(); } R_DoneFreeType(); // shut down platform specific OpenGL stuff if ( destroyWindow ) { GLimp_Shutdown(); // Ridah, release the virtual memory R_Hunk_End(); R_FreeImageBuffer(); ri.Tag_Free(); // wipe all render alloc'd zone memory } tr.registered = qfalse; }
/* =============== RE_Shutdown =============== */ void RE_Shutdown( qboolean destroyWindow ) { // Com_Printf ("RE_Shutdown( %i )\n", destroyWindow ); Cmd_RemoveCommand ("imagelist"); Cmd_RemoveCommand ("shaderlist"); Cmd_RemoveCommand ("skinlist"); Cmd_RemoveCommand ("fontlist"); Cmd_RemoveCommand ("screenshot"); Cmd_RemoveCommand ("screenshot_tga"); Cmd_RemoveCommand ("gfxinfo"); Cmd_RemoveCommand ("r_atihack"); Cmd_RemoveCommand ("r_we"); Cmd_RemoveCommand ("imagecacheinfo"); Cmd_RemoveCommand ("modellist"); Cmd_RemoveCommand ("modelist"); Cmd_RemoveCommand ("modelcacheinfo"); #ifndef DEDICATED if ( r_DynamicGlow && r_DynamicGlow->integer ) { // Release the Glow Vertex Shader. if ( tr.glowVShader ) { qglDeleteProgramsARB( 1, &tr.glowVShader ); } // Release Pixel Shader. if ( tr.glowPShader ) { if ( qglCombinerParameteriNV ) { // Release the Glow Regcom call list. qglDeleteLists( tr.glowPShader, 1 ); } else if ( qglGenProgramsARB ) { // Release the Glow Fragment Shader. qglDeleteProgramsARB( 1, &tr.glowPShader ); } } // Release the scene glow texture. qglDeleteTextures( 1, &tr.screenGlow ); // Release the scene texture. qglDeleteTextures( 1, &tr.sceneImage ); // Release the blur texture. qglDeleteTextures( 1, &tr.blurImage ); } R_TerrainShutdown(); //rwwRMG - added R_ShutdownFonts(); if ( tr.registered ) { R_SyncRenderThread(); R_ShutdownCommandBuffers(); if (destroyWindow) { R_DeleteTextures(); // only do this for vid_restart now, not during things like map load } } // shut down platform specific OpenGL stuff if ( destroyWindow ) { GLimp_Shutdown(); } #endif //!DEDICATED tr.registered = qfalse; }
/* =============== RE_Shutdown =============== */ void RE_Shutdown( qboolean destroyWindow ) { ri.Printf( PRINT_DEVELOPER, "RE_Shutdown( %i )\n", destroyWindow ); ri.Cmd_RemoveCommand( "modellist" ); ri.Cmd_RemoveCommand( "screenshotPNG" ); ri.Cmd_RemoveCommand( "screenshotJPEG" ); ri.Cmd_RemoveCommand( "screenshot" ); ri.Cmd_RemoveCommand( "imagelist" ); ri.Cmd_RemoveCommand( "shaderlist" ); ri.Cmd_RemoveCommand( "skinlist" ); ri.Cmd_RemoveCommand( "gfxinfo" ); ri.Cmd_RemoveCommand( "modelist" ); ri.Cmd_RemoveCommand( "shaderstate" ); ri.Cmd_RemoveCommand( "taginfo" ); // Ridah ri.Cmd_RemoveCommand( "cropimages" ); // done. R_ShutdownCommandBuffers(); // Ridah, keep a backup of the current images if possible // clean out any remaining unused media from the last backup R_PurgeCache(); if ( r_cache->integer ) { if ( tr.registered ) { if ( destroyWindow ) { R_SyncRenderThread(); R_ShutdownCommandBuffers(); R_DeleteTextures(); } else { // backup the current media R_ShutdownCommandBuffers(); R_BackupModels(); R_BackupShaders(); R_BackupImages(); } } } else if ( tr.registered ) { R_SyncRenderThread(); R_ShutdownCommandBuffers(); R_DeleteTextures(); } R_DoneFreeType(); // shut down platform specific OpenGL stuff if ( destroyWindow ) { GLimp_Shutdown(); // Ridah, release the virtual memory R_Hunk_End(); R_FreeImageBuffer(); ri.Tag_Free(); // wipe all render alloc'd zone memory } tr.registered = qfalse; }
/* ================ SV_SpawnServer Change the server to a new map, taking all connected clients along with it. ================ */ void SV_SpawnServer( char *server, ForceReload_e eForceReload, qboolean bAllowScreenDissolve ) { int i; int checksum; // The following fixes for potential issues only work on Xbox #ifdef _XBOX extern qboolean stop_icarus; stop_icarus = qfalse; //Broken scripts may leave the player locked. I think that's always bad. extern qboolean player_locked; player_locked = qfalse; //If you quit while in Matrix Mode, this never gets cleared! extern qboolean MatrixMode; MatrixMode = qfalse; // Temporary code to turn on HDR effect for specific maps only if (!Q_stricmp(server, "t3_rift")) { Cvar_Set( "r_hdreffect", "1" ); } else { Cvar_Set( "r_hdreffect", "0" ); } #endif RE_RegisterMedia_LevelLoadBegin( server, eForceReload, bAllowScreenDissolve ); Cvar_SetValue( "cl_paused", 0 ); Cvar_Set( "timescale", "1" );//jic we were skipping // shut down the existing game if it is running SV_ShutdownGameProgs(qtrue); Com_Printf ("------ Server Initialization ------\n%s\n", com_version->string); Com_Printf ("Server: %s\n",server); #ifdef _XBOX // disable vsync during load for speed qglDisable(GL_VSYNC); #endif // don't let sound stutter and dump all stuff on the hunk CL_MapLoading(); if (!CM_SameMap(server)) { //rww - only clear if not loading the same map CM_ClearMap(); } #ifndef _XBOX else if (CM_HasTerrain()) { //always clear when going between maps with terrain CM_ClearMap(); } #endif // Miniheap never changes sizes, so I just put it really early in mem. G2VertSpaceServer->ResetHeap(); #ifdef _XBOX // Deletes all textures R_DeleteTextures(); #endif Hunk_Clear(); // Moved up from below to help reduce fragmentation if (svs.snapshotEntities) { Z_Free(svs.snapshotEntities); svs.snapshotEntities = NULL; } // wipe the entire per-level structure // Also moved up, trying to do all freeing before new allocs for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) { if ( sv.configstrings[i] ) { Z_Free( sv.configstrings[i] ); sv.configstrings[i] = NULL; } } #ifdef _XBOX SV_ClearLastLevel(); #endif // Collect all the small allocations done by the cvar system // This frees, then allocates. Make it the last thing before other // allocations begin! Cvar_Defrag(); /* This is useful for debugging memory fragmentation. Please don't remove it. */ #ifdef _XBOX // We've over-freed the info array above, this puts it back into a working state Ghoul2InfoArray_Reset(); extern void Z_DumpMemMap_f(void); extern void Z_Details_f(void); extern void Z_TagPointers(memtag_t); Z_DumpMemMap_f(); // Z_TagPointers(TAG_ALL); Z_Details_f(); #endif // init client structures and svs.numSnapshotEntities // This is moved down quite a bit, but should be safe. And keeps // svs.clients right at the beginning of memory if ( !Cvar_VariableIntegerValue("sv_running") ) { SV_Startup(); } // clear out those shaders, images and Models R_InitImages(); R_InitShaders(); R_ModelInit(); // allocate the snapshot entities svs.snapshotEntities = (entityState_t *) Z_Malloc (sizeof(entityState_t)*svs.numSnapshotEntities, TAG_CLIENTS, qtrue ); Music_SetLevelName(server); // toggle the server bit so clients can detect that a // server has changed //!@ svs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT; // set nextmap to the same map, but it may be overriden // by the game startup or another console command Cvar_Set( "nextmap", va("map %s", server) ); memset (&sv, 0, sizeof(sv)); for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) { sv.configstrings[i] = CopyString(""); } sv.time = 1000; G2API_SetTime(sv.time,G2T_SV_TIME); #ifdef _XBOX CL_StartHunkUsers(); CM_LoadMap( va("maps/%s.bsp", server), qfalse, &checksum ); RE_LoadWorldMap(va("maps/%s.bsp", server)); #else CM_LoadMap( va("maps/%s.bsp", server), qfalse, &checksum, qfalse ); #endif // set serverinfo visible name Cvar_Set( "mapname", server ); Cvar_Set( "sv_mapChecksum", va("%i",checksum) ); // serverid should be different each time sv.serverId = com_frameTime; Cvar_Set( "sv_serverid", va("%i", sv.serverId ) ); // clear physics interaction links SV_ClearWorld (); // media configstring setting should be done during // the loading stage, so connected clients don't have // to load during actual gameplay sv.state = SS_LOADING; // load and spawn all other entities SV_InitGameProgs(); // run a few frames to allow everything to settle for ( i = 0 ;i < 3 ; i++ ) { ge->RunFrame( sv.time ); sv.time += 100; G2API_SetTime(sv.time,G2T_SV_TIME); } #ifndef __NO_JK2 if(!Cvar_VariableIntegerValue("com_jk2")) #endif ge->ConnectNavs(sv_mapname->string, sv_mapChecksum->integer); // create a baseline for more efficient communications SV_CreateBaseline (); for (i=0 ; i<1 ; i++) { // clear all time counters, because we have reset sv.time svs.clients[i].lastPacketTime = 0; svs.clients[i].lastConnectTime = 0; svs.clients[i].nextSnapshotTime = 0; // send the new gamestate to all connected clients if (svs.clients[i].state >= CS_CONNECTED) { char *denied; // connect the client again denied = ge->ClientConnect( i, qfalse, eNO/*qfalse*/ ); // firstTime = qfalse, qbFromSavedGame if ( denied ) { // this generally shouldn't happen, because the client // was connected before the level change SV_DropClient( &svs.clients[i], denied ); } else { svs.clients[i].state = CS_CONNECTED; // when we get the next packet from a connected client, // the new gamestate will be sent } } } // run another frame to allow things to look at all connected clients ge->RunFrame( sv.time ); sv.time += 100; G2API_SetTime(sv.time,G2T_SV_TIME); // save systeminfo and serverinfo strings SV_SetConfigstring( CS_SYSTEMINFO, Cvar_InfoString( CVAR_SYSTEMINFO ) ); cvar_modifiedFlags &= ~CVAR_SYSTEMINFO; SV_SetConfigstring( CS_SERVERINFO, Cvar_InfoString( CVAR_SERVERINFO ) ); cvar_modifiedFlags &= ~CVAR_SERVERINFO; // any media configstring setting now should issue a warning // and any configstring changes should be reliably transmitted // to all clients sv.state = SS_GAME; // send a heartbeat now so the master will get up to date info svs.nextHeartbeatTime = -9999999; Hunk_SetMark(); Z_Validate(); Z_Validate(); Z_Validate(); Com_Printf ("-----------------------------------\n"); }
/* =============== RE_Shutdown =============== */ void RE_Shutdown( qboolean destroyWindow ) { ri.Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); ri.Cmd_RemoveCommand ("modellist"); ri.Cmd_RemoveCommand ("screenshotJPEG"); ri.Cmd_RemoveCommand ("screenshot"); ri.Cmd_RemoveCommand ("imagelist"); ri.Cmd_RemoveCommand ("shaderlist"); ri.Cmd_RemoveCommand ("skinlist"); ri.Cmd_RemoveCommand ("gfxinfo"); ri.Cmd_RemoveCommand ("modelist"); ri.Cmd_RemoveCommand ("shaderstate"); ri.Cmd_RemoveCommand ("r_we"); ri.Cmd_RemoveCommand ("modelcacheinfo"); ri.Cmd_RemoveCommand ("imagecacheinfo"); #ifndef DEDICATED if ( r_DynamicGlow && r_DynamicGlow->integer ) { // Release the Glow Vertex Shader. if ( tr.glowVShader ) { qglDeleteProgramsARB( 1, &tr.glowVShader ); } // Release Pixel Shader. if ( tr.glowPShader ) { if ( qglCombinerParameteriNV ) { // Release the Glow Regcom call list. qglDeleteLists( tr.glowPShader, 1 ); } else if ( qglGenProgramsARB ) { // Release the Glow Fragment Shader. qglDeleteProgramsARB( 1, &tr.glowPShader ); } } // Release the scene glow texture. qglDeleteTextures( 1, &tr.screenGlow ); // Release the scene texture. qglDeleteTextures( 1, &tr.sceneImage ); // Release the blur texture. qglDeleteTextures( 1, &tr.blurImage ); } // gamma correction if (tr.gammaPixelShader) { qglDeleteProgramsARB(1, &tr.gammaPixelShader); } if (tr.gammaVertexShader) { qglDeleteProgramsARB(1, &tr.gammaVertexShader); } if (tr.gammaLUTImage) { qglDeleteTextures(1, &tr.gammaLUTImage); } // -------- R_ShutdownFonts(); if ( tr.registered ) { R_SyncRenderThread(); R_ShutdownCommandBuffers(); if (destroyWindow) { R_DeleteTextures(); // only do this for vid_restart now, not during things like map load } } // shut down platform specific OpenGL stuff if ( destroyWindow ) { GLimp_Shutdown(); } #endif //!DEDICATED tr.registered = qfalse; #ifdef G2_COLLISION_ENABLED if (G2VertSpaceServer) { delete G2VertSpaceServer; G2VertSpaceServer = 0; } #endif }
void SV_SpawnServer( char *server, qboolean killBots, ForceReload_e eForceReload ) { int i; int checksum; qboolean isBot; char systemInfo[16384]; const char *p; SV_SendMapChange(); RE_RegisterMedia_LevelLoadBegin(server, eForceReload); // shut down the existing game if it is running SV_ShutdownGameProgs(); Com_Printf ("------ Server Initialization ------\n"); Com_Printf ("Server: %s\n",server); /* Ghoul2 Insert Start */ // de allocate the snapshot entities if (svs.snapshotEntities) { delete[] svs.snapshotEntities; svs.snapshotEntities = NULL; } /* Ghoul2 Insert End */ SV_SendMapChange(); #ifdef _XBOX // disable vsync during load for speed qglDisable(GL_VSYNC); #endif // if not running a dedicated server CL_MapLoading will connect the client to the server // also print some status stuff CL_MapLoading(); #ifndef DEDICATED // make sure all the client stuff is unloaded CL_ShutdownAll(); #endif CM_ClearMap(); #ifdef _XBOX R_DeleteTextures(); #endif // clear the whole hunk because we're (re)loading the server Hunk_Clear(); #ifdef _XBOX SV_ClearLastLevel(); ClientManager::ActivateClient(0); #endif R_InitSkins(); R_InitShaders(qtrue); // This was in SV_DedicatedSpawn, but it gets in the way of my memory maps: if( com_dedicated->integer ) { // Textures have been blown away - need to kill font system so it // will re-register shaders when UI re-scans menu files below: extern void R_ShutdownFonts( void ); R_ShutdownFonts(); } ClientManager::ClientActiveRelocate( !com_dedicated->integer && !ClientManager::splitScreenMode ); #if defined(_XBOX) && !defined(FINAL_BUILD) //Useful for memory debugging. Please don't delete. Comment out if //necessary. extern void Z_DisplayLevelMemory(int, int, int); extern void Z_Details_f(void); extern void Z_TagPointers(memtag_t); Z_DisplayLevelMemory(0, 0, 0); Z_TagPointers( TAG_ALL ); Z_Details_f(); #endif // init client structures and svs.numSnapshotEntities if ( !Cvar_VariableValue("sv_running") ) { SV_Startup(); } else { // check for maxclients change if ( sv_maxclients->modified ) { SV_ChangeMaxClients(); } } // Do dedicated server-specific startup if ( com_dedicated->integer ) { SV_DedicatedSpawn(server); } // Xbox - Correct various problems with broken rules settings when people // change gametype in-game, etc... SV_FixBrokenRules(); SV_SendMapChange(); /* Ghoul2 Insert Start */ // clear out those shaders, images and Models as long as this // isnt a dedicated server. /* if ( !com_dedicated->integer ) { #ifndef DEDICATED R_InitImages(); R_InitShaders(); R_ModelInit(); #endif } else */ if (com_dedicated->integer) { R_SVModelInit(); } SV_SendMapChange(); // clear pak references FS_ClearPakReferences(0); /* Ghoul2 Insert Start */ // allocate the snapshot entities on the hunk // svs.snapshotEntities = (struct entityState_s *)Hunk_Alloc( sizeof(entityState_t)*svs.numSnapshotEntities, h_high ); svs.nextSnapshotEntities = 0; // allocate the snapshot entities svs.snapshotEntities = new entityState_s[svs.numSnapshotEntities]; // we CAN afford to do this here, since we know the STL vectors in Ghoul2 are empty memset(svs.snapshotEntities, 0, sizeof(entityState_t)*svs.numSnapshotEntities); /* Ghoul2 Insert End */ // toggle the server bit so clients can detect that a // server has changed svs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT; // set nextmap to the same map, but it may be overriden // by the game startup or another console command Cvar_Set( "nextmap", "map_restart 0"); // Cvar_Set( "nextmap", va("map %s", server) ); // wipe the entire per-level structure SV_ClearServer(); for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) { sv.configstrings[i] = CopyString(""); } //rww - RAGDOLL_BEGIN G2API_SetTime(svs.time,0); //rww - RAGDOLL_END // make sure we are not paused Cvar_Set("cl_paused", "0"); // get a new checksum feed and restart the file system srand(Com_Milliseconds()); sv.checksumFeed = ( ((int) rand() << 16) ^ rand() ) ^ Com_Milliseconds(); FS_Restart( sv.checksumFeed ); #ifdef _XBOX CL_StartHunkUsers(); CM_LoadMap( va("maps/%s.bsp", server), qfalse, &checksum ); // RE_LoadWorldMap(va("maps/%s.bsp", server)); // Start up voice system if it isn't running yet. (ie, if we're on syslink) if( !logged_on ) g_Voice.Initialize(); #else CM_LoadMap( va("maps/%s.bsp", server), qfalse, &checksum ); #endif SV_SendMapChange(); // set serverinfo visible name Cvar_Set( "mapname", server ); Cvar_Set( "sv_mapChecksum", va("%i",checksum) ); // serverid should be different each time sv.serverId = com_frameTime; sv.restartedServerId = sv.serverId; Cvar_Set( "sv_serverid", va("%i", sv.serverId ) ); // clear physics interaction links SV_ClearWorld (); // media configstring setting should be done during // the loading stage, so connected clients don't have // to load during actual gameplay sv.state = SS_LOADING; // load and spawn all other entities SV_InitGameProgs(); // don't allow a map_restart if game is modified sv_gametype->modified = qfalse; // run a few frames to allow everything to settle for ( i = 0 ;i < 3 ; i++ ) { //rww - RAGDOLL_BEGIN G2API_SetTime(svs.time,0); //rww - RAGDOLL_END VM_Call( gvm, GAME_RUN_FRAME, svs.time ); SV_BotFrame( svs.time ); svs.time += 100; } //rww - RAGDOLL_BEGIN G2API_SetTime(svs.time,0); //rww - RAGDOLL_END // create a baseline for more efficient communications SV_CreateBaseline (); for (i=0 ; i<sv_maxclients->integer ; i++) { // send the new gamestate to all connected clients if (svs.clients[i].state >= CS_CONNECTED) { char *denied; if ( svs.clients[i].netchan.remoteAddress.type == NA_BOT ) { if ( killBots ) { SV_DropClient( &svs.clients[i], "" ); continue; } isBot = qtrue; } else { isBot = qfalse; } // connect the client again denied = (char *)VM_ExplicitArgPtr( gvm, VM_Call( gvm, GAME_CLIENT_CONNECT, i, qfalse, isBot ) ); // firstTime = qfalse if ( denied ) { // this generally shouldn't happen, because the client // was connected before the level change // SV_DropClient( &svs.clients[i], denied ); SV_DropClient( &svs.clients[i], "@MENUS_LOST_CONNECTION" ); } else { if( !isBot ) { // when we get the next packet from a connected client, // the new gamestate will be sent svs.clients[i].state = CS_CONNECTED; } else { client_t *client; sharedEntity_t *ent; client = &svs.clients[i]; client->state = CS_ACTIVE; ent = SV_GentityNum( i ); ent->s.number = i; client->gentity = ent; client->deltaMessage = -1; client->nextSnapshotTime = svs.time; // generate a snapshot immediately VM_Call( gvm, GAME_CLIENT_BEGIN, i ); } } } } // run another frame to allow things to look at all the players VM_Call( gvm, GAME_RUN_FRAME, svs.time ); SV_BotFrame( svs.time ); svs.time += 100; //rww - RAGDOLL_BEGIN G2API_SetTime(svs.time,0); //rww - RAGDOLL_END if ( sv_pure->integer ) { // the server sends these to the clients so they will only // load pk3s also loaded at the server p = FS_LoadedPakChecksums(); Cvar_Set( "sv_paks", p ); if (strlen(p) == 0) { Com_Printf( "WARNING: sv_pure set but no PK3 files loaded\n" ); } p = FS_LoadedPakNames(); Cvar_Set( "sv_pakNames", p ); // if a dedicated pure server we need to touch the cgame because it could be in a // seperate pk3 file and the client will need to load the latest cgame.qvm if ( com_dedicated->integer ) { SV_TouchCGame(); } } else { Cvar_Set( "sv_paks", "" ); Cvar_Set( "sv_pakNames", "" ); } // the server sends these to the clients so they can figure // out which pk3s should be auto-downloaded p = FS_ReferencedPakChecksums(); Cvar_Set( "sv_referencedPaks", p ); p = FS_ReferencedPakNames(); Cvar_Set( "sv_referencedPakNames", p ); // save systeminfo and serverinfo strings Q_strncpyz( systemInfo, Cvar_InfoString_Big( CVAR_SYSTEMINFO ), sizeof( systemInfo ) ); cvar_modifiedFlags &= ~CVAR_SYSTEMINFO; SV_SetConfigstring( CS_SYSTEMINFO, systemInfo ); SV_SetConfigstring( CS_SERVERINFO, Cvar_InfoString( CVAR_SERVERINFO ) ); cvar_modifiedFlags &= ~CVAR_SERVERINFO; // any media configstring setting now should issue a warning // and any configstring changes should be reliably transmitted // to all clients sv.state = SS_GAME; // send a heartbeat now so the master will get up to date info SV_Heartbeat_f(); Hunk_SetMark(); /* MrE: 2000-09-13: now called in CL_DownloadsComplete // don't call when running dedicated if ( !com_dedicated->integer ) { // note that this is called after setting the hunk mark with Hunk_SetMark CL_StartHunkUsers(); } */ // Xbox - Dedicated servers need to do extra work here. Most of this is done in // cl_parse normally, but that never runs in this case: if ( com_dedicated->integer ) { // Normally, we start advertising when we get the first snapshot. // Do it now. This is also necessary so that Net_GetXNKID works below. XBL_MM_Advertise(); // We need to put ourselves into the playerlist. xbOnlineInfo.localIndex = DEDICATED_SERVER_INDEX; XBPlayerInfo *plyrInfo = &xbOnlineInfo.xbPlayerList[DEDICATED_SERVER_INDEX]; memset( plyrInfo, 0, sizeof(XBPlayerInfo) ); // We get the first refIndex plyrInfo->refIndex = svs.clientRefNum++; // Address information plyrInfo->xbAddr = *Net_GetXNADDR( NULL ); XNetXnAddrToInAddr( &plyrInfo->xbAddr, Net_GetXNKID(), &plyrInfo->inAddr ); // Gamertag and XUID Q_strncpyz( plyrInfo->name, Cvar_VariableString("name"), sizeof(plyrInfo->name) ); XONLINE_USER *pUser; if (logged_on && (pUser = &XBLLoggedOnUsers[ IN_GetMainController() ]) && (pUser->hr == S_OK)) plyrInfo->xuid = pUser->xuid; else plyrInfo->xuid.qwUserID = plyrInfo->refIndex; plyrInfo->isActive = true; // Start up the voice chat session g_Voice.JoinSession(); // And mark ourselves as playing, so that others can join our game: XBL_F_SetState( XONLINE_FRIENDSTATE_FLAG_PLAYING, true ); } }