aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRochet2 <rochet2@post.com>2017-01-08 05:55:22 +0200
committertkrokli <tkrokli@users.noreply.github.com>2017-01-08 04:55:22 +0100
commit117d1c31c99b00269fa73d50d1a5ccf7c49a8450 (patch)
tree59c0ffa808fd374603017143bb99835ebcbba129 /src
parent3d245fb2dc40d89ecfbe9f924ef9d3d16bc02cda (diff)
Scripts/Commands: Fix guid usage and enhance commands (#18278)
- 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.
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Accounts/RBAC.h1
-rw-r--r--src/server/game/Chat/Chat.cpp72
-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.cpp101
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp121
-rw-r--r--src/server/scripts/Commands/cs_npc.cpp38
-rw-r--r--src/server/scripts/Commands/cs_wp.cpp19
11 files changed, 270 insertions, 176 deletions
diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h
index 513062e1e60..c998fd4274a 100644
--- a/src/server/game/Accounts/RBAC.h
+++ b/src/server/game/Accounts/RBAC.h
@@ -749,6 +749,7 @@ enum RBACPermissions
RBAC_PERM_COMMAND_RELOAD_CHARACTER_TEMPLATE = 842, // not on 3.3.5a
RBAC_PERM_COMMAND_RELOAD_QUEST_GREETING = 843, // not on 3.3.5a
RBAC_PERM_COMMAND_DEBUG_SEND_PLAYSCENE = 844, // not on 3.3.5a
+ RBAC_PERM_COMMAND_GO_OFFSET = 845,
// custom permissions 1000+
RBAC_PERM_MAX
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
index ee327ea684b..d486a95c52a 100644
--- a/src/server/game/Chat/Chat.cpp
+++ b/src/server/game/Chat/Chat.cpp
@@ -881,25 +881,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(HighGuid::GameObject, 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
@@ -989,9 +994,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[] =
@@ -1002,7 +1007,7 @@ static char const* const guidKeys[] =
nullptr
};
-ObjectGuid ChatHandler::extractGuidFromLink(char* text)
+ObjectGuid::LowType ChatHandler::extractLowGuidFromLink(char* text, HighGuid& guidHigh)
{
int type = 0;
@@ -1011,46 +1016,41 @@ 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();
if (ObjectGuid guid = sObjectMgr->GetPlayerGUIDByName(name))
- return guid;
+ return guid.GetCounter();
- return ObjectGuid::Empty;
+ return 0;
}
- case SPELL_LINK_CREATURE:
+ case GUID_LINK_CREATURE:
{
+ guidHigh = HighGuid::Unit;
ObjectGuid::LowType lowguid = atoul(idS);
-
- if (CreatureData const* data = sObjectMgr->GetCreatureData(lowguid))
- return ObjectGuid(HighGuid::Unit, data->id, lowguid);
- else
- return ObjectGuid::Empty;
+ return lowguid;
}
- case SPELL_LINK_GAMEOBJECT:
+ case GUID_LINK_GAMEOBJECT:
{
+ guidHigh = HighGuid::GameObject;
ObjectGuid::LowType lowguid = atoul(idS);
-
- if (GameObjectData const* data = sObjectMgr->GetGOData(lowguid))
- return ObjectGuid(HighGuid::GameObject, data->id, lowguid);
- else
- return ObjectGuid::Empty;
+ 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 40fad4e4251..9bbe908fa0b 100644
--- a/src/server/game/Chat/Chat.h
+++ b/src/server/game/Chat/Chat.h
@@ -130,7 +130,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(char const* cname, Player*& player, Group*& group, ObjectGuid& guid, bool offline = false);
std::string extractPlayerNameFromLink(char* text);
@@ -141,7 +141,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 79c7c4e457b..f4803d93851 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 6e7499972ec..ddfd35e17e4 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 3d5b4d4ff03..cdeb07ee844 100644
--- a/src/server/scripts/Commands/cs_go.cpp
+++ b/src/server/scripts/Commands/cs_go.cpp
@@ -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, guid, id 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;
@@ -562,6 +562,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 91d677a5859..617bf39dbde 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 = atoi(id);
+ ObjectGuid::LowType guidLow = atoul(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);
@@ -152,7 +147,7 @@ public:
if (spawntimeSecs)
{
- uint32 value = atoi((char*)spawntimeSecs);
+ int32 value = atoi((char*)spawntimeSecs);
object->SetRespawnTime(value);
}
@@ -195,10 +190,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))
{
@@ -312,7 +307,7 @@ public:
return false;
}
- GameObject* target = handler->GetSession()->GetPlayer()->GetMap()->GetGameObject(ObjectGuid(HighGuid::GameObject, id, guidLow));
+ GameObject* target = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, guidLow, objectInfo->name.c_str(), guidLow, id, x, y, z, mapId, o, phase);
@@ -338,16 +333,11 @@ public:
if (!id)
return false;
- ObjectGuid::LowType guidLow = atoi(id);
+ ObjectGuid::LowType guidLow = atoul(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);
@@ -361,7 +351,7 @@ public:
Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(), ownerGuid);
if (!owner || !ownerGuid.IsPlayer())
{
- handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, ownerGuid.GetCounter(), object->GetGUID().GetCounter());
+ handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, ownerGuid.GetCounter(), guidLow);
handler->SetSentErrorMessage(true);
return false;
}
@@ -373,7 +363,7 @@ public:
object->Delete();
object->DeleteFromDB();
- handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, object->GetGUID().GetCounter());
+ handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, object->GetSpawnId());
return true;
}
@@ -386,16 +376,11 @@ public:
if (!id)
return false;
- ObjectGuid::LowType guidLow = atoi(id);
+ ObjectGuid::LowType guidLow = atoul(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);
@@ -455,16 +440,11 @@ public:
if (!id)
return false;
- ObjectGuid::LowType guidLow = atoi(id);
+ ObjectGuid::LowType guidLow = atoul(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,16 +509,11 @@ public:
if (!id)
return false;
- ObjectGuid::LowType guidLow = atoi(id);
+ ObjectGuid::LowType guidLow = atoul(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);
@@ -547,7 +522,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);
@@ -615,13 +590,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 = atoul(cValue);
+ const GameObjectData* data = sObjectMgr->GetGOData(guidLow);
+ if (!data)
+ return false;
+ entry = data->id;
+ }
+ else
+ {
+ entry = atoul(param1);
+ }
GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry);
@@ -641,6 +631,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->maxX, modelInfo->maxY, modelInfo->maxZ, modelInfo->minX, modelInfo->minY, modelInfo->minZ);
return true;
}
@@ -652,15 +649,11 @@ public:
if (!id)
return false;
- ObjectGuid::LowType guidLow = atoi(id);
+ ObjectGuid::LowType guidLow = atoul(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 d4c39099182..9c5e30c340e 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -165,24 +165,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);
@@ -748,26 +778,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);
@@ -775,7 +834,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
@@ -2166,8 +2225,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);
@@ -2192,14 +2251,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;
}
@@ -2212,7 +2267,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 fe6d0f55a38..7b4d648eca9 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -243,7 +243,7 @@ public:
if (!charID)
return false;
- uint32 id = atoi(charID);
+ uint32 id = atoul(charID);
if (!sObjectMgr->GetCreatureTemplate(id))
return false;
@@ -364,7 +364,7 @@ public:
char* guidStr = strtok((char*)args, " ");
char* waitStr = strtok((char*)nullptr, " ");
- ObjectGuid::LowType lowGuid = atoi((char*)guidStr);
+ ObjectGuid::LowType lowGuid = atoul(guidStr);
// attempt check creature existence by DB data
CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid);
@@ -413,7 +413,7 @@ public:
if (!*args)
return false;
- uint32 newEntryNum = atoi(args);
+ uint32 newEntryNum = atoul(args);
if (!newEntryNum)
return false;
@@ -438,7 +438,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);
@@ -473,12 +473,10 @@ public:
if (!cId)
return false;
- ObjectGuid::LowType lowguid = atoi(cId);
+ ObjectGuid::LowType lowguid = atoul(cId);
if (!lowguid)
return false;
-
- if (CreatureData const* cr_data = sObjectMgr->GetCreatureData(lowguid))
- unit = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HighGuid::Unit, cr_data->id, lowguid));
+ unit = handler->GetCreatureFromPlayerMapByDbGuid(lowguid);
}
else
unit = handler->getSelectedCreature();
@@ -542,7 +540,7 @@ public:
if (!*args)
return false;
- uint32 factionId = (uint32) atoi((char*)args);
+ uint32 factionId = atoul(args);
if (!sFactionTemplateStore.LookupEntry(factionId))
{
@@ -585,7 +583,7 @@ public:
if (!*args)
return false;
- uint32 npcFlags = (uint32) atoi((char*)args);
+ uint32 npcFlags = (uint32) atoi(args);
Creature* creature = handler->getSelectedCreature();
@@ -785,7 +783,7 @@ public:
if (!cId)
return false;
- lowguid = atoi(cId);
+ lowguid = atoul(cId);
// Attempting creature load from DB data
CreatureData const* data = sObjectMgr->GetCreatureData(lowguid);
@@ -871,7 +869,7 @@ public:
if (!*args)
return false;
- uint32 displayId = (uint32) atoi((char*)args);
+ uint32 displayId = atoul(args);
Creature* creature = handler->getSelectedCreature();
@@ -965,12 +963,10 @@ public:
}
else // case .setmovetype #creature_guid $move_type (with selected creature)
{
- lowguid = atoi((char*)guid_str);
+ lowguid = atoul(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)
@@ -1043,7 +1039,7 @@ public:
if (!*args)
return false;
- uint32 phasemask = (uint32) atoi((char*)args);
+ uint32 phasemask = atoul(args);
if (phasemask == 0)
{
handler->SendSysMessage(LANG_BAD_VALUE);
@@ -1124,7 +1120,7 @@ public:
if (!stime)
return false;
- int spawnTime = atoi((char*)stime);
+ int spawnTime = atoi(stime);
if (spawnTime < 0)
{
@@ -1323,7 +1319,7 @@ public:
Player* chr = handler->GetSession()->GetPlayer();
- uint32 id = atoi(charID);
+ uint32 id = atoul(charID);
if (!id)
return false;
@@ -1452,7 +1448,7 @@ public:
if (!*args)
return false;
- ObjectGuid::LowType leaderGUID = (uint32) atoi((char*)args);
+ ObjectGuid::LowType leaderGUID = atoul(args);
Creature* creature = handler->getSelectedCreature();
if (!creature || !creature->GetSpawnId())
@@ -1504,7 +1500,7 @@ public:
if (!*args)
return false;
- ObjectGuid::LowType linkguid = (uint32) atoi((char*)args);
+ ObjectGuid::LowType linkguid = atoul(args);
Creature* creature = handler->getSelectedCreature();
diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp
index af6a5189487..ffbc4da5d57 100644
--- a/src/server/scripts/Commands/cs_wp.cpp
+++ b/src/server/scripts/Commands/cs_wp.cpp
@@ -746,7 +746,7 @@ public:
if (target)
handler->SendSysMessage(LANG_WAYPOINT_CREATSELECTED);
- pathid = atoi((char*)guid_str);
+ pathid = atoul(guid_str);
}
std::string show = show_str;
@@ -765,12 +765,12 @@ public:
}
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_ALL_BY_WPGUID);
- stmt->setUInt32(0, target->GetGUID().GetCounter());
+ stmt->setUInt32(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,7 +825,7 @@ public:
{
Field* fields = result2->Fetch();
uint32 wpguid = fields[0].GetUInt32();
- Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HighGuid::Unit, VISUAL_WAYPOINT, wpguid));
+ Creature* creature = handler->GetCreatureFromPlayerMapByDbGuid(wpguid);
if (!creature)
{
@@ -880,7 +880,7 @@ public:
// Set "wpguid" column to the visual waypoint
stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_WPGUID);
- stmt->setInt32(0, int32(wpCreature->GetSpawnId()));
+ stmt->setUInt32(0, wpCreature->GetSpawnId());
stmt->setUInt32(1, pathid);
stmt->setUInt32(2, point);
WorldDatabase.Execute(stmt);
@@ -1021,15 +1021,16 @@ public:
do
{
Field* fields = result->Fetch();
- ObjectGuid::LowType guid = fields[0].GetUInt32();
- Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HighGuid::Unit, VISUAL_WAYPOINT, guid));
+ ObjectGuid::LowType lowguid = fields[0].GetUInt32();
+
+ 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->setUInt32(0, guid);
+ stmt->setUInt32(0, lowguid);
WorldDatabase.Execute(stmt);
}
else