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:
parent
6b9fba7885
commit
5eff2ece21
2 changed files with 15 additions and 2 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue