aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegamage <none@none>2009-05-21 09:59:49 -0500
committermegamage <none@none>2009-05-21 09:59:49 -0500
commit40c58e599296203072c834fde68094b9544abaa6 (patch)
tree002823d80bc6dc66aafb32e79ef3cf6260c1fb48 /src
parenta77f9e209234706931bb8433e2c18b336306aab2 (diff)
*Allow use gm command to set value for gobjects.
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/Chat.cpp26
-rw-r--r--src/game/Chat.h2
-rw-r--r--src/game/Debugcmds.cpp18
-rw-r--r--src/game/Level3.cpp4
4 files changed, 34 insertions, 16 deletions
diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
index 8f8e4a5547b..31df4ee6718 100644
--- a/src/game/Chat.cpp
+++ b/src/game/Chat.cpp
@@ -1269,6 +1269,19 @@ Unit* ChatHandler::getSelectedUnit()
return ObjectAccessor::GetUnit(*m_session->GetPlayer(),guid);
}
+WorldObject *ChatHandler::getSelectedObject()
+{
+ if(!m_session)
+ return NULL;
+
+ uint64 guid = m_session->GetPlayer()->GetSelection();
+
+ if (guid == 0)
+ return GetNearbyGameObject();
+
+ return ObjectAccessor::GetUnit(*m_session->GetPlayer(),guid);
+}
+
Creature* ChatHandler::getSelectedCreature()
{
if(!m_session)
@@ -1421,6 +1434,19 @@ char const *fmtstring( char const *format, ... )
return buf;
}
+GameObject* ChatHandler::GetNearbyGameObject()
+{
+ if(!m_session)
+ return NULL;
+
+ Player* pl = m_session->GetPlayer();
+ GameObject* obj = NULL;
+ Trinity::NearestGameObjectCheck check(*pl);
+ Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectCheck> searcher(pl, obj, check);
+ pl->VisitNearbyGridObject(999, searcher);
+ return obj;
+}
+
GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry)
{
if(!m_session)
diff --git a/src/game/Chat.h b/src/game/Chat.h
index 58929529bbb..f7a587ce463 100644
--- a/src/game/Chat.h
+++ b/src/game/Chat.h
@@ -567,6 +567,7 @@ class ChatHandler
Player* getSelectedPlayer();
Creature* getSelectedCreature();
Unit* getSelectedUnit();
+ WorldObject* getSelectedObject();
char* extractKeyFromLink(char* text, char const* linkType, char** something1 = NULL);
char* extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1 = NULL);
@@ -585,6 +586,7 @@ class ChatHandler
std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; }
std::string GetNameLink(Player* chr) const { return playerLink(chr->GetName()); }
+ GameObject* GetNearbyGameObject();
GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry);
// Utility methods for commands
diff --git a/src/game/Debugcmds.cpp b/src/game/Debugcmds.cpp
index fdc26faf5bc..356b2c25ca2 100644
--- a/src/game/Debugcmds.cpp
+++ b/src/game/Debugcmds.cpp
@@ -200,15 +200,10 @@ bool ChatHandler::HandleDebugSendOpcodeCommand(const char* /*args*/)
}
else if(type == "appgoguid")
{
- uint32 lowguid;
- ifs >> lowguid;
- GameObject *obj = NULL;
- if (GameObjectData const* go_data = objmgr.GetGOData(lowguid))
- obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);
-
+ GameObject *obj = GetNearbyGameObject();
if(!obj)
{
- PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
+ PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, 0);
SetSentErrorMessage(true);
ifs.close();
return false;
@@ -217,15 +212,10 @@ bool ChatHandler::HandleDebugSendOpcodeCommand(const char* /*args*/)
}
else if(type == "goguid")
{
- uint32 lowguid;
- ifs >> lowguid;
- GameObject *obj = NULL;
- if (GameObjectData const* go_data = objmgr.GetGOData(lowguid))
- obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);
-
+ GameObject *obj = GetNearbyGameObject();
if(!obj)
{
- PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
+ PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, 0);
SetSentErrorMessage(true);
ifs.close();
return false;
diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp
index 0c921c2d760..baaafef0cdf 100644
--- a/src/game/Level3.cpp
+++ b/src/game/Level3.cpp
@@ -4788,7 +4788,7 @@ bool ChatHandler::HandleDebugSetValue(const char* args)
if (!px || !py)
return false;
- Unit* target = getSelectedUnit();
+ WorldObject* target = getSelectedObject();
if(!target)
{
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
@@ -4881,7 +4881,7 @@ bool ChatHandler::HandleDebugSet32Bit(const char* args)
if(!*args)
return false;
- Unit* target = getSelectedUnit();
+ WorldObject* target = getSelectedObject();
if(!target)
{
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);