mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 17:54:48 +01:00
Core/Misc: Fix issues reported by static analysis
Coverity defect IDs: 1023115
(cherry picked from commit 391c81d86c)
Conflicts:
src/server/scripts/Commands/cs_npc.cpp
This commit is contained in:
@@ -374,28 +374,13 @@ public:
|
||||
|
||||
ObjectGuid::LowType lowGuid = strtoull(guidStr, nullptr, 10);
|
||||
|
||||
Creature* creature = NULL;
|
||||
|
||||
/* FIXME: impossible without entry
|
||||
if (lowguid)
|
||||
creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), MAKE_GUID(lowguid, HIGHGUID_UNIT));
|
||||
*/
|
||||
|
||||
// attempt check creature existence by DB data
|
||||
if (!creature)
|
||||
CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid);
|
||||
if (!data)
|
||||
{
|
||||
CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid);
|
||||
if (!data)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowGuid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// obtain real GUID for DB operations
|
||||
lowGuid = creature->GetSpawnId();
|
||||
handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowGuid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
int wait = waitStr ? atoi(waitStr) : 0;
|
||||
@@ -411,18 +396,6 @@ public:
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
if (creature && creature->GetWaypointPath())
|
||||
{
|
||||
creature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE);
|
||||
creature->GetMotionMaster()->Initialize();
|
||||
if (creature->IsAlive()) // dead creature will reset movement generator at respawn
|
||||
{
|
||||
creature->setDeathState(JUST_DIED);
|
||||
creature->Respawn(true);
|
||||
}
|
||||
creature->SaveToDB();
|
||||
}
|
||||
|
||||
handler->SendSysMessage(LANG_WAYPOINT_ADDED);
|
||||
|
||||
return true;
|
||||
@@ -836,34 +809,22 @@ public:
|
||||
|
||||
lowguid = strtoull(cId, nullptr, 10);
|
||||
|
||||
/* FIXME: impossible without entry
|
||||
if (lowguid)
|
||||
creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), MAKE_GUID(lowguid, HIGHGUID_UNIT));
|
||||
*/
|
||||
|
||||
// Attempting creature load from DB data
|
||||
if (!creature)
|
||||
CreatureData const* data = sObjectMgr->GetCreatureData(lowguid);
|
||||
if (!data)
|
||||
{
|
||||
CreatureData const* data = sObjectMgr->GetCreatureData(lowguid);
|
||||
if (!data)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 map_id = data->mapid;
|
||||
|
||||
if (handler->GetSession()->GetPlayer()->GetMapId() != map_id)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_CREATUREATSAMEMAP, lowguid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
||||
uint32 map_id = data->mapid;
|
||||
|
||||
if (handler->GetSession()->GetPlayer()->GetMapId() != map_id)
|
||||
{
|
||||
lowguid = creature->GetSpawnId();
|
||||
handler->PSendSysMessage(LANG_COMMAND_CREATUREATSAMEMAP, lowguid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user