/* ==================== CL_PlayDemo_f play [demoname] ==================== */ void CL_PlayDemo_f (void) { char name[256]; if (Cmd_Argc() != 2) { Con_Printf ("play <demoname> : plays a demo\n"); return; } // // disconnect from server // CL_Disconnect (); // // open the demo file // strcpy (name, Cmd_Argv(1)); COM_DefaultExtension (name, ".qwd"); Con_Printf ("Playing demo from %s.\n", name); COM_FOpenFile (name, &cls.demofile); if (!cls.demofile) { Con_Printf ("ERROR: couldn't open.\n"); cls.demonum = -1; // stop demo loop return; } cls.demoplayback = true; cls.state = ca_demostart; Netchan_Setup (&cls.netchan, net_from, 0); realtime = 0; }
/* ================ Host_EndGame ================ */ void Host_EndGame (char *message, ...) { va_list argptr; char string[1024]; va_start (argptr,message); vsnprintf(string, sizeof(string), message,argptr); va_end (argptr); Con_DPrintf ("Host_EndGame: %s\n",string); if (sv.active) Host_ShutdownServer (false); if (cls.state == ca_dedicated) Sys_Error ("Host_EndGame: %s\n",string); // dedicated servers exit if (cls.demonum != -1) { CL_StopPlayback (); // JPG 1.05 - patch by CSR to fix crash CL_NextDemo (); } else CL_Disconnect (); longjmp (host_abortserver, 1); }
/** * This shuts down both the client and server */ void Host_Error(const char *error, ...) { va_list argptr; char string[1024]; static bool inerror = false; if (inerror) Sys_Error("Host_Error: recursively entered"); inerror = true; SCR_EndLoadingPlaque(); // reenable screen updates va_start(argptr, error); vsprintf(string, error, argptr); va_end(argptr); Con_Printf("Host_Error: %s\n", string); if (sv.active) Host_ShutdownServer(false); if (cls.state == ca_dedicated) Sys_Error("Host_Error: %s\n", string); // dedicated servers exit CL_Disconnect(); cls.demonum = -1; inerror = false; longjmp(host_abortserver, 1); }
/* ================== Host_ShutdownServer This only happens at the end of a game, not between levels ================== */ void Host_ShutdownServer(qboolean crash) { int i, count; sizebuf_t buf; unsigned char message[4]; double start; if (!sv.active) return; sv.active = false; // stop all client sounds immediately if (cls.state == ca_connected) CL_Disconnect (); // flush any pending messages - like the score!!! start = Sys_DoubleTime(); do { count = 0; for (i=0, host_client = svs.clients ; i<svs.maxclients ; i++, host_client++) { if (host_client->active && host_client->message.cursize) { if (NET_CanSendMessage (host_client->netconnection)) { NET_SendMessage(host_client->netconnection, &host_client->message); SZ_Clear (&host_client->message); } else { NET_GetMessage(host_client->netconnection); count++; } } } if ((Sys_DoubleTime() - start) > 3.0) break; } while (count); // make sure all the clients know we're disconnecting buf.data = message; buf.maxsize = 4; buf.cursize = 0; MSG_WriteByte(&buf, svc_disconnect); count = NET_SendToAll(&buf, 5); if (count) Con_Printf("Host_ShutdownServer: NET_SendToAll failed for %u clients\n", count); for (i=0, host_client = svs.clients ; i<svs.maxclients ; i++, host_client++) if (host_client->active) SV_DropClient(crash); // // clear structures // memset (&sv, 0, sizeof(sv)); memset (svs.clients, 0, svs.maxclientslimit*sizeof(client_t)); }
/* ================ Host_EndGame ================ */ void Host_EndGame (char *message, ...) { va_list argptr; char* string = Sys_BigStackAlloc(1024, "Host_EndGame"); va_start (argptr,message); vsprintf (string,message,argptr); va_end (argptr); Con_DPrintf ("Host_EndGame: %s\n",string); if (sv.active) Host_ShutdownServer (false); if (cls.state == ca_dedicated) Sys_Error ("Host_EndGame: %s\n",string); // dedicated servers exit Sys_BigStackFree(1024, "Host_EndGame"); if (cls.demonum != -1) { CL_StopPlayback(); CL_NextDemo(); } else CL_Disconnect (); longjmp (host_abortserver, 1); }
/* ================ Host_Error This shuts down both the client and server ================ */ void Host_Error (const char *error, ...) { va_list argptr; char string[1024]; static qboolean inerror = false; if (inerror) Sys_Error ("Host_Error: recursively entered"); inerror = true; SCR_EndLoadingPlaque (); // reenable screen updates va_start (argptr,error); q_vsnprintf (string, sizeof(string), error, argptr); va_end (argptr); Con_Printf ("Host_Error: %s\n",string); if (sv.active) Host_ShutdownServer (false); if (cls.state == ca_dedicated) Sys_Error ("Host_Error: %s\n",string); // dedicated servers exit CL_Disconnect (); cls.demonum = -1; cl.intermission = 0; //johnfitz -- for errors during intermissions (changelevel with no map found, etc.) inerror = false; longjmp (host_abortserver, 1); }
/* ================= CL_DemoCompleted ================= */ void CL_DemoCompleted(void) { #if NEW_DEMOFUNC CL_FreeDemoPoints(); #endif if (cl_timedemo && cl_timedemo->integer) { int time; time = Sys_Milliseconds() - clc.timeDemoStart; if (time > 0) { Com_FuncPrinf("%i frames, %3.1f seconds: %3.1f fps\n", clc.timeDemoFrames, time / 1000.0, clc.timeDemoFrames * 1000.0 / time); } } if (CL_VideoRecording()) { Cmd_ExecuteString("stopvideo"); } if (clc.waverecording) { CL_WriteWaveClose(); clc.waverecording = qfalse; } CL_Disconnect(qtrue); CL_NextDemo(); }
/* <36123> ../engine/host.c:255 */ void __declspec(noreturn) Host_Error(const char *error, ...) { va_list argptr; char string[1024]; static qboolean inerror = FALSE; va_start(argptr, error); if (inerror) Sys_Error("Host_Error: recursively entered"); inerror = TRUE; SCR_EndLoadingPlaque(); Q_vsnprintf(string, sizeof(string), error, argptr); va_end(argptr); if (g_psv.active && developer.value != 0.0 ) CL_WriteMessageHistory(0, 0); Con_Printf("Host_Error: %s\n", string); if (g_psv.active) Host_ShutdownServer(FALSE); if (g_pcls.state) { CL_Disconnect(); g_pcls.demonum = -1; inerror = FALSE; longjmp(host_abortserver, 1); } Sys_Error("Host_Error: %s\n", string); }
/* ===================== CL_MapLoading A local server is starting to load a map, so update the screen to let the user know about it, then dump all client memory on the hunk from cgame, ui, and renderer ===================== */ void CL_MapLoading( void ) { if ( !com_cl_running->integer ) { return; } Con_Close(); Key_SetCatcher( 0 ); // if we are already connected to the local host, stay connected if ( cls.state >= CA_CONNECTED && !Q_stricmp( cls.servername, "localhost" ) ) { cls.state = CA_CONNECTED; // so the connect screen is drawn memset( cls.updateInfoString, 0, sizeof( cls.updateInfoString ) ); // memset( clc.serverMessage, 0, sizeof( clc.serverMessage ) ); memset( &cl.gameState, 0, sizeof( cl.gameState ) ); clc.lastPacketSentTime = -9999; SCR_UpdateScreen(); } else { // clear nextmap so the cinematic shutdown doesn't execute it Cvar_Set( "nextmap", "" ); CL_Disconnect(); Q_strncpyz( cls.servername, "localhost", sizeof(cls.servername) ); cls.state = CA_CHALLENGING; // so the connect screen is drawn Key_SetCatcher( 0 ); SCR_UpdateScreen(); clc.connectTime = -RETRANSMIT_TIMEOUT; NET_StringToAdr( cls.servername, &clc.serverAddress); // we don't need a challenge on the localhost CL_CheckForResend(); } CL_FlushMemory(); }
/* * CL_WebDownloadDoneCb */ static void CL_WebDownloadDoneCb( int status, const char *contentType, void *privatep ) { bool disconnect = cls.download.disconnect; bool cancelled = cls.download.cancelled; bool success = (cls.download.offset == cls.download.size) && (status > -1); Com_Printf( "Web download %s: %s (%i)\n", success ? "successful" : "failed", cls.download.tempname, status ); if( success ) { CL_DownloadComplete(); } CL_StopServerDownload(); if( cancelled ) { cls.download.requestnext = false; } cls.download.web = false; // check if user pressed escape to stop the downloa if( disconnect ) { CL_Disconnect( NULL ); return; } /*if( success || cancelled )*/ { CL_DownloadDone(); } }
void GAME_SetMode (const cgame_export_t *gametype) { const cgame_export_t *list; if (cls.gametype == gametype) return; list = GAME_GetCurrentType(); if (list) { Com_Printf("Shutdown gametype '%s'\n", list->name); list->Shutdown(); /* we dont need to go back to "main" stack if we are already on this stack */ if (!UI_IsWindowOnStack("main")) UI_InitStack("main", "", qtrue, qtrue); } cls.gametype = gametype; CL_Disconnect(); list = GAME_GetCurrentType(); if (list) { Com_Printf("Change gametype to '%s'\n", list->name); /* inventory structure switched/initialized */ INV_DestroyInventory(&cls.i); INV_InitInventory(list->name, &cls.i, &csi, &inventoryImport); /** @todo this should be in GetCGameAPI */ list->Init(NULL); } }
/* ================ Host_Error This shuts down both the client and server ================ */ void Host_Error (char *error, ...) { va_list argptr; char string[1024]; static qboolean inerror = false; if (inerror) Sys_Error ("Host_Error: recursively entered"); inerror = true; SCR_EndLoadingPlaque (); // reenable screen updates va_start (argptr,error); #if defined (__APPLE__) || defined (MACOSX) vsnprintf (string,1024,error,argptr); #else vsprintf (string,error,argptr); #endif /* __APPLE__ || MACOSX */ va_end (argptr); Con_Printf ("Host_Error: %s\n",string); if (sv.active) Host_ShutdownServer (false); if (cls.state == ca_dedicated) Sys_Error ("Host_Error: %s\n",string); // dedicated servers exit CL_Disconnect (); cls.demonum = -1; inerror = false; longjmp (host_abortserver, 1); }
/* ================ Host_EndGame ================ */ void Host_EndGame (char *message, ...) { va_list argptr; char string[1024]; va_start (argptr,message); #if defined (__APPLE__) || defined (MACOSX) vsnprintf (string,1024,message,argptr); #else vsprintf (string,message,argptr); #endif /* __APPLE__ || MACOSX */ va_end (argptr); Con_DPrintf ("Host_EndGame: %s\n",string); if (sv.active) Host_ShutdownServer (false); if (cls.state == ca_dedicated) Sys_Error ("Host_EndGame: %s\n",string); // dedicated servers exit if (cls.demonum != -1) CL_NextDemo (); else CL_Disconnect (); longjmp (host_abortserver, 1); }
/* ================ SV_Shutdown Called when each game quits, before Sys_Quit or Sys_Error ================ */ void SV_Shutdown( char *finalmsg ) { if ( !com_sv_running || !com_sv_running->integer ) { return; } Com_Printf( "----- Server Shutdown -----\n" ); if ( svs.clients && !com_errorEntered ) { SV_FinalMessage( finalmsg ); } SV_RemoveOperatorCommands(); SV_MasterShutdown(); SV_ShutdownGameProgs(); // free current level SV_ClearServer(); // free server static data if ( svs.clients ) { //Z_Free( svs.clients ); free( svs.clients ); // RF, avoid trying to allocate large chunk on a fragmented zone } memset( &svs, 0, sizeof( svs ) ); Cvar_Set( "sv_running", "0" ); Com_Printf( "---------------------------\n" ); // disconnect any local clients CL_Disconnect( qfalse ); }
/* ====================== Host_Map_f handle a map <servername> command from the console. Active clients are kicked off. ====================== */ void Host_Map_f (void) { int i; char name[MAX_QPATH], *p; if (Cmd_Argc() < 2) //no map name given { if (cls.state == ca_dedicated) { if (sv.active) Con_Printf ("Current map: %s\n", sv.name); else Con_Printf ("Server not active\n"); } else if (cls.state == ca_connected) { Con_Printf ("Current map: %s ( %s )\n", cl.levelname, cl.mapname); } else { Con_Printf ("map <levelname>: start a new server\n"); } return; } if (cmd_source != src_command) return; cls.demonum = -1; // stop demo loop in case this fails CL_Disconnect (); Host_ShutdownServer(false); if (cls.state != ca_dedicated) IN_Activate(); key_dest = key_game; // remove console or menu SCR_BeginLoadingPlaque (); svs.serverflags = 0; // haven't completed an episode yet q_strlcpy (name, Cmd_Argv(1), sizeof(name)); // remove (any) trailing ".bsp" from mapname -- S.A. p = strstr(name, ".bsp"); if (p && p[4] == '\0') *p = '\0'; SV_SpawnServer (name); if (!sv.active) return; if (cls.state != ca_dedicated) { memset (cls.spawnparms, 0, MAX_MAPSTRING); for (i = 2; i < Cmd_Argc(); i++) { q_strlcat (cls.spawnparms, Cmd_Argv(i), MAX_MAPSTRING); q_strlcat (cls.spawnparms, " ", MAX_MAPSTRING); } Cmd_ExecuteString ("connect local", src_command); } }
//This shuts down both the client and server void Host_Error (char *error, ...) { va_list argptr; char string[1024]; static qbool inerror = false; if (inerror) Sys_Error ("Host_Error: recursively entered"); inerror = true; va_start (argptr,error); vsnprintf (string, sizeof(string), error, argptr); va_end (argptr); Com_Printf ("\n===========================\n"); Com_Printf ("Host_Error: %s\n",string); Com_Printf ("===========================\n\n"); CL_Disconnect (); if (!host_initialized) Sys_Error ("Host_Error: %s", string); inerror = false; Host_Abort (); }
/* ================ SV_Shutdown Called when each game quits, before Sys_Quit or Sys_Error ================ */ void SV_Shutdown( char *finalmsg ) { if ( !com_sv_running || !com_sv_running->integer ) { return; } Com_Printf( "----- Server Shutdown -----\n" ); if ( svs.clients && !com_errorEntered ) { SV_FinalMessage( finalmsg ); } SV_RemoveOperatorCommands(); SV_MasterShutdown(); SV_ShutdownGameProgs(); // free current level SV_ClearServer(); // free server static data if ( svs.clients ) { Z_Free( svs.clients ); } Com_Memset( &svs, 0, sizeof( svs ) ); Cvar_Set( "sv_running", "0" ); Cvar_Set("ui_singlePlayerActive", "0"); Com_Printf( "---------------------------\n" ); // disconnect any local clients CL_Disconnect( qfalse ); }
/* ================ SV_Shutdown Called when each game quits, before Sys_Quit or Sys_Error ================ */ void SV_Shutdown( char *finalmsg ) { if ( !com_sv_running || !com_sv_running->integer ) return; Com_Printf( "----- Server Shutdown -----\n" ); if( theSVS.svClients_.size() && !com_errorEntered ) { SV_FinalMessage( finalmsg ); } //SV_RemoveOperatorCommands(); //SV_MasterShutdown(); SV_ShutdownGameProgs(); // free current level SV_ClearServer(); // free server static data // if( theSVS.clients_ ) // Z_Free( theSVS.clients_ ); // theSVS.clearClients();// done in theSVS.clear() /// Com_Memset( &svs, 0, sizeof( svs ) ); theSVS.clear(); Cvar_Set( "sv_running", "0" ); Cvar_Set("ui_singlePlayerActive", "0"); Com_Printf( "---------------------------\n" ); // disconnect any local clients CL_Disconnect( false ); }
void Host_Quit() { CL_Disconnect (); Host_ShutdownServer(false); Sys_Quit (); }
void CL_Disconnect_f(void) { CL_Disconnect(); if (sv.active) Host_ShutdownServer(false); }
/* ================ Host_Error This shuts down both the client and server ================ */ void Host_Error (const char *error, ...) { static char hosterrorstring1[MAX_INPUTLINE]; // THREAD UNSAFE static char hosterrorstring2[MAX_INPUTLINE]; // THREAD UNSAFE static qboolean hosterror = false; va_list argptr; // turn off rcon redirect if it was active when the crash occurred // to prevent loops when it is a networking problem Con_Rcon_Redirect_Abort(); va_start (argptr,error); dpvsnprintf (hosterrorstring1,sizeof(hosterrorstring1),error,argptr); va_end (argptr); Con_Printf("Host_Error: %s\n", hosterrorstring1); // LordHavoc: if crashing very early, or currently shutting down, do // Sys_Error instead if (host_framecount < 3 || host_shuttingdown) Sys_Error ("Host_Error: %s", hosterrorstring1); if (hosterror) Sys_Error ("Host_Error: recursively entered (original error was: %s new error is: %s)", hosterrorstring2, hosterrorstring1); hosterror = true; strlcpy(hosterrorstring2, hosterrorstring1, sizeof(hosterrorstring2)); CL_Parse_DumpPacket(); CL_Parse_ErrorCleanUp(); //PR_Crash(); // print out where the crash happened, if it was caused by QC (and do a cleanup) PRVM_Crash(SVVM_prog); PRVM_Crash(CLVM_prog); #ifdef CONFIG_MENU PRVM_Crash(MVM_prog); #endif cl.csqc_loaded = false; Cvar_SetValueQuick(&csqc_progcrc, -1); Cvar_SetValueQuick(&csqc_progsize, -1); SV_LockThreadMutex(); Host_ShutdownServer (); SV_UnlockThreadMutex(); if (cls.state == ca_dedicated) Sys_Error ("Host_Error: %s",hosterrorstring2); // dedicated servers exit CL_Disconnect (); cls.demonum = -1; hosterror = false; Host_AbortCurrentFrame(); }
static void CL_Quit_f (void) { if (!con_module) Sys_Printf ("I hope you wanted to quit\n"); CL_Disconnect (); Sys_Quit (); }
/** * @brief Ensures the right menu cvars are set after error drop or map change * @note E.g. called after an ERR_DROP was thrown * @sa CL_Disconnect * @sa SV_Map */ void CL_Drop (void) { CL_Disconnect(); /* drop loading plaque */ SCR_EndLoadingPlaque(); GAME_Drop(); }
/* ================ SV_Shutdown Called when each game quits, before Sys_Quit or Sys_Error ================ */ void SV_Shutdown( char *finalmsg ) { if ( !com_sv_running || !com_sv_running->integer ) { return; } Com_Printf( "----- Server Shutdown (%s) -----\n", finalmsg ); NET_LeaveMulticast6(); if ( svs.clients && !com_errorEntered ) { SV_FinalMessage( finalmsg ); } SV_RemoveOperatorCommands(); SV_MasterShutdown(); SV_ShutdownGameProgs(); #ifdef DEDICATED Com_ShutdownRef(); #endif MSG_ShutdownNetFields(); // free current level SV_ClearServer(); // free server static data if(svs.players) { int index; for(index = 0; index < sv_maxclients->integer; index++) SV_FreePlayer(&svs.players[index]); Z_Free(svs.players); } if(svs.clients) { int index; for(index = 0; index < sv_maxclients->integer; index++) SV_FreeClient(&svs.clients[index]); Z_Free(svs.clients); } Com_Memset( &svs, 0, sizeof( svs ) ); Cvar_Set( "sv_running", "0" ); Cvar_Set("ui_singlePlayerActive", "0"); Cvar_Set("sv_public", "0"); Com_Printf( "---------------------------\n" ); // disconnect any local clients if( sv_killserver->integer != 2 ) CL_Disconnect( qfalse ); }
/* ================ CL_Drop Called after an Host_Error was thrown ================ */ void CL_Drop( void ) { if( cls.state == ca_uninitialized ) return; CL_Disconnect(); // This fixes crash in menu_playersetup after disconnecting from server CL_ClearEdicts(); }
static void CLQW_Model_NextDownload() { if ( clc.downloadNumber == 0 ) { common->Printf( "Checking models...\n" ); clc.downloadNumber = 1; } clc.downloadType = dl_model; for ( ; cl.qh_model_name[ clc.downloadNumber ][ 0 ] ; clc.downloadNumber++ ) { const char* s = cl.qh_model_name[ clc.downloadNumber ]; if ( s[ 0 ] == '*' ) { continue; // inline brush model } if ( !CL_CheckOrDownloadFile( s ) ) { return; // started a download } } CM_LoadMap( cl.qh_model_name[ 1 ], true, NULL ); cl.model_clip[ 1 ] = 0; R_LoadWorld( cl.qh_model_name[ 1 ] ); for ( int i = 2; i < MAX_MODELS_Q1; i++ ) { if ( !cl.qh_model_name[ i ][ 0 ] ) { break; } cl.model_draw[ i ] = CLQ1_RegisterModel( cl.qh_model_name[ i ] ); if ( cl.qh_model_name[ i ][ 0 ] == '*' ) { cl.model_clip[ i ] = CM_InlineModel( String::Atoi( cl.qh_model_name[ i ] + 1 ) ); } if ( !cl.model_draw[ i ] ) { common->Printf( "\nThe required model file '%s' could not be found or downloaded.\n\n", cl.qh_model_name[ i ] ); common->Printf( "You may need to download or purchase a %s client " "pack in order to play on this server.\n\n", fs_gamedir ); CL_Disconnect( true ); return; } } CLQW_CalcModelChecksum( "progs/player.mdl", "pmodel" ); CLQW_CalcModelChecksum( "progs/eyes.mdl", "emodel" ); // all done R_EndRegistration(); int CheckSum1; int CheckSum2; CM_MapChecksums( CheckSum1, CheckSum2 ); // done with modellist, request first of static signon messages CL_AddReliableCommand( va( "prespawn %i 0 %i", cl.servercount, CheckSum2 ) ); }
/* ================ SV_Shutdown Called when each game quits, before Sys_Quit or Sys_Error ================ */ void SV_Shutdown( char *finalmsg ) { if ( !com_sv_running || !com_sv_running->integer ) { return; } Com_Printf( "----- Server Shutdown -----\n" ); if ( svs.clients && !com_errorEntered ) { SV_FinalMessage( finalmsg ); } SV_RemoveOperatorCommands(); SV_MasterShutdown(); SV_ShutdownGameProgs(); /* Ghoul2 Insert Start */ // de allocate the snapshot entities if (svs.snapshotEntities) { delete[] svs.snapshotEntities; svs.snapshotEntities = NULL; } #ifdef G2_COLLISION_ENABLED if ( com_dedicated->integer && G2VertSpaceServer) { delete G2VertSpaceServer; G2VertSpaceServer = 0; } #endif // free current level SV_ClearServer(); // free server static data if ( svs.clients ) { Z_Free( svs.clients ); } Com_Memset( &svs, 0, sizeof( svs ) ); Cvar_Set( "sv_running", "0" ); Cvar_Set("ui_singlePlayerActive", "0"); Com_Printf( "---------------------------\n" ); // disconnect any local clients CL_Disconnect( qfalse ); // shutdown webserver if (mgsrv) { SV_MV_Websrv_Shutdown(); } }
/* ================== CL_Quit_f ================== */ void CL_Quit_f (void) { if (1 /* key_dest != key_console */ /* && cls.state != ca_dedicated */) { //M_Menu_Quit_f (); return; } CL_Disconnect (); Sys_Quit (); }
/* ================== Host_Stopdemo_f Return to looping demos ================== */ static void Host_Stopdemo_f(void) { if (cls.state == ca_dedicated) return; if (!cls.demoplayback) return; CL_StopPlayback(); CL_Disconnect(); }
void Host_Quit_f (void) { if (!con_module) Sys_Printf ("I hope you wanted to quit\n"); CL_Disconnect (); Host_ShutdownServer (false); Sys_Quit (); }