diff options
| author | click <none@none> | 2010-11-16 21:27:25 +0100 |
|---|---|---|
| committer | click <none@none> | 2010-11-16 21:27:25 +0100 |
| commit | 95e956a0b5145ad0a260557ce9ae1290cdacad2d (patch) | |
| tree | 383a6b273e31ab72e352d2394ab951c1d5b20ec2 /src/server/game/Chat/Commands | |
| parent | e87223b453f1f958b077d9f98234d4cb9fc71557 (diff) | |
Core/Scripts: Convert more commands over to CommandScripts (moves gobject, honor, quest, reload, titles and wp commands to scripts) - Patch by Paradox
(Also fixes a minor visual error on GM-listings (gm ingame/gm list) when the respective user had an R in his/her name).
Closes issue 4792.
--HG--
branch : trunk
Diffstat (limited to 'src/server/game/Chat/Commands')
| -rwxr-xr-x | src/server/game/Chat/Commands/Debugcmds.cpp | 23 | ||||
| -rwxr-xr-x | src/server/game/Chat/Commands/Level2.cpp | 1713 | ||||
| -rwxr-xr-x | src/server/game/Chat/Commands/Level3.cpp | 1388 | ||||
| -rwxr-xr-x | src/server/game/Chat/Commands/TicketCommands.cpp | 6 |
4 files changed, 1 insertions, 3129 deletions
diff --git a/src/server/game/Chat/Commands/Debugcmds.cpp b/src/server/game/Chat/Commands/Debugcmds.cpp index c831fde2ecd..691dab52911 100755 --- a/src/server/game/Chat/Commands/Debugcmds.cpp +++ b/src/server/game/Chat/Commands/Debugcmds.cpp @@ -16,25 +16,4 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "Common.h" -#include "DatabaseEnv.h" -#include "WorldPacket.h" -#include "Vehicle.h" -#include "Player.h" -#include "Opcodes.h" -#include "Chat.h" -#include "Log.h" -#include "Unit.h" -#include "GossipDef.h" -#include "Language.h" -#include "BattlegroundMgr.h" -#include <fstream> -#include "ObjectMgr.h" -#include "Cell.h" -#include "CellImpl.h" -#include "GridNotifiers.h" -#include "GridNotifiersImpl.h" -#include "SpellMgr.h" -#include "ScriptMgr.h" - -// This file is deprecated
\ No newline at end of file +// This file is deprecated diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp index e291957cd13..3c7adbb4d5f 100755 --- a/src/server/game/Chat/Commands/Level2.cpp +++ b/src/server/game/Chat/Commands/Level2.cpp @@ -136,442 +136,6 @@ bool ChatHandler::HandleUnmuteCommand(const char* args) return true; } -bool ChatHandler::HandleGameObjectTargetCommand(const char* args) -{ - Player* pl = m_session->GetPlayer(); - QueryResult result; - GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr.GetActiveEventList(); - if (*args) - { - // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameobject_entry"); - if (!cId) - return false; - - uint32 id = atol(cId); - - if (id) - result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (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 = cId; - WorldDatabase.escape_string(name); - result = WorldDatabase.PQuery( - "SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (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, phaseMask, " - "(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, phase; - uint32 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(); - phase = fields[7].GetUInt16(); - pool_id = sPoolMgr.IsPartOfAPool<GameObject>(lowguid); - if (!pool_id || sPoolMgr.IsSpawnedObject<GameObject>(lowguid)) - found = true; - } while (result->NextRow() && (!found)); - - if (!found) - { - PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); - return false; - } - - GameObjectInfo const* goI = sObjectMgr.GetGameObjectInfo(id); - - if (!goI) - { - PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); - return false; - } - - GameObject* target = m_session->GetPlayer()->GetMap()->GetGameObject(MAKE_NEW_GUID(lowguid,id,HIGHGUID_GAMEOBJECT)); - - PSendSysMessage(LANG_GAMEOBJECT_DETAIL, lowguid, goI->name, lowguid, id, x, y, z, mapid, o, phase); - - if (target) - { - int32 curRespawnDelay = int32(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 = sObjectMgr.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 = sObjectMgr.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(); - } - - obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o); - obj->UpdateRotationFields(); - obj->DestroyForNearbyPlayers(); - obj->UpdateObjectVisibility(); - - obj->SaveToDB(); - obj->Refresh(); - - PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, 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 = sObjectMgr.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(); - obj->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), obj->GetOrientation()); - obj->DestroyForNearbyPlayers(); - obj->UpdateObjectVisibility(); - } - 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; - } - - obj->Relocate(x, y, z, obj->GetOrientation()); - obj->DestroyForNearbyPlayers(); - obj->UpdateObjectVisibility(); - } - - obj->SaveToDB(); - obj->Refresh(); - - PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow()); - - return true; -} - -//spawn go -bool ChatHandler::HandleGameObjectAddCommand(const char* args) -{ - if (!*args) - return false; - - // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameobject_entry"); - if (!cId) - return false; - - uint32 id = atol(cId); - if (!id) - return false; - - char* spawntimeSecs = strtok(NULL, " "); - - const GameObjectInfo *gInfo = sObjectMgr.GetGameObjectInfo(id); - - if (!gInfo) - { - PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); - SetSentErrorMessage(true); - return false; - } - - if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId)) - { - // report to DB errors log as in loading case - sLog.outErrorDb("Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.",id, gInfo->type, gInfo->displayId); - PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA,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 = sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT); - - if (!pGameObj->Create(db_lowGUID, gInfo->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY)) - { - 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(GetTrinityString(LANG_GAMEOBJECT_CURRENT), gInfo->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 ? - sObjectMgr.AddGameobjectToGrid(db_lowGUID, sObjectMgr.GetGOData(db_lowGUID)); - - PSendSysMessage(LANG_GAMEOBJECT_ADD,id,gInfo->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 = sObjectMgr.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.0f : (float)(atof(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 = sObjectMgr.GetGameObjectInfo(entry); - - if (!gInfo) - continue; - - PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name, x, y, z, mapid); - - ++count; - } while (result->NextRow()); - } - - PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE,distance,count); - return true; -} - bool ChatHandler::HandleGUIDCommand(const char* /*args*/) { uint64 guid = m_session->GetPlayer()->GetSelection(); @@ -754,45 +318,6 @@ bool ChatHandler::HandleKickPlayerCommand(const char *args) return true; } -//show info of gameobject -bool ChatHandler::HandleGameObjectInfoCommand(const char* args) -{ - uint32 entry = 0; - uint32 type = 0; - uint32 displayid = 0; - std::string name; - uint32 lootId = 0; - - if (!*args) - { - if (WorldObject * obj = getSelectedObject()) - entry = obj->GetEntry(); - } - else - entry = atoi((char*)args); - - GameObjectInfo const* goinfo = sObjectMgr.GetGameObjectInfo(entry); - - if (!goinfo) - return false; - - type = goinfo->type; - displayid = goinfo->displayId; - name = goinfo->name; - if (type == GAMEOBJECT_TYPE_CHEST) - lootId = goinfo->chest.lootId; - else if (type == GAMEOBJECT_TYPE_FISHINGHOLE) - lootId = goinfo->fishinghole.lootId; - - PSendSysMessage(LANG_GOINFO_ENTRY, entry); - PSendSysMessage(LANG_GOINFO_TYPE, type); - PSendSysMessage(LANG_GOINFO_LOOTID, lootId); - PSendSysMessage(LANG_GOINFO_DISPLAYID, displayid); - PSendSysMessage(LANG_GOINFO_NAME, name.c_str()); - - return true; -} - //show info of player bool ChatHandler::HandlePInfoCommand(const char* args) { @@ -920,931 +445,6 @@ bool ChatHandler::HandlePInfoCommand(const char* args) return true; } -/////WAYPOINT COMMANDS - -/** - * Add a waypoint to a creature. - * - * The user can either select an npc or provide its GUID. - * - * The user can even select a visual waypoint - then the new waypoint - * is placed *after* the selected one - this makes insertion of new - * waypoints possible. - * - * eg: - * .wp add 12345 - * -> adds a waypoint to the npc with the GUID 12345 - * - * .wp add - * -> adds a waypoint to the currently selected creature - * - * - * @param args if the user did not provide a GUID, it is NULL - * - * @return true - command did succeed, false - something went wrong - */ -bool ChatHandler::HandleWpAddCommand(const char* args) -{ - sLog.outDebug("DEBUG: HandleWpAddCommand"); - - // optional - char* path_number = NULL; - uint32 pathid = 0; - - if (*args) - path_number = strtok((char*)args, " "); - - uint32 point = 0; - Creature* target = getSelectedCreature(); - - if (!path_number) - { - if (target) - pathid = target->GetWaypointPath(); - else - { - QueryResult result = WorldDatabase.Query("SELECT MAX(id) FROM waypoint_data"); - uint32 maxpathid = result->Fetch()->GetInt32(); - pathid = maxpathid+1; - sLog.outDebug("DEBUG: HandleWpAddCommand - New path started."); - PSendSysMessage("%s%s|r", "|cff00ff00", "New path started."); - } - } - else - pathid = atoi(path_number); - - // path_id -> ID of the Path - // point -> number of the waypoint (if not 0) - - if (!pathid) - { - sLog.outDebug("DEBUG: HandleWpAddCommand - Current creature haven't loaded path."); - PSendSysMessage("%s%s|r", "|cffff33ff", "Current creature haven't loaded path."); - return true; - } - - sLog.outDebug("DEBUG: HandleWpAddCommand - point == 0"); - - QueryResult result = WorldDatabase.PQuery("SELECT MAX(point) FROM waypoint_data WHERE id = '%u'",pathid); - - if (result) - point = (*result)[0].GetUInt32(); - - Player* player = m_session->GetPlayer(); - //Map *map = player->GetMap(); - - WorldDatabase.PExecute("INSERT INTO waypoint_data (id, point, position_x, position_y, position_z) VALUES ('%u','%u','%f', '%f', '%f')", - pathid, point+1, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); - - PSendSysMessage("%s%s%u%s%u%s|r", "|cff00ff00", "PathID: |r|cff00ffff", pathid, "|r|cff00ff00: Waypoint |r|cff00ffff", point+1,"|r|cff00ff00 created. "); - return true; -} // HandleWpAddCommand - -bool ChatHandler::HandleWpLoadPathCommand(const char *args) -{ - if (!*args) - return false; - - // optional - char* path_number = NULL; - - if (*args) - path_number = strtok((char*)args, " "); - - uint32 pathid = 0; - uint32 guidlow = 0; - Creature* target = getSelectedCreature(); - - // Did player provide a path_id? - if (!path_number) - sLog.outDebug("DEBUG: HandleWpLoadPathCommand - No path number provided"); - - if (!target) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - if (target->GetEntry() == 1) - { - PSendSysMessage("%s%s|r", "|cffff33ff", "You want to load path to a waypoint? Aren't you?"); - SetSentErrorMessage(true); - return false; - } - - pathid = atoi(path_number); - - if (!pathid) - { - PSendSysMessage("%s%s|r", "|cffff33ff", "No vallid path number provided."); - return true; - } - - guidlow = target->GetDBTableGUIDLow(); - QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature_addon WHERE guid = '%u'",guidlow); - - if (result) - WorldDatabase.PExecute("UPDATE creature_addon SET path_id = '%u' WHERE guid = '%u'", pathid, guidlow); - else - WorldDatabase.PExecute("INSERT INTO creature_addon(guid,path_id) VALUES ('%u','%u')", guidlow, pathid); - - WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE, guidlow); - - target->LoadPath(pathid); - target->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); - target->GetMotionMaster()->Initialize(); - target->MonsterSay("Path loaded.",0,0); - - return true; -} - -bool ChatHandler::HandleReloadAllPaths(const char* args) -{ - if (!*args) - return false; - - uint32 id = atoi(args); - - if (!id) - return false; - - PSendSysMessage("%s%s|r|cff00ffff%u|r", "|cff00ff00", "Loading Path: ", id); - sWaypointMgr->UpdatePath(id); - return true; -} - -bool ChatHandler::HandleWpUnLoadPathCommand(const char * /*args*/) -{ - uint32 guidlow = 0; - Creature* target = getSelectedCreature(); - - if (!target) - { - PSendSysMessage("%s%s|r", "|cff33ffff", "You must select target."); - return true; - } - - if (target->GetCreatureAddon()) - { - if (target->GetCreatureAddon()->path_id != 0) - { - WorldDatabase.PExecute("DELETE FROM creature_addon WHERE guid = %u", target->GetGUIDLow()); - target->UpdateWaypointID(0); - WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", IDLE_MOTION_TYPE, guidlow); - target->LoadPath(0); - target->SetDefaultMovementType(IDLE_MOTION_TYPE); - target->GetMotionMaster()->MoveTargetedHome(); - target->GetMotionMaster()->Initialize(); - target->MonsterSay("Path unloaded.",0,0); - return true; - } - PSendSysMessage("%s%s|r", "|cffff33ff", "Target have no loaded path."); - } - return true; -} - -bool ChatHandler::HandleWpEventCommand(const char* args) -{ - if (!*args) - return false; - - char* show_str = strtok((char*)args, " "); - std::string show = show_str; - - // Check - if ((show != "add") && (show != "mod") && (show != "del") && (show != "listid")) return false; - - char* arg_id = strtok(NULL, " "); - uint32 id = 0; - - if (show == "add") - { - if (arg_id) - id = atoi(arg_id); - - if (id) - { - QueryResult result = WorldDatabase.PQuery("SELECT id FROM waypoint_scripts WHERE guid = %u", id); - - if (!result) - { - WorldDatabase.PExecute("INSERT INTO waypoint_scripts(guid)VALUES(%u)", id); - PSendSysMessage("%s%s%u|r", "|cff00ff00", "Wp Event: New waypoint event added: ", id); - } - else - PSendSysMessage("|cff00ff00Wp Event: You have choosed an existing waypoint script guid: %u|r", id); - } - else - { - QueryResult result = WorldDatabase.Query("SELECT MAX(guid) FROM waypoint_scripts"); - id = result->Fetch()->GetUInt32(); - WorldDatabase.PExecute("INSERT INTO waypoint_scripts(guid)VALUES(%u)", id+1); - PSendSysMessage("%s%s%u|r", "|cff00ff00","Wp Event: New waypoint event added: |r|cff00ffff", id+1); - } - - return true; - } - - if (show == "listid") - { - if (!arg_id) - { - PSendSysMessage("%s%s|r", "|cff33ffff","Wp Event: You must provide waypoint script id."); - return true; - } - - id = atoi(arg_id); - - uint32 a2, a3, a4, a5, a6; - float a8, a9, a10, a11; - char const* a7; - - QueryResult result = WorldDatabase.PQuery("SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = %u", id); - - if (!result) - { - PSendSysMessage("%s%s%u|r", "|cff33ffff", "Wp Event: No waypoint scripts found on id: ", id); - return true; - } - - Field *fields; - - do - { - fields = result->Fetch(); - a2 = fields[0].GetUInt32(); - a3 = fields[1].GetUInt32(); - a4 = fields[2].GetUInt32(); - a5 = fields[3].GetUInt32(); - a6 = fields[4].GetUInt32(); - a7 = fields[5].GetCString(); - a8 = fields[6].GetFloat(); - a9 = fields[7].GetFloat(); - a10 = fields[8].GetFloat(); - a11 = fields[9].GetFloat(); - - PSendSysMessage("|cffff33ffid:|r|cff00ffff %u|r|cff00ff00, guid: |r|cff00ffff%u|r|cff00ff00, delay: |r|cff00ffff%u|r|cff00ff00, command: |r|cff00ffff%u|r|cff00ff00, datalong: |r|cff00ffff%u|r|cff00ff00, datalong2: |r|cff00ffff%u|r|cff00ff00, datatext: |r|cff00ffff%s|r|cff00ff00, posx: |r|cff00ffff%f|r|cff00ff00, posy: |r|cff00ffff%f|r|cff00ff00, posz: |r|cff00ffff%f|r|cff00ff00, orientation: |r|cff00ffff%f|r", id, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); - } - while (result->NextRow()); - } - - if (show == "del") - { - id = atoi(arg_id); - - QueryResult result = WorldDatabase.PQuery("SELECT guid FROM waypoint_scripts WHERE guid = %u", id); - - if (result) - { - WorldDatabase.PExecute("DELETE FROM waypoint_scripts WHERE guid = %u", id); - PSendSysMessage("%s%s%u|r","|cff00ff00","Wp Event: Waypoint script removed: ", id); - } - else - PSendSysMessage("|cffff33ffWp Event: ERROR: you have selected a non existing script: %u|r", id); - - return true; - } - - if (show == "mod") - { - if (!arg_id) - { - SendSysMessage("|cffff33ffERROR: Waypoint script guid not present.|r"); - return true; - } - - id = atoi(arg_id); - - if (!id) - { - SendSysMessage("|cffff33ffERROR: No vallid waypoint script id not present.|r"); - return true; - } - - char* arg_2 = strtok(NULL," "); - - if (!arg_2) - { - SendSysMessage("|cffff33ffERROR: No argument present.|r"); - return true; - } - - std::string arg_string = arg_2; - - if ((arg_string != "setid") && (arg_string != "delay") && (arg_string != "command") - && (arg_string != "datalong") && (arg_string != "datalong2") && (arg_string != "dataint") && (arg_string != "posx") - && (arg_string != "posy") && (arg_string != "posz") && (arg_string != "orientation")) - { - SendSysMessage("|cffff33ffERROR: No valid argument present.|r"); - return true; - } - - char* arg_3; - std::string arg_str_2 = arg_2; - arg_3 = strtok(NULL," "); - - if (!arg_3) - { - SendSysMessage("|cffff33ffERROR: No additional argument present.|r"); - return true; - } - - float coord; - - if (arg_str_2 == "setid") - { - uint32 newid = atoi(arg_3); - PSendSysMessage("%s%s|r|cff00ffff%u|r|cff00ff00%s|r|cff00ffff%u|r","|cff00ff00","Wp Event: Wypoint scipt guid: ", newid," id changed: ", id); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET id='%u' WHERE guid='%u'", - newid, id); return true; - } - else - { - QueryResult result = WorldDatabase.PQuery("SELECT id FROM waypoint_scripts WHERE guid='%u'",id); - - if (!result) - { - SendSysMessage("|cffff33ffERROR: You have selected an non existing waypoint script guid.|r"); - return true; - } - - if (arg_str_2 == "posx") - { - coord = (float)(atof(arg_3)); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET x='%f' WHERE guid='%u'", - coord, id); - PSendSysMessage("|cff00ff00Waypoint script:|r|cff00ffff %u|r|cff00ff00 position_x updated.|r", id); - return true; - } - else if (arg_str_2 == "posy") - { - coord = (float)(atof(arg_3)); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET y='%f' WHERE guid='%u'", - coord, id); - PSendSysMessage("|cff00ff00Waypoint script: %u position_y updated.|r", id); - return true; - } - else if (arg_str_2 == "posz") - { - coord = (float)(atof(arg_3)); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET z='%f' WHERE guid='%u'", - coord, id); - PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 position_z updated.|r", id); - return true; - } - else if (arg_str_2 == "orientation") - { - coord = (float)(atof(arg_3)); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET o='%f' WHERE guid='%u'", - coord, id); - PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 orientation updated.|r", id); - return true; - } - else if (arg_str_2 == "dataint") - { - WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%u' WHERE guid='%u'", - arg_2, atoi(arg_3), id); - PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 dataint updated.|r", id); - return true; - } - else - { - std::string arg_str_3 = arg_3; - WorldDatabase.escape_string(arg_str_3); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%s' WHERE guid='%u'", - arg_2, arg_str_3.c_str(), id); - } - } - PSendSysMessage("%s%s|r|cff00ffff%u:|r|cff00ff00 %s %s|r","|cff00ff00","Waypoint script:", id, arg_2,"updated."); - } - return true; -} - -bool ChatHandler::HandleWpModifyCommand(const char* args) -{ - sLog.outDebug("DEBUG: HandleWpModifyCommand"); - - if (!*args) - return false; - - // first arg: add del text emote spell waittime move - char* show_str = strtok((char*)args, " "); - if (!show_str) - { - return false; - } - - std::string show = show_str; - // Check - // Remember: "show" must also be the name of a column! - if ((show != "delay") && (show != "action") && (show != "action_chance") - && (show != "move_flag") && (show != "del") && (show != "move") && (show != "wpadd") -) - { - return false; - } - - // Next arg is: <PATHID> <WPNUM> <ARGUMENT> - char* arg_str = NULL; - - // Did user provide a GUID - // or did the user select a creature? - // -> variable lowguid is filled with the GUID of the NPC - uint32 pathid = 0; - uint32 point = 0; - uint32 wpGuid = 0; - Creature* target = getSelectedCreature(); - - if (!target || target->GetEntry() != VISUAL_WAYPOINT) - { - SendSysMessage("|cffff33ffERROR: You must select a waypoint.|r"); - return false; - } - - sLog.outDebug("DEBUG: HandleWpModifyCommand - User did select an NPC"); - // The visual waypoint - Creature* wpCreature = NULL; - wpGuid = target->GetGUIDLow(); - - // Did the user select a visual spawnpoint? - if (wpGuid) - wpCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - // attempt check creature existence by DB data - else - { - PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, wpGuid); - return false; - } - // User did select a visual waypoint? - // Check the creature - if (wpCreature->GetEntry() == VISUAL_WAYPOINT) - { - QueryResult result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE wpguid = %u", wpGuid); - - if (!result) - { - sLog.outDebug("DEBUG: HandleWpModifyCommand - No waypoint found - used 'wpguid'"); - - PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow()); - // Select waypoint number from database - // Since we compare float values, we have to deal with - // some difficulties. - // Here we search for all waypoints that only differ in one from 1 thousand - // (0.001) - There is no other way to compare C++ floats with mySQL floats - // See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html - const char* maxDIFF = "0.01"; - result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE (abs(position_x - %f) <= %s) and (abs(position_y - %f) <= %s) and (abs(position_z - %f) <= %s)", - wpCreature->GetPositionX(), maxDIFF, wpCreature->GetPositionY(), maxDIFF, wpCreature->GetPositionZ(), maxDIFF); - if (!result) - { - PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid); - return true; - } - } - sLog.outDebug("DEBUG: HandleWpModifyCommand - After getting wpGuid"); - - do - { - Field *fields = result->Fetch(); - pathid = fields[0].GetUInt32(); - point = fields[1].GetUInt32(); - } - while (result->NextRow()); - - // We have the waypoint number and the GUID of the "master npc" - // Text is enclosed in "<>", all other arguments not - arg_str = strtok((char*)NULL, " "); - } - - sLog.outDebug("DEBUG: HandleWpModifyCommand - Parameters parsed - now execute the command"); - - // Check for argument - if (show != "del" && show != "move" && arg_str == NULL) - { - PSendSysMessage(LANG_WAYPOINT_ARGUMENTREQ, show_str); - return false; - } - - if (show == "del" && target) - { - PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid); - - // wpCreature - Creature* wpCreature = NULL; - - if (wpGuid != 0) - { - wpCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - wpCreature->CombatStop(); - wpCreature->DeleteFromDB(); - wpCreature->AddObjectToRemoveList(); - } - - WorldDatabase.PExecute("DELETE FROM waypoint_data WHERE id='%u' AND point='%u'", - pathid, point); - WorldDatabase.PExecute("UPDATE waypoint_data SET point=point-1 WHERE id='%u' AND point>'%u'", - pathid, point); - - PSendSysMessage(LANG_WAYPOINT_REMOVED); - return true; - } // del - - if (show == "move" && target) - { - PSendSysMessage("|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff%u|r", pathid); - - Player *chr = m_session->GetPlayer(); - Map *map = chr->GetMap(); - { - // wpCreature - Creature* wpCreature = NULL; - // What to do: - // Move the visual spawnpoint - // Respawn the owner of the waypoints - if (wpGuid != 0) - { - wpCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - wpCreature->CombatStop(); - wpCreature->DeleteFromDB(); - wpCreature->AddObjectToRemoveList(); - // re-create - Creature* wpCreature2 = new Creature; - if (!wpCreature2->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation())) - { - PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); - delete wpCreature2; - return false; - } - - wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); - wpCreature2->LoadFromDB(wpCreature2->GetDBTableGUIDLow(), map); - map->Add(wpCreature2); - //sMapMgr.GetMap(npcCreature->GetMapId())->Add(wpCreature2); - } - - WorldDatabase.PExecute("UPDATE waypoint_data SET position_x = '%f',position_y = '%f',position_z = '%f' where id = '%u' AND point='%u'", - chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), pathid, point); - - PSendSysMessage(LANG_WAYPOINT_CHANGED); - } - return true; - } // move - - const char *text = arg_str; - - if (text == 0) - { - // show_str check for present in list of correct values, no sql injection possible - WorldDatabase.PExecute("UPDATE waypoint_data SET %s=NULL WHERE id='%u' AND point='%u'", - show_str, pathid, point); - } - else - { - // show_str check for present in list of correct values, no sql injection possible - std::string text2 = text; - WorldDatabase.escape_string(text2); - WorldDatabase.PExecute("UPDATE waypoint_data SET %s='%s' WHERE id='%u' AND point='%u'", - show_str, text2.c_str(), pathid, point); - } - - PSendSysMessage(LANG_WAYPOINT_CHANGED_NO, show_str); - return true; -} - -bool ChatHandler::HandleWpShowCommand(const char* args) -{ - sLog.outDebug("DEBUG: HandleWpShowCommand"); - - if (!*args) - return false; - - // first arg: on, off, first, last - char* show_str = strtok((char*)args, " "); - if (!show_str) - return false; - - // second arg: GUID (optional, if a creature is selected) - char* guid_str = strtok((char*)NULL, " "); - sLog.outDebug("DEBUG: HandleWpShowCommand: show_str: %s guid_str: %s", show_str, guid_str); - - uint32 pathid = 0; - Creature* target = getSelectedCreature(); - - // Did player provide a PathID? - - if (!guid_str) - { - sLog.outDebug("DEBUG: HandleWpShowCommand: !guid_str"); - // No PathID provided - // -> Player must have selected a creature - - if (!target) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - pathid = target->GetWaypointPath(); - } - else - { - sLog.outDebug("|cff00ff00DEBUG: HandleWpShowCommand: PathID provided|r"); - // PathID provided - // Warn if player also selected a creature - // -> Creature selection is ignored <- - if (target) - SendSysMessage(LANG_WAYPOINT_CREATSELECTED); - - pathid = atoi((char*)guid_str); - } - - sLog.outDebug("DEBUG: HandleWpShowCommand: danach"); - - std::string show = show_str; - uint32 Maxpoint; - - sLog.outDebug("DEBUG: HandleWpShowCommand: PathID: %u", pathid); - - //PSendSysMessage("wpshow - show: %s", show); - - // Show info for the selected waypoint - if (show == "info") - { - // Check if the user did specify a visual waypoint - if (target->GetEntry() != VISUAL_WAYPOINT) - { - PSendSysMessage(LANG_WAYPOINT_VP_SELECT); - SetSentErrorMessage(true); - return false; - } - - QueryResult result = WorldDatabase.PQuery("SELECT id, point, delay, move_flag, action, action_chance FROM waypoint_data WHERE wpguid = %u", target->GetGUIDLow()); - - if (!result) - { - SendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM); - return true; - } - - SendSysMessage("|cff00ffffDEBUG: wp show info:|r"); - do - { - Field *fields = result->Fetch(); - pathid = fields[0].GetUInt32(); - uint32 point = fields[1].GetUInt32(); - uint32 delay = fields[2].GetUInt32(); - uint32 flag = fields[3].GetUInt32(); - uint32 ev_id = fields[4].GetUInt32(); - uint32 ev_chance = fields[5].GetUInt32(); - - PSendSysMessage("|cff00ff00Show info: for current point: |r|cff00ffff%u|r|cff00ff00, Path ID: |r|cff00ffff%u|r", point, pathid); - PSendSysMessage("|cff00ff00Show info: delay: |r|cff00ffff%u|r", delay); - PSendSysMessage("|cff00ff00Show info: Move flag: |r|cff00ffff%u|r", flag); - PSendSysMessage("|cff00ff00Show info: Waypoint event: |r|cff00ffff%u|r", ev_id); - PSendSysMessage("|cff00ff00Show info: Event chance: |r|cff00ffff%u|r", ev_chance); - } - while (result->NextRow()); - - return true; - } - - if (show == "on") - { - QueryResult result = WorldDatabase.PQuery("SELECT point, position_x,position_y,position_z FROM waypoint_data WHERE id = '%u'", pathid); - - if (!result) - { - SendSysMessage("|cffff33ffPath no found.|r"); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage("|cff00ff00DEBUG: wp on, PathID: |cff00ffff%u|r", pathid); - - // Delete all visuals for this NPC - QueryResult result2 = WorldDatabase.PQuery("SELECT wpguid FROM waypoint_data WHERE id = '%u' and wpguid <> 0", pathid); - - if (result2) - { - bool hasError = false; - do - { - Field *fields = result2->Fetch(); - uint32 wpguid = fields[0].GetUInt32(); - Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpguid,VISUAL_WAYPOINT,HIGHGUID_UNIT)); - - if (!pCreature) - { - PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpguid); - hasError = true; - WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", wpguid); - } - else - { - pCreature->CombatStop(); - pCreature->DeleteFromDB(); - pCreature->AddObjectToRemoveList(); - } - - } - while (result2->NextRow()); - - if (hasError) - { - PSendSysMessage(LANG_WAYPOINT_TOOFAR1); - PSendSysMessage(LANG_WAYPOINT_TOOFAR2); - PSendSysMessage(LANG_WAYPOINT_TOOFAR3); - } - } - - do - { - Field *fields = result->Fetch(); - uint32 point = fields[0].GetUInt32(); - float x = fields[1].GetFloat(); - float y = fields[2].GetFloat(); - float z = fields[3].GetFloat(); - - uint32 id = VISUAL_WAYPOINT; - - Player *chr = m_session->GetPlayer(); - Map *map = chr->GetMap(); - float o = chr->GetOrientation(); - - Creature* wpCreature = new Creature; - if (!wpCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o)) - { - PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); - delete wpCreature; - return false; - } - - sLog.outDebug("DEBUG: UPDATE waypoint_data SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), pathid, point); - // set "wpguid" column to the visual waypoint - WorldDatabase.PExecute("UPDATE waypoint_data SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), pathid, point); - - wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); - wpCreature->LoadFromDB(wpCreature->GetDBTableGUIDLow(),map); - map->Add(wpCreature); - - if (target) - { - wpCreature->SetDisplayId(target->GetDisplayId()); - wpCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); - wpCreature->SetLevel(point > STRONG_MAX_LEVEL ? STRONG_MAX_LEVEL : point); - } - } - while (result->NextRow()); - - SendSysMessage("|cff00ff00Showing the current creature's path.|r"); - return true; - } - - if (show == "first") - { - PSendSysMessage("|cff00ff00DEBUG: wp first, GUID: %u|r", pathid); - - QueryResult result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z FROM waypoint_data WHERE point='1' AND id = '%u'",pathid); - if (!result) - { - PSendSysMessage(LANG_WAYPOINT_NOTFOUND, pathid); - SetSentErrorMessage(true); - return false; - } - - Field *fields = result->Fetch(); - float x = fields[0].GetFloat(); - float y = fields[1].GetFloat(); - float z = fields[2].GetFloat(); - uint32 id = VISUAL_WAYPOINT; - - Player *chr = m_session->GetPlayer(); - float o = chr->GetOrientation(); - Map *map = chr->GetMap(); - - Creature* pCreature = new Creature; - if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT),map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o)) - { - PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); - delete pCreature; - return false; - } - - pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map); - map->Add(pCreature); - - if (target) - { - pCreature->SetDisplayId(target->GetDisplayId()); - pCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); - } - - return true; - } - - if (show == "last") - { - PSendSysMessage("|cff00ff00DEBUG: wp last, PathID: |r|cff00ffff%u|r", pathid); - - QueryResult result = WorldDatabase.PQuery("SELECT MAX(point) FROM waypoint_data WHERE id = '%u'",pathid); - if (result) - Maxpoint = (*result)[0].GetUInt32(); - else - Maxpoint = 0; - - result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z FROM waypoint_data WHERE point ='%u' AND id = '%u'",Maxpoint, pathid); - if (!result) - { - PSendSysMessage(LANG_WAYPOINT_NOTFOUNDLAST, pathid); - SetSentErrorMessage(true); - return false; - } - Field *fields = result->Fetch(); - float x = fields[0].GetFloat(); - float y = fields[1].GetFloat(); - float z = fields[2].GetFloat(); - uint32 id = VISUAL_WAYPOINT; - - Player *chr = m_session->GetPlayer(); - float o = chr->GetOrientation(); - Map *map = chr->GetMap(); - - Creature* pCreature = new Creature; - if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o)) - { - PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id); - delete pCreature; - return false; - } - - pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map); - map->Add(pCreature); - - if (target) - { - pCreature->SetDisplayId(target->GetDisplayId()); - pCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); - } - - return true; - } - - if (show == "off") - { - QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE id = '%u'", 1); - if (!result) - { - SendSysMessage(LANG_WAYPOINT_VP_NOTFOUND); - SetSentErrorMessage(true); - return false; - } - bool hasError = false; - do - { - Field *fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); - Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(guid,VISUAL_WAYPOINT,HIGHGUID_UNIT)); - if (!pCreature) - { - PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid); - hasError = true; - WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", guid); - } - else - { - pCreature->CombatStop(); - pCreature->DeleteFromDB(); - pCreature->AddObjectToRemoveList(); - } - } - while (result->NextRow()); - // set "wpguid" column to "empty" - no visual waypoint spawned - WorldDatabase.PExecute("UPDATE waypoint_data SET wpguid = '0'"); - //WorldDatabase.PExecute("UPDATE creature_movement SET wpguid = '0' WHERE wpguid <> '0'"); - - if (hasError) - { - PSendSysMessage(LANG_WAYPOINT_TOOFAR1); - PSendSysMessage(LANG_WAYPOINT_TOOFAR2); - PSendSysMessage(LANG_WAYPOINT_TOOFAR3); - } - - SendSysMessage(LANG_WAYPOINT_VP_ALLREMOVED); - return true; - } - - PSendSysMessage("|cffff33ffDEBUG: wpshow - no valid command found|r"); - return true; -} - -//////////// WAYPOINT COMMANDS // - //rename characters bool ChatHandler::HandleCharacterRenameCommand(const char* args) { @@ -2000,64 +600,6 @@ bool ChatHandler::HandleCharacterReputationCommand(const char* args) return true; } -bool ChatHandler::HandleHonorAddCommand(const char* args) -{ - if (!*args) - return false; - - Player *target = getSelectedPlayer(); - if (!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(target, 0)) - return false; - - uint32 amount = (uint32)atoi(args); - target->RewardHonor(NULL, 1, amount); - return true; -} - -bool ChatHandler::HandleHonorAddKillCommand(const char* /*args*/) -{ - Unit *target = getSelectedUnit(); - if (!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target, 0)) - return false; - - m_session->GetPlayer()->RewardHonor(target, 1); - return true; -} - -bool ChatHandler::HandleHonorUpdateCommand(const char* /*args*/) -{ - Player *target = getSelectedPlayer(); - if (!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(target, 0)) - return false; - - target->UpdateHonorFields(); - return true; -} - bool ChatHandler::HandleLookupEventCommand(const char* args) { if (!*args) @@ -2463,73 +1005,6 @@ bool ChatHandler::HandlePetTpCommand(const char *args) return true; } -bool ChatHandler::HandleActivateObjectCommand(const char *args) -{ - if (!*args) - return false; - - 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 = sObjectMgr.GetGOData(lowguid)) - obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); - - if (!obj) - { - PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - // Activate - obj->SetLootState(GO_READY); - obj->UseDoorOrButton(10000); - - PSendSysMessage("Object activated!"); - - return true; -} - -// add go, temp only -bool ChatHandler::HandleTempGameObjectCommand(const char* args) -{ - if (!*args) - return false; - char* charID = strtok((char*)args, " "); - if (!charID) - return false; - - Player *chr = m_session->GetPlayer(); - - char* spawntime = strtok(NULL, " "); - uint32 spawntm = 300; - - if (spawntime) - spawntm = atoi((char*)spawntime); - - float x = chr->GetPositionX(); - float y = chr->GetPositionY(); - float z = chr->GetPositionZ(); - float ang = chr->GetOrientation(); - - float rot2 = sin(ang/2); - float rot3 = cos(ang/2); - - uint32 id = atoi(charID); - - chr->SummonGameObject(id,x,y,z,ang,0,0,rot2,rot3,spawntm); - - return true; -} - bool ChatHandler::HandleLookupTitleCommand(const char* args) { if (!*args) @@ -2613,149 +1088,6 @@ bool ChatHandler::HandleLookupTitleCommand(const char* args) return true; } -bool ChatHandler::HandleTitlesAddCommand(const char* args) -{ - // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r - char* id_p = extractKeyFromLink((char*)args,"Htitle"); - if (!id_p) - return false; - - int32 id = atoi(id_p); - if (id <= 0) - { - PSendSysMessage(LANG_INVALID_TITLE_ID, id); - SetSentErrorMessage(true); - return false; - } - - Player * target = getSelectedPlayer(); - if (!target) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(target, 0)) - return false; - - CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); - if (!titleInfo) - { - PSendSysMessage(LANG_INVALID_TITLE_ID, id); - SetSentErrorMessage(true); - return false; - } - - std::string tNameLink = GetNameLink(target); - - char const* targetName = target->GetName(); - char titleNameStr[80]; - snprintf(titleNameStr,80,titleInfo->name[GetSessionDbcLocale()],targetName); - - target->SetTitle(titleInfo); - PSendSysMessage(LANG_TITLE_ADD_RES, id, titleNameStr, tNameLink.c_str()); - - return true; -} - -bool ChatHandler::HandleTitlesRemoveCommand(const char* args) -{ - // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r - char* id_p = extractKeyFromLink((char*)args,"Htitle"); - if (!id_p) - return false; - - int32 id = atoi(id_p); - if (id <= 0) - { - PSendSysMessage(LANG_INVALID_TITLE_ID, id); - SetSentErrorMessage(true); - return false; - } - - Player * target = getSelectedPlayer(); - if (!target) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(target, 0)) - return false; - - CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); - if (!titleInfo) - { - PSendSysMessage(LANG_INVALID_TITLE_ID, id); - SetSentErrorMessage(true); - return false; - } - - target->SetTitle(titleInfo,true); - - std::string tNameLink = GetNameLink(target); - - char const* targetName = target->GetName(); - char titleNameStr[80]; - snprintf(titleNameStr,80,titleInfo->name[GetSessionDbcLocale()],targetName); - - PSendSysMessage(LANG_TITLE_REMOVE_RES, id, titleNameStr, tNameLink.c_str()); - - if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE))) - { - target->SetUInt32Value(PLAYER_CHOSEN_TITLE,0); - PSendSysMessage(LANG_CURRENT_TITLE_RESET, tNameLink.c_str()); - } - - return true; -} - -//Edit Player KnownTitles -bool ChatHandler::HandleTitlesSetMaskCommand(const char* args) -{ - if (!*args) - return false; - - uint64 titles = 0; - - sscanf((char*)args, UI64FMTD, &titles); - - Player *target = getSelectedPlayer(); - if (!target) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(target, 0)) - return false; - - uint64 titles2 = titles; - - for (uint32 i = 1; i < sCharTitlesStore.GetNumRows(); ++i) - if (CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i)) - titles2 &= ~(uint64(1) << tEntry->bit_index); - - titles &= ~titles2; // remove not existed titles - - target->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles); - SendSysMessage(LANG_DONE); - - if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE))) - { - target->SetUInt32Value(PLAYER_CHOSEN_TITLE,0); - PSendSysMessage(LANG_CURRENT_TITLE_RESET,GetNameLink(target).c_str()); - } - - return true; -} - bool ChatHandler::HandleCharacterTitlesCommand(const char* args) { if (!*args) @@ -2795,48 +1127,3 @@ bool ChatHandler::HandleCharacterTitlesCommand(const char* args) } return true; } - -bool ChatHandler::HandleTitlesCurrentCommand(const char* args) -{ - // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r - char* id_p = extractKeyFromLink((char*)args,"Htitle"); - if (!id_p) - return false; - - int32 id = atoi(id_p); - if (id <= 0) - { - PSendSysMessage(LANG_INVALID_TITLE_ID, id); - SetSentErrorMessage(true); - return false; - } - - Player * target = getSelectedPlayer(); - if (!target) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(target, 0)) - return false; - - CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); - if (!titleInfo) - { - PSendSysMessage(LANG_INVALID_TITLE_ID, id); - SetSentErrorMessage(true); - return false; - } - - std::string tNameLink = GetNameLink(target); - - target->SetTitle(titleInfo); // to be sure that title now known - target->SetUInt32Value(PLAYER_CHOSEN_TITLE,titleInfo->bit_index); - - PSendSysMessage(LANG_TITLE_CURRENT_RES, id, titleInfo->name[GetSessionDbcLocale()], tNameLink.c_str()); - - return true; -} diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp index 521d8e287cd..bfb6c79768c 100755 --- a/src/server/game/Chat/Commands/Level3.cpp +++ b/src/server/game/Chat/Commands/Level3.cpp @@ -61,1131 +61,6 @@ #include "CreatureTextMgr.h" #include "SmartAI.h" -//reload commands -bool ChatHandler::HandleReloadAllCommand(const char*) -{ - HandleReloadSkillFishingBaseLevelCommand(""); - - HandleReloadAllAchievementCommand(""); - HandleReloadAllAreaCommand(""); - HandleReloadAllEventAICommand(""); - HandleReloadAllLootCommand(""); - HandleReloadAllNpcCommand(""); - HandleReloadAllQuestCommand(""); - HandleReloadAllSpellCommand(""); - HandleReloadAllItemCommand(""); - HandleReloadAllGossipsCommand(""); - HandleReloadAllLocalesCommand(""); - - HandleReloadAccessRequirementCommand(""); - HandleReloadMailLevelRewardCommand(""); - HandleReloadCommandCommand(""); - HandleReloadReservedNameCommand(""); - HandleReloadTrinityStringCommand(""); - HandleReloadGameTeleCommand(""); - - HandleReloadAutobroadcastCommand(""); - return true; -} - -bool ChatHandler::HandleReloadAllAchievementCommand(const char*) -{ - HandleReloadAchievementCriteriaDataCommand(""); - HandleReloadAchievementRewardCommand(""); - return true; -} - -bool ChatHandler::HandleReloadAllAreaCommand(const char*) -{ - //HandleReloadQuestAreaTriggersCommand(""); -- reloaded in HandleReloadAllQuestCommand - HandleReloadAreaTriggerTeleportCommand(""); - HandleReloadAreaTriggerTavernCommand(""); - HandleReloadGameGraveyardZoneCommand(""); - return true; -} - -bool ChatHandler::HandleReloadAllLootCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables..."); - LoadLootTables(); - SendGlobalGMSysMessage("DB tables `*_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadAllNpcCommand(const char* args) -{ - if(*args != 'a') // will be reloaded from all_gossips - HandleReloadNpcGossipCommand("a"); - HandleReloadNpcTrainerCommand("a"); - HandleReloadNpcVendorCommand("a"); - HandleReloadPointsOfInterestCommand("a"); - HandleReloadSpellClickSpellsCommand("a"); - return true; -} - -bool ChatHandler::HandleReloadAllQuestCommand(const char* /*args*/) -{ - HandleReloadQuestAreaTriggersCommand("a"); - HandleReloadQuestPOICommand("a"); - HandleReloadQuestTemplateCommand("a"); - - sLog.outString("Re-Loading Quests Relations..."); - sObjectMgr.LoadQuestRelations(); - SendGlobalGMSysMessage("DB tables `*_questrelation` and `*_involvedrelation` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAllScriptsCommand(const char*) -{ - if (sWorld.IsScriptScheduled()) - { - PSendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - sLog.outString("Re-Loading Scripts..."); - HandleReloadGameObjectScriptsCommand("a"); - HandleReloadGossipScriptsCommand("a"); - HandleReloadEventScriptsCommand("a"); - HandleReloadQuestEndScriptsCommand("a"); - HandleReloadQuestStartScriptsCommand("a"); - HandleReloadSpellScriptsCommand("a"); - SendGlobalGMSysMessage("DB tables `*_scripts` reloaded."); - HandleReloadDbScriptStringCommand("a"); - HandleReloadWpScriptsCommand("a"); - return true; -} - -bool ChatHandler::HandleReloadAllEventAICommand(const char*) -{ - HandleReloadEventAITextsCommand("a"); - HandleReloadEventAISummonsCommand("a"); - HandleReloadEventAIScriptsCommand("a"); - return true; -} - -bool ChatHandler::HandleReloadAllSpellCommand(const char*) -{ - HandleReloadSkillDiscoveryTemplateCommand("a"); - HandleReloadSkillExtraItemTemplateCommand("a"); - HandleReloadSpellRequiredCommand("a"); - HandleReloadSpellAreaCommand("a"); - HandleReloadSpellGroupsCommand("a"); - HandleReloadSpellLearnSpellCommand("a"); - HandleReloadSpellLinkedSpellCommand("a"); - HandleReloadSpellProcEventCommand("a"); - HandleReloadSpellBonusesCommand("a"); - HandleReloadSpellTargetPositionCommand("a"); - HandleReloadSpellThreatsCommand("a"); - HandleReloadSpellGroupStackRulesCommand("a"); - HandleReloadSpellPetAurasCommand("a"); - return true; -} - -bool ChatHandler::HandleReloadAllGossipsCommand(const char* args) -{ - HandleReloadGossipMenuCommand("a"); - HandleReloadGossipMenuOptionCommand("a"); - if(*args != 'a') // already reload from all_scripts - HandleReloadGossipScriptsCommand("a"); - HandleReloadNpcGossipCommand("a"); - HandleReloadPointsOfInterestCommand("a"); - return true; -} - -bool ChatHandler::HandleReloadAllItemCommand(const char*) -{ - HandleReloadPageTextsCommand("a"); - HandleReloadItemEnchantementsCommand("a"); - return true; -} - -bool ChatHandler::HandleReloadAllLocalesCommand(const char* /*args*/) -{ - HandleReloadLocalesAchievementRewardCommand("a"); - HandleReloadLocalesCreatureCommand("a"); - HandleReloadLocalesGameobjectCommand("a"); - HandleReloadLocalesGossipMenuOptionCommand("a"); - HandleReloadLocalesItemCommand("a"); - HandleReloadLocalesNpcTextCommand("a"); - HandleReloadLocalesPageTextCommand("a"); - HandleReloadLocalesPointsOfInterestCommand("a"); - HandleReloadLocalesQuestCommand("a"); - return true; -} - -bool ChatHandler::HandleReloadConfigCommand(const char* /*args*/) -{ - sLog.outString("Re-Loading config settings..."); - sWorld.LoadConfigSettings(true); - sMapMgr.InitializeVisibilityDistanceInfo(); - SendGlobalGMSysMessage("World config settings reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAccessRequirementCommand(const char*) -{ - sLog.outString("Re-Loading Access Requirement definitions..."); - sObjectMgr.LoadAccessRequirements(); - SendGlobalGMSysMessage("DB table `access_requirement` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAchievementCriteriaDataCommand(const char*) -{ - sLog.outString("Re-Loading Additional Achievement Criteria Data..."); - sAchievementMgr.LoadAchievementCriteriaData(); - SendGlobalGMSysMessage("DB table `achievement_criteria_data` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAchievementRewardCommand(const char*) -{ - sLog.outString("Re-Loading Achievement Reward Data..."); - sAchievementMgr.LoadRewards(); - SendGlobalGMSysMessage("DB table `achievement_reward` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAreaTriggerTavernCommand(const char*) -{ - sLog.outString("Re-Loading Tavern Area Triggers..."); - sObjectMgr.LoadTavernAreaTriggers(); - SendGlobalGMSysMessage("DB table `areatrigger_tavern` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAreaTriggerTeleportCommand(const char*) -{ - sLog.outString("Re-Loading AreaTrigger teleport definitions..."); - sObjectMgr.LoadAreaTriggerTeleports(); - SendGlobalGMSysMessage("DB table `areatrigger_teleport` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAutobroadcastCommand(const char*) -{ - sLog.outString("Re-Loading Autobroadcast..."); - sWorld.LoadAutobroadcasts(); - SendGlobalGMSysMessage("DB table `autobroadcast` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadCommandCommand(const char*) -{ - load_command_table = true; - SendGlobalGMSysMessage("DB table `command` will be reloaded at next chat command use."); - return true; -} - -bool ChatHandler::HandleReloadOnKillReputationCommand(const char*) -{ - sLog.outString("Re-Loading creature award reputation definitions..."); - sObjectMgr.LoadReputationOnKill(); - SendGlobalGMSysMessage("DB table `creature_onkill_reputation` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadCreatureTemplateCommand(const char* args) -{ - if (!*args) - return false; - - uint32 entry = (uint32) atoi((char*)args); - QueryResult result = WorldDatabase.PQuery("SELECT difficulty_entry_1,difficulty_entry_2,difficulty_entry_3,KillCredit1,KillCredit2,modelid1,modelid2,modelid3,modelid4,name,subname,IconName,gossip_menu_id,minlevel,maxlevel,exp,faction_A,faction_H,npcflag,speed_walk,speed_run,scale,rank,mindmg,maxdmg,dmgschool,attackpower,dmg_multiplier,baseattacktime,rangeattacktime,unit_class,unit_flags,dynamicflags,family,trainer_type,trainer_spell,trainer_class,trainer_race,minrangedmg,maxrangedmg,rangedattackpower,type,type_flags,lootid,pickpocketloot,skinloot,resistance1,resistance2,resistance3,resistance4,resistance5,resistance6,spell1,spell2,spell3,spell4,spell5,spell6,spell7,spell8,PetSpellDataId,VehicleId,mingold,maxgold,AIName,MovementType,InhabitType,Health_mod,Mana_mod,Armor_mod,RacialLeader,questItem1,questItem2,questItem3,questItem4,questItem5,questItem6,movementId,RegenHealth,equipment_id,mechanic_immune_mask,flags_extra,ScriptName FROM creature_template WHERE entry = %u", entry); - if (!result) - { - PSendSysMessage(LANG_COMMAND_CREATURETEMPLATE_NOTFOUND, entry); - SetSentErrorMessage(true); - return false; - } - - CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(entry); - if (!cInfo) - { - PSendSysMessage(LANG_COMMAND_CREATURESTORAGE_NOTFOUND, entry); - SetSentErrorMessage(true); - return false; - } - - sLog.outString("Reloading creature template entry %u", entry); - - Field *fields = result->Fetch(); - - const_cast<CreatureInfo*>(cInfo)->DifficultyEntry[0] = fields[0].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->DifficultyEntry[1] = fields[1].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->DifficultyEntry[2] = fields[2].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->KillCredit[0] = fields[3].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->KillCredit[1] = fields[4].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->Modelid1 = fields[5].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->Modelid2 = fields[6].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->Modelid3 = fields[7].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->Modelid4 = fields[8].GetUInt32(); - size_t len = 0; - if (const char* temp = fields[9].GetCString()) - { - delete[] cInfo->Name; - len = strlen(temp)+1; - const_cast<CreatureInfo*>(cInfo)->Name = new char[len]; - strncpy(cInfo->Name, temp, len); - } - if (const char* temp = fields[10].GetCString()) - { - delete[] cInfo->SubName; - len = strlen(temp)+1; - const_cast<CreatureInfo*>(cInfo)->SubName = new char[len]; - strncpy(cInfo->SubName, temp, len); - } - if (const char* temp = fields[11].GetCString()) - { - delete[] cInfo->IconName; - len = strlen(temp)+1; - const_cast<CreatureInfo*>(cInfo)->IconName = new char[len]; - strncpy(cInfo->IconName, temp, len); - } - const_cast<CreatureInfo*>(cInfo)->GossipMenuId = fields[12].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->minlevel = fields[13].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->maxlevel = fields[14].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->expansion = fields[15].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->faction_A = fields[16].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->faction_H = fields[17].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->npcflag = fields[18].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->speed_walk = fields[19].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->speed_run = fields[20].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->scale = fields[21].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->rank = fields[22].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->mindmg = fields[23].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->maxdmg = fields[24].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->dmgschool = fields[25].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->attackpower = fields[26].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->dmg_multiplier = fields[27].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->baseattacktime = fields[28].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->rangeattacktime = fields[29].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->unit_class = fields[30].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->unit_flags = fields[31].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->dynamicflags = fields[32].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->family = fields[33].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->trainer_type = fields[34].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->trainer_spell = fields[35].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->trainer_class = fields[36].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->trainer_race = fields[37].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->minrangedmg = fields[38].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->maxrangedmg = fields[39].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->rangedattackpower = fields[40].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->type = fields[41].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->type_flags = fields[42].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->lootid = fields[43].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->pickpocketLootId = fields[44].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->SkinLootId = fields[45].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->resistance1 = fields[46].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->resistance2 = fields[47].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->resistance3 = fields[48].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->resistance4 = fields[49].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->resistance5 = fields[50].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->resistance6 = fields[51].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->spells[0] = fields[52].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->spells[1] = fields[53].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->spells[2] = fields[54].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->spells[3] = fields[55].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->spells[4] = fields[56].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->spells[5] = fields[57].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->spells[6] = fields[58].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->spells[7] = fields[59].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->PetSpellDataId = fields[60].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->VehicleId = fields[61].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->mingold = fields[62].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->maxgold = fields[63].GetUInt32(); - if (const char* temp = fields[64].GetCString()) - { - delete[] cInfo->AIName; - len = strlen(temp)+1; - const_cast<CreatureInfo*>(cInfo)->AIName = new char[len]; - strncpy(const_cast<char*>(cInfo->AIName), temp, len); - } - const_cast<CreatureInfo*>(cInfo)->MovementType = fields[65].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->InhabitType = fields[66].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->ModHealth = fields[67].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->ModMana = fields[68].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->ModArmor = fields[69].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->RacialLeader = fields[70].GetBool(); - const_cast<CreatureInfo*>(cInfo)->questItems[0] = fields[71].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->questItems[1] = fields[72].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->questItems[2] = fields[73].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->questItems[3] = fields[74].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->questItems[4] = fields[75].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->questItems[5] = fields[76].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->movementId = fields[77].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->RegenHealth = fields[78].GetBool(); - const_cast<CreatureInfo*>(cInfo)->equipmentId = fields[79].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->MechanicImmuneMask = fields[80].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->flags_extra = fields[81].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->ScriptID = sObjectMgr.GetScriptId(fields[82].GetCString()); - - sObjectMgr.CheckCreatureTemplate(cInfo); - - SendGlobalGMSysMessage("Creature template reloaded."); - return true; -} - -bool ChatHandler::HandleReloadCreatureQuestRelationsCommand(const char*) -{ - sLog.outString("Loading Quests Relations... (`creature_questrelation`)"); - sObjectMgr.LoadCreatureQuestRelations(); - SendGlobalGMSysMessage("DB table `creature_questrelation` (creature quest givers) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadCreatureLinkedRespawnCommand(const char * /*args*/) -{ - sLog.outString("Loading Linked Respawns... (`creature_linked_respawn`)"); - sObjectMgr.LoadCreatureLinkedRespawn(); - SendGlobalGMSysMessage("DB table `creature_linked_respawn` (creature linked respawns) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadCreatureQuestInvRelationsCommand(const char*) -{ - sLog.outString("Loading Quests Relations... (`creature_involvedrelation`)"); - sObjectMgr.LoadCreatureInvolvedRelations(); - SendGlobalGMSysMessage("DB table `creature_involvedrelation` (creature quest takers) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadGossipMenuCommand(const char*) -{ - sLog.outString("Re-Loading `gossip_menu` Table!"); - sObjectMgr.LoadGossipMenu(); - SendGlobalGMSysMessage("DB table `gossip_menu` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadGossipMenuOptionCommand(const char*) -{ - sLog.outString("Re-Loading `gossip_menu_option` Table!"); - sObjectMgr.LoadGossipMenuItems(); - SendGlobalGMSysMessage("DB table `gossip_menu_option` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadGOQuestRelationsCommand(const char*) -{ - sLog.outString("Loading Quests Relations... (`gameobject_questrelation`)"); - sObjectMgr.LoadGameobjectQuestRelations(); - SendGlobalGMSysMessage("DB table `gameobject_questrelation` (gameobject quest givers) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadGOQuestInvRelationsCommand(const char*) -{ - sLog.outString("Loading Quests Relations... (`gameobject_involvedrelation`)"); - sObjectMgr.LoadGameobjectInvolvedRelations(); - SendGlobalGMSysMessage("DB table `gameobject_involvedrelation` (gameobject quest takers) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadQuestAreaTriggersCommand(const char*) -{ - sLog.outString("Re-Loading Quest Area Triggers..."); - sObjectMgr.LoadQuestAreaTriggers(); - SendGlobalGMSysMessage("DB table `areatrigger_involvedrelation` (quest area triggers) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadQuestTemplateCommand(const char*) -{ - sLog.outString("Re-Loading Quest Templates..."); - sObjectMgr.LoadQuests(); - SendGlobalGMSysMessage("DB table `quest_template` (quest definitions) reloaded."); - - /// dependent also from `gameobject` but this table not reloaded anyway - sLog.outString("Re-Loading GameObjects for quests..."); - sObjectMgr.LoadGameObjectForQuests(); - SendGlobalGMSysMessage("Data GameObjects for quests reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesCreatureCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`creature_loot_template`)"); - LoadLootTemplates_Creature(); - LootTemplates_Creature.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `creature_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesDisenchantCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`disenchant_loot_template`)"); - LoadLootTemplates_Disenchant(); - LootTemplates_Disenchant.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `disenchant_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesFishingCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`fishing_loot_template`)"); - LoadLootTemplates_Fishing(); - LootTemplates_Fishing.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `fishing_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesGameobjectCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`gameobject_loot_template`)"); - LoadLootTemplates_Gameobject(); - LootTemplates_Gameobject.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `gameobject_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesItemCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`item_loot_template`)"); - LoadLootTemplates_Item(); - LootTemplates_Item.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `item_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesMillingCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`milling_loot_template`)"); - LoadLootTemplates_Milling(); - LootTemplates_Milling.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `milling_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesPickpocketingCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`pickpocketing_loot_template`)"); - LoadLootTemplates_Pickpocketing(); - LootTemplates_Pickpocketing.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `pickpocketing_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesProspectingCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`prospecting_loot_template`)"); - LoadLootTemplates_Prospecting(); - LootTemplates_Prospecting.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `prospecting_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesMailCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`mail_loot_template`)"); - LoadLootTemplates_Mail(); - LootTemplates_Mail.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `mail_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesReferenceCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`reference_loot_template`)"); - LoadLootTemplates_Reference(); - SendGlobalGMSysMessage("DB table `reference_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesSkinningCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`skinning_loot_template`)"); - LoadLootTemplates_Skinning(); - LootTemplates_Skinning.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `skinning_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesSpellCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`spell_loot_template`)"); - LoadLootTemplates_Spell(); - LootTemplates_Spell.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `spell_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadTrinityStringCommand(const char*) -{ - sLog.outString("Re-Loading trinity_string Table!"); - sObjectMgr.LoadTrinityStrings(); - SendGlobalGMSysMessage("DB table `trinity_string` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadNpcGossipCommand(const char*) -{ - sLog.outString("Re-Loading `npc_gossip` Table!"); - sObjectMgr.LoadNpcTextId(); - SendGlobalGMSysMessage("DB table `npc_gossip` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadNpcTrainerCommand(const char*) -{ - sLog.outString("Re-Loading `npc_trainer` Table!"); - sObjectMgr.LoadTrainerSpell(); - SendGlobalGMSysMessage("DB table `npc_trainer` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadNpcVendorCommand(const char*) -{ - sLog.outString("Re-Loading `npc_vendor` Table!"); - sObjectMgr.LoadVendors(); - SendGlobalGMSysMessage("DB table `npc_vendor` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadPointsOfInterestCommand(const char*) -{ - sLog.outString("Re-Loading `points_of_interest` Table!"); - sObjectMgr.LoadPointsOfInterest(); - SendGlobalGMSysMessage("DB table `points_of_interest` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadQuestPOICommand(const char*) -{ - sLog.outString( "Re-Loading Quest POI ..." ); - sObjectMgr.LoadQuestPOI(); - SendGlobalGMSysMessage("DB Table `quest_poi` and `quest_poi_points` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellClickSpellsCommand(const char*) -{ - sLog.outString("Re-Loading `npc_spellclick_spells` Table!"); - sObjectMgr.LoadNPCSpellClickSpells(); - SendGlobalGMSysMessage("DB table `npc_spellclick_spells` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadReservedNameCommand(const char*) -{ - sLog.outString("Loading ReservedNames... (`reserved_name`)"); - sObjectMgr.LoadReservedPlayersNames(); - SendGlobalGMSysMessage("DB table `reserved_name` (player reserved names) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadReputationRewardRateCommand(const char*) -{ - sLog.outString( "Re-Loading `reputation_reward_rate` Table!" ); - sObjectMgr.LoadReputationRewardRate(); - SendGlobalSysMessage("DB table `reputation_reward_rate` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadReputationSpilloverTemplateCommand(const char*) -{ - sLog.outString( "Re-Loading `reputation_spillover_template` Table!" ); - sObjectMgr.LoadReputationSpilloverTemplate(); - SendGlobalSysMessage("DB table `reputation_spillover_template` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSkillDiscoveryTemplateCommand(const char* /*args*/) -{ - sLog.outString("Re-Loading Skill Discovery Table..."); - LoadSkillDiscoveryTable(); - SendGlobalGMSysMessage("DB table `skill_discovery_template` (recipes discovered at crafting) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSkillExtraItemTemplateCommand(const char* /*args*/) -{ - sLog.outString("Re-Loading Skill Extra Item Table..."); - LoadSkillExtraItemTable(); - SendGlobalGMSysMessage("DB table `skill_extra_item_template` (extra item creation when crafting) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSkillFishingBaseLevelCommand(const char* /*args*/) -{ - sLog.outString("Re-Loading Skill Fishing base level requirements..."); - sObjectMgr.LoadFishingBaseSkillLevel(); - SendGlobalGMSysMessage("DB table `skill_fishing_base_level` (fishing base level for zone/subzone) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellAreaCommand(const char*) -{ - sLog.outString("Re-Loading SpellArea Data..."); - sSpellMgr.LoadSpellAreas(); - SendGlobalGMSysMessage("DB table `spell_area` (spell dependences from area/quest/auras state) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellRequiredCommand(const char*) -{ - sLog.outString("Re-Loading Spell Required Data... "); - sSpellMgr.LoadSpellRequired(); - SendGlobalGMSysMessage("DB table `spell_required` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellGroupsCommand(const char*) -{ - sLog.outString("Re-Loading Spell Groups..."); - sSpellMgr.LoadSpellGroups(); - SendGlobalGMSysMessage("DB table `spell_group` (spell groups) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellLearnSpellCommand(const char*) -{ - sLog.outString("Re-Loading Spell Learn Spells..."); - sSpellMgr.LoadSpellLearnSpells(); - SendGlobalGMSysMessage("DB table `spell_learn_spell` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellLinkedSpellCommand(const char*) -{ - sLog.outString("Re-Loading Spell Linked Spells..."); - sSpellMgr.LoadSpellLinked(); - SendGlobalGMSysMessage("DB table `spell_linked_spell` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellProcEventCommand(const char*) -{ - sLog.outString("Re-Loading Spell Proc Event conditions..."); - sSpellMgr.LoadSpellProcEvents(); - SendGlobalGMSysMessage("DB table `spell_proc_event` (spell proc trigger requirements) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellBonusesCommand(const char*) -{ - sLog.outString("Re-Loading Spell Bonus Data..."); - sSpellMgr.LoadSpellBonusess(); - SendGlobalGMSysMessage("DB table `spell_bonus_data` (spell damage/healing coefficients) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellTargetPositionCommand(const char*) -{ - sLog.outString("Re-Loading Spell target coordinates..."); - sSpellMgr.LoadSpellTargetPositions(); - SendGlobalGMSysMessage("DB table `spell_target_position` (destination coordinates for spell targets) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellThreatsCommand(const char*) -{ - sLog.outString("Re-Loading Aggro Spells Definitions..."); - sSpellMgr.LoadSpellThreats(); - SendGlobalGMSysMessage("DB table `spell_threat` (spell aggro definitions) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellGroupStackRulesCommand(const char*) -{ - sLog.outString("Re-Loading Spell Group Stack Rules..."); - sSpellMgr.LoadSpellGroupStackRules(); - SendGlobalGMSysMessage("DB table `spell_group_stack_rules` (spell stacking definitions) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellPetAurasCommand(const char*) -{ - sLog.outString("Re-Loading Spell pet auras..."); - sSpellMgr.LoadSpellPetAuras(); - SendGlobalGMSysMessage("DB table `spell_pet_auras` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadPageTextsCommand(const char*) -{ - sLog.outString("Re-Loading Page Texts..."); - sObjectMgr.LoadPageTexts(); - SendGlobalGMSysMessage("DB table `page_texts` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadItemEnchantementsCommand(const char*) -{ - sLog.outString("Re-Loading Item Random Enchantments Table..."); - LoadRandomEnchantmentsTable(); - SendGlobalGMSysMessage("DB table `item_enchantment_template` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadItemSetNamesCommand(const char*) -{ - sLog.outString("Re-Loading Item set names..."); - LoadRandomEnchantmentsTable(); - SendGlobalGMSysMessage("DB table `item_set_names` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadGossipScriptsCommand(const char* arg) -{ - if (sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if (*arg != 'a') - sLog.outString("Re-Loading Scripts from `gossip_scripts`..."); - - sObjectMgr.LoadGossipScripts(); - - if (*arg != 'a') - SendGlobalGMSysMessage("DB table `gossip_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadGameObjectScriptsCommand(const char* arg) -{ - if (sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if (*arg != 'a') - sLog.outString("Re-Loading Scripts from `gameobject_scripts`..."); - - sObjectMgr.LoadGameObjectScripts(); - - if (*arg != 'a') - SendGlobalGMSysMessage("DB table `gameobject_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadEventScriptsCommand(const char* arg) -{ - if (sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if (*arg != 'a') - sLog.outString("Re-Loading Scripts from `event_scripts`..."); - - sObjectMgr.LoadEventScripts(); - - if (*arg != 'a') - SendGlobalGMSysMessage("DB table `event_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadWpScriptsCommand(const char* arg) -{ - if (sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if (*arg != 'a') - sLog.outString("Re-Loading Scripts from `waypoint_scripts`..."); - - sObjectMgr.LoadWaypointScripts(); - - if (*arg != 'a') - SendGlobalGMSysMessage("DB table `waypoint_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadEventAITextsCommand(const char* /*args*/) -{ - - sLog.outString("Re-Loading Texts from `creature_ai_texts`..."); - sEventAIMgr.LoadCreatureEventAI_Texts(); - SendGlobalGMSysMessage("DB table `creature_ai_texts` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadEventAISummonsCommand(const char* /*args*/) -{ - sLog.outString("Re-Loading Summons from `creature_ai_summons`..."); - sEventAIMgr.LoadCreatureEventAI_Summons(); - SendGlobalGMSysMessage("DB table `creature_ai_summons` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadEventAIScriptsCommand(const char* /*args*/) -{ - sLog.outString("Re-Loading Scripts from `creature_ai_scripts`..."); - sEventAIMgr.LoadCreatureEventAI_Scripts(); - SendGlobalGMSysMessage("DB table `creature_ai_scripts` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadQuestEndScriptsCommand(const char* arg) -{ - if (sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if (*arg != 'a') - sLog.outString("Re-Loading Scripts from `quest_end_scripts`..."); - - sObjectMgr.LoadQuestEndScripts(); - - if (*arg != 'a') - SendGlobalGMSysMessage("DB table `quest_end_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadQuestStartScriptsCommand(const char* arg) -{ - if (sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if (*arg != 'a') - sLog.outString("Re-Loading Scripts from `quest_start_scripts`..."); - - sObjectMgr.LoadQuestStartScripts(); - - if (*arg != 'a') - SendGlobalGMSysMessage("DB table `quest_start_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadSpellScriptsCommand(const char* arg) -{ - if (sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if (*arg != 'a') - sLog.outString("Re-Loading Scripts from `spell_scripts`..."); - - sObjectMgr.LoadSpellScripts(); - - if (*arg != 'a') - SendGlobalGMSysMessage("DB table `spell_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadDbScriptStringCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Script strings from `db_script_string`..."); - sObjectMgr.LoadDbScriptStrings(); - SendGlobalGMSysMessage("DB table `db_script_string` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadGameGraveyardZoneCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Graveyard-zone links..."); - - sObjectMgr.LoadGraveyardZones(); - - SendGlobalGMSysMessage("DB table `game_graveyard_zone` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadGameTeleCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Game Tele coordinates..."); - - sObjectMgr.LoadGameTele(); - - SendGlobalGMSysMessage("DB table `game_tele` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadDisablesCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading disables table..."); - sDisableMgr.LoadDisables(); - sLog.outString("Checking quest disables..."); - sDisableMgr.CheckQuestDisables(); - SendGlobalGMSysMessage("DB table `disables` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesAchievementRewardCommand(const char*) -{ - sLog.outString("Re-Loading Locales Achievement Reward Data..."); - sAchievementMgr.LoadRewardLocales(); - SendGlobalGMSysMessage("DB table `locales_achievement_reward` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLfgEncountersCommand(const char*) -{ - sLog.outString("Re-Loading dungeon encounter lfg associations..."); - sLFGMgr.LoadDungeonEncounters(); - SendGlobalGMSysMessage("DB table `lfg_dungeon_encounters` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLfgRewardsCommand(const char*) -{ - sLog.outString("Re-Loading lfg dungeon rewards..."); - sLFGMgr.LoadRewards(); - SendGlobalGMSysMessage("DB table `lfg_dungeon_rewards` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesCreatureCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Locales Creature ..."); - sObjectMgr.LoadCreatureLocales(); - SendGlobalGMSysMessage("DB table `locales_creature` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesGameobjectCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Locales Gameobject ... "); - sObjectMgr.LoadGameObjectLocales(); - SendGlobalGMSysMessage("DB table `locales_gameobject` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesGossipMenuOptionCommand(const char* /*arg*/) -{ - sLog.outString( "Re-Loading Locales Gossip Menu Option ... "); - sObjectMgr.LoadGossipMenuItemsLocales(); - SendGlobalGMSysMessage("DB table `locales_gossip_menu_option` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesItemCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Locales Item ... "); - sObjectMgr.LoadItemLocales(); - SendGlobalGMSysMessage("DB table `locales_item` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesItemSetNameCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Locales Item set name... "); - sObjectMgr.LoadItemSetNameLocales(); - SendGlobalGMSysMessage("DB table `locales_item_set_name` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesNpcTextCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Locales NPC Text ... "); - sObjectMgr.LoadNpcTextLocales(); - SendGlobalGMSysMessage("DB table `locales_npc_text` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesPageTextCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Locales Page Text ... "); - sObjectMgr.LoadPageTextLocales(); - SendGlobalGMSysMessage("DB table `locales_page_text` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesPointsOfInterestCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Locales Points Of Interest ... "); - sObjectMgr.LoadPointOfInterestLocales(); - SendGlobalGMSysMessage("DB table `locales_points_of_interest` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesQuestCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Locales Quest ... "); - sObjectMgr.LoadQuestLocales(); - SendGlobalGMSysMessage("DB table `locales_quest` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadMailLevelRewardCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Player level dependent mail rewards..."); - sObjectMgr.LoadMailLevelRewards(); - SendGlobalGMSysMessage("DB table `mail_level_reward` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAuctionsCommand(const char * /*args*/) -{ - ///- Reload dynamic data tables from the database - sLog.outString("Re-Loading Auctions..."); - sAuctionMgr.LoadAuctionItems(); - sAuctionMgr.LoadAuctions(); - SendGlobalGMSysMessage("Auctions reloaded."); - return true; -} - -bool ChatHandler::HandleReloadConditions(const char* /*args*/) -{ - sLog.outString("Re-Loading Conditions..."); - sConditionMgr.LoadConditions(true); - SendGlobalGMSysMessage("Conditions reloaded."); - return true; -} - -bool ChatHandler::HandleReloadCreatureText(const char* /*args*/) -{ - sLog.outString("Re-Loading Creature Texts..."); - sCreatureTextMgr.LoadCreatureTexts(); - SendGlobalGMSysMessage("Creature Texts reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSmartScripts(const char* /*args*/) -{ - sLog.outString("Re-Loading Smart Scripts..."); - sSmartScriptMgr.LoadSmartAIFromDB(); - SendGlobalGMSysMessage("Smart Scripts reloaded."); - return true; -} - bool ChatHandler::HandleMaxSkillCommand(const char* /*args*/) { Player* SelectedPlayer = getSelectedPlayer(); @@ -1784,65 +659,6 @@ bool ChatHandler::HandleListObjectCommand(const char *args) return true; } -bool ChatHandler::HandleGameObjectStateCommand(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* gobj = NULL; - - if (GameObjectData const* goData = sObjectMgr.GetGOData(lowguid)) - gobj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, goData->id); - - if (!gobj) - { - PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - char* ctype = strtok(NULL, " "); - if (!ctype) - return false; - - int32 type = atoi(ctype); - if (type < 0) - { - if (type == -1) - gobj->SendObjectDeSpawnAnim(gobj->GetGUID()); - else if (type == -2) - { - return false; - } - return true; - } - - char* cstate = strtok(NULL, " "); - if (!cstate) - return false; - - int32 state = atoi(cstate); - - if (type < 4) - gobj->SetByteValue(GAMEOBJECT_BYTES_1, type, state); - else if (type == 4) - { - WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM,8+4); - data << gobj->GetGUID(); - data << (uint32)(state); - gobj->SendMessageToSet(&data, true); - } - PSendSysMessage("Set gobject type %d state %d", type, state); - - return true; -} - bool ChatHandler::HandleListCreatureCommand(const char *args) { if (!*args) @@ -4033,210 +2849,6 @@ bool ChatHandler::HandleServerIdleShutDownCommand(const char *args) return true; } -bool ChatHandler::HandleQuestAdd(const char *args) -{ - Player* player = getSelectedPlayer(); - if (!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // .addquest #entry' - // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hquest"); - if (!cId) - return false; - - uint32 entry = atol(cId); - - Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); - - if (!pQuest) - { - PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND,entry); - SetSentErrorMessage(true); - return false; - } - - // check item starting quest (it can work incorrectly if added without item in inventory) - for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) - { - ItemPrototype const *pProto = sItemStorage.LookupEntry<ItemPrototype>(id); - if (!pProto) - continue; - - if (pProto->StartQuest == entry) - { - PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, pProto->ItemId); - SetSentErrorMessage(true); - return false; - } - } - - // ok, normal (creature/GO starting) quest - if (player->CanAddQuest(pQuest, true)) - { - player->AddQuest(pQuest, NULL); - - if (player->CanCompleteQuest(entry)) - player->CompleteQuest(entry); - } - - return true; -} - -bool ChatHandler::HandleQuestRemove(const char *args) -{ - Player* player = getSelectedPlayer(); - if (!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // .removequest #entry' - // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hquest"); - if (!cId) - return false; - - uint32 entry = atol(cId); - - Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); - - if (!pQuest) - { - PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); - SetSentErrorMessage(true); - return false; - } - - // remove all quest entries for 'entry' from quest log - for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot) - { - uint32 quest = player->GetQuestSlotQuestId(slot); - if (quest == entry) - { - player->SetQuestSlot(slot,0); - - // we ignore unequippable quest items in this case, its' still be equipped - player->TakeQuestSourceItem(quest, false); - } - } - - // set quest status to not started (will updated in DB at next save) - player->SetQuestStatus(entry, QUEST_STATUS_NONE); - - // reset rewarded for restart repeatable quest - player->getQuestStatusMap()[entry].m_rewarded = false; - - SendSysMessage(LANG_COMMAND_QUEST_REMOVED); - return true; -} - -bool ChatHandler::HandleQuestComplete(const char *args) -{ - Player* player = getSelectedPlayer(); - if (!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // .quest complete #entry - // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hquest"); - if (!cId) - return false; - - uint32 entry = atol(cId); - - Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); - - // If player doesn't have the quest - if (!pQuest || player->GetQuestStatus(entry) == QUEST_STATUS_NONE) - { - PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); - SetSentErrorMessage(true); - return false; - } - - // Add quest items for quests that require items - for (uint8 x = 0; x < QUEST_ITEM_OBJECTIVES_COUNT; ++x) - { - uint32 id = pQuest->ReqItemId[x]; - uint32 count = pQuest->ReqItemCount[x]; - if (!id || !count) - continue; - - uint32 curItemCount = player->GetItemCount(id,true); - - ItemPosCountVec dest; - uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, id, count-curItemCount); - if (msg == EQUIP_ERR_OK) - { - Item* item = player->StoreNewItem(dest, id, true); - player->SendNewItem(item,count-curItemCount,true,false); - } - } - - // All creature/GO slain/casted (not required, but otherwise it will display "Creature slain 0/10") - for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) - { - int32 creature = pQuest->ReqCreatureOrGOId[i]; - uint32 creaturecount = pQuest->ReqCreatureOrGOCount[i]; - - if (uint32 spell_id = pQuest->ReqSpell[i]) - { - for (uint16 z = 0; z < creaturecount; ++z) - player->CastedCreatureOrGO(creature,0,spell_id); - } - else if (creature > 0) - { - if (CreatureInfo const* cInfo = sObjectMgr.GetCreatureTemplate(creature)) - for (uint16 z = 0; z < creaturecount; ++z) - player->KilledMonster(cInfo,0); - } - else if (creature < 0) - { - for (uint16 z = 0; z < creaturecount; ++z) - player->CastedCreatureOrGO(creature,0,0); - } - } - - // If the quest requires reputation to complete - if (uint32 repFaction = pQuest->GetRepObjectiveFaction()) - { - uint32 repValue = pQuest->GetRepObjectiveValue(); - uint32 curRep = player->GetReputationMgr().GetReputation(repFaction); - if (curRep < repValue) - if (FactionEntry const *factionEntry = sFactionStore.LookupEntry(repFaction)) - player->GetReputationMgr().SetReputation(factionEntry,repValue); - } - - // If the quest requires a SECOND reputation to complete - if (uint32 repFaction = pQuest->GetRepObjectiveFaction2()) - { - uint32 repValue2 = pQuest->GetRepObjectiveValue2(); - uint32 curRep = player->GetReputationMgr().GetReputation(repFaction); - if (curRep < repValue2) - if (FactionEntry const *factionEntry = sFactionStore.LookupEntry(repFaction)) - player->GetReputationMgr().SetReputation(factionEntry,repValue2); - } - - // If the quest requires money - int32 ReqOrRewMoney = pQuest->GetRewOrReqMoney(); - if (ReqOrRewMoney < 0) - player->ModifyMoney(-ReqOrRewMoney); - - player->CompleteQuest(entry); - return true; -} - bool ChatHandler::HandleBanAccountCommand(const char *args) { return HandleBanHelper(BAN_ACCOUNT,args); diff --git a/src/server/game/Chat/Commands/TicketCommands.cpp b/src/server/game/Chat/Commands/TicketCommands.cpp index 018e4da0ad6..34f04041bc4 100755 --- a/src/server/game/Chat/Commands/TicketCommands.cpp +++ b/src/server/game/Chat/Commands/TicketCommands.cpp @@ -427,12 +427,6 @@ bool ChatHandler::HandleGMTicketDeleteByIdCommand(const char* args) return true; } -bool ChatHandler::HandleGMTicketReloadCommand(const char* /* args */) -{ - sTicketMgr.LoadGMTickets(); - return true; -} - bool ChatHandler::HandleToggleGMTicketSystem(const char* /* args */) { sTicketMgr.SetStatus(!sTicketMgr.GetStatus()); |
