/* ================ 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 ( 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 ); }
/* * ================ * SV_Shutdown * * Called when each game quits, * before Sys_Quit or Sys_Error * ================ */ void SV_Shutdown(char *finalmsg, qboolean reconnect) { if (svs.clients) { SV_FinalMessage(finalmsg, reconnect); } Master_Shutdown(); SV_ShutdownGameProgs(); // free current level if (sv.demofile) { FS_FCloseFile(sv.demofile); } memset(&sv, 0, sizeof(sv)); Com_SetServerState(sv.state); // free server static data if (svs.clients) { Z_Free(svs.clients); } if (svs.client_entities) { Z_Free(svs.client_entities); } if (svs.demofile) { fclose(svs.demofile); } memset(&svs, 0, sizeof(svs)); }
/* ================ SV_Shutdown Quake calls this before calling Sys_Quit or Sys_Error ================ */ void SV_Shutdown (char *finalmsg) { int i; SV_FinalMessage (finalmsg); PR_FreeStrings (); Master_Shutdown (); NET_ServerConfig (false); if (sv_fraglogfile) { fclose (sv_fraglogfile); sv_fraglogfile = NULL; } memset (&sv, 0, sizeof(sv)); sv.state = ss_dead; com_serveractive = false; for (i = 0; i < MAX_CLIENTS; i++) SV_FreeDelayedPackets(&svs.clients[i]); memset (svs.clients, 0, sizeof(svs.clients)); svs.lastuserid = 0; }
void SV_Quit_f (void) { SV_FinalMessage ("server shutdown\n"); Con_Printf ("Shutting down.\n"); SV_Shutdown (); Sys_Quit (); }
/* ================ 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 ); }
/* ================ 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 ); }
/* ================ 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(); } }
/* ================ 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(); // free current level SV_ClearServer(); // free siege static data since this is cross level or shutdown, not map restart if(svs.siege) { Z_Free(svs.siege); } // free server static data 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"); Com_Printf( "---------------------------\n" ); // disconnect any local clients if( sv_killserver->integer != 2 ) 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 ( svs.clients && !com_errorEntered ) { SV_FinalMessage( finalmsg ); } SV_RemoveOperatorCommands(); SV_MasterShutdown(); SV_ShutdownGameProgs(); svs.gameStarted = qfalse; /* Ghoul2 Insert Start */ // de allocate the snapshot entities if (svs.snapshotEntities) { delete[] svs.snapshotEntities; svs.snapshotEntities = NULL; } // free current level SV_ClearServer(); CM_ClearMap();//jfm: add a clear here since it's commented out in clearServer. This prevents crashing cmShaderTable on exit. // 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 if( sv_killserver->integer != 2 ) CL_Disconnect( qfalse ); }
/* ================ SV_Shutdown Called when each game quits, before Sys_Quit or Sys_Error ================ */ void SV_Shutdown( char *finalmsg ) { int i; 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_ShutdownGameProgs(qfalse); if (svs.snapshotEntities) { Z_Free(svs.snapshotEntities); svs.snapshotEntities = NULL; } for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) { if ( sv.configstrings[i] ) { Z_Free( sv.configstrings[i] ); } } // free current level memset( &sv, 0, sizeof( sv ) ); // free server static data if ( svs.clients ) { SV_FreeClient(svs.clients); Z_Free( svs.clients ); } memset( &svs, 0, sizeof( svs ) ); // Ensure we free any memory used by the leaf cache. CM_CleanLeafCache(); Cvar_Set( "sv_running", "0" ); //Com_Printf( "---------------------------\n" ); }
/** * @brief Called when each game quits, before Sys_Quit or Sys_Error * @param[in] finalmsg The message all clients get as server shutdown message * @param[in] reconnect True if this is only a restart (new map or map restart), * false if the server shutdown completely and you also want to disconnect all clients */ void SV_Shutdown (const char *finalmsg, qboolean reconnect) { unsigned int i; if (!svs.initialized) return; if (svs.clients) SV_FinalMessage(finalmsg, reconnect); Com_Printf("Shutdown server: %s\n", finalmsg); Master_Shutdown(); SV_ShutdownGameProgs(); NET_DatagramSocketClose(svs.netDatagramSocket); SV_Stop(); for (i = 0; i < sv->numSVModels; i++) { sv_model_t *model = &sv->svModels[i]; if (model->name) Mem_Free(model->name); } /* free current level */ OBJZERO(*sv); /* free server static data */ if (svs.clients) Mem_Free(svs.clients); if (svs.serverMutex != NULL) TH_MutexDestroy(svs.serverMutex); OBJZERO(svs); /* maybe we shut down before we init - e.g. in case of an error */ if (sv_maxclients) sv_maxclients->flags &= ~CVAR_LATCH; if (sv_mapname) sv_mapname->flags &= ~CVAR_NOSET; }
/* ================ 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 ); // stop server-side demos (if any) Cbuf_ExecuteText(EXEC_NOW, "stopserverdemo all"); if ( svs.clients && !com_errorEntered ) { SV_FinalMessage( finalmsg ); } SV_RemoveOperatorCommands(); SV_MasterShutdown(); SV_ShutdownGameProgs(); // free current level SV_ClearServer(); #ifdef USE_SQLITE_BANS #ifdef DEDICATED SV_BansShutdown(); #endif #endif // 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 if( sv_killserver->integer != 2 ) CL_Disconnect( qfalse ); }
// Called when each game quits, before Sys_Quit or Sys_Error void SV_Shutdown( const 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(); svs.gameStarted = qfalse; // free current level SV_ClearServer(); // free server static data if(svs.clients) { int index; for(index = 0; index < sv_maxclients->integer; index++) SV_FreeClient(&svs.clients[index]); Z_Free(svs.clients); } memset( &svs, 0, sizeof( svs ) ); Cvar_Set( "sv_running", "0" ); Com_Printf( "---------------------------\n" ); // disconnect any local clients if( sv_killserver->integer != 2 ) CL_Disconnect( qfalse, "Server shutdown" ); }
/* ================ 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_MasterShutdown(); SV_ShutdownGameProgs(); // stop any demos if (sv.demoState == DS_RECORDING) SV_DemoStopRecord(); if (sv.demoState == DS_PLAYBACK) SV_DemoStopPlayback(); // 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 if( sv_killserver->integer != 2 ) CL_Disconnect( qfalse ); }
/* ================ SV_Shutdown Called when each game quits, before Sys_Quit or Sys_Error ================ */ void SV_Shutdown( qboolean reconnect ) { // already freed if( !SV_Active( )) return; if( host.type == HOST_DEDICATED ) MsgDev( D_INFO, "SV_Shutdown: %s\n", host.finalmsg ); if( svs.clients ) SV_FinalMessage( host.finalmsg, reconnect ); Master_Shutdown(); if( !reconnect ) SV_UnloadProgs (); else SV_DeactivateServer (); // free current level Q_memset( &sv, 0, sizeof( sv )); Host_SetServerState( sv.state ); // free server static data if( svs.clients ) { Z_Free( svs.clients ); svs.clients = NULL; } if( svs.baselines ) { Z_Free( svs.baselines ); svs.baselines = NULL; } if( svs.packet_entities ) { Z_Free( svs.packet_entities ); svs.packet_entities = NULL; svs.num_client_entities = 0; svs.next_client_entities = 0; } svs.initialized = false; }
/* ================ 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_ShutdownGameProgs(); if (svs.snapshotEntities) { Z_Free(svs.snapshotEntities); svs.snapshotEntities = NULL; } // remove allocated space for ghoul2 game side model transforms delete G2VertSpaceServer; G2VertSpaceServer = NULL; // free current level memset( &sv, 0, sizeof( sv ) ); // free server static data if ( svs.clients ) { Z_Free( svs.clients ); } memset( &svs, 0, sizeof( svs ) ); // Ensure we free any memory used by the leaf cache. CM_CleanLeafCache(); Cvar_Set( "sv_running", "0" ); Com_Printf( "---------------------------\n" ); }
/* ================ SV_Error Sends a datagram to all the clients informing them of the server crash, then exits ================ */ void SV_Error (const char *error, ...) { va_list argptr; static char string[1024]; static qboolean inerror = false; if (inerror) Sys_Error ("%s: recursive error! (%s)", __thisfunc__, string); inerror = true; va_start (argptr, error); q_vsnprintf (string, sizeof(string), error, argptr); va_end (argptr); Con_Printf ("%s: %s\n", __thisfunc__, string); SV_FinalMessage (va("server crashed: %s\n", string)); SV_Shutdown (); Sys_Error ("%s: %s\n", __thisfunc__, string); }
/* * SV_ShutdownGame * * Called when each game quits */ void SV_ShutdownGame( const char *finalmsg, qboolean reconnect ) { if( !svs.initialized ) return; if( svs.demo.file ) SV_Demo_Stop_f(); if( svs.clients ) SV_FinalMessage( finalmsg, reconnect ); SV_ShutdownGameProgs(); // SV_MM_Shutdown(); NET_CloseSocket( &svs.socket_loopback ); NET_CloseSocket( &svs.socket_udp ); NET_CloseSocket( &svs.socket_udp6 ); #ifdef TCP_ALLOW_CONNECT if( sv_tcp->integer ) NET_CloseSocket( &svs.socket_tcp ); #endif // get any latched variable changes (sv_maxclients, etc) Cvar_GetLatchedVars( CVAR_LATCH ); if( svs.clients ) { Mem_Free( svs.clients ); svs.clients = NULL; } if( svs.client_entities.entities ) { Mem_Free( svs.client_entities.entities ); memset( &svs.client_entities, 0, sizeof( svs.client_entities ) ); } if( svs.cms ) { CM_Free( svs.cms ); svs.cms = NULL; } memset( &sv, 0, sizeof( sv ) ); Com_SetServerState( sv.state ); Com_FreePureList( &svs.purelist ); if( svs.motd ) { Mem_Free( svs.motd ); svs.motd = NULL; } if( sv_mempool ) Mem_EmptyPool( sv_mempool ); memset( &svs, 0, sizeof( svs ) ); svs.initialized = 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" ); //Replaced com_errorEntered check with a recursion check inside //SV_FinalMessage. How else can the clients know to disconnect? if ( svs.clients/* && !com_errorEntered*/ ) { SV_FinalMessage( finalmsg ); } SV_RemoveOperatorCommands(); #ifndef _XBOX // No master on Xbox SV_MasterShutdown(); #endif SV_ShutdownGameProgs(); /* Ghoul2 Insert Start */ // de allocate the snapshot entities if (svs.snapshotEntities) { delete[] svs.snapshotEntities; svs.snapshotEntities = NULL; } // free current level SV_ClearServer(); CM_ClearMap();//jfm: add a clear here since it's commented out in clearServer. This prevents crashing cmShaderTable on exit. // 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" ); #ifdef _XBOX // If we were advertising on Live, remove the listing. This also unregisters // the server's key. SysLink keys are never unregistered, so we don't do anything // special here for them. if ( logged_on ) XBL_MM_Shutdown( true ); // Leave the voice session g_Voice.LeaveSession(); // Tear down voice now if we're on system link (Live keeps it active) if( !logged_on ) g_Voice.Shutdown(); if( logged_on ) { XBL_F_OnClientLeaveSession(); XBL_PL_OnClientLeaveSession(); } // Wipe our player list - this is important memset( &xbOnlineInfo, 0, sizeof(xbOnlineInfo) ); #endif // disconnect any local clients CL_Disconnect( qfalse ); }
/* ================== SV_WriteEntitiesToClient ================== */ void SV_WriteEntitiesToClient( sv_client_t *cl, sizebuf_t *msg ) { edict_t *clent; edict_t *viewent; // may be NULL client_frame_t *frame; entity_state_t *state; static sv_ents_t frame_ents; int i, send_pings; clent = cl->edict; if( !SV_IsValidEdict( clent ) ) { SV_DropClient ( cl ); return; } viewent = cl->pViewEntity; // himself or trigger_camera frame = &cl->frames[cl->netchan.outgoing_sequence & SV_UPDATE_MASK]; send_pings = SV_ShouldUpdatePing( cl ); sv.net_framenum++; // now all portal-through entities are invalidate sv.hostflags &= ~SVF_PORTALPASS; // clear everything in this snapshot frame_ents.num_entities = c_fullsend = 0; // add all the entities directly visible to the eye, which // may include portal entities that merge other viewpoints SV_AddEntitiesToPacket( viewent, clent, frame, &frame_ents ); // if there were portals visible, there may be out of order entities // in the list which will need to be resorted for the delta compression // to work correctly. This also catches the error condition // of an entity being included twice. qsort( frame_ents.entities, frame_ents.num_entities, sizeof( frame_ents.entities[0] ), SV_EntityNumbers ); // copy the entity states out frame->num_entities = 0; // It will break all connected clients, but it takes more than one week to overflow it if( ( (unsigned int) svs.next_client_entities ) + frame_ents.num_entities >= 0x7FFFFFFE ) { // just reset counter svs.next_client_entities = 0; // delta is broken now, cannot keep connected clients SV_FinalMessage( "Server is running to long, reconnecting!", true ); } frame->first_entity = svs.next_client_entities; for( i = 0; i < frame_ents.num_entities; i++ ) { // add it to the circular packet_entities array state = &svs.packet_entities[svs.next_client_entities % svs.num_client_entities]; *state = frame_ents.entities[i]; svs.next_client_entities++; // this should never hit, map should always be restarted first in SV_Frame //if( svs.next_client_entities >= 0x7FFFFFFE ) //Host_Error( "svs.next_client_entities wrapped\n" ); frame->num_entities++; } SV_EmitPacketEntities( cl, frame, msg ); SV_EmitEvents( cl, frame, msg ); if( send_pings ) SV_EmitPings( msg ); }
/* * SV_ShutdownGame * * Called when each game quits */ void SV_ShutdownGame( const char *finalmsg, bool reconnect ) { if( !svs.initialized ) { return; } if( svs.demo.file ) { SV_Demo_Stop_f(); } if( svs.clients ) { SV_FinalMessage( finalmsg, reconnect ); } SV_ShutdownGameProgs(); // SV_MM_Shutdown(); SV_MasterSendQuit(); NET_CloseSocket( &svs.socket_loopback ); NET_CloseSocket( &svs.socket_udp ); NET_CloseSocket( &svs.socket_udp6 ); #ifdef TCP_ALLOW_CONNECT if( sv_tcp->integer ) { NET_CloseSocket( &svs.socket_tcp ); NET_CloseSocket( &svs.socket_tcp6 ); } #endif // get any latched variable changes (sv_maxclients, etc) Cvar_GetLatchedVars( CVAR_LATCH ); if( svs.clients ) { Mem_Free( svs.clients ); svs.clients = NULL; } if( svs.client_entities.entities ) { Mem_Free( svs.client_entities.entities ); memset( &svs.client_entities, 0, sizeof( svs.client_entities ) ); } if( svs.cms ) { // CM_ReleaseReference will take care of freeing up the memory // if there are no other modules referencing the collision model CM_ReleaseReference( svs.cms ); svs.cms = NULL; } Com_SetServerCM( NULL, 0 ); memset( &sv, 0, sizeof( sv ) ); Com_SetServerState( sv.state ); Com_FreePureList( &svs.purelist ); if( svs.motd ) { Mem_Free( svs.motd ); svs.motd = NULL; } if( sv_mempool ) { Mem_EmptyPool( sv_mempool ); } if( svs.wakelock ) { Sys_ReleaseWakeLock( svs.wakelock ); svs.wakelock = NULL; } memset( &svs, 0, sizeof( svs ) ); svs.initialized = false; }
char *Sys_ConsoleInput (void) { int c; if (consolewindowhandle) { MSG msg; while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)) { if (!GetMessage (&msg, NULL, 0, 0)) return NULL; TranslateMessage (&msg); DispatchMessage (&msg); } return NULL; } #ifdef SUBSERVERS if (SSV_IsSubServer()) { DWORD avail; static char text[1024]; static int textpos = 0; HANDLE input = GetStdHandle(STD_INPUT_HANDLE); if (!PeekNamedPipe(input, NULL, 0, NULL, &avail, NULL)) { SV_FinalMessage("Cluster shut down\n"); Cmd_ExecuteString("quit force", RESTRICT_LOCAL); } else if (avail) { if (avail > sizeof(text)-1-textpos) avail = sizeof(text)-1-textpos; if (ReadFile(input, text+textpos, avail, &avail, NULL)) { textpos += avail; while(textpos >= 2) { unsigned short len = text[0] | (text[1]<<8); if (textpos >= len && len >= 2) { memcpy(net_message.data, text+2, len-2); net_message.cursize = len-2; MSG_BeginReading (msg_nullnetprim); SSV_ReadFromControlServer(); memmove(text, text+len, textpos - len); textpos -= len; } else break; } } } return NULL; } #endif // read a line out while (_kbhit()) { c = _getch(); if (c == '\r') { coninput_text[coninput_len] = 0; putch ('\n'); putch (']'); coninput_len = 0; return coninput_text; } if (c == 8) { if (coninput_len) { putch (c); putch (' '); putch (c); coninput_len--; coninput_text[coninput_len] = 0; } continue; } if (c == '\t') { int i; char *s = Cmd_CompleteCommand(coninput_text, true, true, 0, NULL); if(s) { for (i = 0; i < coninput_len; i++) putch('\b'); for (i = 0; i < coninput_len; i++) putch(' '); for (i = 0; i < coninput_len; i++) putch('\b'); strcpy(coninput_text, s); coninput_len = strlen(coninput_text); printf("%s", coninput_text); } continue; } putch (c); coninput_text[coninput_len] = c; coninput_len++; coninput_text[coninput_len] = 0; if (coninput_len == sizeof(coninput_text)) coninput_len = 0; } return NULL; }