*Allow use gm command to set value for gobjects.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-05-21 09:59:49 -05:00
parent a77f9e2092
commit 40c58e5992
4 changed files with 34 additions and 16 deletions
+26
View File
@@ -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)
+2
View File
@@ -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
+4 -14
View File
@@ -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;
+2 -2
View File
@@ -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);