Skip to content

Commit 500b07d

Browse files
committed
Make trigger triggerLatentClientEvent return eventId instead of true
1 parent 1660597 commit 500b07d

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

Server/mods/deathmatch/logic/CGame.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4697,7 +4697,10 @@ bool CGame::SendPacket(unsigned char ucPacketID, const NetServerPlayerID& player
46974697
return g_pNetServer->SendPacket(ucPacketID, playerID, pBitStream, bBroadcast, packetPriority, packetReliability, packetOrdering);
46984698
}
46994699
else
4700-
GetLatentTransferManager()->AddSend(playerID, pBitStream->Version(), m_iLatentSendsBandwidth, m_pLatentSendsLuaMain, m_usLatentSendsResourceNetId);
4700+
{
4701+
SSendHandle handle = GetLatentTransferManager()->AddSend(playerID, pBitStream->Version(), m_iLatentSendsBandwidth, m_pLatentSendsLuaMain, m_usLatentSendsResourceNetId);
4702+
m_LastSentHandle = handle;
4703+
}
47014704
return true;
47024705
}
47034706

Server/mods/deathmatch/logic/CGame.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ class CGame
465465
NetServerPacketPriority packetPriority, NetServerPacketReliability packetReliability,
466466
ePacketOrdering packetOrdering = PACKET_ORDERING_DEFAULT);
467467
void SendPacketBatchEnd();
468+
uint GetLastSentHandle() const { return m_LastSentHandle; }
468469

469470
bool IsBulletSyncActive();
470471
void SendSyncSettings(CPlayer* pPlayer = NULL);
@@ -671,6 +672,7 @@ class CGame
671672
int m_iLatentSendsBandwidth;
672673
CLuaMain* m_pLatentSendsLuaMain;
673674
ushort m_usLatentSendsResourceNetId;
675+
uint m_LastSentHandle;
674676

675677
CMtaVersion m_strPrevMinClientKickRequirement;
676678
CMtaVersion m_strPrevMinClientConnectRequirement;

Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ bool CStaticFunctionDefinitions::TriggerClientEvent(const std::vector<CPlayer*>&
229229
return true;
230230
}
231231

232-
bool CStaticFunctionDefinitions::TriggerLatentClientEvent(const std::vector<CPlayer*>& sendList, const char* szName, CElement* pCallWithElement,
232+
uint CStaticFunctionDefinitions::TriggerLatentClientEvent(const std::vector<CPlayer*>& sendList, const char* szName,
233+
CElement* pCallWithElement,
233234
CLuaArguments& Arguments, int iBandwidth, CLuaMain* pLuaMain, ushort usResourceNetId)
234235
{
235236
assert(szName);
@@ -246,7 +247,7 @@ bool CStaticFunctionDefinitions::TriggerLatentClientEvent(const std::vector<CPla
246247
g_pGame->EnableLatentSends(false);
247248

248249
CPerfStatEventPacketUsage::GetSingleton()->UpdateEventUsageOut(szName, sendList.size());
249-
return true;
250+
return g_pGame->GetLastSentHandle();
250251
}
251252

252253
bool CStaticFunctionDefinitions::CancelEvent(bool bCancel, const char* szReason)

Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class CStaticFunctionDefinitions
3434
static bool RemoveEventHandler(CLuaMain* pLuaMain, const char* szName, CElement* pElement, const CLuaFunctionRef& iLuaFunction);
3535
static bool TriggerEvent(const char* szName, CElement* pElement, const CLuaArguments& Arguments, bool& bWasCancelled);
3636
static bool TriggerClientEvent(const std::vector<CPlayer*>& sendList, const char* szName, CElement* pCallWithElement, CLuaArguments& Arguments);
37-
static bool TriggerLatentClientEvent(const std::vector<CPlayer*>& sendList, const char* szName, CElement* pCallWithElement, CLuaArguments& Arguments,
38-
int iBandwidth, CLuaMain* pLuaMain, ushort usResourceNetId);
37+
static uint TriggerLatentClientEvent(const std::vector<CPlayer*>& sendList, const char* szName, CElement* pCallWithElement,
38+
CLuaArguments& Arguments, int iBandwidth, CLuaMain* pLuaMain, ushort usResourceNetId);
3939

4040
static bool CancelEvent(bool bCancel, const char* szReason);
4141
static const char* GetCancelReason();

Server/mods/deathmatch/logic/luadefs/CLuaFunctionDefs.Event.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,17 @@ int CLuaFunctionDefs::TriggerLatentClientEvent(lua_State* luaVM)
310310
markerLatentEvent.SetAndStoreString(SString("Get args (%d,%s)", sendList.size(), *strName));
311311

312312
// Trigger it
313-
if (CStaticFunctionDefinitions::TriggerLatentClientEvent(sendList, strName, pCallWithElement, Arguments, iBandwidth, pLuaMain, usResourceNetId))
313+
uint handle = CStaticFunctionDefinitions::TriggerLatentClientEvent(sendList, strName, pCallWithElement, Arguments, iBandwidth, pLuaMain, usResourceNetId);
314+
if (handle >= 0)
314315
{
315316
markerLatentEvent.Set("End");
316317

317318
// Add debug info if wanted
318319
if (CPerfStatDebugInfo::GetSingleton()->IsActive("TriggerLatentClientEvent"))
319320
CPerfStatDebugInfo::GetSingleton()->AddLine("TriggerLatentClientEvent", markerLatentEvent.GetString());
320321

321-
lua_pushboolean(luaVM, true);
322+
// Return the handle id
323+
lua_pushnumber(luaVM, handle);
322324
return 1;
323325
}
324326
}

0 commit comments

Comments
 (0)