Scripts/Commands: Fix guid usage and enhance commands

- Fix targeting gameobjects and creatures for .dist and .gps. The old code used DB guid to search from core generated guid lists.
- Fix some error messages saying 'no player found' even if creatures and gameobjects and players were searched
- Change atoi to atoul when receiving lowguids as string or other uint32 values
- Use ObjectGuid::LowType instead of uint32 for lowguid type
- Allow .gob info to take in gameobject guid link as well as entry link in addition to gameobject entry and update the documentation of the command
- Change .gob delete to post the spawnid (dbguid) instead of the ingame generated guid (which is basically never seen or used by the player in any other commands that I see)
- Allow spawntimesecs to be negative when spawning a gameobject
- Disable searching by ingame spawn id in commands. (it makes little sense for a user to provide a number which is then attempted to be used as DB guid and non DB guid when both could have a match)
- Update .gob turn documentation to tell about possibility to provide orientation in command
- Correct the types in .gob add command result trinity_string
- Correct the creature search for .npc del
- Change .event to .event info
- Add .go offset command
- Remove the .go command for empty string (no subcommand given) because it just used .go xyz
- Extend .gob info to show size, faction, flags and model dimensions
- Remove some unnecessary casts
- Document .wp show better (first and last were not documented)
- Insert spawnid to .wp show info error message
- Fix spawntime printing for .gobject target
- Fix guid targetting for .npc set movetype
- Fix query by spawnid for .wp show info
- Fix deleting of existing waypoints when twice doing the command .wp show on
- Fix deleting of existing waypoints when doing the command .wp show off
- Change wpguid column in DB and in core to uint32, which is what the spawnid type is in core and db.
This commit is contained in:
Aokromes committed 2017-04-02 07:41:03 +02:00
1 parent e24178406d
commit 2d54defdf0
14 files changed
+301 -174

No files matched your search

+88 -33
View File
@@ -164,24 +164,54 @@ public:
static bool HandleGPSCommand(ChatHandler* handler, char const* args)
{
WorldObject* object = NULL;
WorldObject* object = nullptr;
if (*args)
{
ObjectGuid guid = handler->extractGuidFromLink((char*)args);
if (guid)
object = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT);
if (!object)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
handler->SetSentErrorMessage(true);
HighGuid guidHigh;
ObjectGuid::LowType guidLow = handler->extractLowGuidFromLink((char*)args, guidHigh);
if (!guidLow)
return false;
switch (guidHigh)
{
case HighGuid::Player:
{
object = sObjectMgr->GetPlayerByLowGUID(guidLow);
if (!object)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
handler->SetSentErrorMessage(true);
}
break;
}
case HighGuid::Unit:
{
object = handler->GetCreatureFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->SendSysMessage(LANG_COMMAND_NOCREATUREFOUND);
handler->SetSentErrorMessage(true);
}
break;
}
case HighGuid::GameObject:
{
object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND);
handler->SetSentErrorMessage(true);
}
break;
}
default:
return false;
}
if (!object)
return false;
}
else
{
object = handler->getSelectedUnit();
if (!object)
{
handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
@@ -763,26 +793,55 @@ public:
static bool HandleGetDistanceCommand(ChatHandler* handler, char const* args)
{
WorldObject* obj = NULL;
WorldObject* object = nullptr;
if (*args)
{
ObjectGuid guid = handler->extractGuidFromLink((char*)args);
if (guid)
obj = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT);
if (!obj)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
handler->SetSentErrorMessage(true);
HighGuid guidHigh;
ObjectGuid::LowType guidLow = handler->extractLowGuidFromLink((char*)args, guidHigh);
if (!guidLow)
return false;
switch (guidHigh)
{
case HighGuid::Player:
{
object = sObjectMgr->GetPlayerByLowGUID(guidLow);
if (!object)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
handler->SetSentErrorMessage(true);
}
break;
}
case HighGuid::Unit:
{
object = handler->GetCreatureFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->SendSysMessage(LANG_COMMAND_NOCREATUREFOUND);
handler->SetSentErrorMessage(true);
}
break;
}
case HighGuid::GameObject:
{
object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND);
handler->SetSentErrorMessage(true);
}
break;
}
default:
return false;
}
if (!object)
return false;
}
else
{
obj = handler->getSelectedUnit();
if (!obj)
object = handler->getSelectedUnit();
if (!object)
{
handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
handler->SetSentErrorMessage(true);
@@ -790,7 +849,7 @@ public:
}
}
handler->PSendSysMessage(LANG_DISTANCE, handler->GetSession()->GetPlayer()->GetDistance(obj), handler->GetSession()->GetPlayer()->GetDistance2d(obj), handler->GetSession()->GetPlayer()->GetExactDist(obj), handler->GetSession()->GetPlayer()->GetExactDist2d(obj));
handler->PSendSysMessage(LANG_DISTANCE, handler->GetSession()->GetPlayer()->GetDistance(object), handler->GetSession()->GetPlayer()->GetDistance2d(object), handler->GetSession()->GetPlayer()->GetExactDist(object), handler->GetSession()->GetPlayer()->GetExactDist2d(object));
return true;
}
// Teleport player to last position
@@ -2178,8 +2237,8 @@ public:
return false;
}
int32 guid = atoi(guidStr);
if (!guid)
ObjectGuid::LowType guidLow = atoul(guidStr);
if (!guidLow)
{
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
@@ -2204,14 +2263,10 @@ public:
if (Player* player = handler->GetSession()->GetPlayer())
{
GameObject* go = NULL;
if (GameObjectData const* goData = sObjectMgr->GetGOData(guid))
go = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guid, goData->id);
GameObject* go = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!go)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guid);
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
handler->SetSentErrorMessage(true);
return false;
}
@@ -2224,7 +2279,7 @@ public:
}
go->ModifyHealth(-damage, player);
handler->PSendSysMessage(LANG_GAMEOBJECT_DAMAGED, go->GetName().c_str(), guid, -damage, go->GetGOValue()->Building.Health);
handler->PSendSysMessage(LANG_GAMEOBJECT_DAMAGED, go->GetName().c_str(), guidLow, -damage, go->GetGOValue()->Building.Health);
}
return true;