mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[7493] Move .gobject functions in one place, update/fix security levels in code and mangos.sql.
This commit is contained in:
parent
bfa67880f2
commit
a63977d767
7 changed files with 557 additions and 547 deletions
|
|
@ -22,7 +22,7 @@
|
||||||
DROP TABLE IF EXISTS `db_version`;
|
DROP TABLE IF EXISTS `db_version`;
|
||||||
CREATE TABLE `db_version` (
|
CREATE TABLE `db_version` (
|
||||||
`version` varchar(120) default NULL,
|
`version` varchar(120) default NULL,
|
||||||
`required_7472_01_mangos_mangos_string` bit(1) default NULL
|
`required_7493_01_mangos_command` bit(1) default NULL
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
@ -301,8 +301,8 @@ INSERT INTO `command` VALUES
|
||||||
('gobject add',2,'Syntax: .gobject add #id <spawntimeSecs>\r\n\r\nAdd a game object from game object templates to the world at your current location using the #id.\r\nspawntimesecs sets the spawntime, it is optional.\r\n\r\nNote: this is a copy of .gameobject.'),
|
('gobject add',2,'Syntax: .gobject add #id <spawntimeSecs>\r\n\r\nAdd a game object from game object templates to the world at your current location using the #id.\r\nspawntimesecs sets the spawntime, it is optional.\r\n\r\nNote: this is a copy of .gameobject.'),
|
||||||
('gobject delete',2,'Syntax: .gobject delete #go_guid\r\nDelete gameobject with guid #go_guid.'),
|
('gobject delete',2,'Syntax: .gobject delete #go_guid\r\nDelete gameobject with guid #go_guid.'),
|
||||||
('gobject move',2,'Syntax: .gobject move #goguid [#x #y #z]\r\n\r\nMove gameobject #goguid to character coordinates (or to (#x,#y,#z) coordinates if its provide).'),
|
('gobject move',2,'Syntax: .gobject move #goguid [#x #y #z]\r\n\r\nMove gameobject #goguid to character coordinates (or to (#x,#y,#z) coordinates if its provide).'),
|
||||||
('gobject near',3,'Syntax: .gobject near [#distance]\r\n\r\nOutput gameobjects at distance #distance from player. Output gameobject guids and coordinates sorted by distance from character. If #distance not provided use 10 as default value.'),
|
('gobject near',2,'Syntax: .gobject near [#distance]\r\n\r\nOutput gameobjects at distance #distance from player. Output gameobject guids and coordinates sorted by distance from character. If #distance not provided use 10 as default value.'),
|
||||||
('gobject phase',3,'Syntax: .gobject phase #guid #phasemask\r\n\r\nGameobject with DB guid #guid phasemask changed to #phasemask with related world vision update for players. Gameobject state saved to DB and persistent.'),
|
('gobject setphase',2,'Syntax: .gobject setphase #guid #phasemask\r\n\r\nGameobject with DB guid #guid phasemask changed to #phasemask with related world vision update for players. Gameobject state saved to DB and persistent.'),
|
||||||
('gobject turn',2,'Syntax: .gobject turn #goguid \r\n\r\nSet for gameobject #goguid orientation same as current character orientation.'),
|
('gobject turn',2,'Syntax: .gobject turn #goguid \r\n\r\nSet for gameobject #goguid orientation same as current character orientation.'),
|
||||||
('gobject target',2,'Syntax: .gobject target [#go_id|#go_name_part]\r\n\r\nLocate and show position nearest gameobject. If #go_id or #go_name_part provide then locate and show position of nearest gameobject with gameobject template id #go_id or name included #go_name_part as part.'),
|
('gobject target',2,'Syntax: .gobject target [#go_id|#go_name_part]\r\n\r\nLocate and show position nearest gameobject. If #go_id or #go_name_part provide then locate and show position of nearest gameobject with gameobject template id #go_id or name included #go_name_part as part.'),
|
||||||
('goname',1,'Syntax: .goname $charactername\r\n\r\nTeleport to the given character. Either specify the character name or click on the character\'s portrait, e.g. when you are in a group.'),
|
('goname',1,'Syntax: .goname $charactername\r\n\r\nTeleport to the given character. Either specify the character name or click on the character\'s portrait, e.g. when you are in a group.'),
|
||||||
|
|
|
||||||
7
sql/updates/7493_01_mangos_command.sql
Normal file
7
sql/updates/7493_01_mangos_command.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
ALTER TABLE db_version CHANGE COLUMN required_7472_01_mangos_mangos_string required_7493_01_mangos_command bit;
|
||||||
|
|
||||||
|
DELETE FROM `command` WHERE `name` IN ('gobject near','gobject phase','gobject setphase');
|
||||||
|
|
||||||
|
INSERT INTO `command` VALUES
|
||||||
|
('gobject near',2,'Syntax: .gobject near [#distance]\r\n\r\nOutput gameobjects at distance #distance from player. Output gameobject guids and coordinates sorted by distance from character. If #distance not provided use 10 as default value.'),
|
||||||
|
('gobject setphase',2,'Syntax: .gobject setphase #guid #phasemask\r\n\r\nGameobject with DB guid #guid phasemask changed to #phasemask with related world vision update for players. Gameobject state saved to DB and persistent.');
|
||||||
|
|
@ -198,6 +198,7 @@ pkgdata_DATA = \
|
||||||
7422_01_mangos_mangos_string.sql \
|
7422_01_mangos_mangos_string.sql \
|
||||||
7439_01_mangos_mangos_string.sql \
|
7439_01_mangos_mangos_string.sql \
|
||||||
7472_01_mangos_mangos_string.sql \
|
7472_01_mangos_mangos_string.sql \
|
||||||
|
7493_01_mangos_command.sql \
|
||||||
README
|
README
|
||||||
|
|
||||||
## Additional files to include when running 'make dist'
|
## Additional files to include when running 'make dist'
|
||||||
|
|
@ -376,4 +377,5 @@ EXTRA_DIST = \
|
||||||
7422_01_mangos_mangos_string.sql \
|
7422_01_mangos_mangos_string.sql \
|
||||||
7439_01_mangos_mangos_string.sql \
|
7439_01_mangos_mangos_string.sql \
|
||||||
7472_01_mangos_mangos_string.sql \
|
7472_01_mangos_mangos_string.sql \
|
||||||
|
7493_01_mangos_command.sql \
|
||||||
README
|
README
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||||
{ "add", SEC_GAMEMASTER, false, &ChatHandler::HandleGameObjectAddCommand, "", NULL },
|
{ "add", SEC_GAMEMASTER, false, &ChatHandler::HandleGameObjectAddCommand, "", NULL },
|
||||||
{ "delete", SEC_GAMEMASTER, false, &ChatHandler::HandleGameObjectDeleteCommand, "", NULL },
|
{ "delete", SEC_GAMEMASTER, false, &ChatHandler::HandleGameObjectDeleteCommand, "", NULL },
|
||||||
{ "move", SEC_GAMEMASTER, false, &ChatHandler::HandleGameObjectMoveCommand, "", NULL },
|
{ "move", SEC_GAMEMASTER, false, &ChatHandler::HandleGameObjectMoveCommand, "", NULL },
|
||||||
{ "near", SEC_ADMINISTRATOR, false, &ChatHandler::HandleGameObjectNearCommand, "", NULL },
|
{ "near", SEC_GAMEMASTER, false, &ChatHandler::HandleGameObjectNearCommand, "", NULL },
|
||||||
{ "setphase", SEC_GAMEMASTER, false, &ChatHandler::HandleGameObjectPhaseCommand, "", NULL },
|
{ "setphase", SEC_GAMEMASTER, false, &ChatHandler::HandleGameObjectPhaseCommand, "", NULL },
|
||||||
{ "target", SEC_GAMEMASTER, false, &ChatHandler::HandleGameObjectTargetCommand, "", NULL },
|
{ "target", SEC_GAMEMASTER, false, &ChatHandler::HandleGameObjectTargetCommand, "", NULL },
|
||||||
{ "turn", SEC_GAMEMASTER, false, &ChatHandler::HandleGameObjectTurnCommand, "", NULL },
|
{ "turn", SEC_GAMEMASTER, false, &ChatHandler::HandleGameObjectTurnCommand, "", NULL },
|
||||||
|
|
|
||||||
|
|
@ -155,172 +155,6 @@ bool ChatHandler::HandleUnmuteCommand(const char* args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatHandler::HandleGameObjectTargetCommand(const char* args)
|
|
||||||
{
|
|
||||||
Player* pl = m_session->GetPlayer();
|
|
||||||
QueryResult *result;
|
|
||||||
GameEventMgr::ActiveEvents const& activeEventsList = gameeventmgr.GetActiveEventList();
|
|
||||||
if(*args)
|
|
||||||
{
|
|
||||||
int32 id = atoi((char*)args);
|
|
||||||
if(id)
|
|
||||||
result = WorldDatabase.PQuery("SELECT 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 WHERE map = '%i' AND id = '%u' ORDER BY order_ ASC LIMIT 1",
|
|
||||||
pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),id);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string name = args;
|
|
||||||
WorldDatabase.escape_string(name);
|
|
||||||
result = WorldDatabase.PQuery(
|
|
||||||
"SELECT 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,gameobject_template WHERE gameobject_template.entry = gameobject.id AND map = %i AND name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" ORDER BY order_ ASC LIMIT 1",
|
|
||||||
pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),name.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::ostringstream eventFilter;
|
|
||||||
eventFilter << " AND (event IS NULL ";
|
|
||||||
bool initString = true;
|
|
||||||
|
|
||||||
for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr)
|
|
||||||
{
|
|
||||||
if (initString)
|
|
||||||
{
|
|
||||||
eventFilter << "OR event IN (" <<*itr;
|
|
||||||
initString =false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
eventFilter << "," << *itr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!initString)
|
|
||||||
eventFilter << "))";
|
|
||||||
else
|
|
||||||
eventFilter << ")";
|
|
||||||
|
|
||||||
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 10",
|
|
||||||
m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetMapId(),eventFilter.str().c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
SendSysMessage(LANG_COMMAND_TARGETOBJNOTFOUND);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameObject* target = ObjectAccessor::GetGameObject(*m_session->GetPlayer(),MAKE_NEW_GUID(lowguid,id,HIGHGUID_GAMEOBJECT));
|
|
||||||
|
|
||||||
PSendSysMessage(LANG_GAMEOBJECT_DETAIL, lowguid, goI->name, lowguid, id, x, y, z, mapid, o);
|
|
||||||
|
|
||||||
if(target)
|
|
||||||
{
|
|
||||||
int32 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL);
|
|
||||||
if(curRespawnDelay < 0)
|
|
||||||
curRespawnDelay = 0;
|
|
||||||
|
|
||||||
std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true);
|
|
||||||
std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true);
|
|
||||||
|
|
||||||
PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//teleport to gameobject
|
|
||||||
bool ChatHandler::HandleGoObjectCommand(const char* args)
|
|
||||||
{
|
|
||||||
if(!*args)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Player* _player = m_session->GetPlayer();
|
|
||||||
|
|
||||||
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
|
|
||||||
char* cId = extractKeyFromLink((char*)args,"Hgameobject");
|
|
||||||
if(!cId)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int32 guid = atoi(cId);
|
|
||||||
if(!guid)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
float x, y, z, ort;
|
|
||||||
int mapid;
|
|
||||||
|
|
||||||
// by DB guid
|
|
||||||
if (GameObjectData const* go_data = objmgr.GetGOData(guid))
|
|
||||||
{
|
|
||||||
x = go_data->posX;
|
|
||||||
y = go_data->posY;
|
|
||||||
z = go_data->posZ;
|
|
||||||
ort = go_data->orientation;
|
|
||||||
mapid = go_data->mapid;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND);
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!MapManager::IsValidMapCoord(mapid,x,y,z,ort))
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// stop flight if need
|
|
||||||
if(_player->isInFlight())
|
|
||||||
{
|
|
||||||
_player->GetMotionMaster()->MovementExpired();
|
|
||||||
_player->m_taxi.ClearTaxiDestinations();
|
|
||||||
}
|
|
||||||
// save only in non-flight case
|
|
||||||
else
|
|
||||||
_player->SaveRecallPosition();
|
|
||||||
|
|
||||||
_player->TeleportTo(mapid, x, y, z, ort);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChatHandler::HandleGoTriggerCommand(const char* args)
|
bool ChatHandler::HandleGoTriggerCommand(const char* args)
|
||||||
{
|
{
|
||||||
Player* _player = m_session->GetPlayer();
|
Player* _player = m_session->GetPlayer();
|
||||||
|
|
@ -518,6 +352,501 @@ bool ChatHandler::HandleGoCreatureCommand(const char* args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//teleport to gameobject
|
||||||
|
bool ChatHandler::HandleGoObjectCommand(const char* args)
|
||||||
|
{
|
||||||
|
if(!*args)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Player* _player = m_session->GetPlayer();
|
||||||
|
|
||||||
|
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
|
||||||
|
char* cId = extractKeyFromLink((char*)args,"Hgameobject");
|
||||||
|
if(!cId)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int32 guid = atoi(cId);
|
||||||
|
if(!guid)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
float x, y, z, ort;
|
||||||
|
int mapid;
|
||||||
|
|
||||||
|
// by DB guid
|
||||||
|
if (GameObjectData const* go_data = objmgr.GetGOData(guid))
|
||||||
|
{
|
||||||
|
x = go_data->posX;
|
||||||
|
y = go_data->posY;
|
||||||
|
z = go_data->posZ;
|
||||||
|
ort = go_data->orientation;
|
||||||
|
mapid = go_data->mapid;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!MapManager::IsValidMapCoord(mapid,x,y,z,ort))
|
||||||
|
{
|
||||||
|
PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stop flight if need
|
||||||
|
if(_player->isInFlight())
|
||||||
|
{
|
||||||
|
_player->GetMotionMaster()->MovementExpired();
|
||||||
|
_player->m_taxi.ClearTaxiDestinations();
|
||||||
|
}
|
||||||
|
// save only in non-flight case
|
||||||
|
else
|
||||||
|
_player->SaveRecallPosition();
|
||||||
|
|
||||||
|
_player->TeleportTo(mapid, x, y, z, ort);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChatHandler::HandleGameObjectTargetCommand(const char* args)
|
||||||
|
{
|
||||||
|
Player* pl = m_session->GetPlayer();
|
||||||
|
QueryResult *result;
|
||||||
|
GameEventMgr::ActiveEvents const& activeEventsList = gameeventmgr.GetActiveEventList();
|
||||||
|
if(*args)
|
||||||
|
{
|
||||||
|
int32 id = atoi((char*)args);
|
||||||
|
if(id)
|
||||||
|
result = WorldDatabase.PQuery("SELECT 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 WHERE map = '%i' AND id = '%u' ORDER BY order_ ASC LIMIT 1",
|
||||||
|
pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),id);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string name = args;
|
||||||
|
WorldDatabase.escape_string(name);
|
||||||
|
result = WorldDatabase.PQuery(
|
||||||
|
"SELECT 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,gameobject_template WHERE gameobject_template.entry = gameobject.id AND map = %i AND name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" ORDER BY order_ ASC LIMIT 1",
|
||||||
|
pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),name.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::ostringstream eventFilter;
|
||||||
|
eventFilter << " AND (event IS NULL ";
|
||||||
|
bool initString = true;
|
||||||
|
|
||||||
|
for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr)
|
||||||
|
{
|
||||||
|
if (initString)
|
||||||
|
{
|
||||||
|
eventFilter << "OR event IN (" <<*itr;
|
||||||
|
initString =false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
eventFilter << "," << *itr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!initString)
|
||||||
|
eventFilter << "))";
|
||||||
|
else
|
||||||
|
eventFilter << ")";
|
||||||
|
|
||||||
|
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 10",
|
||||||
|
m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetMapId(),eventFilter.str().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
SendSysMessage(LANG_COMMAND_TARGETOBJNOTFOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameObject* target = ObjectAccessor::GetGameObject(*m_session->GetPlayer(),MAKE_NEW_GUID(lowguid,id,HIGHGUID_GAMEOBJECT));
|
||||||
|
|
||||||
|
PSendSysMessage(LANG_GAMEOBJECT_DETAIL, lowguid, goI->name, lowguid, id, x, y, z, mapid, o);
|
||||||
|
|
||||||
|
if(target)
|
||||||
|
{
|
||||||
|
int32 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL);
|
||||||
|
if(curRespawnDelay < 0)
|
||||||
|
curRespawnDelay = 0;
|
||||||
|
|
||||||
|
std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true);
|
||||||
|
std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true);
|
||||||
|
|
||||||
|
PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//delete object by selection or guid
|
||||||
|
bool ChatHandler::HandleGameObjectDeleteCommand(const char* args)
|
||||||
|
{
|
||||||
|
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
|
||||||
|
char* cId = extractKeyFromLink((char*)args,"Hgameobject");
|
||||||
|
if(!cId)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
uint32 lowguid = atoi(cId);
|
||||||
|
if(!lowguid)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
GameObject* obj = NULL;
|
||||||
|
|
||||||
|
// by DB guid
|
||||||
|
if (GameObjectData const* go_data = objmgr.GetGOData(lowguid))
|
||||||
|
obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);
|
||||||
|
|
||||||
|
if(!obj)
|
||||||
|
{
|
||||||
|
PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64 owner_guid = obj->GetOwnerGUID();
|
||||||
|
if(owner_guid)
|
||||||
|
{
|
||||||
|
Unit* owner = ObjectAccessor::GetUnit(*m_session->GetPlayer(),owner_guid);
|
||||||
|
if(!owner && !IS_PLAYER_GUID(owner_guid))
|
||||||
|
{
|
||||||
|
PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow());
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
owner->RemoveGameObject(obj,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
obj->SetRespawnTime(0); // not save respawn time
|
||||||
|
obj->Delete();
|
||||||
|
obj->DeleteFromDB();
|
||||||
|
|
||||||
|
PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, obj->GetGUIDLow());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//turn selected object
|
||||||
|
bool ChatHandler::HandleGameObjectTurnCommand(const char* args)
|
||||||
|
{
|
||||||
|
// number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
|
||||||
|
char* cId = extractKeyFromLink((char*)args,"Hgameobject");
|
||||||
|
if(!cId)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
uint32 lowguid = atoi(cId);
|
||||||
|
if(!lowguid)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
GameObject* obj = NULL;
|
||||||
|
|
||||||
|
// by DB guid
|
||||||
|
if (GameObjectData const* go_data = objmgr.GetGOData(lowguid))
|
||||||
|
obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);
|
||||||
|
|
||||||
|
if(!obj)
|
||||||
|
{
|
||||||
|
PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* po = strtok(NULL, " ");
|
||||||
|
float o;
|
||||||
|
|
||||||
|
if (po)
|
||||||
|
{
|
||||||
|
o = (float)atof(po);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Player *chr = m_session->GetPlayer();
|
||||||
|
o = chr->GetOrientation();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map* map = obj->GetMap();
|
||||||
|
map->Remove(obj,false);
|
||||||
|
|
||||||
|
obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o);
|
||||||
|
obj->UpdateRotationFields();
|
||||||
|
|
||||||
|
map->Add(obj);
|
||||||
|
|
||||||
|
obj->SaveToDB();
|
||||||
|
obj->Refresh();
|
||||||
|
|
||||||
|
PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, obj->GetGUIDLow(), o);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//move selected object
|
||||||
|
bool ChatHandler::HandleGameObjectMoveCommand(const char* args)
|
||||||
|
{
|
||||||
|
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
|
||||||
|
char* cId = extractKeyFromLink((char*)args,"Hgameobject");
|
||||||
|
if(!cId)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
uint32 lowguid = atoi(cId);
|
||||||
|
if(!lowguid)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
GameObject* obj = NULL;
|
||||||
|
|
||||||
|
// by DB guid
|
||||||
|
if (GameObjectData const* go_data = objmgr.GetGOData(lowguid))
|
||||||
|
obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);
|
||||||
|
|
||||||
|
if(!obj)
|
||||||
|
{
|
||||||
|
PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* px = strtok(NULL, " ");
|
||||||
|
char* py = strtok(NULL, " ");
|
||||||
|
char* pz = strtok(NULL, " ");
|
||||||
|
|
||||||
|
if (!px)
|
||||||
|
{
|
||||||
|
Player *chr = m_session->GetPlayer();
|
||||||
|
|
||||||
|
Map* map = obj->GetMap();
|
||||||
|
map->Remove(obj,false);
|
||||||
|
|
||||||
|
obj->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), obj->GetOrientation());
|
||||||
|
obj->SetFloatValue(GAMEOBJECT_POS_X, chr->GetPositionX());
|
||||||
|
obj->SetFloatValue(GAMEOBJECT_POS_Y, chr->GetPositionY());
|
||||||
|
obj->SetFloatValue(GAMEOBJECT_POS_Z, chr->GetPositionZ());
|
||||||
|
|
||||||
|
map->Add(obj);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!py || !pz)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
float x = (float)atof(px);
|
||||||
|
float y = (float)atof(py);
|
||||||
|
float z = (float)atof(pz);
|
||||||
|
|
||||||
|
if(!MapManager::IsValidMapCoord(obj->GetMapId(),x,y,z))
|
||||||
|
{
|
||||||
|
PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,obj->GetMapId());
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map* map = obj->GetMap();
|
||||||
|
map->Remove(obj,false);
|
||||||
|
|
||||||
|
obj->Relocate(x, y, z, obj->GetOrientation());
|
||||||
|
obj->SetFloatValue(GAMEOBJECT_POS_X, x);
|
||||||
|
obj->SetFloatValue(GAMEOBJECT_POS_Y, y);
|
||||||
|
obj->SetFloatValue(GAMEOBJECT_POS_Z, z);
|
||||||
|
|
||||||
|
map->Add(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
obj->SaveToDB();
|
||||||
|
obj->Refresh();
|
||||||
|
|
||||||
|
PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, obj->GetGUIDLow());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//spawn go
|
||||||
|
bool ChatHandler::HandleGameObjectAddCommand(const char* args)
|
||||||
|
{
|
||||||
|
if (!*args)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char* pParam1 = strtok((char*)args, " ");
|
||||||
|
if (!pParam1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
uint32 id = atoi((char*)pParam1);
|
||||||
|
if(!id)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char* spawntimeSecs = strtok(NULL, " ");
|
||||||
|
|
||||||
|
const GameObjectInfo *goI = objmgr.GetGameObjectInfo(id);
|
||||||
|
|
||||||
|
if (!goI)
|
||||||
|
{
|
||||||
|
PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player *chr = m_session->GetPlayer();
|
||||||
|
float x = float(chr->GetPositionX());
|
||||||
|
float y = float(chr->GetPositionY());
|
||||||
|
float z = float(chr->GetPositionZ());
|
||||||
|
float o = float(chr->GetOrientation());
|
||||||
|
Map *map = chr->GetMap();
|
||||||
|
|
||||||
|
GameObject* pGameObj = new GameObject;
|
||||||
|
uint32 db_lowGUID = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
|
||||||
|
|
||||||
|
if(!pGameObj->Create(db_lowGUID, goI->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, 1))
|
||||||
|
{
|
||||||
|
delete pGameObj;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( spawntimeSecs )
|
||||||
|
{
|
||||||
|
uint32 value = atoi((char*)spawntimeSecs);
|
||||||
|
pGameObj->SetRespawnTime(value);
|
||||||
|
//sLog.outDebug("*** spawntimeSecs: %d", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// fill the gameobject data and save to the db
|
||||||
|
pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()),chr->GetPhaseMaskForSpawn());
|
||||||
|
|
||||||
|
// this will generate a new guid if the object is in an instance
|
||||||
|
if(!pGameObj->LoadFromDB(db_lowGUID, map))
|
||||||
|
{
|
||||||
|
delete pGameObj;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
sLog.outDebug(GetMangosString(LANG_GAMEOBJECT_CURRENT), goI->name, db_lowGUID, x, y, z, o);
|
||||||
|
|
||||||
|
map->Add(pGameObj);
|
||||||
|
|
||||||
|
// TODO: is it really necessary to add both the real and DB table guid here ?
|
||||||
|
objmgr.AddGameobjectToGrid(db_lowGUID, objmgr.GetGOData(db_lowGUID));
|
||||||
|
|
||||||
|
PSendSysMessage(LANG_GAMEOBJECT_ADD,id,goI->name,db_lowGUID,x,y,z);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//set pahsemask for selected object
|
||||||
|
bool ChatHandler::HandleGameObjectPhaseCommand(const char* args)
|
||||||
|
{
|
||||||
|
// number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
|
||||||
|
char* cId = extractKeyFromLink((char*)args,"Hgameobject");
|
||||||
|
if(!cId)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
uint32 lowguid = atoi(cId);
|
||||||
|
if(!lowguid)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
GameObject* obj = NULL;
|
||||||
|
|
||||||
|
// by DB guid
|
||||||
|
if (GameObjectData const* go_data = objmgr.GetGOData(lowguid))
|
||||||
|
obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);
|
||||||
|
|
||||||
|
if(!obj)
|
||||||
|
{
|
||||||
|
PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* phaseStr = strtok (NULL, " ");
|
||||||
|
uint32 phasemask = phaseStr? atoi(phaseStr) : 0;
|
||||||
|
if ( phasemask == 0 )
|
||||||
|
{
|
||||||
|
SendSysMessage(LANG_BAD_VALUE);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
obj->SetPhaseMask(phasemask,true);
|
||||||
|
obj->SaveToDB();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChatHandler::HandleGameObjectNearCommand(const char* args)
|
||||||
|
{
|
||||||
|
float distance = (!*args) ? 10 : atol(args);
|
||||||
|
uint32 count = 0;
|
||||||
|
|
||||||
|
Player* pl = m_session->GetPlayer();
|
||||||
|
QueryResult *result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, "
|
||||||
|
"(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ "
|
||||||
|
"FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_",
|
||||||
|
pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),
|
||||||
|
pl->GetMapId(),pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),distance*distance);
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Field *fields = result->Fetch();
|
||||||
|
uint32 guid = fields[0].GetUInt32();
|
||||||
|
uint32 entry = fields[1].GetUInt32();
|
||||||
|
float x = fields[2].GetFloat();
|
||||||
|
float y = fields[3].GetFloat();
|
||||||
|
float z = fields[4].GetFloat();
|
||||||
|
int mapid = fields[5].GetUInt16();
|
||||||
|
|
||||||
|
GameObjectInfo const * gInfo = objmgr.GetGameObjectInfo(entry);
|
||||||
|
|
||||||
|
if(!gInfo)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
PSendSysMessage(LANG_GO_LIST_CHAT, guid, guid, gInfo->name, x, y, z, mapid);
|
||||||
|
|
||||||
|
++count;
|
||||||
|
} while (result->NextRow());
|
||||||
|
|
||||||
|
delete result;
|
||||||
|
}
|
||||||
|
|
||||||
|
PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE,distance,count);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ChatHandler::HandleGUIDCommand(const char* /*args*/)
|
bool ChatHandler::HandleGUIDCommand(const char* /*args*/)
|
||||||
{
|
{
|
||||||
uint64 guid = m_session->GetPlayer()->GetSelection();
|
uint64 guid = m_session->GetPlayer()->GetSelection();
|
||||||
|
|
@ -1701,186 +2030,6 @@ bool ChatHandler::HandleItemMoveCommand(const char* args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete object by selection or guid
|
|
||||||
bool ChatHandler::HandleGameObjectDeleteCommand(const char* args)
|
|
||||||
{
|
|
||||||
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
|
|
||||||
char* cId = extractKeyFromLink((char*)args,"Hgameobject");
|
|
||||||
if(!cId)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uint32 lowguid = atoi(cId);
|
|
||||||
if(!lowguid)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
GameObject* obj = NULL;
|
|
||||||
|
|
||||||
// by DB guid
|
|
||||||
if (GameObjectData const* go_data = objmgr.GetGOData(lowguid))
|
|
||||||
obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);
|
|
||||||
|
|
||||||
if(!obj)
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64 owner_guid = obj->GetOwnerGUID();
|
|
||||||
if(owner_guid)
|
|
||||||
{
|
|
||||||
Unit* owner = ObjectAccessor::GetUnit(*m_session->GetPlayer(),owner_guid);
|
|
||||||
if(!owner && !IS_PLAYER_GUID(owner_guid))
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow());
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
owner->RemoveGameObject(obj,false);
|
|
||||||
}
|
|
||||||
|
|
||||||
obj->SetRespawnTime(0); // not save respawn time
|
|
||||||
obj->Delete();
|
|
||||||
obj->DeleteFromDB();
|
|
||||||
|
|
||||||
PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, obj->GetGUIDLow());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//turn selected object
|
|
||||||
bool ChatHandler::HandleGameObjectTurnCommand(const char* args)
|
|
||||||
{
|
|
||||||
// number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
|
|
||||||
char* cId = extractKeyFromLink((char*)args,"Hgameobject");
|
|
||||||
if(!cId)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uint32 lowguid = atoi(cId);
|
|
||||||
if(!lowguid)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
GameObject* obj = NULL;
|
|
||||||
|
|
||||||
// by DB guid
|
|
||||||
if (GameObjectData const* go_data = objmgr.GetGOData(lowguid))
|
|
||||||
obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);
|
|
||||||
|
|
||||||
if(!obj)
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* po = strtok(NULL, " ");
|
|
||||||
float o;
|
|
||||||
|
|
||||||
if (po)
|
|
||||||
{
|
|
||||||
o = (float)atof(po);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Player *chr = m_session->GetPlayer();
|
|
||||||
o = chr->GetOrientation();
|
|
||||||
}
|
|
||||||
|
|
||||||
Map* map = obj->GetMap();
|
|
||||||
map->Remove(obj,false);
|
|
||||||
|
|
||||||
obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o);
|
|
||||||
obj->UpdateRotationFields();
|
|
||||||
|
|
||||||
map->Add(obj);
|
|
||||||
|
|
||||||
obj->SaveToDB();
|
|
||||||
obj->Refresh();
|
|
||||||
|
|
||||||
PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, obj->GetGUIDLow(), o);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//move selected object
|
|
||||||
bool ChatHandler::HandleGameObjectMoveCommand(const char* args)
|
|
||||||
{
|
|
||||||
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
|
|
||||||
char* cId = extractKeyFromLink((char*)args,"Hgameobject");
|
|
||||||
if(!cId)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uint32 lowguid = atoi(cId);
|
|
||||||
if(!lowguid)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
GameObject* obj = NULL;
|
|
||||||
|
|
||||||
// by DB guid
|
|
||||||
if (GameObjectData const* go_data = objmgr.GetGOData(lowguid))
|
|
||||||
obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);
|
|
||||||
|
|
||||||
if(!obj)
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* px = strtok(NULL, " ");
|
|
||||||
char* py = strtok(NULL, " ");
|
|
||||||
char* pz = strtok(NULL, " ");
|
|
||||||
|
|
||||||
if (!px)
|
|
||||||
{
|
|
||||||
Player *chr = m_session->GetPlayer();
|
|
||||||
|
|
||||||
Map* map = obj->GetMap();
|
|
||||||
map->Remove(obj,false);
|
|
||||||
|
|
||||||
obj->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), obj->GetOrientation());
|
|
||||||
obj->SetFloatValue(GAMEOBJECT_POS_X, chr->GetPositionX());
|
|
||||||
obj->SetFloatValue(GAMEOBJECT_POS_Y, chr->GetPositionY());
|
|
||||||
obj->SetFloatValue(GAMEOBJECT_POS_Z, chr->GetPositionZ());
|
|
||||||
|
|
||||||
map->Add(obj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(!py || !pz)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
float x = (float)atof(px);
|
|
||||||
float y = (float)atof(py);
|
|
||||||
float z = (float)atof(pz);
|
|
||||||
|
|
||||||
if(!MapManager::IsValidMapCoord(obj->GetMapId(),x,y,z))
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,obj->GetMapId());
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map* map = obj->GetMap();
|
|
||||||
map->Remove(obj,false);
|
|
||||||
|
|
||||||
obj->Relocate(x, y, z, obj->GetOrientation());
|
|
||||||
obj->SetFloatValue(GAMEOBJECT_POS_X, x);
|
|
||||||
obj->SetFloatValue(GAMEOBJECT_POS_Y, y);
|
|
||||||
obj->SetFloatValue(GAMEOBJECT_POS_Z, z);
|
|
||||||
|
|
||||||
map->Add(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
obj->SaveToDB();
|
|
||||||
obj->Refresh();
|
|
||||||
|
|
||||||
PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, obj->GetGUIDLow());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//demorph player or unit
|
//demorph player or unit
|
||||||
bool ChatHandler::HandleDeMorphCommand(const char* /*args*/)
|
bool ChatHandler::HandleDeMorphCommand(const char* /*args*/)
|
||||||
{
|
{
|
||||||
|
|
@ -3622,75 +3771,6 @@ bool ChatHandler::HandleCustomizeCommand(const char* args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//spawn go
|
|
||||||
bool ChatHandler::HandleGameObjectAddCommand(const char* args)
|
|
||||||
{
|
|
||||||
if (!*args)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
char* pParam1 = strtok((char*)args, " ");
|
|
||||||
if (!pParam1)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uint32 id = atoi((char*)pParam1);
|
|
||||||
if(!id)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
char* spawntimeSecs = strtok(NULL, " ");
|
|
||||||
|
|
||||||
const GameObjectInfo *goI = objmgr.GetGameObjectInfo(id);
|
|
||||||
|
|
||||||
if (!goI)
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id);
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player *chr = m_session->GetPlayer();
|
|
||||||
float x = float(chr->GetPositionX());
|
|
||||||
float y = float(chr->GetPositionY());
|
|
||||||
float z = float(chr->GetPositionZ());
|
|
||||||
float o = float(chr->GetOrientation());
|
|
||||||
Map *map = chr->GetMap();
|
|
||||||
|
|
||||||
GameObject* pGameObj = new GameObject;
|
|
||||||
uint32 db_lowGUID = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
|
|
||||||
|
|
||||||
if(!pGameObj->Create(db_lowGUID, goI->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, 1))
|
|
||||||
{
|
|
||||||
delete pGameObj;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( spawntimeSecs )
|
|
||||||
{
|
|
||||||
uint32 value = atoi((char*)spawntimeSecs);
|
|
||||||
pGameObj->SetRespawnTime(value);
|
|
||||||
//sLog.outDebug("*** spawntimeSecs: %d", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// fill the gameobject data and save to the db
|
|
||||||
pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()),chr->GetPhaseMaskForSpawn());
|
|
||||||
|
|
||||||
// this will generate a new guid if the object is in an instance
|
|
||||||
if(!pGameObj->LoadFromDB(db_lowGUID, map))
|
|
||||||
{
|
|
||||||
delete pGameObj;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
sLog.outDebug(GetMangosString(LANG_GAMEOBJECT_CURRENT), goI->name, db_lowGUID, x, y, z, o);
|
|
||||||
|
|
||||||
map->Add(pGameObj);
|
|
||||||
|
|
||||||
// TODO: is it really necessary to add both the real and DB table guid here ?
|
|
||||||
objmgr.AddGameobjectToGrid(db_lowGUID, objmgr.GetGOData(db_lowGUID));
|
|
||||||
|
|
||||||
PSendSysMessage(LANG_GAMEOBJECT_ADD,id,goI->name,db_lowGUID,x,y,z);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//show animation
|
//show animation
|
||||||
bool ChatHandler::HandleDebugAnimCommand(const char* args)
|
bool ChatHandler::HandleDebugAnimCommand(const char* args)
|
||||||
{
|
{
|
||||||
|
|
@ -4297,41 +4377,3 @@ bool ChatHandler::HandleWaterwalkCommand(const char* args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//set pahsemask for selected object
|
|
||||||
bool ChatHandler::HandleGameObjectPhaseCommand(const char* args)
|
|
||||||
{
|
|
||||||
// number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
|
|
||||||
char* cId = extractKeyFromLink((char*)args,"Hgameobject");
|
|
||||||
if(!cId)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uint32 lowguid = atoi(cId);
|
|
||||||
if(!lowguid)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
GameObject* obj = NULL;
|
|
||||||
|
|
||||||
// by DB guid
|
|
||||||
if (GameObjectData const* go_data = objmgr.GetGOData(lowguid))
|
|
||||||
obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);
|
|
||||||
|
|
||||||
if(!obj)
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* phaseStr = strtok (NULL, " ");
|
|
||||||
uint32 phasemask = phaseStr? atoi(phaseStr) : 0;
|
|
||||||
if ( phasemask == 0 )
|
|
||||||
{
|
|
||||||
SendSysMessage(LANG_BAD_VALUE);
|
|
||||||
SetSentErrorMessage(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
obj->SetPhaseMask(phasemask,true);
|
|
||||||
obj->SaveToDB();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -2368,47 +2368,6 @@ bool ChatHandler::HandleListObjectCommand(const char* args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatHandler::HandleGameObjectNearCommand(const char* args)
|
|
||||||
{
|
|
||||||
float distance = (!*args) ? 10 : atol(args);
|
|
||||||
uint32 count = 0;
|
|
||||||
|
|
||||||
Player* pl = m_session->GetPlayer();
|
|
||||||
QueryResult *result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, "
|
|
||||||
"(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ "
|
|
||||||
"FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_",
|
|
||||||
pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),
|
|
||||||
pl->GetMapId(),pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),distance*distance);
|
|
||||||
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
Field *fields = result->Fetch();
|
|
||||||
uint32 guid = fields[0].GetUInt32();
|
|
||||||
uint32 entry = fields[1].GetUInt32();
|
|
||||||
float x = fields[2].GetFloat();
|
|
||||||
float y = fields[3].GetFloat();
|
|
||||||
float z = fields[4].GetFloat();
|
|
||||||
int mapid = fields[5].GetUInt16();
|
|
||||||
|
|
||||||
GameObjectInfo const * gInfo = objmgr.GetGameObjectInfo(entry);
|
|
||||||
|
|
||||||
if(!gInfo)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
PSendSysMessage(LANG_GO_LIST_CHAT, guid, guid, gInfo->name, x, y, z, mapid);
|
|
||||||
|
|
||||||
++count;
|
|
||||||
} while (result->NextRow());
|
|
||||||
|
|
||||||
delete result;
|
|
||||||
}
|
|
||||||
|
|
||||||
PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE,distance,count);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ChatHandler::HandleListCreatureCommand(const char* args)
|
bool ChatHandler::HandleListCreatureCommand(const char* args)
|
||||||
{
|
{
|
||||||
if(!*args)
|
if(!*args)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7492"
|
#define REVISION_NR "7493"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue