Skip to content

Commit 7b7b314

Browse files
committed
Revert "Removed unused ClientMessageProcessor and other small fixes"
This reverts commit 4019fed.
1 parent 4230804 commit 7b7b314

File tree

6 files changed

+32
-3
lines changed

6 files changed

+32
-3
lines changed

Client/core/CCore.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ CCore::CCore ( void )
135135

136136
CCrashDumpWriter::SetHandlers();
137137

138+
m_pfnMessageProcessor = NULL;
138139
m_pMessageBox = NULL;
139140

140141
m_bFirstFrame = true;
@@ -658,6 +659,12 @@ void CCore::ForceCursorVisible ( bool bVisible, bool bToggleControls )
658659
}
659660

660661

662+
void CCore::SetMessageProcessor ( pfnProcessMessage pfnMessageProcessor )
663+
{
664+
m_pfnMessageProcessor = pfnMessageProcessor;
665+
}
666+
667+
661668
void CCore::ShowMessageBox ( const char* szTitle, const char* szText, unsigned int uiFlags, GUI_CALLBACK * ResponseHandler )
662669
{
663670
RemoveMessageBox ();

Client/core/CCore.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ class CCore : public CCoreInterface, public CSingleton < CCore >
158158
// Mod
159159
void SetOfflineMod ( bool bOffline );
160160
void ForceCursorVisible ( bool bVisible, bool bToggleControls = true );
161+
void SetMessageProcessor ( pfnProcessMessage pfnMessageProcessor );
161162
void ShowMessageBox ( const char* szTitle, const char* szText, unsigned int uiFlags, GUI_CALLBACK * ResponseHandler = NULL );
162163
void RemoveMessageBox ( bool bNextFrame = false );
163164
void ShowErrorMessageBox ( const SString& strTitle, SString strMessage, const SString& strTroubleLink = "" );
@@ -193,6 +194,8 @@ class CCore : public CCoreInterface, public CSingleton < CCore >
193194
HWND GetHookedWindow ( void );
194195
void SwitchRenderWindow ( HWND hWnd, HWND hWndInput );
195196
void CallSetCursorPos ( int X, int Y );
197+
void SetClientMessageProcessor ( pfnProcessMessage pfnMessageProcessor ) { m_pfnMessageProcessor = pfnMessageProcessor; };
198+
pfnProcessMessage GetClientMessageProcessor ( void ) { return m_pfnMessageProcessor; }
196199
void ChangeResolution ( long width, long height, long depth );
197200

198201
bool IsFocused ( void ) { return ( GetForegroundWindow ( ) == GetHookedWindow ( ) ); };
@@ -331,6 +334,7 @@ class CCore : public CCoreInterface, public CSingleton < CCore >
331334
bool m_bFirstFrame;
332335
bool m_bIsOfflineMod;
333336
bool m_bCursorToggleControls;
337+
pfnProcessMessage m_pfnMessageProcessor;
334338

335339
CGUIMessageBox* m_pMessageBox;
336340

Client/core/CMessageLoopHook.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,23 @@ LRESULT CALLBACK CMessageLoopHook::ProcessMessage ( HWND hwnd,
424424
// Lead the message through the keybinds message processor
425425
g_pCore->GetKeyBinds ()->ProcessMessage ( hwnd, uMsg, wParam, lParam );
426426

427+
bool bProcessed = false, bClientProcessed = false;
428+
427429
// Check and see if the GUI should process this message
428-
bool bProcessed = CLocalGUI::GetSingleton ().ProcessMessage ( hwnd, uMsg, wParam, lParam );
430+
bProcessed = CLocalGUI::GetSingleton ().ProcessMessage ( hwnd, uMsg, wParam, lParam );
429431

432+
// Check and see if the Core/mod should process this message
433+
if ( !CCore::GetSingleton ().GetGame ()->IsAtMenu() )
434+
{
435+
pfnProcessMessage pfnClientMessageProcessor = CCore::GetSingleton ().GetClientMessageProcessor();
436+
if ( pfnClientMessageProcessor )
437+
{
438+
bClientProcessed = pfnClientMessageProcessor ( hwnd, uMsg, wParam, lParam );
439+
}
440+
}
441+
430442
// If GTA can process this key
431-
if ( !bProcessed )
443+
if ( !bProcessed && !bClientProcessed )
432444
{
433445
// ALWAYS return true on escape to stop us getting to GTA's menu
434446
if ( uMsg == WM_KEYDOWN && wParam == VK_ESCAPE )

Client/core/CModManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ void CModManager::Unload ( void )
219219
CLocalGUI::GetSingleton ().GetDebugView ()->Clear ();
220220
CLocalGUI::GetSingleton ().SetDebugViewVisible ( false );
221221

222-
// NULL the unhandled command handler
222+
// NULL the message processor and the unhandled command handler
223+
CCore::GetSingleton ().SetClientMessageProcessor ( NULL );
223224
CCore::GetSingleton ().GetCommands ()->SetExecuteHandler ( NULL );
224225

225226
// Reset cursor alpha

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ CClientGame::CClientGame ( bool bLocalPlay )
288288
g_pGame->SetPreWeaponFireHandler ( CClientGame::PreWeaponFire );
289289
g_pGame->SetPostWeaponFireHandler ( CClientGame::PostWeaponFire );
290290
g_pGame->SetTaskSimpleBeHitHandler ( CClientGame::StaticTaskSimpleBeHitHandler );
291+
g_pCore->SetMessageProcessor ( CClientGame::StaticProcessMessage );
291292
g_pCore->GetKeyBinds ()->SetKeyStrokeHandler ( CClientGame::StaticKeyStrokeHandler );
292293
g_pCore->GetKeyBinds ()->SetCharacterKeyHandler ( CClientGame::StaticCharacterKeyHandler );
293294
g_pNet->RegisterPacketHandler ( CClientGame::StaticProcessPacket );
@@ -444,6 +445,7 @@ CClientGame::~CClientGame ( void )
444445
g_pGame->SetPostWeaponFireHandler ( NULL );
445446
g_pGame->SetTaskSimpleBeHitHandler ( NULL );
446447
g_pGame->GetAudio ()->SetWorldSoundHandler ( NULL );
448+
g_pCore->SetMessageProcessor ( NULL );
447449
g_pCore->GetKeyBinds ()->SetKeyStrokeHandler ( NULL );
448450
g_pCore->GetKeyBinds ()->SetCharacterKeyHandler ( NULL );
449451
g_pNet->StopNetwork ();

Client/sdk/core/CCoreInterface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include "xml/CXML.h"
2828
#include <gui/CGUI.h>
2929

30+
typedef bool (*pfnProcessMessage) ( HWND, UINT, WPARAM, LPARAM );
31+
3032
class CMultiplayer;
3133
class CNet;
3234
class CGame;
@@ -113,6 +115,7 @@ class CCoreInterface
113115
virtual void ShowServerInfo ( unsigned int WindowType ) = 0;
114116

115117
virtual void ForceCursorVisible ( bool bVisible, bool bToggleControls = true ) = 0;
118+
virtual void SetMessageProcessor ( pfnProcessMessage pfnMessageProcessor ) = 0;
116119
virtual void ShowMessageBox ( const char* szTitle, const char* szText, unsigned int uiFlags, GUI_CALLBACK * ResponseHandler = NULL ) = 0;
117120
virtual void RemoveMessageBox ( bool bNextFrame = false ) = 0;
118121
virtual void ShowErrorMessageBox ( const SString& strTitle, SString strMessage, const SString& strTroubleLink = "" ) = 0;

0 commit comments

Comments
 (0)