From 791461c8738f85d4b946a2987ca4f77b2d807f49 Mon Sep 17 00:00:00 2001 From: Teddi Date: Sun, 10 Nov 2024 12:20:36 +0000 Subject: [PATCH 1/7] Some initial considerations / checks --- .github/workflows/build-pr.yml | 11 +++++++++++ src/fwens.cpp | 14 ++++++++++++++ src/fwens.h | 4 +++- src/main.cpp | 20 ++++++++++++++++---- 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 74197cb..50c8c13 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -92,6 +92,11 @@ jobs: cd gfwens ./premake5.exe vs2019 MSBuild.exe /p:Configuration=Release + + - uses: actions/upload-artifact@v4 + with: + name: gmsv_fwens_win${{matrix.arch}}.dll + path: gfwens\bin\release\gmsv_fwens_win${{matrix.arch}}.dll ### build-linux: @@ -131,6 +136,12 @@ jobs: ./premake5 gmake2 make config=release_x${{matrix.arch}} + - uses: actions/upload-artifact@v4 + if: ${{ matrix.arch != 64 }} + with: + name: gmsv_fwens_linux.dll + path: gfwens/bin/release/gmsv_fwens_linux.dll + release: name: Build Cleanup runs-on: ubuntu-latest diff --git a/src/fwens.cpp b/src/fwens.cpp index 0ec4c61..413bc25 100644 --- a/src/fwens.cpp +++ b/src/fwens.cpp @@ -27,6 +27,20 @@ Fwens* Fwens::GetInstance() return instance; } +void Fwens::Destroy(); +{ + if (instance != NULL) + { + delete instance; + instance = NULL; + } +} + +bool Fwens::IsInstanceValid() +{ + return instance != NULL; +} + void Fwens::SetLuaInstance(GarrysMod::Lua::ILuaBase* ILuaBase) { LUA = ILuaBase; diff --git a/src/fwens.h b/src/fwens.h index d42b4fe..a22f7b5 100644 --- a/src/fwens.h +++ b/src/fwens.h @@ -13,11 +13,13 @@ class Fwens public: ~Fwens(); static Fwens* GetInstance(); + bool IsInstanceValid(); + 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); diff --git a/src/main.cpp b/src/main.cpp index 02d1294..4c01a0f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -85,10 +85,22 @@ GMOD_MODULE_OPEN() GMOD_MODULE_CLOSE() { -#ifdef _WIN32 - Fwens* fwenVar = Fwens::GetInstance(); - delete fwenVar; -#endif +// #ifdef _WIN32 +// Fwens* fwenVar = Fwens::GetInstance(); +// delete fwenVar; +// #endif + if (Fwens::IsInstanceValid()) + { + LUA->PushSpecial(SPECIAL_GLOB); + LUA->CreateTable(); + LUA->GetField(-1, "print"); + LUA->PushString("we have a valid instance of fwens?"); + LUA->Call(1, 0); + + Fwens* fwenVar = Fwens::GetInstance(); + delete fwenVar; + } + return 0; } From f472007a81bc454965ee7d4278925ad0ee190d9d Mon Sep 17 00:00:00 2001 From: Teddi Date: Sun, 10 Nov 2024 12:23:54 +0000 Subject: [PATCH 2/7] typo --- src/fwens.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fwens.cpp b/src/fwens.cpp index 413bc25..c54cda8 100644 --- a/src/fwens.cpp +++ b/src/fwens.cpp @@ -27,7 +27,7 @@ Fwens* Fwens::GetInstance() return instance; } -void Fwens::Destroy(); +void Fwens::Destroy() { if (instance != NULL) { From db7e4c135084c099819af6ec8d7cd12f0826df66 Mon Sep 17 00:00:00 2001 From: Teddi Date: Sun, 10 Nov 2024 12:31:15 +0000 Subject: [PATCH 3/7] Whoops, forgot to make static --- src/fwens.h | 2 +- src/main.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fwens.h b/src/fwens.h index a22f7b5..130908b 100644 --- a/src/fwens.h +++ b/src/fwens.h @@ -13,7 +13,7 @@ class Fwens public: ~Fwens(); static Fwens* GetInstance(); - bool IsInstanceValid(); + static bool IsInstanceValid(); void Destroy(); void InitSteamAPIConnection(); bool GetSteamContextActive(); diff --git a/src/main.cpp b/src/main.cpp index 4c01a0f..1c04e80 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -89,6 +89,7 @@ GMOD_MODULE_CLOSE() // Fwens* fwenVar = Fwens::GetInstance(); // delete fwenVar; // #endif + if (Fwens::IsInstanceValid()) { LUA->PushSpecial(SPECIAL_GLOB); From 5653c2273b0e3e94b04b7f7f4c3a928242091d56 Mon Sep 17 00:00:00 2001 From: Teddi Date: Sun, 10 Nov 2024 12:42:01 +0000 Subject: [PATCH 4/7] Add a debug message to confirm the consideration... --- src/fwens.h | 2 +- src/main.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/fwens.h b/src/fwens.h index 130908b..8085989 100644 --- a/src/fwens.h +++ b/src/fwens.h @@ -14,7 +14,7 @@ class Fwens ~Fwens(); static Fwens* GetInstance(); static bool IsInstanceValid(); - void Destroy(); + static void Destroy(); void InitSteamAPIConnection(); bool GetSteamContextActive(); void SetLuaInstance(GarrysMod::Lua::ILuaBase* ILuaBase); diff --git a/src/main.cpp b/src/main.cpp index 1c04e80..832d04c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -101,6 +101,14 @@ GMOD_MODULE_CLOSE() Fwens* fwenVar = Fwens::GetInstance(); delete fwenVar; } + else + { + LUA->PushSpecial(SPECIAL_GLOB); + LUA->CreateTable(); + LUA->GetField(-1, "print"); + LUA->PushString("We dont have a valid instance of fwens?"); + LUA->Call(1, 0); + } return 0; } From cd33501b0d6fb1bbc872ea295fc3e82a460a81bf Mon Sep 17 00:00:00 2001 From: Teddi Date: Sun, 10 Nov 2024 12:47:47 +0000 Subject: [PATCH 5/7] Have module take care of its own cleanup --- src/main.cpp | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 832d04c..ab2ac3d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -85,31 +85,7 @@ GMOD_MODULE_OPEN() GMOD_MODULE_CLOSE() { -// #ifdef _WIN32 -// Fwens* fwenVar = Fwens::GetInstance(); -// delete fwenVar; -// #endif - - if (Fwens::IsInstanceValid()) - { - LUA->PushSpecial(SPECIAL_GLOB); - LUA->CreateTable(); - LUA->GetField(-1, "print"); - LUA->PushString("we have a valid instance of fwens?"); - LUA->Call(1, 0); - - Fwens* fwenVar = Fwens::GetInstance(); - delete fwenVar; - } - else - { - LUA->PushSpecial(SPECIAL_GLOB); - LUA->CreateTable(); - LUA->GetField(-1, "print"); - LUA->PushString("We dont have a valid instance of fwens?"); - LUA->Call(1, 0); - } - + Fwens::Destroy(); return 0; } From dd4480d95631dd39014ddeb3c2723f1e7e64aa47 Mon Sep 17 00:00:00 2001 From: Teddi Date: Sun, 10 Nov 2024 12:52:23 +0000 Subject: [PATCH 6/7] Remove IsInstanceValid as no longer required --- src/fwens.cpp | 5 ----- src/fwens.h | 1 - 2 files changed, 6 deletions(-) diff --git a/src/fwens.cpp b/src/fwens.cpp index c54cda8..ccd91b4 100644 --- a/src/fwens.cpp +++ b/src/fwens.cpp @@ -36,11 +36,6 @@ void Fwens::Destroy() } } -bool Fwens::IsInstanceValid() -{ - return instance != NULL; -} - void Fwens::SetLuaInstance(GarrysMod::Lua::ILuaBase* ILuaBase) { LUA = ILuaBase; diff --git a/src/fwens.h b/src/fwens.h index 8085989..6fd1ab2 100644 --- a/src/fwens.h +++ b/src/fwens.h @@ -13,7 +13,6 @@ class Fwens public: ~Fwens(); static Fwens* GetInstance(); - static bool IsInstanceValid(); static void Destroy(); void InitSteamAPIConnection(); bool GetSteamContextActive(); From 9791e7fbda77269d9ec42f9a5f5cd225e264485b Mon Sep 17 00:00:00 2001 From: Teddi Date: Sun, 10 Nov 2024 12:58:22 +0000 Subject: [PATCH 7/7] Remove debug artifact uploads --- .github/workflows/build-pr.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 50c8c13..74197cb 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -92,11 +92,6 @@ jobs: cd gfwens ./premake5.exe vs2019 MSBuild.exe /p:Configuration=Release - - - uses: actions/upload-artifact@v4 - with: - name: gmsv_fwens_win${{matrix.arch}}.dll - path: gfwens\bin\release\gmsv_fwens_win${{matrix.arch}}.dll ### build-linux: @@ -136,12 +131,6 @@ jobs: ./premake5 gmake2 make config=release_x${{matrix.arch}} - - uses: actions/upload-artifact@v4 - if: ${{ matrix.arch != 64 }} - with: - name: gmsv_fwens_linux.dll - path: gfwens/bin/release/gmsv_fwens_linux.dll - release: name: Build Cleanup runs-on: ubuntu-latest