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

+60 -15
View File
@@ -49,7 +49,7 @@ public:
{ "zonexy", rbac::RBAC_PERM_COMMAND_GO_ZONEXY, false, &HandleGoZoneXYCommand, "" },
{ "xyz", rbac::RBAC_PERM_COMMAND_GO_XYZ, false, &HandleGoXYZCommand, "" },
{ "ticket", rbac::RBAC_PERM_COMMAND_GO_TICKET, false, &HandleGoTicketCommand, "" },
{ "", rbac::RBAC_PERM_COMMAND_GO, false, &HandleGoXYZCommand, "" },
{ "offset", rbac::RBAC_PERM_COMMAND_GO_OFFSET, false, &HandleGoOffsetCommand,
};
static std::vector<ChatCommand> commandTable =
@@ -96,7 +96,7 @@ public:
if (!id)
return false;
int32 entry = atoi(id);
uint32 entry = atoul(id);
if (!entry)
return false;
@@ -104,17 +104,17 @@ public:
}
else
{
int32 guid = atoi(param1);
ObjectGuid::LowType guidLow = atoul(param1);
// Number is invalid - maybe the user specified the mob's name
if (!guid)
if (!guidLow)
{
std::string name = param1;
WorldDatabase.EscapeString(name);
whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name " _LIKE_" '" << name << '\'';
}
else
whereClause << "WHERE guid = '" << guid << '\'';
whereClause << "WHERE guid = '" << guidLow << '\'';
}
QueryResult result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z, orientation, map FROM creature %s", whereClause.str().c_str());
@@ -172,7 +172,7 @@ public:
if (!gyId)
return false;
int32 graveyardId = atoi(gyId);
uint32 graveyardId = atoul(gyId);
if (!graveyardId)
return false;
@@ -221,7 +221,7 @@ public:
if (!gridX || !gridY)
return false;
uint32 mapId = id ? (uint32)atoi(id) : player->GetMapId();
uint32 mapId = id ? atoul(id) : player->GetMapId();
// center of grid
float x = ((float)atof(gridX) - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
@@ -264,15 +264,15 @@ public:
if (!id)
return false;
int32 guid = atoi(id);
if (!guid)
ObjectGuid::LowType guidLow = atoul(id);
if (!guidLow)
return false;
float x, y, z, o;
uint32 mapId;
// by DB guid
if (GameObjectData const* goData = sObjectMgr->GetGOData(guid))
if (GameObjectData const* goData = sObjectMgr->GetGOData(guidLow))
{
x = goData->posX;
y = goData->posY;
@@ -319,7 +319,7 @@ public:
if (!id)
return false;
int32 nodeId = atoi(id);
uint32 nodeId = atoul(id);
if (!nodeId)
return false;
@@ -364,7 +364,7 @@ public:
if (!id)
return false;
int32 areaTriggerId = atoi(id);
uint32 areaTriggerId = atoul(id);
if (!areaTriggerId)
return false;
@@ -422,7 +422,7 @@ public:
if ((x == 0.0f && *zoneX != '0') || (y == 0.0f && *zoneY != '0'))
return false;
uint32 areaId = id ? (uint32)atoi(id) : player->GetZoneId();
uint32 areaId = id ? atoul(id) : player->GetZoneId();
AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaId);
@@ -492,7 +492,7 @@ public:
float y = (float)atof(goY);
float z;
float ort = port ? (float)atof(port) : player->GetOrientation();
uint32 mapId = id ? (uint32)atoi(id) : player->GetMapId();
uint32 mapId = id ? atoul(id) : player->GetMapId();
if (goZ)
{
@@ -539,7 +539,7 @@ public:
if (!id)
return false;
uint32 ticketId = atoi(id);
uint32 ticketId = atoul(id);
if (!ticketId)
return false;
@@ -564,6 +564,51 @@ public:
}
};
static bool HandleGoOffsetCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
Player* player = handler->GetSession()->GetPlayer();
char* goX = strtok((char*)args, " ");
char* goY = strtok(NULL, " ");
char* goZ = strtok(NULL, " ");
char* port = strtok(NULL, " ");
float x, y, z, o;
player->GetPosition(x, y, z, o);
if (goX)
x += atof(goX);
if (goY)
y += atof(goY);
if (goZ)
z += atof(goZ);
if (port)
o += atof(port);
if (!Trinity::IsValidMapCoord(x, y, z, o))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, player->GetMapId());
handler->SetSentErrorMessage(true);
return false;
}
// stop flight if need
if (player->IsInFlight())
{
player->GetMotionMaster()->MovementExpired();
player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
player->SaveRecallPosition();
player->TeleportTo(player->GetMapId(), x, y, z, o);
return true;
}
};
void AddSC_go_commandscript()
{
new go_commandscript();