diff options
| author | joschiwald <joschiwald.trinity@gmail.com> | 2014-12-29 01:00:16 +0100 |
|---|---|---|
| committer | joschiwald <joschiwald.trinity@gmail.com> | 2014-12-29 01:00:16 +0100 |
| commit | 9ecc578cb187cc1ae0fd454883dab0cd058d3807 (patch) | |
| tree | 6322b594c6ff6958de870dc5b4f0effee1f6e5c7 /src/server/game/Battlefield/Battlefield.cpp | |
| parent | 21360bb50c6a1390fbeb51c9c27bb0823ad0f252 (diff) | |
Core/Scripts: multiple changes
- fixed non pch build
- fixed some warnings
- fixed some coverity issues
- some random things here and there
Diffstat (limited to 'src/server/game/Battlefield/Battlefield.cpp')
| -rw-r--r-- | src/server/game/Battlefield/Battlefield.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index d4aa1d37f11..73b9822af0d 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -771,6 +771,13 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl return nullptr; } + CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry); + if (!cinfo) + { + TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: entry %u does not exist.", entry); + return nullptr; + } + Creature* creature = new Creature(); if (!creature->Create(sObjectMgr->GetGenerator<HighGuid::Creature>()->Generate(), map, PHASEMASK_NORMAL, entry, x, y, z, o)) { @@ -778,14 +785,8 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl delete creature; return nullptr; } - creature->SetHomePosition(x, y, z, o); - CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry); - if (!cinfo) - { - TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: entry %u does not exist.", entry); - return nullptr; - } + creature->SetHomePosition(x, y, z, o); // Set creature in world map->AddToMap(creature); @@ -798,18 +799,27 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl GameObject* Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z, float o) { // Get map object - Map* map = sMapMgr->CreateBaseMap(571); // *vomits* + Map* map = sMapMgr->CreateBaseMap(m_MapId); if (!map) - return 0; + { + TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Can't create GameObject (Entry: %u). Map not found.", entry); + return nullptr; + } + + GameObjectTemplate const* goInfo = sObjectMgr->GetGameObjectTemplate(entry); + if (!goInfo) + { + TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: GameObject template %u not found in database! Battlefield not created!", entry); + return nullptr; + } // Create gameobject GameObject* go = new GameObject; if (!go->Create(sObjectMgr->GetGenerator<HighGuid::GameObject>()->Generate(), entry, map, PHASEMASK_NORMAL, x, y, z, o, 0, 0, 0, 0, 100, GO_STATE_READY)) { - TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Gameobject template %u not found in database! Battlefield not created!", entry); TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Cannot create gameobject template %u! Battlefield not created!", entry); delete go; - return NULL; + return nullptr; } // Add to world |
