aboutsummaryrefslogtreecommitdiff
path: root/src/game/Level2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/Level2.cpp')
-rw-r--r--src/game/Level2.cpp37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp
index 21f196c74e2..42fbea8255d 100644
--- a/src/game/Level2.cpp
+++ b/src/game/Level2.cpp
@@ -35,6 +35,7 @@
#include "World.h"
#include "GameEvent.h"
#include "SpellMgr.h"
+#include "PoolHandler.h"
#include "AccountMgr.h"
//#include "GMTicketMgr.h"
#include "WaypointManager.h"
@@ -204,7 +205,7 @@ bool ChatHandler::HandleTargetObjectCommand(const char* args)
result = WorldDatabase.PQuery("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, "
"(POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ FROM gameobject "
- "LEFT OUTER JOIN game_event_gameobject on gameobject.guid=game_event_gameobject.guid WHERE map = '%i' %s ORDER BY order_ ASC LIMIT 1",
+ "LEFT OUTER JOIN game_event_gameobject on gameobject.guid=game_event_gameobject.guid WHERE map = '%i' %s ORDER BY order_ ASC LIMIT 10",
m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetMapId(),eventFilter.str().c_str());
}
@@ -214,16 +215,34 @@ bool ChatHandler::HandleTargetObjectCommand(const char* args)
return true;
}
- Field *fields = result->Fetch();
- uint32 lowguid = fields[0].GetUInt32();
- uint32 id = fields[1].GetUInt32();
- float x = fields[2].GetFloat();
- float y = fields[3].GetFloat();
- float z = fields[4].GetFloat();
- float o = fields[5].GetFloat();
- int mapid = fields[6].GetUInt16();
+ bool found = false;
+ float x, y, z, o;
+ uint32 lowguid, id;
+ uint16 mapid, pool_id;
+
+ do
+ {
+ Field *fields = result->Fetch();
+ lowguid = fields[0].GetUInt32();
+ id = fields[1].GetUInt32();
+ x = fields[2].GetFloat();
+ y = fields[3].GetFloat();
+ z = fields[4].GetFloat();
+ o = fields[5].GetFloat();
+ mapid = fields[6].GetUInt16();
+ pool_id = poolhandler.IsPartOfAPool(lowguid, TYPEID_GAMEOBJECT);
+ if (!pool_id || (pool_id && poolhandler.IsSpawnedObject(pool_id, lowguid, TYPEID_GAMEOBJECT)))
+ found = true;
+ } while( result->NextRow() && (!found) );
+
delete result;
+ if (!found)
+ {
+ PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id);
+ return false;
+ }
+
GameObjectInfo const* goI = objmgr.GetGameObjectInfo(id);
if (!goI)