- fixed shutdown crash sourcemm-1.6.0
authorDavid Anderson <dvander@alliedmods.net>
Sat Sep 29 15:01:32 2007 +0000 (2007-09-29)
branchsourcemm-1.6.0
changeset 365afdf36dee1a6
parent 364 30ac566e3e94
child 366 cbfac4e86a2a
- fixed shutdown crash
- fixed makefile for linux
sourcemm/Makefile.ep1
sourcemm/episode1/console.cpp
sourcemm/episode1/provider_ep1.cpp
sourcemm/episode1/provider_ep1.h
sourcemm/metamod.cpp
sourcemm/metamod_provider.h
     1.1 --- a/sourcemm/Makefile.ep1	Sat Sep 29 04:09:05 2007 +0000
     1.2 +++ b/sourcemm/Makefile.ep1	Sat Sep 29 15:01:32 2007 +0000
     1.3 @@ -53,7 +53,7 @@
     1.4  	ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so
     1.5  	ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so
     1.6  	ln -sf $(SMM_ROOT)/sourcehook/sourcehook.cpp sourcehook.cpp
     1.7 -	$(MAKE) sourcemm
     1.8 +	$(MAKE) -f Makefile.ep1 sourcemm
     1.9  	rm -rf $(BINARY)
    1.10  	ln -sf $(BIN_DIR)/$(BINARY) $(BINARY)
    1.11  
    1.12 @@ -61,7 +61,7 @@
    1.13  	$(CPP) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
    1.14  
    1.15  debug:	
    1.16 -	$(MAKE) all DEBUG=true
    1.17 +	$(MAKE) -f Makefile.ep1 all DEBUG=true
    1.18  
    1.19  default: all
    1.20  
     2.1 --- a/sourcemm/episode1/console.cpp	Sat Sep 29 04:09:05 2007 +0000
     2.2 +++ b/sourcemm/episode1/console.cpp	Sat Sep 29 15:01:32 2007 +0000
     2.3 @@ -80,6 +80,37 @@
     2.4  	}
     2.5  }
     2.6  
     2.7 +void SMConVarAccessor::UnregisterGameDLLCommands()
     2.8 +{
     2.9 +	ConCommandBase *begin = icvar->GetCommands();
    2.10 +	ConCommandBase *iter = begin;
    2.11 +	ConCommandBase *prev = NULL;
    2.12 +	while (iter)
    2.13 +	{
    2.14 +		/* Watch out for the ETERNAL COMMAND! */
    2.15 +		if (iter != &s_EternalCommand && iter->IsBitSet(FCVAR_GAMEDLL))
    2.16 +		{
    2.17 +			/* Remove it! */
    2.18 +			if (iter == begin)
    2.19 +			{
    2.20 +				s_EternalCommand.BringToFront();
    2.21 +				iter = const_cast<ConCommandBase*>(iter->GetNext());
    2.22 +				s_EternalCommand.SetNext(iter);
    2.23 +				prev = &s_EternalCommand;
    2.24 +				continue;
    2.25 +			}
    2.26 +			else
    2.27 +			{
    2.28 +				iter = const_cast<ConCommandBase*>(iter->GetNext());
    2.29 +				prev->SetNext(iter);
    2.30 +				continue;
    2.31 +			}
    2.32 +		}
    2.33 +		prev = iter;
    2.34 +		iter = const_cast<ConCommandBase*>(iter->GetNext());
    2.35 +	}
    2.36 +}
    2.37 +
    2.38  void SMConVarAccessor::Unregister(ConCommandBase *pCommand)
    2.39  {
    2.40  	ConCommandBase *ptr = icvar->GetCommands();
     3.1 --- a/sourcemm/episode1/provider_ep1.cpp	Sat Sep 29 04:09:05 2007 +0000
     3.2 +++ b/sourcemm/episode1/provider_ep1.cpp	Sat Sep 29 15:01:32 2007 +0000
     3.3 @@ -85,6 +85,12 @@
     3.4  	ConCommandBaseMgr::OneTimeInit(&g_SMConVarAccessor);
     3.5  }
     3.6  
     3.7 +void BaseProvider::Notify_DLLShutdown_Pre()
     3.8 +{
     3.9 +	g_SMConVarAccessor.MarkCommandsAsGameDLL();
    3.10 +	g_SMConVarAccessor.UnregisterGameDLLCommands();
    3.11 +}
    3.12 +
    3.13  bool BaseProvider::IsRemotePrintingAvailable()
    3.14  {
    3.15  	return (echo_msg_func != NULL);
     4.1 --- a/sourcemm/episode1/provider_ep1.h	Sat Sep 29 04:09:05 2007 +0000
     4.2 +++ b/sourcemm/episode1/provider_ep1.h	Sat Sep 29 15:01:32 2007 +0000
     4.3 @@ -28,6 +28,7 @@
     4.4  	virtual void Notify_DLLInit_Pre(void *gamedll,
     4.5  		CreateInterfaceFn engineFactory, 
     4.6  		CreateInterfaceFn serverFactory);
     4.7 +	void Notify_DLLShutdown_Pre();
     4.8  	virtual void ServerCommand(const char *cmd);
     4.9  	virtual ConVar *CreateConVar(const char *name, 
    4.10  		const char *defval, 
     5.1 --- a/sourcemm/metamod.cpp	Sat Sep 29 04:09:05 2007 +0000
     5.2 +++ b/sourcemm/metamod.cpp	Sat Sep 29 15:01:32 2007 +0000
     5.3 @@ -54,7 +54,6 @@
     5.4  	CreateInterfaceFn factory;
     5.5  };
     5.6  
     5.7 -SourceHook::CallClass<IServerGameDLL> *g_GameDllPatch;
     5.8  String mod_path;
     5.9  String metamod_path;
    5.10  String full_bin_path;
    5.11 @@ -662,8 +661,6 @@
    5.12  	physics_factory = physicsFactory;
    5.13  	gpGlobals = pGlobals;
    5.14  
    5.15 -	g_GameDllPatch = SH_GET_CALLCLASS(server);
    5.16 -
    5.17  	provider->Notify_DLLInit_Pre(server, engineFactory, gamedll_info.factory);
    5.18  
    5.19  	metamod_version = provider->CreateConVar("metamod_version", 
    5.20 @@ -724,10 +721,9 @@
    5.21  	/* Unload plugins */
    5.22  	g_PluginMngr.UnloadAll();
    5.23  
    5.24 -	SH_CALL(g_GameDllPatch, &IServerGameDLL::DLLShutdown)();
    5.25 +	provider->Notify_DLLShutdown_Pre();
    5.26  
    5.27 -	SH_RELEASE_CALLCLASS(g_GameDllPatch);
    5.28 -	g_GameDllPatch = NULL;
    5.29 +	SH_CALL(server, &IServerGameDLL::DLLShutdown)();
    5.30  
    5.31  	g_SourceHook.CompleteShutdown();
    5.32  
     6.1 --- a/sourcemm/metamod_provider.h	Sat Sep 29 04:09:05 2007 +0000
     6.2 +++ b/sourcemm/metamod_provider.h	Sat Sep 29 15:01:32 2007 +0000
     6.3 @@ -163,6 +163,8 @@
     6.4  			CreateInterfaceFn engineFactory, 
     6.5  			CreateInterfaceFn serverFactory) =0;
     6.6  
     6.7 +		virtual void Notify_DLLShutdown_Pre() =0;
     6.8 +
     6.9  		/**
    6.10  		 * @brief Wrapper around IVEngineServer::ServerCommand()
    6.11  		 *