Skip to content

Commit 0aaea2d

Browse files
committed
Moved m_hWnd to be a global variable as hWnd
1 parent 54d35bf commit 0aaea2d

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

globals.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ enum : std::uint8_t
7373
HUD_PRINTCENTER
7474
};
7575

76+
//---------------------------------------------------------------------------------
77+
// Public variables.
78+
//---------------------------------------------------------------------------------
79+
// Windows API Window Handle
80+
static HWND hWnd;
81+
7682
//---------------------------------------------------------------------------------
7783
// Interfaces from the engine.
7884
//---------------------------------------------------------------------------------

p2sm.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CP2SMPlusPlusPlugin, IServerPluginCallbacks, I
2626
//---------------------------------------------------------------------------------
2727
CP2SMPlusPlusPlugin::CP2SMPlusPlusPlugin()
2828
{
29-
this->m_hWnd = nullptr;
29+
hWnd = nullptr;
3030
this->m_bPluginLoaded = false;
3131
this->m_bNoUnload = false; // If we fail to load, we don't want to run anything on Unload() to get what the error was.
3232
}
@@ -76,8 +76,8 @@ bool CP2SMPlusPlusPlugin::Load(CreateInterfaceFn interfaceFactory, CreateInterfa
7676
Log(INFO, false, "Loading plugin...");
7777

7878
Log(INFO, true, "Grabbing game window handle...");
79-
this->m_hWnd = FindWindow("Valve001", nullptr);
80-
if (!this->m_hWnd)
79+
hWnd = FindWindow("Valve001", nullptr);
80+
if (!hWnd)
8181
Log(WARNING, false, "Failed to find game window!");
8282

8383
Log(INFO, true, "Connecting tier libraries...");
@@ -157,7 +157,7 @@ void CP2SMPlusPlusPlugin::Unload(void)
157157
if (m_bNoUnload)
158158
{
159159
m_bNoUnload = false;
160-
MessageBox(this->m_hWnd, "P2SM++ ran into a error when starting!\nPlease check the console for more info!", "P2SM++ Startup Error", MB_OK | MB_ICONERROR);
160+
MessageBox(hWnd, "P2SM++ ran into a error when starting!\nPlease check the console for more info!", "P2SM++ Startup Error", MB_OK | MB_ICONERROR);
161161
return;
162162
}
163163

p2sm.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ class CP2SMPlusPlusPlugin : public IServerPluginCallbacks
4545
virtual bool BNetworkCryptKeyValidate(uint32 unFromIP, uint16 usFromPort, uint32 unAccountIdProvidedByClient, int nEncryptionKeyIndexFromClient, int numEncryptedBytesFromClient, byte* pbEncryptedBufferFromClient, byte* pbPlainTextKeyForNetchan);
4646

4747
private:
48-
// Windows API Window Handle
49-
HWND m_hWnd;
50-
5148
// Plugin state member variables.
5249
bool m_bPluginLoaded;
5350
bool m_bNoUnload;

0 commit comments

Comments
 (0)