Skip to content

Commit

Permalink
Implement a more robust cleanup strategy (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
TeddiO authored Nov 10, 2024
1 parent 25bd7aa commit deffd88
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/fwens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ Fwens* Fwens::GetInstance()
return instance;
}

void Fwens::Destroy()
{
if (instance != NULL)
{
delete instance;
instance = NULL;
}
}

void Fwens::SetLuaInstance(GarrysMod::Lua::ILuaBase* ILuaBase)
{
LUA = ILuaBase;
Expand Down
3 changes: 2 additions & 1 deletion src/fwens.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ class Fwens
public:
~Fwens();
static Fwens* GetInstance();
static void Destroy();
void InitSteamAPIConnection();
bool GetSteamContextActive();
void SetLuaInstance(GarrysMod::Lua::ILuaBase* ILuaBase);
void RequestUserGroupStatus(CSteamID player, CSteamID groupID);
void ClearSteamContext();
void ClearSteamContext();
void NotifyLuaSteamConnectionEvent(bool connected);

STEAM_GAMESERVER_CALLBACK(Fwens, Steam_HandleSteamConnected, SteamServersConnected_t, m_steamcallback_HandleConnected);
Expand Down
5 changes: 1 addition & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ GMOD_MODULE_OPEN()

GMOD_MODULE_CLOSE()
{
#ifdef _WIN32
Fwens* fwenVar = Fwens::GetInstance();
delete fwenVar;
#endif
Fwens::Destroy();
return 0;
}

0 comments on commit deffd88

Please sign in to comment.