mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 19:37:02 +00:00
[11987] Fix possible memory leak in .gameobject add command
Thanks to Kid10 for pointing Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
parent
744995d27c
commit
0645d10286
2 changed files with 14 additions and 16 deletions
|
|
@ -1058,7 +1058,6 @@ bool ChatHandler::HandleGameObjectAddCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const GameObjectInfo* gInfo = ObjectMgr::GetGameObjectInfo(id);
|
const GameObjectInfo* gInfo = ObjectMgr::GetGameObjectInfo(id);
|
||||||
|
|
||||||
if (!gInfo)
|
if (!gInfo)
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, id);
|
PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, id);
|
||||||
|
|
@ -1075,14 +1074,12 @@ bool ChatHandler::HandleGameObjectAddCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player *chr = m_session->GetPlayer();
|
Player* plr = m_session->GetPlayer();
|
||||||
float x = float(chr->GetPositionX());
|
float x = float(plr->GetPositionX());
|
||||||
float y = float(chr->GetPositionY());
|
float y = float(plr->GetPositionY());
|
||||||
float z = float(chr->GetPositionZ());
|
float z = float(plr->GetPositionZ());
|
||||||
float o = float(chr->GetOrientation());
|
float o = float(plr->GetOrientation());
|
||||||
Map *map = chr->GetMap();
|
Map* map = plr->GetMap();
|
||||||
|
|
||||||
GameObject* pGameObj = new GameObject;
|
|
||||||
|
|
||||||
// used guids from specially reserved range (can be 0 if no free values)
|
// used guids from specially reserved range (can be 0 if no free values)
|
||||||
uint32 db_lowGUID = sObjectMgr.GenerateStaticGameObjectLowGuid();
|
uint32 db_lowGUID = sObjectMgr.GenerateStaticGameObjectLowGuid();
|
||||||
|
|
@ -1093,7 +1090,8 @@ bool ChatHandler::HandleGameObjectAddCommand(char* args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pGameObj->Create(db_lowGUID, gInfo->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o))
|
GameObject* pGameObj = new GameObject;
|
||||||
|
if (!pGameObj->Create(db_lowGUID, gInfo->id, map, plr->GetPhaseMaskForSpawn(), x, y, z, o))
|
||||||
{
|
{
|
||||||
delete pGameObj;
|
delete pGameObj;
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1103,7 +1101,7 @@ bool ChatHandler::HandleGameObjectAddCommand(char* args)
|
||||||
pGameObj->SetRespawnTime(spawntimeSecs);
|
pGameObj->SetRespawnTime(spawntimeSecs);
|
||||||
|
|
||||||
// fill the gameobject data and save to the db
|
// fill the gameobject data and save to the db
|
||||||
pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()),chr->GetPhaseMaskForSpawn());
|
pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), plr->GetPhaseMaskForSpawn());
|
||||||
|
|
||||||
// this will generate a new guid if the object is in an instance
|
// this will generate a new guid if the object is in an instance
|
||||||
if (!pGameObj->LoadFromDB(db_lowGUID, map))
|
if (!pGameObj->LoadFromDB(db_lowGUID, map))
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11986"
|
#define REVISION_NR "11987"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue