/* ================= CL_PrepVideo Call before entering a new level, or after changing dlls ================= */ void CL_PrepVideo( void ) { string mdlname, mapname; int i, mdlcount, step; int map_checksum; // dummy if( !cl.model_precache[1][0] ) return; // no map loaded Cvar_SetFloat( "scr_loading", 0.0f ); // reset progress bar MsgDev( D_NOTE, "CL_PrepVideo: %s\n", clgame.mapname ); // let the render dll load the map Q_strncpy( mapname, cl.model_precache[1], MAX_STRING ); Mod_LoadWorld( mapname, (uint *)&map_checksum, false ); cl.worldmodel = Mod_Handle( 1 ); // get world pointer Cvar_SetFloat( "scr_loading", 25.0f ); SCR_UpdateScreen(); // make sure what map is valid if( !cls.demoplayback && map_checksum != cl.checksum ) Host_Error( "Local map version differs from server: %i != '%i'\n", map_checksum, cl.checksum ); for( i = 0, mdlcount = 0; i < MAX_MODELS && cl.model_precache[i+1][0]; i++ ) mdlcount++; // total num models step = mdlcount/10; for( i = 0; i < MAX_MODELS && cl.model_precache[i+1][0]; i++ ) { Q_strncpy( mdlname, cl.model_precache[i+1], MAX_STRING ); Mod_RegisterModel( mdlname, i+1 ); Cvar_SetFloat( "scr_loading", scr_loading->value + 75.0f / mdlcount ); if( step && !( i % step ) && ( cl_allow_levelshots->integer || cl.background ) ) SCR_UpdateScreen(); } // update right muzzleflash indexes CL_RegisterMuzzleFlashes (); // invalidate all decal indexes Q_memset( cl.decal_index, 0, sizeof( cl.decal_index )); CL_ClearWorld (); R_NewMap(); // tell the render about new map V_SetupOverviewState(); // set overview bounds // must be called after lightmap loading! clgame.dllFuncs.pfnVidInit(); // release unused SpriteTextures for( i = 1; i < MAX_IMAGES; i++ ) { if( !clgame.sprites[i].name[0] ) continue; // free slot if( clgame.sprites[i].needload != clgame.load_sequence ) Mod_UnloadSpriteModel( &clgame.sprites[i] ); } Mod_FreeUnused (); Q_memset( cl.playermodels, 0, sizeof( cl.playermodels ) ); Cvar_SetFloat( "scr_loading", 100.0f ); // all done if( host.decalList ) { // need to reapply all decals after restarting for( i = 0; i < host.numdecals; i++ ) { decallist_t *entry = &host.decalList[i]; cl_entity_t *pEdict = CL_GetEntityByIndex( entry->entityIndex ); int decalIndex = CL_DecalIndex( CL_DecalIndexFromName( entry->name )); int modelIndex = 0; if( pEdict ) modelIndex = pEdict->curstate.modelindex; CL_DecalShoot( decalIndex, entry->entityIndex, modelIndex, entry->position, entry->flags ); } Z_Free( host.decalList ); } host.decalList = NULL; host.numdecals = 0; if( host.soundList ) { // need to reapply all ambient sounds after restarting for( i = 0; i < host.numsounds; i++ ) { soundlist_t *entry = &host.soundList[i]; if( entry->looping && entry->entnum != -1 ) { MsgDev( D_NOTE, "Restarting sound %s...\n", entry->name ); S_AmbientSound( entry->origin, entry->entnum, S_RegisterSound( entry->name ), entry->volume, entry->attenuation, entry->pitch, 0 ); } } } host.soundList = NULL; host.numsounds = 0; if( host.developer <= 2 ) Con_ClearNotify(); // clear any lines of console text SCR_UpdateScreen (); cl.video_prepped = true; cl.force_refdef = true; }
/* ================ SV_ActivateServer activate server on changed map, run physics ================ */ void SV_ActivateServer( void ) { int i, numFrames; if( !svs.initialized ) return; // custom muzzleflashes pfnPrecacheModel( "sprites/muzzleflash.spr" ); pfnPrecacheModel( "sprites/muzzleflash1.spr" ); pfnPrecacheModel( "sprites/muzzleflash2.spr" ); pfnPrecacheModel( "sprites/muzzleflash3.spr" ); // rocket flare pfnPrecacheModel( "sprites/animglow01.spr" ); // ricochet sprite pfnPrecacheModel( "sprites/richo1.spr" ); // Activate the DLL server code svgame.dllFuncs.pfnServerActivate( svgame.edicts, svgame.numEntities, svgame.globals->maxClients ); // create a baseline for more efficient communications SV_CreateBaseline(); // check and count all files that marked by user as unmodified (typically is a player models etc) sv.num_consistency_resources = SV_TransferConsistencyInfo(); // send serverinfo to all connected clients for( i = 0; i < sv_maxclients->integer; i++ ) { if( svs.clients[i].state >= cs_connected ) { Netchan_Clear( &svs.clients[i].netchan ); svs.clients[i].delta_sequence = -1; } } numFrames = (sv.loadgame) ? 1 : 2; if( !sv.loadgame || svgame.globals->changelevel ) host.frametime = 0.1f; // GoldSrc rules // NOTE: this stuff is breaking sound from func_rotating in multiplayer // e.g. ambience\boomer.wav on snark_pit.bsp numFrames *= sv_maxclients->integer; // run some frames to allow everything to settle for( i = 0; i < numFrames; i++ ) { SV_Physics(); } // invoke to refresh all movevars Q_memset( &svgame.oldmovevars, 0, sizeof( movevars_t )); svgame.globals->changelevel = false; // changelevel ends here // setup hostflags sv.hostflags = 0; // tell what kind of server has been started. if( svgame.globals->maxClients > 1 ) { MsgDev( D_INFO, "%i player server started\n", svgame.globals->maxClients ); Cvar_Reset( "clockwindow" ); } else { // clear the ugly moving delay in singleplayer Cvar_SetFloat( "clockwindow", 0.0f ); MsgDev( D_INFO, "Game started\n" ); } if( host.type == HOST_DEDICATED ) { Mod_FreeUnused (); } sv.state = ss_active; physinfo->modified = true; sv.changelevel = false; sv.paused = false; Host_SetServerState( sv.state ); if( sv_maxclients->integer > 1 && public_server->integer ) { MsgDev( D_INFO, "Adding your server to master server list\n" ); Master_Add( ); } }