22#include < msgpack.hpp>
33#include < map>
44
5- std::map<std::string, PluginUserMessage> scriptingUserMessages;
5+ std::map<std::string, PluginUserMessage* > scriptingUserMessages;
66
7- PluginUserMessage FetchUserMessage (std::string uuid)
7+ PluginUserMessage* FetchUserMessage (std::string uuid)
88{
9- if (!ExistsUserMessage (uuid)) return PluginUserMessage ( " " ) ;
9+ if (!ExistsUserMessage (uuid)) return nullptr ;
1010 return scriptingUserMessages.at (uuid);
1111}
1212
@@ -18,11 +18,10 @@ bool ExistsUserMessage(std::string uuid)
1818void EraseUserMessage (std::string uuid)
1919{
2020 if (!ExistsUserMessage (uuid)) return ;
21-
2221 scriptingUserMessages.erase (uuid);
2322}
2423
25- std::string InsertUserMessage (PluginUserMessage um)
24+ std::string InsertUserMessage (PluginUserMessage* um)
2625{
2726 std::string uuid = get_uuid ();
2827 if (ExistsUserMessage (uuid)) EraseUserMessage (uuid);
@@ -36,8 +35,7 @@ bool UserMessages_SendNetMessage(INetChannel* pNetChan, CNetMessage* pData, int
3635 auto netmsg = pData->GetNetMessage ();
3736 int playerid = FindClientByNetChannel (pNetChan);
3837
39- PluginUserMessage um (netmsg, netmsg->GetNetMessageInfo (), pData);
40-
38+ PluginUserMessage* um = new PluginUserMessage (netmsg, netmsg->GetNetMessageInfo (), pData);
4139 std::string uuid = InsertUserMessage (um);
4240
4341 std::stringstream ss;
@@ -54,6 +52,7 @@ bool UserMessages_SendNetMessage(INetChannel* pNetChan, CNetMessage* pData, int
5452 delete event;
5553
5654 EraseUserMessage (uuid);
55+ delete um;
5756
5857 return (result != EventResult::Stop);
5958}
0 commit comments