aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRochet2 <rochet2@post.com>2017-03-11 12:29:37 +0100
committerShauren <shauren.trinity@gmail.com>2017-03-11 12:29:37 +0100
commit80cf4e3070dd099e19f5b303f7eeaf0475b8acd6 (patch)
tree36135f45483f434cc546bdf667092aa345b7b2e5 /src
parent6067d19dfc43f40590a2052d3ce9b75a14920aa3 (diff)
* 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. Closes #18978
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Accounts/RBAC.h1
-rw-r--r--src/server/game/Chat/Chat.cpp78
-rw-r--r--src/server/game/Chat/Chat.h5
-rw-r--r--src/server/game/Miscellaneous/Language.h5
-rw-r--r--src/server/scripts/Commands/cs_achievement.cpp2
-rw-r--r--src/server/scripts/Commands/cs_event.cpp8
-rw-r--r--src/server/scripts/Commands/cs_go.cpp74
-rw-r--r--src/server/scripts/Commands/cs_gobject.cpp97
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp120
-rw-r--r--src/server/scripts/Commands/cs_npc.cpp38
-rw-r--r--src/server/scripts/Commands/cs_wp.cpp19
11 files changed, 272 insertions, 175 deletions
diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h
index 9fd7d4d3a70..efeb3d93465 100644
--- a/src/server/game/Accounts/RBAC.h
+++ b/src/server/game/Accounts/RBAC.h
@@ -756,6 +756,7 @@ enum RBACPermissions
RBAC_PERM_COMMAND_LIST_SCENES = 849,
RBAC_PERM_COMMAND_RELOAD_SCENE_TEMPLATE = 850,
RBAC_PERM_COMMAND_RELOAD_AREATRIGGER_TEMPLATE = 851,
+ RBAC_PERM_COMMAND_GO_OFFSET = 852,
// custom permissions 1000+
RBAC_PERM_MAX
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
index 3bbe05dd813..88c718c19e7 100644
--- a/src/server/game/Chat/Chat.cpp
+++ b/src/server/game/Chat/Chat.cpp
@@ -770,25 +770,30 @@ GameObject* ChatHandler::GetNearbyGameObject()
return obj;
}
-GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(ObjectGuid::LowType lowguid, uint32 entry)
+GameObject* ChatHandler::GetObjectFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
{
if (!m_session)
return nullptr;
+ auto bounds = m_session->GetPlayer()->GetMap()->GetGameObjectBySpawnIdStore().equal_range(lowguid);
+ if (bounds.first != bounds.second)
+ return bounds.first->second;
+ return nullptr;
+}
- Player* pl = m_session->GetPlayer();
-
- GameObject* obj = pl->GetMap()->GetGameObject(ObjectGuid::Create<HighGuid::GameObject>(pl->GetMapId(), entry, lowguid));
-
- if (!obj && sObjectMgr->GetGOData(lowguid)) // guid is DB guid of object
+Creature* ChatHandler::GetCreatureFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
+{
+ if (!m_session)
+ return nullptr;
+ // Select the first alive creature or a dead one if not found
+ Creature* creature = nullptr;
+ auto bounds = m_session->GetPlayer()->GetMap()->GetCreatureBySpawnIdStore().equal_range(lowguid);
+ for (auto it = bounds.first; it != bounds.second; ++it)
{
- auto bounds = pl->GetMap()->GetGameObjectBySpawnIdStore().equal_range(lowguid);
- if (bounds.first == bounds.second)
- return nullptr;
-
- return bounds.first->second;
+ creature = it->second;
+ if (it->second->IsAlive())
+ break;
}
-
- return obj;
+ return creature;
}
enum SpellLinkType
@@ -874,9 +879,9 @@ GameTele const* ChatHandler::extractGameTeleFromLink(char* text)
enum GuidLinkType
{
- SPELL_LINK_PLAYER = 0, // must be first for selection in not link case
- SPELL_LINK_CREATURE = 1,
- SPELL_LINK_GAMEOBJECT = 2
+ GUID_LINK_PLAYER = 0, // must be first for selection in not link case
+ GUID_LINK_CREATURE = 1,
+ GUID_LINK_GAMEOBJECT = 2
};
static char const* const guidKeys[] =
@@ -887,7 +892,7 @@ static char const* const guidKeys[] =
nullptr
};
-ObjectGuid ChatHandler::extractGuidFromLink(char* text)
+ObjectGuid::LowType ChatHandler::extractLowGuidFromLink(char* text, HighGuid& guidHigh)
{
int type = 0;
@@ -896,43 +901,42 @@ ObjectGuid ChatHandler::extractGuidFromLink(char* text)
// |color|Hplayer:name|h[name]|h|r
char* idS = extractKeyFromLink(text, guidKeys, &type);
if (!idS)
- return ObjectGuid::Empty;
+ return 0;
switch (type)
{
- case SPELL_LINK_PLAYER:
+ case GUID_LINK_PLAYER:
{
+ guidHigh = HighGuid::Player;
std::string name = idS;
if (!normalizePlayerName(name))
- return ObjectGuid::Empty;
+ return 0;
if (Player* player = ObjectAccessor::FindPlayerByName(name))
- return player->GetGUID();
+ return player->GetGUID().GetCounter();
+
+ ObjectGuid guid = ObjectMgr::GetPlayerGUIDByName(name);
+ if (guid.IsEmpty())
+ return 0;
- return ObjectMgr::GetPlayerGUIDByName(name);
+ return guid.GetCounter();
}
- case SPELL_LINK_CREATURE:
+ case GUID_LINK_CREATURE:
{
- ObjectGuid::LowType lowguid = strtoull(idS, nullptr, 10);
-
- if (CreatureData const* data = sObjectMgr->GetCreatureData(lowguid))
- return ObjectGuid::Create<HighGuid::Creature>(data->mapid, data->id, lowguid);
- else
- return ObjectGuid::Empty;
+ guidHigh = HighGuid::Creature;
+ ObjectGuid::LowType lowguid = atoull(idS);
+ return lowguid;
}
- case SPELL_LINK_GAMEOBJECT:
+ case GUID_LINK_GAMEOBJECT:
{
- ObjectGuid::LowType lowguid = strtoull(idS, nullptr, 10);
-
- if (GameObjectData const* data = sObjectMgr->GetGOData(lowguid))
- return ObjectGuid::Create<HighGuid::GameObject>(data->mapid, data->id, lowguid);
- else
- return ObjectGuid::Empty;
+ guidHigh = HighGuid::GameObject;
+ ObjectGuid::LowType lowguid = atoull(idS);
+ return lowguid;
}
}
// unknown type?
- return ObjectGuid::Empty;
+ return 0;
}
std::string ChatHandler::extractPlayerNameFromLink(char* text)
diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h
index dfadccfaa91..697a92e65bb 100644
--- a/src/server/game/Chat/Chat.h
+++ b/src/server/game/Chat/Chat.h
@@ -123,7 +123,7 @@ class TC_GAME_API ChatHandler
char* extractQuotedArg(char* args);
uint32 extractSpellIdFromLink(char* text);
- ObjectGuid extractGuidFromLink(char* text);
+ ObjectGuid::LowType extractLowGuidFromLink(char* text, HighGuid& guidHigh);
GameTele const* extractGameTeleFromLink(char* text);
bool GetPlayerGroupAndGUIDByName(const char* cname, Player*& player, Group*& group, ObjectGuid& guid, bool offline = false);
std::string extractPlayerNameFromLink(char* text);
@@ -134,7 +134,8 @@ class TC_GAME_API ChatHandler
std::string GetNameLink(Player* chr) const;
GameObject* GetNearbyGameObject();
- GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(ObjectGuid::LowType lowguid, uint32 entry);
+ GameObject* GetObjectFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid);
+ Creature* GetCreatureFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid);
bool HasSentErrorMessage() const { return sentErrorMessage; }
void SetSentErrorMessage(bool val){ sentErrorMessage = val; }
diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h
index a9a6832e8db..e27e389cefc 100644
--- a/src/server/game/Miscellaneous/Language.h
+++ b/src/server/game/Miscellaneous/Language.h
@@ -114,7 +114,10 @@ enum TrinityStrings
LANG_PVPSTATS_DISABLED = 81,
LANG_COMMAND_NEARGRAVEYARD = 82,
LANG_COMMAND_NEARGRAVEYARD_NOTFOUND = 83,
- // Free 84 - 95
+ LANG_GOINFO_SIZE = 84,
+ LANG_GOINFO_ADDON = 85,
+ LANG_GOINFO_MODEL = 86,
+ // Free 87 - 95
LANG_GUILD_RENAME_ALREADY_EXISTS = 96,
diff --git a/src/server/scripts/Commands/cs_achievement.cpp b/src/server/scripts/Commands/cs_achievement.cpp
index cd328be4a56..e843888783d 100644
--- a/src/server/scripts/Commands/cs_achievement.cpp
+++ b/src/server/scripts/Commands/cs_achievement.cpp
@@ -55,7 +55,7 @@ public:
if (!achievementId)
{
if (char* id = handler->extractKeyFromLink((char*)args, "Hachievement"))
- achievementId = atoi(id);
+ achievementId = atoul(id);
if (!achievementId)
return false;
}
diff --git a/src/server/scripts/Commands/cs_event.cpp b/src/server/scripts/Commands/cs_event.cpp
index c24f6ccadf0..05b49f9b4e7 100644
--- a/src/server/scripts/Commands/cs_event.cpp
+++ b/src/server/scripts/Commands/cs_event.cpp
@@ -40,7 +40,7 @@ public:
{ "activelist", rbac::RBAC_PERM_COMMAND_EVENT_ACTIVELIST, true, &HandleEventActiveListCommand, "" },
{ "start", rbac::RBAC_PERM_COMMAND_EVENT_START, true, &HandleEventStartCommand, "" },
{ "stop", rbac::RBAC_PERM_COMMAND_EVENT_STOP, true, &HandleEventStopCommand, "" },
- { "", rbac::RBAC_PERM_COMMAND_EVENT, true, &HandleEventInfoCommand, "" },
+ { "info", rbac::RBAC_PERM_COMMAND_EVENT, true, &HandleEventInfoCommand, "" },
};
static std::vector<ChatCommand> commandTable =
{
@@ -88,7 +88,7 @@ public:
if (!id)
return false;
- uint32 eventId = atoi(id);
+ uint32 eventId = atoul(id);
GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
@@ -137,7 +137,7 @@ public:
if (!id)
return false;
- int32 eventId = atoi(id);
+ uint32 eventId = atoul(id);
GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
@@ -178,7 +178,7 @@ public:
if (!id)
return false;
- int32 eventId = atoi(id);
+ uint32 eventId = atoul(id);
GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp
index 004184a7b84..46f076bf594 100644
--- a/src/server/scripts/Commands/cs_go.cpp
+++ b/src/server/scripts/Commands/cs_go.cpp
@@ -52,7 +52,7 @@ public:
{ "bugticket", rbac::RBAC_PERM_COMMAND_GO_BUG_TICKET, false, &HandleGoTicketCommand<BugTicket>, "" },
{ "complaintticket", rbac::RBAC_PERM_COMMAND_GO_COMPLAINT_TICKET, false, &HandleGoTicketCommand<ComplaintTicket>, "" },
{ "suggestionticket", rbac::RBAC_PERM_COMMAND_GO_SUGGESTION_TICKET, false, &HandleGoTicketCommand<SuggestionTicket>, "" },
- { "", rbac::RBAC_PERM_COMMAND_GO, false, &HandleGoXYZCommand, "" },
+ { "offset", rbac::RBAC_PERM_COMMAND_GO_OFFSET, false, &HandleGoOffsetCommand, "" },
};
static std::vector<ChatCommand> commandTable =
@@ -99,7 +99,7 @@ public:
if (!id)
return false;
- int32 entry = atoi(id);
+ uint32 entry = atoul(id);
if (!entry)
return false;
@@ -107,17 +107,17 @@ public:
}
else
{
- int32 guid = atoi(param1);
+ ObjectGuid::LowType guidLow = atoull(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());
@@ -170,7 +170,7 @@ public:
if (!gyId)
return false;
- int32 graveyardId = atoi(gyId);
+ uint32 graveyardId = atoul(gyId);
if (!graveyardId)
return false;
@@ -219,7 +219,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;
@@ -262,15 +262,15 @@ public:
if (!id)
return false;
- ObjectGuid::LowType guid = strtoull(id, nullptr, 10);
- if (!guid)
+ ObjectGuid::LowType guidLow = atoull(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;
@@ -382,7 +382,7 @@ public:
if (!id)
return false;
- int32 nodeId = atoi(id);
+ uint32 nodeId = atoul(id);
if (!nodeId)
return false;
@@ -427,7 +427,7 @@ public:
if (!id)
return false;
- int32 areaTriggerId = atoi(id);
+ uint32 areaTriggerId = atoul(id);
if (!areaTriggerId)
return false;
@@ -485,7 +485,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);
@@ -555,7 +555,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)
{
@@ -603,7 +603,7 @@ public:
if (!id)
return false;
- uint32 ticketId = atoi(id);
+ uint32 ticketId = atoul(id);
if (!ticketId)
return false;
@@ -626,6 +626,50 @@ public:
ticket->TeleportTo(player);
return true;
}
+
+ 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()
diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp
index c0d0ae92efb..19928261e16 100644
--- a/src/server/scripts/Commands/cs_gobject.cpp
+++ b/src/server/scripts/Commands/cs_gobject.cpp
@@ -77,16 +77,11 @@ public:
if (!id)
return false;
- ObjectGuid::LowType guidLow = strtoull(id, nullptr, 10);
+ ObjectGuid::LowType guidLow = atoull(id);
if (!guidLow)
return false;
- GameObject* object = NULL;
-
- // by DB guid
- if (GameObjectData const* goData = sObjectMgr->GetGOData(guidLow))
- object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, goData->id);
-
+ GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
@@ -153,7 +148,7 @@ public:
if (spawntimeSecs)
{
- uint32 value = atoi((char*)spawntimeSecs);
+ int32 value = atoi(spawntimeSecs);
object->SetRespawnTime(value);
}
@@ -196,10 +191,10 @@ public:
uint32 spawntm = 300;
if (spawntime)
- spawntm = atoi((char*)spawntime);
+ spawntm = atoul(spawntime);
G3D::Quat rotation = G3D::Matrix3::fromEulerAnglesZYX(player->GetOrientation(), 0.f, 0.f);
- uint32 objectId = atoi(id);
+ uint32 objectId = atoul(id);
if (!sObjectMgr->GetGameObjectTemplate(objectId))
{
@@ -314,7 +309,7 @@ public:
return false;
}
- GameObject* target = handler->GetSession()->GetPlayer()->GetMap()->GetGameObject(ObjectGuid::Create<HighGuid::GameObject>(mapId, id, guidLow));
+ GameObject* target = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, guidLow, objectInfo->name.c_str(), guidLow, id, x, y, z, mapId, o, phaseId, phaseGroup);
@@ -340,16 +335,11 @@ public:
if (!id)
return false;
- ObjectGuid::LowType guidLow = strtoull(id, nullptr, 10);
+ ObjectGuid::LowType guidLow = atoull(id);
if (!guidLow)
return false;
- GameObject* object = NULL;
-
- // by DB guid
- if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
- object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
-
+ GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
@@ -388,16 +378,11 @@ public:
if (!id)
return false;
- ObjectGuid::LowType guidLow = strtoull(id, nullptr, 10);
+ ObjectGuid::LowType guidLow = atoull(id);
if (!guidLow)
return false;
- GameObject* object = NULL;
-
- // by DB guid
- if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
- object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
-
+ GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
@@ -448,16 +433,11 @@ public:
if (!id)
return false;
- ObjectGuid::LowType guidLow = strtoull(id, nullptr, 10);
+ ObjectGuid::LowType guidLow = atoull(id);
if (!guidLow)
return false;
- GameObject* object = NULL;
-
- // by DB guid
- if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
- object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
-
+ GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
@@ -511,16 +491,11 @@ public:
if (!id)
return false;
- uint32 guidLow = atoi(id);
+ ObjectGuid::LowType guidLow = atoull(id);
if (!guidLow)
return false;
- GameObject* object = NULL;
-
- // by DB guid
- if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
- object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
-
+ GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
@@ -529,7 +504,7 @@ public:
}
char* phase = strtok (NULL, " ");
- uint32 phaseMask = phase ? atoi(phase) : 0;
+ uint32 phaseMask = phase ? atoul(phase) : 0;
if (phaseMask == 0)
{
handler->SendSysMessage(LANG_BAD_VALUE);
@@ -597,13 +572,28 @@ public:
uint32 lootId = 0;
if (!*args)
+ return false;
+
+ char* param1 = handler->extractKeyFromLink((char*)args, "Hgameobject_entry");
+ if (!param1)
+ return false;
+
+ if (strcmp(param1, "guid") == 0)
{
- if (WorldObject* object = handler->getSelectedObject())
- entry = object->GetEntry();
- else
- entry = atoi((char*)args);
- } else
- entry = atoi((char*)args);
+ char* tail = strtok(nullptr, "");
+ char* cValue = handler->extractKeyFromLink(tail, "Hgameobject");
+ if (!cValue)
+ return false;
+ ObjectGuid::LowType guidLow = atoull(cValue);
+ const GameObjectData* data = sObjectMgr->GetGOData(guidLow);
+ if (!data)
+ return false;
+ entry = data->id;
+ }
+ else
+ {
+ entry = atoul(param1);
+ }
GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry);
@@ -620,6 +610,13 @@ public:
handler->PSendSysMessage(LANG_GOINFO_LOOTID, lootId);
handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayId);
handler->PSendSysMessage(LANG_GOINFO_NAME, name.c_str());
+ handler->PSendSysMessage(LANG_GOINFO_SIZE, gameObjectInfo->size);
+
+ if (GameObjectTemplateAddon const* addon = sObjectMgr->GetGameObjectTemplateAddon(entry))
+ handler->PSendSysMessage(LANG_GOINFO_ADDON, addon->faction, addon->flags);
+
+ if (GameObjectDisplayInfoEntry const* modelInfo = sGameObjectDisplayInfoStore.LookupEntry(displayId))
+ handler->PSendSysMessage(LANG_GOINFO_MODEL, modelInfo->GeoBoxMax.X, modelInfo->GeoBoxMax.Y, modelInfo->GeoBoxMax.Z, modelInfo->GeoBoxMin.X, modelInfo->GeoBoxMin.Y, modelInfo->GeoBoxMin.Z);
return true;
}
@@ -631,15 +628,11 @@ public:
if (!id)
return false;
- ObjectGuid::LowType guidLow = strtoull(id, nullptr, 10);
+ ObjectGuid::LowType guidLow = atoull(id);
if (!guidLow)
return false;
- GameObject* object = NULL;
-
- if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
- object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
-
+ GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index a846e0056af..913aa5c71f0 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -168,19 +168,50 @@ 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.IsEmpty())
- 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::Creature:
+ {
+ 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
{
@@ -774,26 +805,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.IsEmpty())
- 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::Creature:
+ {
+ 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);
@@ -801,7 +861,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
@@ -2253,8 +2313,8 @@ public:
return false;
}
- ObjectGuid::LowType guid = strtoull(guidStr, nullptr, 10);
- if (!guid)
+ ObjectGuid::LowType guidLow = atoull(guidStr);
+ if (!guidLow)
{
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
@@ -2279,14 +2339,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;
}
@@ -2299,7 +2355,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;
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp
index ee2f7f2f940..ec7835b5654 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -245,7 +245,7 @@ public:
if (!charID)
return false;
- uint32 id = atoi(charID);
+ uint32 id = atoul(charID);
if (!sObjectMgr->GetCreatureTemplate(id))
return false;
@@ -368,7 +368,7 @@ public:
char* guidStr = strtok((char*)args, " ");
char* waitStr = strtok((char*)nullptr, " ");
- ObjectGuid::LowType lowGuid = strtoull(guidStr, nullptr, 10);
+ ObjectGuid::LowType lowGuid = atoull(guidStr);
// attempt check creature existence by DB data
CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid);
@@ -417,7 +417,7 @@ public:
if (!*args)
return false;
- uint32 newEntryNum = atoi(args);
+ uint32 newEntryNum = atoul(args);
if (!newEntryNum)
return false;
@@ -442,7 +442,7 @@ public:
if (!*args)
return false;
- uint8 lvl = (uint8) atoi((char*)args);
+ uint8 lvl = (uint8) atoi(args);
if (lvl < 1 || lvl > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) + 3)
{
handler->SendSysMessage(LANG_BAD_VALUE);
@@ -477,12 +477,10 @@ public:
if (!cId)
return false;
- ObjectGuid::LowType lowguid = strtoull(cId, nullptr, 10);
+ ObjectGuid::LowType lowguid = atoull(cId);
if (!lowguid)
return false;
-
- if (CreatureData const* cr_data = sObjectMgr->GetCreatureData(lowguid))
- unit = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid::Create<HighGuid::Creature>(cr_data->mapid, cr_data->id, lowguid));
+ unit = handler->GetCreatureFromPlayerMapByDbGuid(lowguid);
}
else
unit = handler->getSelectedCreature();
@@ -548,7 +546,7 @@ public:
if (!*args)
return false;
- uint32 factionId = (uint32) atoi((char*)args);
+ uint32 factionId = atoul(args);
if (!sFactionTemplateStore.LookupEntry(factionId))
{
@@ -591,7 +589,7 @@ public:
if (!*args)
return false;
- uint64 npcFlags = std::strtoull(args, nullptr, 10);
+ uint64 npcFlags = atoull(args);
Creature* creature = handler->getSelectedCreature();
@@ -807,7 +805,7 @@ public:
if (!cId)
return false;
- lowguid = strtoull(cId, nullptr, 10);
+ lowguid = atoull(cId);
// Attempting creature load from DB data
CreatureData const* data = sObjectMgr->GetCreatureData(lowguid);
@@ -893,7 +891,7 @@ public:
if (!*args)
return false;
- uint32 displayId = (uint32) atoi((char*)args);
+ uint32 displayId = atoul(args);
Creature* creature = handler->getSelectedCreature();
@@ -987,12 +985,10 @@ public:
}
else // case .setmovetype #creature_guid $move_type (with selected creature)
{
- lowguid = strtoull(guid_str, nullptr, 10);
+ lowguid = atoull(guid_str);
- /* impossible without entry
if (lowguid)
- creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), MAKE_GUID(lowguid, HIGHGUID_UNIT));
- */
+ creature = handler->GetCreatureFromPlayerMapByDbGuid(lowguid);
// attempt check creature existence by DB data
if (!creature)
@@ -1095,7 +1091,7 @@ public:
if (!*args)
return false;
- uint32 phaseID = uint32(atoi((char*)args));
+ uint32 phaseID = atoul(args);
if (!sPhaseStore.LookupEntry(phaseID))
{
handler->SendSysMessage(LANG_PHASE_NOTFOUND);
@@ -1177,7 +1173,7 @@ public:
if (!stime)
return false;
- int spawnTime = atoi((char*)stime);
+ int spawnTime = atoi(stime);
if (spawnTime < 0)
{
@@ -1376,7 +1372,7 @@ public:
Player* chr = handler->GetSession()->GetPlayer();
- uint32 id = atoi(charID);
+ uint32 id = atoul(charID);
if (!id)
return false;
@@ -1505,7 +1501,7 @@ public:
if (!*args)
return false;
- ObjectGuid::LowType leaderGUID = strtoull(args, nullptr, 10);
+ ObjectGuid::LowType leaderGUID = atoull(args);
Creature* creature = handler->getSelectedCreature();
if (!creature || !creature->GetSpawnId())
@@ -1557,7 +1553,7 @@ public:
if (!*args)
return false;
- ObjectGuid::LowType linkguid = strtoull(args, nullptr, 10);
+ ObjectGuid::LowType linkguid = atoull(args);
Creature* creature = handler->getSelectedCreature();
diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp
index e0c9e43c047..6aac5045d78 100644
--- a/src/server/scripts/Commands/cs_wp.cpp
+++ b/src/server/scripts/Commands/cs_wp.cpp
@@ -750,7 +750,7 @@ public:
if (target)
handler->SendSysMessage(LANG_WAYPOINT_CREATSELECTED);
- pathid = atoi((char*)guid_str);
+ pathid = atoul(guid_str);
}
std::string show = show_str;
@@ -769,12 +769,12 @@ public:
}
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_ALL_BY_WPGUID);
- stmt->setUInt64(0, target->GetGUID().GetCounter());
+ stmt->setUInt64(0, target->GetSpawnId());
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
{
- handler->SendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM);
+ handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, target->GetSpawnId());
return true;
}
@@ -825,12 +825,11 @@ public:
if (result2)
{
bool hasError = false;
- Map* map = handler->GetSession()->GetPlayer()->GetMap();
do
{
Field* fields = result2->Fetch();
ObjectGuid::LowType wpguid = fields[0].GetUInt64();
- Creature* creature = map->GetCreature(ObjectGuid::Create<HighGuid::Creature>(map->GetId(), VISUAL_WAYPOINT, wpguid));
+ Creature* creature = handler->GetCreatureFromPlayerMapByDbGuid(wpguid);
if (!creature)
{
@@ -1028,19 +1027,19 @@ public:
return false;
}
bool hasError = false;
- Map* map = handler->GetSession()->GetPlayer()->GetMap();
do
{
Field* fields = result->Fetch();
- ObjectGuid::LowType guid = fields[0].GetUInt64();
- Creature* creature = map->GetCreature(ObjectGuid::Create<HighGuid::Creature>(map->GetId(), VISUAL_WAYPOINT, guid));
+ ObjectGuid::LowType lowguid = fields[0].GetUInt64();
+
+ Creature* creature = handler->GetCreatureFromPlayerMapByDbGuid(lowguid);
if (!creature)
{
- handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid);
+ handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, lowguid);
hasError = true;
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
- stmt->setUInt64(0, guid);
+ stmt->setUInt64(0, lowguid);
WorldDatabase.Execute(stmt);
}
else