fix(Core/Misc): Memleaks fixes. Part I. (#5546)

This commit is contained in:
UltraNix
2021-04-30 17:03:02 +02:00
committed by GitHub
parent 632883538c
commit adad43a15c
9 changed files with 51 additions and 37 deletions

View File

@@ -787,7 +787,14 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
if (!map)
{
LOG_ERROR("server", "Battlefield::SpawnCreature: Can't create creature entry: %u map not found", entry);
return 0;
return nullptr;
}
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry);
if (!cinfo)
{
LOG_ERROR("sql.sql", "Battlefield::SpawnCreature: entry %u does not exist.", entry);
return nullptr;
}
Creature* creature = new Creature(true);
@@ -801,12 +808,6 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
creature->setFaction(BattlefieldFactions[teamId]);
creature->SetHomePosition(x, y, z, o);
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry);
if (!cinfo)
{
LOG_ERROR("sql.sql", "Battlefield::SpawnCreature: entry %u does not exist.", entry);
return nullptr;
}
// force using DB speeds -- do we really need this?
creature->SetSpeed(MOVE_WALK, cinfo->speed_walk);
creature->SetSpeed(MOVE_RUN, cinfo->speed_run);