1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 18:19:55 +00:00

[Server] Fix memory leaks related to WorldEvents as suggested by Koncord

This commit is contained in:
David Cernat 2017-01-29 20:18:19 +02:00
parent 6b9fba7885
commit 5eff2ece21
2 changed files with 15 additions and 2 deletions

View file

@ -21,7 +21,7 @@ using namespace std;
Networking *Networking::sThis = 0;
static WorldEvent *worldEvent;
static WorldEvent *worldEvent = nullptr;
Networking::Networking(RakNet::RakPeerInterface *peer)
{
@ -417,6 +417,13 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
return;
WorldPacket *myPacket = worldController->GetPacket(packet->data[0]);
if (worldEvent)
{
delete worldEvent;
worldEvent = nullptr;
}
worldEvent = new WorldEvent(player->guid);
mwmp::WorldObject worldObject;

View file

@ -9,7 +9,7 @@
using namespace mwmp;
static WorldEvent *worldEvent;
static WorldEvent *worldEvent = nullptr;
std::regex exteriorCellPattern("^(-?\\d+), (-?\\d+)$");
@ -18,6 +18,12 @@ void WorldFunctions::CreateWorldEvent(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player, );
if (worldEvent)
{
delete worldEvent;
worldEvent = nullptr;
}
worldEvent = new WorldEvent(player->guid);
}