11#include " MessageHandlers.h"
22
3+ // thread waiting for message event signaling
34DWORD WINAPI WaitForNewMessagesThreadProc (LPVOID lpParam)
45{
56 UNREFERENCED_PARAMETER (lpParam);
@@ -16,7 +17,8 @@ DWORD WINAPI WaitForNewMessagesThreadProc(LPVOID lpParam)
1617 case WAIT_OBJECT_0 + 0 :
1718 if (ArkApi::GetApiUtils ().GetWorld ())
1819 {
19- OnNewMessagesFromDatabase ();
20+ std::lock_guard<std::mutex> lock (plugin.new_message_available_mutex );
21+ plugin.new_message_available = true ;
2022 }
2123 break ;
2224 case WAIT_OBJECT_0 + 1 :
@@ -34,6 +36,19 @@ DWORD WINAPI WaitForNewMessagesThreadProc(LPVOID lpParam)
3436 return 0 ;
3537}
3638
39+ // check for new messages on game tick
40+ void MessageTimer (float delta)
41+ {
42+ auto &plugin = Plugin::Get ();
43+ if (plugin.new_message_available )
44+ {
45+ std::lock_guard<std::mutex> lock (plugin.new_message_available_mutex );
46+ plugin.new_message_available = false ;
47+
48+ OnNewMessagesFromDatabase ();
49+ }
50+ }
51+
3752// when the database has been updated with new messages
3853void OnNewMessagesFromDatabase ()
3954{
@@ -82,14 +97,14 @@ void HandleMessageFromDatabase(
8297 int icon)
8398{
8499 auto &plugin = Plugin::Get ();
100+ auto isLocal = serverKey.compare (plugin.serverKey ) == 0 ;
101+
85102 // send chat message to users
86103 if (rcon == 0 )
87104 {
88105 auto chatIcon = static_cast <ChatIcon>(icon);
89106 UTexture2D *iconTexture = nullptr ;
90107
91- auto isLocal = serverKey.compare (plugin.serverKey ) == 0 ;
92-
93108 // get chat icon
94109 if (chatIcon == ChatIcon::Admin)
95110 {
@@ -132,7 +147,7 @@ void HandleMessageFromDatabase(
132147 FromUTF16 (message).c_str (),
133148 iconTexture);
134149 }
135- else
150+ else if (!isLocal)
136151 {
137152 SendRconChatMessageToAll (FromUTF16 (message));
138153 }
0 commit comments