示例#1
0
文件: sv_init.c 项目: scenna/etlegacy
/**
 * @brief Called when each game quits, before Sys_Quit or Sys_Error
 */
void SV_Shutdown(char *finalmsg)
{
	// close attack log
	SV_CloseAttackLog();

	if (!com_sv_running || !com_sv_running->integer)
	{
		return;
	}

	Com_Printf("----- Server Shutdown -----\n");

	if (svs.clients && !com_errorEntered)
	{
		SV_FinalCommand(va("print \"%s\"", finalmsg), qtrue);
	}

	SV_RemoveOperatorCommands();
	SV_MasterShutdown();
	SV_ShutdownGameProgs();

	// stop any demos
	if (sv.demoState == DS_RECORDING)
	{
		SV_DemoStopRecord();
	}
	else if (sv.demoState == DS_PLAYBACK)
	{
		SV_DemoStopPlayback();
	}

	// free current level
	SV_ClearServer();

	// free server static data
	if (svs.clients)
	{
		//Z_Free( svs.clients );
		free(svs.clients);      // avoid trying to allocate large chunk on a fragmented zone
	}
	memset(&svs, 0, sizeof(svs));
	svs.serverLoad = -1;

	Cvar_Set("sv_running", "0");

	Com_Printf("---------------------------\n");

	// disconnect any local clients
	CL_Disconnect(qfalse);

#ifdef FEATURE_TRACKER
	Tracker_ServerStop();
#endif
}
示例#2
0
/**
 * @brief Called when each game quits, before Sys_Quit or Sys_Error
 */
void SV_Shutdown(char *finalmsg)
{
	// close attack log
	SV_CloseAttackLog();

	if (!com_sv_running || !com_sv_running->integer)
	{
		return;
	}

	Com_Printf("----- Server Shutdown -----\n");

	if (svs.clients && !com_errorEntered)
	{
		SV_FinalCommand(va("print \"%s\"", finalmsg), qtrue);
	}

	SV_RemoveOperatorCommands();
	SV_MasterShutdown();
	SV_ShutdownGameProgs();

	SV_DemoStopAll();

	// free current level
	SV_ClearServer();

	// free server static data
	if (svs.clients)
	{
		int index;

		for (index = 0; index < sv_maxclients->integer; index++)
		{
			SV_Netchan_ClearQueue(&svs.clients[index]);
		}

		//Z_Free( svs.clients );
		free(svs.clients);      // avoid trying to allocate large chunk on a fragmented zone
	}
	memset(&svs, 0, sizeof(svs));
	svs.serverLoad = -1;

	Cvar_Set("sv_running", "0");

	Com_Printf("---------------------------\n");

	// disconnect any local clients
	CL_Disconnect(qfalse);

#ifdef FEATURE_TRACKER
	Tracker_ServerStop();
#endif
}