diff options
-rw-r--r-- | src/server/scripts/Commands/cs_account.cpp | 849 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_achievement.cpp | 74 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_debug.cpp | 1868 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_event.cpp | 294 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_gm.cpp | 374 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_go.cpp | 979 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_gobject.cpp | 995 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_honor.cpp | 139 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_learn.cpp | 1950 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_modify.cpp | 2148 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_npc.cpp | 2170 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_quest.cpp | 351 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_reload.cpp | 2211 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_tele.cpp | 442 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_titles.cpp | 333 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_wp.cpp | 1448 |
16 files changed, 8298 insertions, 8327 deletions
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index b9cd6367816..8641d70ceb4 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -28,526 +28,525 @@ EndScriptData */ class account_commandscript : public CommandScript { - public: - account_commandscript() : CommandScript("account_commandscript") { } +public: + account_commandscript() : CommandScript("account_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const + { + static ChatCommand accountSetCommandTable[] = { - static ChatCommand accountSetCommandTable[] = - { - { "addon", SEC_ADMINISTRATOR, true, &HandleAccountSetAddonCommand, "", NULL }, - { "gmlevel", SEC_CONSOLE, true, &HandleAccountSetGmLevelCommand, "", NULL }, - { "password", SEC_CONSOLE, true, &HandleAccountSetPasswordCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand accountCommandTable[] = - { - { "addon", SEC_MODERATOR, false, &HandleAccountAddonCommand, "", NULL }, - { "create", SEC_CONSOLE, true, &HandleAccountCreateCommand, "", NULL }, - { "delete", SEC_CONSOLE, true, &HandleAccountDeleteCommand, "", NULL }, - { "onlinelist", SEC_CONSOLE, true, &HandleAccountOnlineListCommand, "", NULL }, - { "lock", SEC_PLAYER, false, &HandleAccountLockCommand, "", NULL }, - { "set", SEC_ADMINISTRATOR, true, NULL, "", accountSetCommandTable }, - { "password", SEC_PLAYER, false, &HandleAccountPasswordCommand, "", NULL }, - { "", SEC_PLAYER, false, &HandleAccountCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand commandTable[] = - { - { "account", SEC_PLAYER, true, NULL, "", accountCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - return commandTable; - } - - static bool HandleAccountAddonCommand(ChatHandler* handler, const char* args) + { "addon", SEC_ADMINISTRATOR, true, &HandleAccountSetAddonCommand, "", NULL }, + { "gmlevel", SEC_CONSOLE, true, &HandleAccountSetGmLevelCommand, "", NULL }, + { "password", SEC_CONSOLE, true, &HandleAccountSetPasswordCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand accountCommandTable[] = { - if (!*args) - { - handler->SendSysMessage(LANG_CMD_SYNTAX); - handler->SetSentErrorMessage(true); - return false; - } - - char *szExp = strtok((char*)args, " "); - - uint32 account_id = handler->GetSession()->GetAccountId(); + { "addon", SEC_MODERATOR, false, &HandleAccountAddonCommand, "", NULL }, + { "create", SEC_CONSOLE, true, &HandleAccountCreateCommand, "", NULL }, + { "delete", SEC_CONSOLE, true, &HandleAccountDeleteCommand, "", NULL }, + { "onlinelist", SEC_CONSOLE, true, &HandleAccountOnlineListCommand, "", NULL }, + { "lock", SEC_PLAYER, false, &HandleAccountLockCommand, "", NULL }, + { "set", SEC_ADMINISTRATOR, true, NULL, "", accountSetCommandTable }, + { "password", SEC_PLAYER, false, &HandleAccountPasswordCommand, "", NULL }, + { "", SEC_PLAYER, false, &HandleAccountCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "account", SEC_PLAYER, true, NULL, "", accountCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } + + static bool HandleAccountAddonCommand(ChatHandler* handler, const char* args) + { + if (!*args) + { + handler->SendSysMessage(LANG_CMD_SYNTAX); + handler->SetSentErrorMessage(true); + return false; + } - int expansion = atoi(szExp); //get int anyway (0 if error) - if (expansion < 0 || uint8(expansion) > sWorld.getIntConfig(CONFIG_EXPANSION)) - { - handler->SendSysMessage(LANG_IMPROPER_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + char *szExp = strtok((char*)args, " "); - // No SQL injection - LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, account_id); - handler->PSendSysMessage(LANG_ACCOUNT_ADDON, expansion); - return true; - } + uint32 account_id = handler->GetSession()->GetAccountId(); - /// Create an account - static bool HandleAccountCreateCommand(ChatHandler* handler, const char* args) + int expansion = atoi(szExp); //get int anyway (0 if error) + if (expansion < 0 || uint8(expansion) > sWorld.getIntConfig(CONFIG_EXPANSION)) { - if (!*args) - return false; + handler->SendSysMessage(LANG_IMPROPER_VALUE); + handler->SetSentErrorMessage(true); + return false; + } - ///- %Parse the command line arguments - char *szAcc = strtok((char*)args, " "); - char *szPassword = strtok(NULL, " "); - if (!szAcc || !szPassword) - return false; + // No SQL injection + LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, account_id); + handler->PSendSysMessage(LANG_ACCOUNT_ADDON, expansion); + return true; + } - // normalized in sAccountMgr.CreateAccount - std::string account_name = szAcc; - std::string password = szPassword; + /// Create an account + static bool HandleAccountCreateCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - AccountOpResult result = sAccountMgr.CreateAccount(account_name, password); - switch(result) - { - case AOR_OK: - handler->PSendSysMessage(LANG_ACCOUNT_CREATED,account_name.c_str()); - break; - case AOR_NAME_TOO_LONG: - handler->SendSysMessage(LANG_ACCOUNT_TOO_LONG); - handler->SetSentErrorMessage(true); - return false; - case AOR_NAME_ALREDY_EXIST: - handler->SendSysMessage(LANG_ACCOUNT_ALREADY_EXIST); - handler->SetSentErrorMessage(true); - return false; - case AOR_DB_INTERNAL_ERROR: - handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED_SQL_ERROR,account_name.c_str()); - handler->SetSentErrorMessage(true); - return false; - default: - handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED,account_name.c_str()); - handler->SetSentErrorMessage(true); - return false; - } + ///- %Parse the command line arguments + char *szAcc = strtok((char*)args, " "); + char *szPassword = strtok(NULL, " "); + if (!szAcc || !szPassword) + return false; - return true; - } + // normalized in sAccountMgr.CreateAccount + std::string account_name = szAcc; + std::string password = szPassword; - /// Delete a user account and all associated characters in this realm - /// \todo This function has to be enhanced to respect the login/realm split (delete char, delete account chars in realm, delete account chars in realm then delete account - static bool HandleAccountDeleteCommand(ChatHandler* handler, const char* args) + AccountOpResult result = sAccountMgr.CreateAccount(account_name, password); + switch(result) { - if (!*args) - return false; + case AOR_OK: + handler->PSendSysMessage(LANG_ACCOUNT_CREATED,account_name.c_str()); + break; + case AOR_NAME_TOO_LONG: + handler->SendSysMessage(LANG_ACCOUNT_TOO_LONG); + handler->SetSentErrorMessage(true); + return false; + case AOR_NAME_ALREDY_EXIST: + handler->SendSysMessage(LANG_ACCOUNT_ALREADY_EXIST); + handler->SetSentErrorMessage(true); + return false; + case AOR_DB_INTERNAL_ERROR: + handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED_SQL_ERROR,account_name.c_str()); + handler->SetSentErrorMessage(true); + return false; + default: + handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED,account_name.c_str()); + handler->SetSentErrorMessage(true); + return false; + } - ///- Get the account name from the command line - char *account_name_str=strtok ((char*)args," "); - if (!account_name_str) - return false; + return true; + } - std::string account_name = account_name_str; - if (!AccountMgr::normalizeString(account_name)) - { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - handler->SetSentErrorMessage(true); - return false; - } - - uint32 account_id = sAccountMgr.GetId(account_name); - if (!account_id) - { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - handler->SetSentErrorMessage(true); - return false; - } + /// Delete a user account and all associated characters in this realm + /// \todo This function has to be enhanced to respect the login/realm split (delete char, delete account chars in realm, delete account chars in realm then delete account + static bool HandleAccountDeleteCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - /// Commands not recommended call from chat, but support anyway - /// can delete only for account with less security - /// This is also reject self apply in fact - if (handler->HasLowerSecurityAccount (NULL,account_id,true)) - return false; + ///- Get the account name from the command line + char *account_name_str=strtok ((char*)args," "); + if (!account_name_str) + return false; - AccountOpResult result = sAccountMgr.DeleteAccount(account_id); - switch(result) - { - case AOR_OK: - handler->PSendSysMessage(LANG_ACCOUNT_DELETED,account_name.c_str()); - break; - case AOR_NAME_NOT_EXIST: - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - handler->SetSentErrorMessage(true); - return false; - case AOR_DB_INTERNAL_ERROR: - handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED_SQL_ERROR,account_name.c_str()); - handler->SetSentErrorMessage(true); - return false; - default: - handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED,account_name.c_str()); - handler->SetSentErrorMessage(true); - return false; - } + std::string account_name = account_name_str; + if (!AccountMgr::normalizeString(account_name)) + { + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); + handler->SetSentErrorMessage(true); + return false; + } - return true; + uint32 account_id = sAccountMgr.GetId(account_name); + if (!account_id) + { + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); + handler->SetSentErrorMessage(true); + return false; } - /// Display info on users currently in the realm - static bool HandleAccountOnlineListCommand(ChatHandler* handler, const char* /*args*/) + /// Commands not recommended call from chat, but support anyway + /// can delete only for account with less security + /// This is also reject self apply in fact + if (handler->HasLowerSecurityAccount (NULL,account_id,true)) + return false; + + AccountOpResult result = sAccountMgr.DeleteAccount(account_id); + switch(result) { - ///- Get the list of accounts ID logged to the realm - QueryResult resultDB = CharacterDatabase.Query("SELECT name,account,map,zone FROM characters WHERE online > 0"); - if (!resultDB) - { - handler->SendSysMessage(LANG_ACCOUNT_LIST_EMPTY); - return true; - } + case AOR_OK: + handler->PSendSysMessage(LANG_ACCOUNT_DELETED,account_name.c_str()); + break; + case AOR_NAME_NOT_EXIST: + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); + handler->SetSentErrorMessage(true); + return false; + case AOR_DB_INTERNAL_ERROR: + handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED_SQL_ERROR,account_name.c_str()); + handler->SetSentErrorMessage(true); + return false; + default: + handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED,account_name.c_str()); + handler->SetSentErrorMessage(true); + return false; + } - ///- Display the list of account/characters online - handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR_HEADER); - handler->SendSysMessage(LANG_ACCOUNT_LIST_HEADER); - handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR); + return true; + } - ///- Circle through accounts - do - { - Field *fieldsDB = resultDB->Fetch(); - std::string name = fieldsDB[0].GetString(); - uint32 account = fieldsDB[1].GetUInt32(); - - ///- Get the username, last IP and GM level of each account - // No SQL injection. account is uint32. - QueryResult resultLogin = - LoginDatabase.PQuery("SELECT a.username, a.last_ip, aa.gmlevel, a.expansion " - "FROM account a " - "LEFT JOIN account_access aa " - "ON (a.id = aa.id) " - "WHERE a.id = '%u'", account); - if (resultLogin) - { - Field *fieldsLogin = resultLogin->Fetch(); - handler->PSendSysMessage(LANG_ACCOUNT_LIST_LINE, - fieldsLogin[0].GetCString(),name.c_str(),fieldsLogin[1].GetCString(),fieldsDB[2].GetInt32(),fieldsDB[3].GetInt32(),fieldsLogin[3].GetUInt32(),fieldsLogin[2].GetUInt32()); - } - else - handler->PSendSysMessage(LANG_ACCOUNT_LIST_ERROR,name.c_str()); - - }while (resultDB->NextRow()); - - handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR); + /// Display info on users currently in the realm + static bool HandleAccountOnlineListCommand(ChatHandler* handler, const char* /*args*/) + { + ///- Get the list of accounts ID logged to the realm + QueryResult resultDB = CharacterDatabase.Query("SELECT name,account,map,zone FROM characters WHERE online > 0"); + if (!resultDB) + { + handler->SendSysMessage(LANG_ACCOUNT_LIST_EMPTY); return true; } - static bool HandleAccountLockCommand(ChatHandler* handler, const char* args) + ///- Display the list of account/characters online + handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR_HEADER); + handler->SendSysMessage(LANG_ACCOUNT_LIST_HEADER); + handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR); + + ///- Cycle through accounts + do { - if (!*args) + Field *fieldsDB = resultDB->Fetch(); + std::string name = fieldsDB[0].GetString(); + uint32 account = fieldsDB[1].GetUInt32(); + + ///- Get the username, last IP and GM level of each account + // No SQL injection. account is uint32. + QueryResult resultLogin = + LoginDatabase.PQuery("SELECT a.username, a.last_ip, aa.gmlevel, a.expansion " + "FROM account a " + "LEFT JOIN account_access aa " + "ON (a.id = aa.id) " + "WHERE a.id = '%u'", account); + if (resultLogin) { - handler->SendSysMessage(LANG_USE_BOL); - handler->SetSentErrorMessage(true); - return false; + Field *fieldsLogin = resultLogin->Fetch(); + handler->PSendSysMessage(LANG_ACCOUNT_LIST_LINE, + fieldsLogin[0].GetCString(),name.c_str(),fieldsLogin[1].GetCString(),fieldsDB[2].GetInt32(),fieldsDB[3].GetInt32(),fieldsLogin[3].GetUInt32(),fieldsLogin[2].GetUInt32()); } + else + handler->PSendSysMessage(LANG_ACCOUNT_LIST_ERROR,name.c_str()); - std::string argstr = (char*)args; - if (argstr == "on") - { - LoginDatabase.PExecute("UPDATE account SET locked = '1' WHERE id = '%d'",handler->GetSession()->GetAccountId()); - handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED); - return true; - } + }while (resultDB->NextRow()); - if (argstr == "off") - { - LoginDatabase.PExecute("UPDATE account SET locked = '0' WHERE id = '%d'",handler->GetSession()->GetAccountId()); - handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED); - return true; - } + handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR); + return true; + } + static bool HandleAccountLockCommand(ChatHandler* handler, const char* args) + { + if (!*args) + { handler->SendSysMessage(LANG_USE_BOL); handler->SetSentErrorMessage(true); return false; } - static bool HandleAccountPasswordCommand(ChatHandler* handler, const char* args) + std::string argstr = (char*)args; + if (argstr == "on") { - if (!*args) - { - handler->SendSysMessage(LANG_CMD_SYNTAX); - handler->SetSentErrorMessage(true); - return false; - } + LoginDatabase.PExecute("UPDATE account SET locked = '1' WHERE id = '%d'",handler->GetSession()->GetAccountId()); + handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED); + return true; + } - char *old_pass = strtok((char*)args, " "); - char *new_pass = strtok(NULL, " "); - char *new_pass_c = strtok(NULL, " "); + if (argstr == "off") + { + LoginDatabase.PExecute("UPDATE account SET locked = '0' WHERE id = '%d'",handler->GetSession()->GetAccountId()); + handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED); + return true; + } - if (!old_pass || !new_pass || !new_pass_c) - { - handler->SendSysMessage(LANG_CMD_SYNTAX); - handler->SetSentErrorMessage(true); - return false; - } + handler->SendSysMessage(LANG_USE_BOL); + handler->SetSentErrorMessage(true); + return false; + } - std::string password_old = old_pass; - std::string password_new = new_pass; - std::string password_new_c = new_pass_c; + static bool HandleAccountPasswordCommand(ChatHandler* handler, const char* args) + { + if (!*args) + { + handler->SendSysMessage(LANG_CMD_SYNTAX); + handler->SetSentErrorMessage(true); + return false; + } - if (!sAccountMgr.CheckPassword(handler->GetSession()->GetAccountId(), password_old)) - { - handler->SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD); - handler->SetSentErrorMessage(true); - return false; - } + char *old_pass = strtok((char*)args, " "); + char *new_pass = strtok(NULL, " "); + char *new_pass_c = strtok(NULL, " "); - if (strcmp(new_pass, new_pass_c) != 0) - { - handler->SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH); - handler->SetSentErrorMessage(true); - return false; - } + if (!old_pass || !new_pass || !new_pass_c) + { + handler->SendSysMessage(LANG_CMD_SYNTAX); + handler->SetSentErrorMessage(true); + return false; + } - AccountOpResult result = sAccountMgr.ChangePassword(handler->GetSession()->GetAccountId(), password_new); - switch(result) - { - case AOR_OK: - handler->SendSysMessage(LANG_COMMAND_PASSWORD); - break; - case AOR_PASS_TOO_LONG: - handler->SendSysMessage(LANG_PASSWORD_TOO_LONG); - handler->SetSentErrorMessage(true); - return false; - default: - handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD); - handler->SetSentErrorMessage(true); - return false; - } + std::string password_old = old_pass; + std::string password_new = new_pass; + std::string password_new_c = new_pass_c; - return true; + if (!sAccountMgr.CheckPassword(handler->GetSession()->GetAccountId(), password_old)) + { + handler->SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD); + handler->SetSentErrorMessage(true); + return false; } - static bool HandleAccountCommand(ChatHandler* handler, const char* /*args*/) + if (strcmp(new_pass, new_pass_c) != 0) { - AccountTypes gmlevel = handler->GetSession()->GetSecurity(); - handler->PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(gmlevel)); - return true; + handler->SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH); + handler->SetSentErrorMessage(true); + return false; } - /// Set/Unset the expansion level for an account - static bool HandleAccountSetAddonCommand(ChatHandler* handler, const char *args) + AccountOpResult result = sAccountMgr.ChangePassword(handler->GetSession()->GetAccountId(), password_new); + switch(result) { - ///- Get the command line arguments - char *szAcc = strtok((char*)args," "); - char *szExp = strtok(NULL," "); + case AOR_OK: + handler->SendSysMessage(LANG_COMMAND_PASSWORD); + break; + case AOR_PASS_TOO_LONG: + handler->SendSysMessage(LANG_PASSWORD_TOO_LONG); + handler->SetSentErrorMessage(true); + return false; + default: + handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD); + handler->SetSentErrorMessage(true); + return false; + } - if (!szAcc) - return false; + return true; + } - std::string account_name; - uint32 account_id; + static bool HandleAccountCommand(ChatHandler* handler, const char* /*args*/) + { + AccountTypes gmlevel = handler->GetSession()->GetSecurity(); + handler->PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(gmlevel)); + return true; + } - if (!szExp) - { - Player* player = handler->getSelectedPlayer(); - if (!player) - return false; + /// Set/Unset the expansion level for an account + static bool HandleAccountSetAddonCommand(ChatHandler* handler, const char *args) + { + ///- Get the command line arguments + char *szAcc = strtok((char*)args," "); + char *szExp = strtok(NULL," "); - account_id = player->GetSession()->GetAccountId(); - sAccountMgr.GetName(account_id,account_name); - szExp = szAcc; - } - else - { - ///- Convert Account name to Upper Format - account_name = szAcc; - if (!AccountMgr::normalizeString(account_name)) - { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - handler->SetSentErrorMessage(true); - return false; - } - - account_id = sAccountMgr.GetId(account_name); - if (!account_id) - { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - handler->SetSentErrorMessage(true); - return false; - } + if (!szAcc) + return false; - } + std::string account_name; + uint32 account_id; - // Let set addon state only for lesser (strong) security level - // or to self account - if (handler->GetSession() && handler->GetSession()->GetAccountId () != account_id && - handler->HasLowerSecurityAccount (NULL,account_id,true)) + if (!szExp) + { + Player* player = handler->getSelectedPlayer(); + if (!player) return false; - int expansion = atoi(szExp); //get int anyway (0 if error) - if (expansion < 0 || uint8(expansion) > sWorld.getIntConfig(CONFIG_EXPANSION)) - return false; - - // No SQL injection - LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",expansion,account_id); - handler->PSendSysMessage(LANG_ACCOUNT_SETADDON,account_name.c_str(),account_id,expansion); - return true; + account_id = player->GetSession()->GetAccountId(); + sAccountMgr.GetName(account_id,account_name); + szExp = szAcc; } - - static bool HandleAccountSetGmLevelCommand(ChatHandler* handler, const char *args) + else { - if (!*args) - return false; - - std::string targetAccountName; - uint32 targetAccountId = 0; - uint32 targetSecurity = 0; - uint32 gm = 0; - char* arg1 = strtok((char*)args, " "); - char* arg2 = strtok(NULL, " "); - char* arg3 = strtok(NULL, " "); - bool isAccountNameGiven = true; - - if (arg1 && !arg3) + ///- Convert Account name to Upper Format + account_name = szAcc; + if (!AccountMgr::normalizeString(account_name)) { - if (!handler->getSelectedPlayer()) - return false; - isAccountNameGiven = false; - } - - // Check for second parameter - if (!isAccountNameGiven && !arg2) + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); + handler->SetSentErrorMessage(true); return false; - - // Check for account - if (isAccountNameGiven) - { - targetAccountName = arg1; - if (!AccountMgr::normalizeString(targetAccountName)) - { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str()); - handler->SetSentErrorMessage(true); - return false; - } } - // Check for invalid specified GM level. - gm = (isAccountNameGiven) ? atoi(arg2) : atoi(arg1); - if (gm > SEC_CONSOLE) + account_id = sAccountMgr.GetId(account_name); + if (!account_id) { - handler->SendSysMessage(LANG_BAD_VALUE); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); handler->SetSentErrorMessage(true); return false; } - // handler->getSession() == NULL only for console - targetAccountId = (isAccountNameGiven) ? sAccountMgr.GetId(targetAccountName) : handler->getSelectedPlayer()->GetSession()->GetAccountId(); - int32 gmRealmID = (isAccountNameGiven) ? atoi(arg3) : atoi(arg2); - uint32 plSecurity; - if (handler->GetSession()) - plSecurity = sAccountMgr.GetSecurity(handler->GetSession()->GetAccountId(), gmRealmID); - else - plSecurity = SEC_CONSOLE; + } - // can set security level only for target with less security and to less security that we have - // This is also reject self apply in fact - targetSecurity = sAccountMgr.GetSecurity(targetAccountId, gmRealmID); - if (targetSecurity >= plSecurity || gm >= plSecurity) - { - handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); - handler->SetSentErrorMessage(true); - return false; - } + // Let set addon state only for lesser (strong) security level + // or to self account + if (handler->GetSession() && handler->GetSession()->GetAccountId () != account_id && + handler->HasLowerSecurityAccount (NULL,account_id,true)) + return false; - // Check and abort if the target gm has a higher rank on one of the realms and the new realm is -1 - if (gmRealmID == -1) - { - QueryResult result = LoginDatabase.PQuery("SELECT * FROM account_access WHERE id = '%u' AND gmlevel > '%d'", targetAccountId, gm); - if (result) - { - handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); - handler->SetSentErrorMessage(true); - return false; - } - } + int expansion = atoi(szExp); //get int anyway (0 if error) + if (expansion < 0 || uint8(expansion) > sWorld.getIntConfig(CONFIG_EXPANSION)) + return false; - // Check if provided realmID has a negative value other than -1 - if (gmRealmID < -1) - { - handler->SendSysMessage(LANG_INVALID_REALMID); - handler->SetSentErrorMessage(true); - return false; - } + // No SQL injection + LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",expansion,account_id); + handler->PSendSysMessage(LANG_ACCOUNT_SETADDON,account_name.c_str(),account_id,expansion); + return true; + } - // If gmRealmID is -1, delete all values for the account id, else, insert values for the specific realmID - if (gmRealmID == -1) - LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u'", targetAccountId); - else - LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u' AND (RealmID = '%d' OR RealmID = '-1')", targetAccountId, realmID); + static bool HandleAccountSetGmLevelCommand(ChatHandler* handler, const char *args) + { + if (!*args) + return false; - if (gm != 0) - LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u','%d','%d')", targetAccountId, gm, realmID); - handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); - return true; - } + std::string targetAccountName; + uint32 targetAccountId = 0; + uint32 targetSecurity = 0; + uint32 gm = 0; + char* arg1 = strtok((char*)args, " "); + char* arg2 = strtok(NULL, " "); + char* arg3 = strtok(NULL, " "); + bool isAccountNameGiven = true; - /// Set password for account - static bool HandleAccountSetPasswordCommand(ChatHandler* handler, const char *args) + if (arg1 && !arg3) { - if (!*args) + if (!handler->getSelectedPlayer()) return false; + isAccountNameGiven = false; + } - ///- Get the command line arguments - char *szAccount = strtok ((char*)args," "); - char *szPassword1 = strtok (NULL," "); - char *szPassword2 = strtok (NULL," "); - - if (!szAccount||!szPassword1 || !szPassword2) - return false; + // Check for second parameter + if (!isAccountNameGiven && !arg2) + return false; - std::string account_name = szAccount; - if (!AccountMgr::normalizeString(account_name)) + // Check for account + if (isAccountNameGiven) + { + targetAccountName = arg1; + if (!AccountMgr::normalizeString(targetAccountName)) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str()); handler->SetSentErrorMessage(true); return false; } + } + + // Check for invalid specified GM level. + gm = (isAccountNameGiven) ? atoi(arg2) : atoi(arg1); + if (gm > SEC_CONSOLE) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; + } + + // handler->getSession() == NULL only for console + targetAccountId = (isAccountNameGiven) ? sAccountMgr.GetId(targetAccountName) : handler->getSelectedPlayer()->GetSession()->GetAccountId(); + int32 gmRealmID = (isAccountNameGiven) ? atoi(arg3) : atoi(arg2); + uint32 plSecurity; + if (handler->GetSession()) + plSecurity = sAccountMgr.GetSecurity(handler->GetSession()->GetAccountId(), gmRealmID); + else + plSecurity = SEC_CONSOLE; + + // can set security level only for target with less security and to less security that we have + // This is also reject self apply in fact + targetSecurity = sAccountMgr.GetSecurity(targetAccountId, gmRealmID); + if (targetSecurity >= plSecurity || gm >= plSecurity) + { + handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); + handler->SetSentErrorMessage(true); + return false; + } - uint32 targetAccountId = sAccountMgr.GetId(account_name); - if (!targetAccountId) + // Check and abort if the target gm has a higher rank on one of the realms and the new realm is -1 + if (gmRealmID == -1) + { + QueryResult result = LoginDatabase.PQuery("SELECT * FROM account_access WHERE id = '%u' AND gmlevel > '%d'", targetAccountId, gm); + if (result) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); + handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); handler->SetSentErrorMessage(true); return false; } + } - /// can set password only for target with less security - /// This is also reject self apply in fact - if (handler->HasLowerSecurityAccount (NULL,targetAccountId,true)) - return false; + // Check if provided realmID has a negative value other than -1 + if (gmRealmID < -1) + { + handler->SendSysMessage(LANG_INVALID_REALMID); + handler->SetSentErrorMessage(true); + return false; + } - if (strcmp(szPassword1,szPassword2)) - { - handler->SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH); - handler->SetSentErrorMessage (true); - return false; - } + // If gmRealmID is -1, delete all values for the account id, else, insert values for the specific realmID + if (gmRealmID == -1) + LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u'", targetAccountId); + else + LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u' AND (RealmID = '%d' OR RealmID = '-1')", targetAccountId, realmID); + + if (gm != 0) + LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u','%d','%d')", targetAccountId, gm, realmID); + handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); + return true; + } + + /// Set password for account + static bool HandleAccountSetPasswordCommand(ChatHandler* handler, const char *args) + { + if (!*args) + return false; - AccountOpResult result = sAccountMgr.ChangePassword(targetAccountId, szPassword1); + ///- Get the command line arguments + char *szAccount = strtok ((char*)args," "); + char *szPassword1 = strtok (NULL," "); + char *szPassword2 = strtok (NULL," "); - switch (result) - { - case AOR_OK: - handler->SendSysMessage(LANG_COMMAND_PASSWORD); - break; - case AOR_NAME_NOT_EXIST: - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - handler->SetSentErrorMessage(true); - return false; - case AOR_PASS_TOO_LONG: - handler->SendSysMessage(LANG_PASSWORD_TOO_LONG); - handler->SetSentErrorMessage(true); - return false; - default: - handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD); - handler->SetSentErrorMessage(true); - return false; - } + if (!szAccount||!szPassword1 || !szPassword2) + return false; - return true; + std::string account_name = szAccount; + if (!AccountMgr::normalizeString(account_name)) + { + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); + handler->SetSentErrorMessage(true); + return false; + } + + uint32 targetAccountId = sAccountMgr.GetId(account_name); + if (!targetAccountId) + { + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); + handler->SetSentErrorMessage(true); + return false; + } + + /// can set password only for target with less security + /// This is also reject self apply in fact + if (handler->HasLowerSecurityAccount (NULL,targetAccountId,true)) + return false; + + if (strcmp(szPassword1,szPassword2)) + { + handler->SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH); + handler->SetSentErrorMessage (true); + return false; + } + + AccountOpResult result = sAccountMgr.ChangePassword(targetAccountId, szPassword1); + + switch (result) + { + case AOR_OK: + handler->SendSysMessage(LANG_COMMAND_PASSWORD); + break; + case AOR_NAME_NOT_EXIST: + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); + handler->SetSentErrorMessage(true); + return false; + case AOR_PASS_TOO_LONG: + handler->SendSysMessage(LANG_PASSWORD_TOO_LONG); + handler->SetSentErrorMessage(true); + return false; + default: + handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD); + handler->SetSentErrorMessage(true); + return false; } + return true; + } }; void AddSC_account_commandscript() diff --git a/src/server/scripts/Commands/cs_achievement.cpp b/src/server/scripts/Commands/cs_achievement.cpp index 06bf2563000..a61021e361f 100644 --- a/src/server/scripts/Commands/cs_achievement.cpp +++ b/src/server/scripts/Commands/cs_achievement.cpp @@ -27,51 +27,51 @@ EndScriptData */ class achievement_commandscript : public CommandScript { - public: - achievement_commandscript() : CommandScript("achievement_commandscript") { } +public: + achievement_commandscript() : CommandScript("achievement_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const + { + static ChatCommand achievementCommandTable[] = { - static ChatCommand achievementCommandTable[] = - { - { "add", SEC_ADMINISTRATOR, false, &HandleAchievementAddCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand commandTable[] = - { - { "achievement", SEC_ADMINISTRATOR, false, NULL, "", achievementCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - return commandTable; - } - - static bool HandleAchievementAddCommand(ChatHandler* handler, const char *args) + { "add", SEC_ADMINISTRATOR, false, &HandleAchievementAddCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = { - if (!*args) - return false; + { "achievement", SEC_ADMINISTRATOR, false, NULL, "", achievementCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } - uint32 achievementId = atoi((char*)args); - if (!achievementId) - { - if (char* cId = handler->extractKeyFromLink((char*)args, "Hachievement")) - achievementId = atoi(cId); - if (!achievementId) - return false; - } + static bool HandleAchievementAddCommand(ChatHandler* handler, const char *args) + { + if (!*args) + return false; - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); + uint32 achievementId = atoi((char*)args); + if (!achievementId) + { + if (char* cId = handler->extractKeyFromLink((char*)args, "Hachievement")) + achievementId = atoi(cId); + if (!achievementId) return false; - } - - if (AchievementEntry const* pAE = GetAchievementStore()->LookupEntry(achievementId)) - target->CompletedAchievement(pAE, true); + } - return true; + Player* target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; } + + if (AchievementEntry const* pAE = GetAchievementStore()->LookupEntry(achievementId)) + target->CompletedAchievement(pAE, true); + + return true; + } }; void AddSC_achievement_commandscript() diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 2a8ba7934e4..bbeaf5bbbc8 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -36,1201 +36,1201 @@ EndScriptData */ class debug_commandscript : public CommandScript { - public: - debug_commandscript() : CommandScript("debug_commandscript") { } +public: + debug_commandscript() : CommandScript("debug_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const + { + static ChatCommand debugPlayCommandTable[] = { - static ChatCommand debugPlayCommandTable[] = - { - { "cinematic", SEC_MODERATOR, false, &HandleDebugPlayCinematicCommand, "", NULL }, - { "movie", SEC_MODERATOR, false, &HandleDebugPlayMovieCommand, "", NULL }, - { "sound", SEC_MODERATOR, false, &HandleDebugPlaySoundCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand debugSendCommandTable[] = - { - { "buyerror", SEC_ADMINISTRATOR, false, &HandleDebugSendBuyErrorCommand, "", NULL }, - { "channelnotify", SEC_ADMINISTRATOR, false, &HandleDebugSendChannelNotifyCommand, "", NULL }, - { "chatmmessage", SEC_ADMINISTRATOR, false, &HandleDebugSendChatMsgCommand, "", NULL }, - { "equiperror", SEC_ADMINISTRATOR, false, &HandleDebugSendEquipErrorCommand, "", NULL }, - { "largepacket", SEC_ADMINISTRATOR, false, &HandleDebugSendLargePacketCommand, "", NULL }, - { "opcode", SEC_ADMINISTRATOR, false, &HandleDebugSendOpcodeCommand, "", NULL }, - { "poi", SEC_ADMINISTRATOR, false, &HandleDebugSendPoiCommand, "", NULL }, - { "qpartymsg", SEC_ADMINISTRATOR, false, &HandleDebugSendQuestPartyMsgCommand, "", NULL }, - { "qinvalidmsg", SEC_ADMINISTRATOR, false, &HandleDebugSendQuestInvalidMsgCommand,"", NULL }, - { "sellerror", SEC_ADMINISTRATOR, false, &HandleDebugSendSellErrorCommand, "", NULL }, - { "setphaseshift", SEC_ADMINISTRATOR, false, &HandleDebugSendSetPhaseShiftCommand, "", NULL }, - { "spellfail", SEC_ADMINISTRATOR, false, &HandleDebugSendSpellFailCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand debugCommandTable[] = - { - { "setbit", SEC_ADMINISTRATOR, false, &HandleDebugSet32BitCommand, "", NULL }, - { "threat", SEC_ADMINISTRATOR, false, &HandleDebugThreatListCommand, "", NULL }, - { "hostil", SEC_ADMINISTRATOR, false, &HandleDebugHostileRefListCommand, "", NULL }, - { "anim", SEC_GAMEMASTER, false, &HandleDebugAnimCommand, "", NULL }, - { "arena", SEC_ADMINISTRATOR, false, &HandleDebugArenaCommand, "", NULL }, - { "bg", SEC_ADMINISTRATOR, false, &HandleDebugBattlegroundCommand, "", NULL }, - { "getitemstate", SEC_ADMINISTRATOR, false, &HandleDebugGetItemStateCommand, "", NULL }, - { "lootrecipient", SEC_GAMEMASTER, false, &HandleDebugGetLootRecipientCommand,"", NULL }, - { "getvalue", SEC_ADMINISTRATOR, false, &HandleDebugGetValueCommand, "", NULL }, - { "getitemvalue", SEC_ADMINISTRATOR, false, &HandleDebugGetItemValueCommand, "", NULL }, - { "Mod32Value", SEC_ADMINISTRATOR, false, &HandleDebugMod32ValueCommand, "", NULL }, - { "play", SEC_MODERATOR, false, NULL, "", debugPlayCommandTable }, - { "send", SEC_ADMINISTRATOR, false, NULL, "", debugSendCommandTable }, - { "setaurastate", SEC_ADMINISTRATOR, false, &HandleDebugSetAuraStateCommand, "", NULL }, - { "setitemvalue", SEC_ADMINISTRATOR, false, &HandleDebugSetItemValueCommand, "", NULL }, - { "setvalue", SEC_ADMINISTRATOR, false, &HandleDebugSetValueCommand, "", NULL }, - { "spawnvehicle", SEC_ADMINISTRATOR, false, &HandleDebugSpawnVehicleCommand, "", NULL }, - { "setvid", SEC_ADMINISTRATOR, false, &HandleDebugSetVehicleIdCommand, "", NULL }, - { "entervehicle", SEC_ADMINISTRATOR, false, &HandleDebugEnterVehicleCommand, "", NULL }, - { "uws", SEC_ADMINISTRATOR, false, &HandleDebugUpdateWorldStateCommand,"", NULL }, - { "update", SEC_ADMINISTRATOR, false, &HandleDebugUpdateCommand, "", NULL }, - { "itemexpire", SEC_ADMINISTRATOR, false, &HandleDebugItemExpireCommand, "", NULL }, - { "areatriggers", SEC_ADMINISTRATOR, false, &HandleDebugAreaTriggersCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand commandTable[] = - { - { "debug", SEC_MODERATOR, true, NULL, "", debugCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - return commandTable; - } - - static bool HandleDebugPlayCinematicCommand(ChatHandler* handler, const char* args) + { "cinematic", SEC_MODERATOR, false, &HandleDebugPlayCinematicCommand, "", NULL }, + { "movie", SEC_MODERATOR, false, &HandleDebugPlayMovieCommand, "", NULL }, + { "sound", SEC_MODERATOR, false, &HandleDebugPlaySoundCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand debugSendCommandTable[] = { - // USAGE: .debug play cinematic #cinematicid - // #cinematicid - ID decimal number from CinemaicSequences.dbc (1st column) - if (!*args) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + { "buyerror", SEC_ADMINISTRATOR, false, &HandleDebugSendBuyErrorCommand, "", NULL }, + { "channelnotify", SEC_ADMINISTRATOR, false, &HandleDebugSendChannelNotifyCommand, "", NULL }, + { "chatmmessage", SEC_ADMINISTRATOR, false, &HandleDebugSendChatMsgCommand, "", NULL }, + { "equiperror", SEC_ADMINISTRATOR, false, &HandleDebugSendEquipErrorCommand, "", NULL }, + { "largepacket", SEC_ADMINISTRATOR, false, &HandleDebugSendLargePacketCommand, "", NULL }, + { "opcode", SEC_ADMINISTRATOR, false, &HandleDebugSendOpcodeCommand, "", NULL }, + { "poi", SEC_ADMINISTRATOR, false, &HandleDebugSendPoiCommand, "", NULL }, + { "qpartymsg", SEC_ADMINISTRATOR, false, &HandleDebugSendQuestPartyMsgCommand, "", NULL }, + { "qinvalidmsg", SEC_ADMINISTRATOR, false, &HandleDebugSendQuestInvalidMsgCommand,"", NULL }, + { "sellerror", SEC_ADMINISTRATOR, false, &HandleDebugSendSellErrorCommand, "", NULL }, + { "setphaseshift", SEC_ADMINISTRATOR, false, &HandleDebugSendSetPhaseShiftCommand, "", NULL }, + { "spellfail", SEC_ADMINISTRATOR, false, &HandleDebugSendSpellFailCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand debugCommandTable[] = + { + { "setbit", SEC_ADMINISTRATOR, false, &HandleDebugSet32BitCommand, "", NULL }, + { "threat", SEC_ADMINISTRATOR, false, &HandleDebugThreatListCommand, "", NULL }, + { "hostil", SEC_ADMINISTRATOR, false, &HandleDebugHostileRefListCommand, "", NULL }, + { "anim", SEC_GAMEMASTER, false, &HandleDebugAnimCommand, "", NULL }, + { "arena", SEC_ADMINISTRATOR, false, &HandleDebugArenaCommand, "", NULL }, + { "bg", SEC_ADMINISTRATOR, false, &HandleDebugBattlegroundCommand, "", NULL }, + { "getitemstate", SEC_ADMINISTRATOR, false, &HandleDebugGetItemStateCommand, "", NULL }, + { "lootrecipient", SEC_GAMEMASTER, false, &HandleDebugGetLootRecipientCommand,"", NULL }, + { "getvalue", SEC_ADMINISTRATOR, false, &HandleDebugGetValueCommand, "", NULL }, + { "getitemvalue", SEC_ADMINISTRATOR, false, &HandleDebugGetItemValueCommand, "", NULL }, + { "Mod32Value", SEC_ADMINISTRATOR, false, &HandleDebugMod32ValueCommand, "", NULL }, + { "play", SEC_MODERATOR, false, NULL, "", debugPlayCommandTable }, + { "send", SEC_ADMINISTRATOR, false, NULL, "", debugSendCommandTable }, + { "setaurastate", SEC_ADMINISTRATOR, false, &HandleDebugSetAuraStateCommand, "", NULL }, + { "setitemvalue", SEC_ADMINISTRATOR, false, &HandleDebugSetItemValueCommand, "", NULL }, + { "setvalue", SEC_ADMINISTRATOR, false, &HandleDebugSetValueCommand, "", NULL }, + { "spawnvehicle", SEC_ADMINISTRATOR, false, &HandleDebugSpawnVehicleCommand, "", NULL }, + { "setvid", SEC_ADMINISTRATOR, false, &HandleDebugSetVehicleIdCommand, "", NULL }, + { "entervehicle", SEC_ADMINISTRATOR, false, &HandleDebugEnterVehicleCommand, "", NULL }, + { "uws", SEC_ADMINISTRATOR, false, &HandleDebugUpdateWorldStateCommand,"", NULL }, + { "update", SEC_ADMINISTRATOR, false, &HandleDebugUpdateCommand, "", NULL }, + { "itemexpire", SEC_ADMINISTRATOR, false, &HandleDebugItemExpireCommand, "", NULL }, + { "areatriggers", SEC_ADMINISTRATOR, false, &HandleDebugAreaTriggersCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "debug", SEC_MODERATOR, true, NULL, "", debugCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } - uint32 dwId = atoi((char*)args); + static bool HandleDebugPlayCinematicCommand(ChatHandler* handler, const char* args) + { + // USAGE: .debug play cinematic #cinematicid + // #cinematicid - ID decimal number from CinemaicSequences.dbc (1st column) + if (!*args) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; + } - if (!sCinematicSequencesStore.LookupEntry(dwId)) - { - handler->PSendSysMessage(LANG_CINEMATIC_NOT_EXIST, dwId); - handler->SetSentErrorMessage(true); - return false; - } + uint32 dwId = atoi((char*)args); - handler->GetSession()->GetPlayer()->SendCinematicStart(dwId); - return true; + if (!sCinematicSequencesStore.LookupEntry(dwId)) + { + handler->PSendSysMessage(LANG_CINEMATIC_NOT_EXIST, dwId); + handler->SetSentErrorMessage(true); + return false; } - static bool HandleDebugPlayMovieCommand(ChatHandler* handler, const char* args) + handler->GetSession()->GetPlayer()->SendCinematicStart(dwId); + return true; + } + + static bool HandleDebugPlayMovieCommand(ChatHandler* handler, const char* args) + { + // USAGE: .debug play movie #movieid + // #movieid - ID decimal number from Movie.dbc (1st column) + if (!*args) { - // USAGE: .debug play movie #movieid - // #movieid - ID decimal number from Movie.dbc (1st column) - if (!*args) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; + } - uint32 dwId = atoi((char*)args); + uint32 dwId = atoi((char*)args); - if (!sMovieStore.LookupEntry(dwId)) - { - handler->PSendSysMessage(LANG_MOVIE_NOT_EXIST, dwId); - handler->SetSentErrorMessage(true); - return false; - } + if (!sMovieStore.LookupEntry(dwId)) + { + handler->PSendSysMessage(LANG_MOVIE_NOT_EXIST, dwId); + handler->SetSentErrorMessage(true); + return false; + } - handler->GetSession()->GetPlayer()->SendMovieStart(dwId); - return true; + handler->GetSession()->GetPlayer()->SendMovieStart(dwId); + return true; + } + + //Play sound + static bool HandleDebugPlaySoundCommand(ChatHandler* handler, const char* args) + { + // USAGE: .debug playsound #soundid + // #soundid - ID decimal number from SoundEntries.dbc (1st column) + if (!*args) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; } - //Play sound - static bool HandleDebugPlaySoundCommand(ChatHandler* handler, const char* args) + uint32 dwSoundId = atoi((char*)args); + + if (!sSoundEntriesStore.LookupEntry(dwSoundId)) { - // USAGE: .debug playsound #soundid - // #soundid - ID decimal number from SoundEntries.dbc (1st column) - if (!*args) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId); + handler->SetSentErrorMessage(true); + return false; + } - uint32 dwSoundId = atoi((char*)args); + Unit* unit = handler->getSelectedUnit(); + if (!unit) + { + handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } - if (!sSoundEntriesStore.LookupEntry(dwSoundId)) - { - handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId); - handler->SetSentErrorMessage(true); - return false; - } + if (handler->GetSession()->GetPlayer()->GetSelection()) + unit->PlayDistanceSound(dwSoundId,handler->GetSession()->GetPlayer()); + else + unit->PlayDirectSound(dwSoundId,handler->GetSession()->GetPlayer()); - Unit* unit = handler->getSelectedUnit(); - if (!unit) - { - handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + handler->PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId); + return true; + } - if (handler->GetSession()->GetPlayer()->GetSelection()) - unit->PlayDistanceSound(dwSoundId,handler->GetSession()->GetPlayer()); - else - unit->PlayDirectSound(dwSoundId,handler->GetSession()->GetPlayer()); + static bool HandleDebugSendSpellFailCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - handler->PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId); - return true; - } + char* px = strtok((char*)args, " "); + if (!px) + return false; - static bool HandleDebugSendSpellFailCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + uint8 failnum = (uint8)atoi(px); + if (failnum == 0 && *px != '0') + return false; - char* px = strtok((char*)args, " "); - if (!px) - return false; + char* p1 = strtok(NULL, " "); + uint8 failarg1 = p1 ? (uint8)atoi(p1) : 0; - uint8 failnum = (uint8)atoi(px); - if (failnum == 0 && *px != '0') - return false; + char* p2 = strtok(NULL, " "); + uint8 failarg2 = p2 ? (uint8)atoi(p2) : 0; - char* p1 = strtok(NULL, " "); - uint8 failarg1 = p1 ? (uint8)atoi(p1) : 0; + WorldPacket data(SMSG_CAST_FAILED, 5); + data << uint8(0); + data << uint32(133); + data << uint8(failnum); + if (p1 || p2) + data << uint32(failarg1); + if (p2) + data << uint32(failarg2); - char* p2 = strtok(NULL, " "); - uint8 failarg2 = p2 ? (uint8)atoi(p2) : 0; + handler->GetSession()->SendPacket(&data); - WorldPacket data(SMSG_CAST_FAILED, 5); - data << uint8(0); - data << uint32(133); - data << uint8(failnum); - if (p1 || p2) - data << uint32(failarg1); - if (p2) - data << uint32(failarg2); + return true; + } - handler->GetSession()->SendPacket(&data); + static bool HandleDebugSendPoiCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; + Player *pPlayer = handler->GetSession()->GetPlayer(); + Unit* target = handler->getSelectedUnit(); + if (!target) + { + handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); return true; } - static bool HandleDebugSendPoiCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + char* icon_text = strtok((char*)args, " "); + char* flags_text = strtok(NULL, " "); + if (!icon_text || !flags_text) + return false; - Player *pPlayer = handler->GetSession()->GetPlayer(); - Unit* target = handler->getSelectedUnit(); - if (!target) - { - handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - return true; - } + uint32 icon = atol(icon_text); + uint32 flags = atol(flags_text); - char* icon_text = strtok((char*)args, " "); - char* flags_text = strtok(NULL, " "); - if (!icon_text || !flags_text) - return false; + sLog.outDetail("Command : POI, NPC = %u, icon = %u flags = %u", target->GetGUIDLow(), icon,flags); + pPlayer->PlayerTalkClass->SendPointOfInterest(target->GetPositionX(), target->GetPositionY(), Poi_Icon(icon), flags, 30, "Test POI"); + return true; + } - uint32 icon = atol(icon_text); - uint32 flags = atol(flags_text); + static bool HandleDebugSendEquipErrorCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - sLog.outDetail("Command : POI, NPC = %u, icon = %u flags = %u", target->GetGUIDLow(), icon,flags); - pPlayer->PlayerTalkClass->SendPointOfInterest(target->GetPositionX(), target->GetPositionY(), Poi_Icon(icon), flags, 30, "Test POI"); - return true; - } + uint8 msg = atoi(args); + handler->GetSession()->GetPlayer()->SendEquipError(msg, NULL, NULL); + return true; + } - static bool HandleDebugSendEquipErrorCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + static bool HandleDebugSendSellErrorCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - uint8 msg = atoi(args); - handler->GetSession()->GetPlayer()->SendEquipError(msg, NULL, NULL); - return true; - } + uint8 msg = atoi(args); + handler->GetSession()->GetPlayer()->SendSellError(msg, 0, 0, 0); + return true; + } - static bool HandleDebugSendSellErrorCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + static bool HandleDebugSendBuyErrorCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - uint8 msg = atoi(args); - handler->GetSession()->GetPlayer()->SendSellError(msg, 0, 0, 0); - return true; - } + uint8 msg = atoi(args); + handler->GetSession()->GetPlayer()->SendBuyError(msg, 0, 0, 0); + return true; + } - static bool HandleDebugSendBuyErrorCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + static bool HandleDebugSendOpcodeCommand(ChatHandler* handler, const char* /*args*/) + { + Unit *unit = handler->getSelectedUnit(); + Player *player = NULL; + if (!unit || (unit->GetTypeId() != TYPEID_PLAYER)) + player = handler->GetSession()->GetPlayer(); + else + player = (Player*)unit; + if (!unit) unit = player; - uint8 msg = atoi(args); - handler->GetSession()->GetPlayer()->SendBuyError(msg, 0, 0, 0); - return true; - } + std::ifstream ifs("opcode.txt"); + if (ifs.bad()) + return false; - static bool HandleDebugSendOpcodeCommand(ChatHandler* handler, const char* /*args*/) - { - Unit *unit = handler->getSelectedUnit(); - Player *player = NULL; - if (!unit || (unit->GetTypeId() != TYPEID_PLAYER)) - player = handler->GetSession()->GetPlayer(); - else - player = (Player*)unit; - if (!unit) unit = player; + uint32 opcode; + ifs >> opcode; - std::ifstream ifs("opcode.txt"); - if (ifs.bad()) - return false; + WorldPacket data(opcode, 0); - uint32 opcode; - ifs >> opcode; + while (!ifs.eof()) + { + std::string type; + ifs >> type; - WorldPacket data(opcode, 0); + if (type == "") + break; - while (!ifs.eof()) + if (type == "uint8") { - std::string type; - ifs >> type; - - if (type == "") - break; - - if (type == "uint8") - { - uint16 val1; - ifs >> val1; - data << uint8(val1); - } - else if (type == "uint16") - { - uint16 val2; - ifs >> val2; - data << val2; - } - else if (type == "uint32") - { - uint32 val3; - ifs >> val3; - data << val3; - } - else if (type == "uint64") - { - uint64 val4; - ifs >> val4; - data << val4; - } - else if (type == "float") - { - float val5; - ifs >> val5; - data << val5; - } - else if (type == "string") - { - std::string val6; - ifs >> val6; - data << val6; - } - else if (type == "appitsguid") - { - data.append(unit->GetPackGUID()); - } - else if (type == "appmyguid") - { - data.append(player->GetPackGUID()); - } - else if (type == "appgoguid") - { - GameObject *obj = handler->GetNearbyGameObject(); - if (!obj) - { - handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, 0); - handler->SetSentErrorMessage(true); - ifs.close(); - return false; - } - data.append(obj->GetPackGUID()); - } - else if (type == "goguid") - { - GameObject *obj = handler->GetNearbyGameObject(); - if (!obj) - { - handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, 0); - handler->SetSentErrorMessage(true); - ifs.close(); - return false; - } - data << uint64(obj->GetGUID()); - } - else if (type == "myguid") - { - data << uint64(player->GetGUID()); - } - else if (type == "itsguid") - { - data << uint64(unit->GetGUID()); - } - else if (type == "pos") - { - data << unit->GetPositionX(); - data << unit->GetPositionY(); - data << unit->GetPositionZ(); - } - else if (type == "mypos") + uint16 val1; + ifs >> val1; + data << uint8(val1); + } + else if (type == "uint16") + { + uint16 val2; + ifs >> val2; + data << val2; + } + else if (type == "uint32") + { + uint32 val3; + ifs >> val3; + data << val3; + } + else if (type == "uint64") + { + uint64 val4; + ifs >> val4; + data << val4; + } + else if (type == "float") + { + float val5; + ifs >> val5; + data << val5; + } + else if (type == "string") + { + std::string val6; + ifs >> val6; + data << val6; + } + else if (type == "appitsguid") + { + data.append(unit->GetPackGUID()); + } + else if (type == "appmyguid") + { + data.append(player->GetPackGUID()); + } + else if (type == "appgoguid") + { + GameObject *obj = handler->GetNearbyGameObject(); + if (!obj) { - data << player->GetPositionX(); - data << player->GetPositionY(); - data << player->GetPositionZ(); + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, 0); + handler->SetSentErrorMessage(true); + ifs.close(); + return false; } - else + data.append(obj->GetPackGUID()); + } + else if (type == "goguid") + { + GameObject *obj = handler->GetNearbyGameObject(); + if (!obj) { - sLog.outDebug("Sending opcode: unknown type '%s'", type.c_str()); - break; + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, 0); + handler->SetSentErrorMessage(true); + ifs.close(); + return false; } + data << uint64(obj->GetGUID()); } - ifs.close(); - sLog.outDebug("Sending opcode %u", data.GetOpcode()); - data.hexlike(); - player->GetSession()->SendPacket(&data); - handler->PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName()); - return true; - } - - static bool HandleDebugUpdateWorldStateCommand(ChatHandler* handler, const char* args) - { - char* w = strtok((char*)args, " "); - char* s = strtok(NULL, " "); - - if (!w || !s) - return false; - - uint32 world = (uint32)atoi(w); - uint32 state = (uint32)atoi(s); - handler->GetSession()->GetPlayer()->SendUpdateWorldState(world, state); - return true; - } - - static bool HandleDebugAreaTriggersCommand(ChatHandler* handler, const char* /*args*/) - { - Player* plr = handler->GetSession()->GetPlayer(); - if (!plr->isDebugAreaTriggers) + else if (type == "myguid") { - handler->PSendSysMessage(LANG_DEBUG_AREATRIGGER_ON); - plr->isDebugAreaTriggers = true; - } else { - handler->PSendSysMessage(LANG_DEBUG_AREATRIGGER_OFF); - plr->isDebugAreaTriggers = false; + data << uint64(player->GetGUID()); + } + else if (type == "itsguid") + { + data << uint64(unit->GetGUID()); + } + else if (type == "pos") + { + data << unit->GetPositionX(); + data << unit->GetPositionY(); + data << unit->GetPositionZ(); + } + else if (type == "mypos") + { + data << player->GetPositionX(); + data << player->GetPositionY(); + data << player->GetPositionZ(); + } + else + { + sLog.outDebug("Sending opcode: unknown type '%s'", type.c_str()); + break; } - return true; } + ifs.close(); + sLog.outDebug("Sending opcode %u", data.GetOpcode()); + data.hexlike(); + player->GetSession()->SendPacket(&data); + handler->PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName()); + return true; + } - //Send notification in channel - static bool HandleDebugSendChannelNotifyCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + static bool HandleDebugUpdateWorldStateCommand(ChatHandler* handler, const char* args) + { + char* w = strtok((char*)args, " "); + char* s = strtok(NULL, " "); - const char *name = "test"; - uint8 code = atoi(args); + if (!w || !s) + return false; - WorldPacket data(SMSG_CHANNEL_NOTIFY, (1+10)); - data << code; // notify type - data << name; // channel name - data << uint32(0); - data << uint32(0); - handler->GetSession()->SendPacket(&data); - return true; - } + uint32 world = (uint32)atoi(w); + uint32 state = (uint32)atoi(s); + handler->GetSession()->GetPlayer()->SendUpdateWorldState(world, state); + return true; + } - //Send notification in chat - static bool HandleDebugSendChatMsgCommand(ChatHandler* handler, const char* args) + static bool HandleDebugAreaTriggersCommand(ChatHandler* handler, const char* /*args*/) + { + Player* plr = handler->GetSession()->GetPlayer(); + if (!plr->isDebugAreaTriggers) { - if (!*args) - return false; - - const char *msg = "testtest"; - uint8 type = atoi(args); - WorldPacket data; - ChatHandler::FillMessageData(&data, handler->GetSession(), type, 0, "chan", handler->GetSession()->GetPlayer()->GetGUID(), msg, handler->GetSession()->GetPlayer()); - handler->GetSession()->SendPacket(&data); - return true; + handler->PSendSysMessage(LANG_DEBUG_AREATRIGGER_ON); + plr->isDebugAreaTriggers = true; + } else { + handler->PSendSysMessage(LANG_DEBUG_AREATRIGGER_OFF); + plr->isDebugAreaTriggers = false; } + return true; + } - static bool HandleDebugSendQuestPartyMsgCommand(ChatHandler* handler, const char* args) - { - uint32 msg = atol((char*)args); - handler->GetSession()->GetPlayer()->SendPushToPartyResponse(handler->GetSession()->GetPlayer(), msg); - return true; - } + //Send notification in channel + static bool HandleDebugSendChannelNotifyCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; + + const char *name = "test"; + uint8 code = atoi(args); + + WorldPacket data(SMSG_CHANNEL_NOTIFY, (1+10)); + data << code; // notify type + data << name; // channel name + data << uint32(0); + data << uint32(0); + handler->GetSession()->SendPacket(&data); + return true; + } - static bool HandleDebugGetLootRecipientCommand(ChatHandler* handler, const char* /*args*/) - { - Creature* target = handler->getSelectedCreature(); - if (!target) - return false; + //Send notification in chat + static bool HandleDebugSendChatMsgCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; + + const char *msg = "testtest"; + uint8 type = atoi(args); + WorldPacket data; + ChatHandler::FillMessageData(&data, handler->GetSession(), type, 0, "chan", handler->GetSession()->GetPlayer()->GetGUID(), msg, handler->GetSession()->GetPlayer()); + handler->GetSession()->SendPacket(&data); + return true; + } - handler->PSendSysMessage("loot recipient: %s", target->hasLootRecipient()?(target->GetLootRecipient()?target->GetLootRecipient()->GetName():"offline"):"no loot recipient"); - return true; - } + static bool HandleDebugSendQuestPartyMsgCommand(ChatHandler* handler, const char* args) + { + uint32 msg = atol((char*)args); + handler->GetSession()->GetPlayer()->SendPushToPartyResponse(handler->GetSession()->GetPlayer(), msg); + return true; + } - static bool HandleDebugSendQuestInvalidMsgCommand(ChatHandler* handler, const char* args) - { - uint32 msg = atol((char*)args); - handler->GetSession()->GetPlayer()->SendCanTakeQuestResponse(msg); - return true; - } + static bool HandleDebugGetLootRecipientCommand(ChatHandler* handler, const char* /*args*/) + { + Creature* target = handler->getSelectedCreature(); + if (!target) + return false; - static bool HandleDebugGetItemStateCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + handler->PSendSysMessage("loot recipient: %s", target->hasLootRecipient()?(target->GetLootRecipient()?target->GetLootRecipient()->GetName():"offline"):"no loot recipient"); + return true; + } - std::string state_str = args; + static bool HandleDebugSendQuestInvalidMsgCommand(ChatHandler* handler, const char* args) + { + uint32 msg = atol((char*)args); + handler->GetSession()->GetPlayer()->SendCanTakeQuestResponse(msg); + return true; + } - ItemUpdateState state = ITEM_UNCHANGED; - bool list_queue = false, check_all = false; - if (state_str == "unchanged") state = ITEM_UNCHANGED; - else if (state_str == "changed") state = ITEM_CHANGED; - else if (state_str == "new") state = ITEM_NEW; - else if (state_str == "removed") state = ITEM_REMOVED; - else if (state_str == "queue") list_queue = true; - else if (state_str == "check_all") check_all = true; - else return false; + static bool HandleDebugGetItemStateCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - Player* player = handler->getSelectedPlayer(); - if (!player) player = handler->GetSession()->GetPlayer(); + std::string state_str = args; - if (!list_queue && !check_all) + ItemUpdateState state = ITEM_UNCHANGED; + bool list_queue = false, check_all = false; + if (state_str == "unchanged") state = ITEM_UNCHANGED; + else if (state_str == "changed") state = ITEM_CHANGED; + else if (state_str == "new") state = ITEM_NEW; + else if (state_str == "removed") state = ITEM_REMOVED; + else if (state_str == "queue") list_queue = true; + else if (state_str == "check_all") check_all = true; + else return false; + + Player* player = handler->getSelectedPlayer(); + if (!player) player = handler->GetSession()->GetPlayer(); + + if (!list_queue && !check_all) + { + state_str = "The player has the following " + state_str + " items: "; + handler->SendSysMessage(state_str.c_str()); + for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) { - state_str = "The player has the following " + state_str + " items: "; - handler->SendSysMessage(state_str.c_str()); - for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) - { - if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) - continue; + if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) + continue; - Item *item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); - if (!item) continue; - if (!item->IsBag()) - { - if (item->GetState() == state) - handler->PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID())); - } - else + Item *item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (!item) continue; + if (!item->IsBag()) + { + if (item->GetState() == state) + handler->PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID())); + } + else + { + Bag *bag = (Bag*)item; + for (uint8 j = 0; j < bag->GetBagSize(); ++j) { - Bag *bag = (Bag*)item; - for (uint8 j = 0; j < bag->GetBagSize(); ++j) - { - Item* item2 = bag->GetItemByPos(j); - if (item2 && item2->GetState() == state) - handler->PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID())); - } + Item* item2 = bag->GetItemByPos(j); + if (item2 && item2->GetState() == state) + handler->PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID())); } } } + } - if (list_queue) + if (list_queue) + { + std::vector<Item *> &updateQueue = player->GetItemUpdateQueue(); + for (size_t i = 0; i < updateQueue.size(); ++i) { - std::vector<Item *> &updateQueue = player->GetItemUpdateQueue(); - for (size_t i = 0; i < updateQueue.size(); ++i) - { - Item *item = updateQueue[i]; - if (!item) continue; - - Bag *container = item->GetContainer(); - uint8 bag_slot = container ? container->GetSlot() : uint8(INVENTORY_SLOT_BAG_0); + Item *item = updateQueue[i]; + if (!item) continue; - std::string st; - switch(item->GetState()) - { - case ITEM_UNCHANGED: st = "unchanged"; break; - case ITEM_CHANGED: st = "changed"; break; - case ITEM_NEW: st = "new"; break; - case ITEM_REMOVED: st = "removed"; break; - } + Bag *container = item->GetContainer(); + uint8 bag_slot = container ? container->GetSlot() : uint8(INVENTORY_SLOT_BAG_0); - handler->PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bag_slot, item->GetSlot(), item->GetGUIDLow(), st.c_str()); + std::string st; + switch(item->GetState()) + { + case ITEM_UNCHANGED: st = "unchanged"; break; + case ITEM_CHANGED: st = "changed"; break; + case ITEM_NEW: st = "new"; break; + case ITEM_REMOVED: st = "removed"; break; } - if (updateQueue.empty()) - handler->PSendSysMessage("updatequeue empty"); + + handler->PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bag_slot, item->GetSlot(), item->GetGUIDLow(), st.c_str()); } + if (updateQueue.empty()) + handler->PSendSysMessage("updatequeue empty"); + } - if (check_all) + if (check_all) + { + bool error = false; + std::vector<Item *> &updateQueue = player->GetItemUpdateQueue(); + for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) { - bool error = false; - std::vector<Item *> &updateQueue = player->GetItemUpdateQueue(); - for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) + if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) + continue; + + Item *item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); + if (!item) continue; + + if (item->GetSlot() != i) { - if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) - continue; + handler->PSendSysMessage("item at slot %d, guid %d has an incorrect slot value: %d", i, item->GetGUIDLow(), item->GetSlot()); + error = true; continue; + } - Item *item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); - if (!item) continue; + if (item->GetOwnerGUID() != player->GetGUID()) + { + handler->PSendSysMessage("for the item at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); + error = true; continue; + } - if (item->GetSlot() != i) + if (Bag *container = item->GetContainer()) + { + handler->PSendSysMessage("item at slot: %d guid: %d has a container (slot: %d, guid: %d) but shouldnt!", item->GetSlot(), item->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow()); + error = true; continue; + } + + if (item->IsInUpdateQueue()) + { + uint16 qp = item->GetQueuePos(); + if (qp > updateQueue.size()) { - handler->PSendSysMessage("item at slot %d, guid %d has an incorrect slot value: %d", i, item->GetGUIDLow(), item->GetSlot()); + handler->PSendSysMessage("item at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! ", item->GetSlot(), item->GetGUIDLow(), qp); error = true; continue; } - if (item->GetOwnerGUID() != player->GetGUID()) + if (updateQueue[qp] == NULL) { - handler->PSendSysMessage("for the item at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); + handler->PSendSysMessage("item at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!", item->GetSlot(), item->GetGUIDLow(), qp); error = true; continue; } - if (Bag *container = item->GetContainer()) + if (updateQueue[qp] != item) { - handler->PSendSysMessage("item at slot: %d guid: %d has a container (slot: %d, guid: %d) but shouldnt!", item->GetSlot(), item->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow()); + handler->PSendSysMessage("item at slot: %d guid: %d has has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", item->GetSlot(), item->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow()); error = true; continue; } + } + else if (item->GetState() != ITEM_UNCHANGED) + { + handler->PSendSysMessage("item at slot: %d guid: %d is not in queue but should be (state: %d)!", item->GetSlot(), item->GetGUIDLow(), item->GetState()); + error = true; continue; + } - if (item->IsInUpdateQueue()) + if (item->IsBag()) + { + Bag *bag = (Bag*)item; + for (uint8 j = 0; j < bag->GetBagSize(); ++j) { - uint16 qp = item->GetQueuePos(); - if (qp > updateQueue.size()) + Item* item2 = bag->GetItemByPos(j); + if (!item2) continue; + + if (item2->GetSlot() != j) { - handler->PSendSysMessage("item at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! ", item->GetSlot(), item->GetGUIDLow(), qp); + handler->PSendSysMessage("the item in bag %d slot %d, guid %d has an incorrect slot value: %d", bag->GetSlot(), j, item2->GetGUIDLow(), item2->GetSlot()); error = true; continue; } - if (updateQueue[qp] == NULL) + if (item2->GetOwnerGUID() != player->GetGUID()) { - handler->PSendSysMessage("item at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!", item->GetSlot(), item->GetGUIDLow(), qp); + handler->PSendSysMessage("for the item in bag %d at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID()), player->GetGUIDLow()); error = true; continue; } - if (updateQueue[qp] != item) + Bag *container = item2->GetContainer(); + if (!container) { - handler->PSendSysMessage("item at slot: %d guid: %d has has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", item->GetSlot(), item->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow()); + handler->PSendSysMessage("the item in bag %d at slot %d with guid %d has no container!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow()); error = true; continue; } - } - else if (item->GetState() != ITEM_UNCHANGED) - { - handler->PSendSysMessage("item at slot: %d guid: %d is not in queue but should be (state: %d)!", item->GetSlot(), item->GetGUIDLow(), item->GetState()); - error = true; continue; - } - if (item->IsBag()) - { - Bag *bag = (Bag*)item; - for (uint8 j = 0; j < bag->GetBagSize(); ++j) + if (container != bag) { - Item* item2 = bag->GetItemByPos(j); - if (!item2) continue; - - if (item2->GetSlot() != j) - { - handler->PSendSysMessage("the item in bag %d slot %d, guid %d has an incorrect slot value: %d", bag->GetSlot(), j, item2->GetGUIDLow(), item2->GetSlot()); - error = true; continue; - } - - if (item2->GetOwnerGUID() != player->GetGUID()) - { - handler->PSendSysMessage("for the item in bag %d at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID()), player->GetGUIDLow()); - error = true; continue; - } + handler->PSendSysMessage("the item in bag %d at slot %d with guid %d has a different container(slot %d guid %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow()); + error = true; continue; + } - Bag *container = item2->GetContainer(); - if (!container) + if (item2->IsInUpdateQueue()) + { + uint16 qp = item2->GetQueuePos(); + if (qp > updateQueue.size()) { - handler->PSendSysMessage("the item in bag %d at slot %d with guid %d has no container!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow()); + handler->PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp); error = true; continue; } - if (container != bag) + if (updateQueue[qp] == NULL) { - handler->PSendSysMessage("the item in bag %d at slot %d with guid %d has a different container(slot %d guid %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow()); + handler->PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp); error = true; continue; } - if (item2->IsInUpdateQueue()) + if (updateQueue[qp] != item2) { - uint16 qp = item2->GetQueuePos(); - if (qp > updateQueue.size()) - { - handler->PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp); - error = true; continue; - } - - if (updateQueue[qp] == NULL) - { - handler->PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp); - error = true; continue; - } - - if (updateQueue[qp] != item2) - { - handler->PSendSysMessage("item in bag: %d at slot: %d guid: %d has has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow()); - error = true; continue; - } - } - else if (item2->GetState() != ITEM_UNCHANGED) - { - handler->PSendSysMessage("item in bag: %d at slot: %d guid: %d is not in queue but should be (state: %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), item2->GetState()); + handler->PSendSysMessage("item in bag: %d at slot: %d guid: %d has has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow()); error = true; continue; } } + else if (item2->GetState() != ITEM_UNCHANGED) + { + handler->PSendSysMessage("item in bag: %d at slot: %d guid: %d is not in queue but should be (state: %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), item2->GetState()); + error = true; continue; + } } } + } - for (size_t i = 0; i < updateQueue.size(); ++i) - { - Item *item = updateQueue[i]; - if (!item) continue; + for (size_t i = 0; i < updateQueue.size(); ++i) + { + Item *item = updateQueue[i]; + if (!item) continue; - if (item->GetOwnerGUID() != player->GetGUID()) - { - handler->PSendSysMessage("queue(" SIZEFMTD "): for the an item (guid %d), the owner's guid (%d) and player's guid (%d) don't match!", i, item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); - error = true; continue; - } + if (item->GetOwnerGUID() != player->GetGUID()) + { + handler->PSendSysMessage("queue(" SIZEFMTD "): for the an item (guid %d), the owner's guid (%d) and player's guid (%d) don't match!", i, item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); + error = true; continue; + } - if (item->GetQueuePos() != i) - { - handler->PSendSysMessage("queue(" SIZEFMTD "): for the an item (guid %d), the queuepos doesn't match it's position in the queue!", i, item->GetGUIDLow()); - error = true; continue; - } + if (item->GetQueuePos() != i) + { + handler->PSendSysMessage("queue(" SIZEFMTD "): for the an item (guid %d), the queuepos doesn't match it's position in the queue!", i, item->GetGUIDLow()); + error = true; continue; + } - if (item->GetState() == ITEM_REMOVED) continue; - Item *test = player->GetItemByPos(item->GetBagSlot(), item->GetSlot()); + if (item->GetState() == ITEM_REMOVED) continue; + Item *test = player->GetItemByPos(item->GetBagSlot(), item->GetSlot()); - if (test == NULL) - { - handler->PSendSysMessage("queue(" SIZEFMTD "): the bag(%d) and slot(%d) values for the item with guid %d are incorrect, the player doesn't have an item at that position!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow()); - error = true; continue; - } + if (test == NULL) + { + handler->PSendSysMessage("queue(" SIZEFMTD "): the bag(%d) and slot(%d) values for the item with guid %d are incorrect, the player doesn't have an item at that position!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow()); + error = true; continue; + } - if (test != item) - { - handler->PSendSysMessage("queue(" SIZEFMTD "): the bag(%d) and slot(%d) values for the item with guid %d are incorrect, the item with guid %d is there instead!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow()); - error = true; continue; - } + if (test != item) + { + handler->PSendSysMessage("queue(" SIZEFMTD "): the bag(%d) and slot(%d) values for the item with guid %d are incorrect, the item with guid %d is there instead!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow()); + error = true; continue; } - if (!error) - handler->SendSysMessage("All OK!"); } - - return true; + if (!error) + handler->SendSysMessage("All OK!"); } - static bool HandleDebugBattlegroundCommand(ChatHandler* /*handler*/, const char* /*args*/) - { - sBattlegroundMgr.ToggleTesting(); - return true; - } + return true; + } + + static bool HandleDebugBattlegroundCommand(ChatHandler* /*handler*/, const char* /*args*/) + { + sBattlegroundMgr.ToggleTesting(); + return true; + } - static bool HandleDebugArenaCommand(ChatHandler* /*handler*/, const char* /*args*/) + static bool HandleDebugArenaCommand(ChatHandler* /*handler*/, const char* /*args*/) + { + sBattlegroundMgr.ToggleArenaTesting(); + return true; + } + + static bool HandleDebugThreatListCommand(ChatHandler* handler, const char* /*args*/) + { + Creature* target = handler->getSelectedCreature(); + if (!target || target->isTotem() || target->isPet()) + return false; + + std::list<HostileReference*>& tlist = target->getThreatManager().getThreatList(); + std::list<HostileReference*>::iterator itr; + uint32 cnt = 0; + handler->PSendSysMessage("Threat list of %s (guid %u)",target->GetName(), target->GetGUIDLow()); + for (itr = tlist.begin(); itr != tlist.end(); ++itr) { - sBattlegroundMgr.ToggleArenaTesting(); - return true; + Unit* unit = (*itr)->getTarget(); + if (!unit) + continue; + ++cnt; + handler->PSendSysMessage(" %u. %s (guid %u) - threat %f",cnt,unit->GetName(), unit->GetGUIDLow(), (*itr)->getThreat()); } + handler->SendSysMessage("End of threat list."); + return true; + } - static bool HandleDebugThreatListCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleDebugHostileRefListCommand(ChatHandler* handler, const char* /*args*/) + { + Unit* target = handler->getSelectedUnit(); + if (!target) + target = handler->GetSession()->GetPlayer(); + HostileReference* ref = target->getHostileRefManager().getFirst(); + uint32 cnt = 0; + handler->PSendSysMessage("Hostil reference list of %s (guid %u)",target->GetName(), target->GetGUIDLow()); + while (ref) { - Creature* target = handler->getSelectedCreature(); - if (!target || target->isTotem() || target->isPet()) - return false; - - std::list<HostileReference*>& tlist = target->getThreatManager().getThreatList(); - std::list<HostileReference*>::iterator itr; - uint32 cnt = 0; - handler->PSendSysMessage("Threat list of %s (guid %u)",target->GetName(), target->GetGUIDLow()); - for (itr = tlist.begin(); itr != tlist.end(); ++itr) + if (Unit * unit = ref->getSource()->getOwner()) { - Unit* unit = (*itr)->getTarget(); - if (!unit) - continue; ++cnt; - handler->PSendSysMessage(" %u. %s (guid %u) - threat %f",cnt,unit->GetName(), unit->GetGUIDLow(), (*itr)->getThreat()); + handler->PSendSysMessage(" %u. %s (guid %u) - threat %f",cnt,unit->GetName(), unit->GetGUIDLow(), ref->getThreat()); } - handler->SendSysMessage("End of threat list."); - return true; + ref = ref->next(); } + handler->SendSysMessage("End of hostil reference list."); + return true; + } - static bool HandleDebugHostileRefListCommand(ChatHandler* handler, const char* /*args*/) - { - Unit* target = handler->getSelectedUnit(); - if (!target) - target = handler->GetSession()->GetPlayer(); - HostileReference* ref = target->getHostileRefManager().getFirst(); - uint32 cnt = 0; - handler->PSendSysMessage("Hostil reference list of %s (guid %u)",target->GetName(), target->GetGUIDLow()); - while (ref) - { - if (Unit * unit = ref->getSource()->getOwner()) - { - ++cnt; - handler->PSendSysMessage(" %u. %s (guid %u) - threat %f",cnt,unit->GetName(), unit->GetGUIDLow(), ref->getThreat()); - } - ref = ref->next(); - } - handler->SendSysMessage("End of hostil reference list."); - return true; - } + static bool HandleDebugSetVehicleIdCommand(ChatHandler* handler, const char* args) + { + Unit* target = handler->getSelectedUnit(); + if (!target || target->IsVehicle()) + return false; - static bool HandleDebugSetVehicleIdCommand(ChatHandler* handler, const char* args) - { - Unit* target = handler->getSelectedUnit(); - if (!target || target->IsVehicle()) - return false; + if (!args) + return false; - if (!args) - return false; + char* i = strtok((char*)args, " "); + if (!i) + return false; - char* i = strtok((char*)args, " "); - if (!i) - return false; + uint32 id = (uint32)atoi(i); + //target->SetVehicleId(id); + handler->PSendSysMessage("Vehicle id set to %u", id); + return true; + } - uint32 id = (uint32)atoi(i); - //target->SetVehicleId(id); - handler->PSendSysMessage("Vehicle id set to %u", id); - return true; - } + static bool HandleDebugEnterVehicleCommand(ChatHandler* handler, const char* args) + { + Unit* target = handler->getSelectedUnit(); + if (!target || !target->IsVehicle()) + return false; - static bool HandleDebugEnterVehicleCommand(ChatHandler* handler, const char* args) - { - Unit* target = handler->getSelectedUnit(); - if (!target || !target->IsVehicle()) - return false; + if (!args) + return false; - if (!args) - return false; + char* i = strtok((char*)args, " "); + if (!i) + return false; + + char* j = strtok(NULL, " "); - char* i = strtok((char*)args, " "); - if (!i) + uint32 entry = (uint32)atoi(i); + int8 seatId = j ? (int8)atoi(j) : -1; + + if (!entry) + handler->GetSession()->GetPlayer()->EnterVehicle(target, seatId); + else + { + Creature *passenger = NULL; + Trinity::AllCreaturesOfEntryInRange check(handler->GetSession()->GetPlayer(), entry, 20.0f); + Trinity::CreatureSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(handler->GetSession()->GetPlayer(), passenger, check); + handler->GetSession()->GetPlayer()->VisitNearbyObject(30.0f, searcher); + if (!passenger || passenger == target) return false; + passenger->EnterVehicle(target, seatId); + } - char* j = strtok(NULL, " "); + handler->PSendSysMessage("Unit %u entered vehicle %d", entry, (int32)seatId); + return true; + } - uint32 entry = (uint32)atoi(i); - int8 seatId = j ? (int8)atoi(j) : -1; + static bool HandleDebugSpawnVehicleCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - if (!entry) - handler->GetSession()->GetPlayer()->EnterVehicle(target, seatId); - else - { - Creature *passenger = NULL; - Trinity::AllCreaturesOfEntryInRange check(handler->GetSession()->GetPlayer(), entry, 20.0f); - Trinity::CreatureSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(handler->GetSession()->GetPlayer(), passenger, check); - handler->GetSession()->GetPlayer()->VisitNearbyObject(30.0f, searcher); - if (!passenger || passenger == target) - return false; - passenger->EnterVehicle(target, seatId); - } + char* e = strtok((char*)args, " "); + char* i = strtok(NULL, " "); - handler->PSendSysMessage("Unit %u entered vehicle %d", entry, (int32)seatId); - return true; - } + if (!e) + return false; - static bool HandleDebugSpawnVehicleCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + uint32 entry = (uint32)atoi(e); - char* e = strtok((char*)args, " "); - char* i = strtok(NULL, " "); + float x, y, z, o = handler->GetSession()->GetPlayer()->GetOrientation(); + handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, handler->GetSession()->GetPlayer()->GetObjectSize()); - if (!e) - return false; + if (!i) + return handler->GetSession()->GetPlayer()->SummonCreature(entry, x, y, z, o); - uint32 entry = (uint32)atoi(e); + uint32 id = (uint32)atoi(i); - float x, y, z, o = handler->GetSession()->GetPlayer()->GetOrientation(); - handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, handler->GetSession()->GetPlayer()->GetObjectSize()); + CreatureInfo const *ci = sObjectMgr.GetCreatureTemplate(entry); - if (!i) - return handler->GetSession()->GetPlayer()->SummonCreature(entry, x, y, z, o); + if (!ci) + return false; - uint32 id = (uint32)atoi(i); + VehicleEntry const *ve = sVehicleStore.LookupEntry(id); - CreatureInfo const *ci = sObjectMgr.GetCreatureTemplate(entry); + if (!ve) + return false; - if (!ci) - return false; + Creature *v = new Creature; - VehicleEntry const *ve = sVehicleStore.LookupEntry(id); + Map *map = handler->GetSession()->GetPlayer()->GetMap(); - if (!ve) - return false; + if (!v->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_VEHICLE), map, handler->GetSession()->GetPlayer()->GetPhaseMask(), entry, id, handler->GetSession()->GetPlayer()->GetTeam(), x, y, z, o)) + { + delete v; + return false; + } - Creature *v = new Creature; + map->Add(v->ToCreature()); - Map *map = handler->GetSession()->GetPlayer()->GetMap(); + return true; + } - if (!v->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_VEHICLE), map, handler->GetSession()->GetPlayer()->GetPhaseMask(), entry, id, handler->GetSession()->GetPlayer()->GetTeam(), x, y, z, o)) - { - delete v; - return false; - } + static bool HandleDebugSendLargePacketCommand(ChatHandler* handler, const char* /*args*/) + { + const char* stuffingString = "This is a dummy string to push the packet's size beyond 128000 bytes. "; + std::ostringstream ss; + while (ss.str().size() < 128000) + ss << stuffingString; + handler->SendSysMessage(ss.str().c_str()); + return true; + } - map->Add(v->ToCreature()); + static bool HandleDebugSendSetPhaseShiftCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - return true; - } + uint32 PhaseShift = atoi(args); + handler->GetSession()->SendSetPhaseShift(PhaseShift); + return true; + } - static bool HandleDebugSendLargePacketCommand(ChatHandler* handler, const char* /*args*/) - { - const char* stuffingString = "This is a dummy string to push the packet's size beyond 128000 bytes. "; - std::ostringstream ss; - while (ss.str().size() < 128000) - ss << stuffingString; - handler->SendSysMessage(ss.str().c_str()); - return true; - } + static bool HandleDebugGetItemValueCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - static bool HandleDebugSendSetPhaseShiftCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + char* e = strtok((char*)args, " "); + char* f = strtok(NULL, " "); - uint32 PhaseShift = atoi(args); - handler->GetSession()->SendSetPhaseShift(PhaseShift); - return true; - } + if (!e || !f) + return false; - static bool HandleDebugGetItemValueCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + uint32 guid = (uint32)atoi(e); + uint32 index = (uint32)atoi(f); - char* e = strtok((char*)args, " "); - char* f = strtok(NULL, " "); + Item *i = handler->GetSession()->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM)); - if (!e || !f) - return false; + if (!i) + return false; - uint32 guid = (uint32)atoi(e); - uint32 index = (uint32)atoi(f); + if (index >= i->GetValuesCount()) + return false; - Item *i = handler->GetSession()->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM)); + uint32 value = i->GetUInt32Value(index); - if (!i) - return false; + handler->PSendSysMessage("Item %u: value at %u is %u", guid, index, value); - if (index >= i->GetValuesCount()) - return false; + return true; + } - uint32 value = i->GetUInt32Value(index); + static bool HandleDebugSetItemValueCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - handler->PSendSysMessage("Item %u: value at %u is %u", guid, index, value); + char* e = strtok((char*)args, " "); + char* f = strtok(NULL, " "); + char* g = strtok(NULL, " "); - return true; - } + if (!e || !f || !g) + return false; - static bool HandleDebugSetItemValueCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + uint32 guid = (uint32)atoi(e); + uint32 index = (uint32)atoi(f); + uint32 value = (uint32)atoi(g); - char* e = strtok((char*)args, " "); - char* f = strtok(NULL, " "); - char* g = strtok(NULL, " "); + Item *i = handler->GetSession()->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM)); - if (!e || !f || !g) - return false; + if (!i) + return false; - uint32 guid = (uint32)atoi(e); - uint32 index = (uint32)atoi(f); - uint32 value = (uint32)atoi(g); + if (index >= i->GetValuesCount()) + return false; - Item *i = handler->GetSession()->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM)); + i->SetUInt32Value(index, value); - if (!i) - return false; + return true; + } - if (index >= i->GetValuesCount()) - return false; + static bool HandleDebugItemExpireCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - i->SetUInt32Value(index, value); + char* e = strtok((char*)args, " "); + if (!e) + return false; - return true; - } + uint32 guid = (uint32)atoi(e); - static bool HandleDebugItemExpireCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + Item *i = handler->GetSession()->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM)); - char* e = strtok((char*)args, " "); - if (!e) - return false; + if (!i) + return false; - uint32 guid = (uint32)atoi(e); + handler->GetSession()->GetPlayer()->DestroyItem(i->GetBagSlot(), i->GetSlot(), true); + sScriptMgr.OnItemExpire(handler->GetSession()->GetPlayer(), i->GetProto()); - Item *i = handler->GetSession()->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM)); + return true; + } - if (!i) - return false; + //show animation + static bool HandleDebugAnimCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - handler->GetSession()->GetPlayer()->DestroyItem(i->GetBagSlot(), i->GetSlot(), true); - sScriptMgr.OnItemExpire(handler->GetSession()->GetPlayer(), i->GetProto()); + uint32 anim_id = atoi((char*)args); + handler->GetSession()->GetPlayer()->HandleEmoteCommand(anim_id); + return true; + } - return true; + static bool HandleDebugSetAuraStateCommand(ChatHandler* handler, const char* args) + { + if (!*args) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; } - //show animation - static bool HandleDebugAnimCommand(ChatHandler* handler, const char* args) + Unit* unit = handler->getSelectedUnit(); + if (!unit) { - if (!*args) - return false; + handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } - uint32 anim_id = atoi((char*)args); - handler->GetSession()->GetPlayer()->HandleEmoteCommand(anim_id); + int32 state = atoi((char*)args); + if (!state) + { + // reset all states + for (int i = 1; i <= 32; ++i) + unit->ModifyAuraState(AuraState(i),false); return true; } - static bool HandleDebugSetAuraStateCommand(ChatHandler* handler, const char* args) - { - if (!*args) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + unit->ModifyAuraState(AuraState(abs(state)),state > 0); + return true; + } - Unit* unit = handler->getSelectedUnit(); - if (!unit) - { - handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + static bool HandleDebugSetValueCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - int32 state = atoi((char*)args); - if (!state) - { - // reset all states - for (int i = 1; i <= 32; ++i) - unit->ModifyAuraState(AuraState(i),false); - return true; - } + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); + char* pz = strtok(NULL, " "); - unit->ModifyAuraState(AuraState(abs(state)),state > 0); - return true; - } + if (!px || !py) + return false; - static bool HandleDebugSetValueCommand(ChatHandler* handler, const char* args) + WorldObject* target = handler->getSelectedObject(); + if (!target) { - if (!*args) - return false; + handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* pz = strtok(NULL, " "); + uint64 guid = target->GetGUID(); - if (!px || !py) - return false; + uint32 Opcode = (uint32)atoi(px); + if (Opcode >= target->GetValuesCount()) + { + handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); + return false; + } + uint32 iValue; + float fValue; + bool isint32 = true; + if (pz) + isint32 = (bool)atoi(pz); + if (isint32) + { + iValue = (uint32)atoi(py); + sLog.outDebug(handler->GetTrinityString(LANG_SET_UINT), GUID_LOPART(guid), Opcode, iValue); + target->SetUInt32Value(Opcode , iValue); + handler->PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), Opcode,iValue); + } + else + { + fValue = (float)atof(py); + sLog.outDebug(handler->GetTrinityString(LANG_SET_FLOAT), GUID_LOPART(guid), Opcode, fValue); + target->SetFloatValue(Opcode , fValue); + handler->PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), Opcode,fValue); + } - WorldObject* target = handler->getSelectedObject(); - if (!target) - { - handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + return true; + } - uint64 guid = target->GetGUID(); + static bool HandleDebugGetValueCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - uint32 Opcode = (uint32)atoi(px); - if (Opcode >= target->GetValuesCount()) - { - handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); - return false; - } - uint32 iValue; - float fValue; - bool isint32 = true; - if (pz) - isint32 = (bool)atoi(pz); - if (isint32) - { - iValue = (uint32)atoi(py); - sLog.outDebug(handler->GetTrinityString(LANG_SET_UINT), GUID_LOPART(guid), Opcode, iValue); - target->SetUInt32Value(Opcode , iValue); - handler->PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), Opcode,iValue); - } - else - { - fValue = (float)atof(py); - sLog.outDebug(handler->GetTrinityString(LANG_SET_FLOAT), GUID_LOPART(guid), Opcode, fValue); - target->SetFloatValue(Opcode , fValue); - handler->PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), Opcode,fValue); - } + char* px = strtok((char*)args, " "); + char* pz = strtok(NULL, " "); - return true; + if (!px) + return false; + + Unit* target = handler->getSelectedUnit(); + if (!target) + { + handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + handler->SetSentErrorMessage(true); + return false; } - static bool HandleDebugGetValueCommand(ChatHandler* handler, const char* args) + uint64 guid = target->GetGUID(); + + uint32 Opcode = (uint32)atoi(px); + if (Opcode >= target->GetValuesCount()) { - if (!*args) - return false; + handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); + return false; + } + uint32 iValue; + float fValue; + bool isint32 = true; + if (pz) + isint32 = (bool)atoi(pz); - char* px = strtok((char*)args, " "); - char* pz = strtok(NULL, " "); + if (isint32) + { + iValue = target->GetUInt32Value(Opcode); + sLog.outDebug(handler->GetTrinityString(LANG_GET_UINT), GUID_LOPART(guid), Opcode, iValue); + handler->PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue); + } + else + { + fValue = target->GetFloatValue(Opcode); + sLog.outDebug(handler->GetTrinityString(LANG_GET_FLOAT), GUID_LOPART(guid), Opcode, fValue); + handler->PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue); + } - if (!px) - return false; + return true; + } - Unit* target = handler->getSelectedUnit(); - if (!target) - { - handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + static bool HandleDebugMod32ValueCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - uint64 guid = target->GetGUID(); + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); - uint32 Opcode = (uint32)atoi(px); - if (Opcode >= target->GetValuesCount()) - { - handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); - return false; - } - uint32 iValue; - float fValue; - bool isint32 = true; - if (pz) - isint32 = (bool)atoi(pz); + if (!px || !py) + return false; - if (isint32) - { - iValue = target->GetUInt32Value(Opcode); - sLog.outDebug(handler->GetTrinityString(LANG_GET_UINT), GUID_LOPART(guid), Opcode, iValue); - handler->PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue); - } - else - { - fValue = target->GetFloatValue(Opcode); - sLog.outDebug(handler->GetTrinityString(LANG_GET_FLOAT), GUID_LOPART(guid), Opcode, fValue); - handler->PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue); - } + uint32 Opcode = (uint32)atoi(px); + int Value = atoi(py); - return true; + if (Opcode >= handler->GetSession()->GetPlayer()->GetValuesCount()) + { + handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, handler->GetSession()->GetPlayer()->GetGUIDLow(), handler->GetSession()->GetPlayer()->GetValuesCount()); + return false; } - static bool HandleDebugMod32ValueCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + sLog.outDebug(handler->GetTrinityString(LANG_CHANGE_32BIT), Opcode, Value); - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); + int CurrentValue = (int)handler->GetSession()->GetPlayer()->GetUInt32Value(Opcode); - if (!px || !py) - return false; + CurrentValue += Value; + handler->GetSession()->GetPlayer()->SetUInt32Value(Opcode , (uint32)CurrentValue); - uint32 Opcode = (uint32)atoi(px); - int Value = atoi(py); + handler->PSendSysMessage(LANG_CHANGE_32BIT_FIELD, Opcode,CurrentValue); - if (Opcode >= handler->GetSession()->GetPlayer()->GetValuesCount()) - { - handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, handler->GetSession()->GetPlayer()->GetGUIDLow(), handler->GetSession()->GetPlayer()->GetValuesCount()); - return false; - } + return true; + } - sLog.outDebug(handler->GetTrinityString(LANG_CHANGE_32BIT), Opcode, Value); + static bool HandleDebugUpdateCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - int CurrentValue = (int)handler->GetSession()->GetPlayer()->GetUInt32Value(Opcode); + uint32 updateIndex; + uint32 value; - CurrentValue += Value; - handler->GetSession()->GetPlayer()->SetUInt32Value(Opcode , (uint32)CurrentValue); + char* pUpdateIndex = strtok((char*)args, " "); - handler->PSendSysMessage(LANG_CHANGE_32BIT_FIELD, Opcode,CurrentValue); + Unit* chr = handler->getSelectedUnit(); + if (chr == NULL) + { + handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } + if (!pUpdateIndex) + { return true; } - - static bool HandleDebugUpdateCommand(ChatHandler* handler, const char* args) + updateIndex = atoi(pUpdateIndex); + //check updateIndex + if (chr->GetTypeId() == TYPEID_PLAYER) { - if (!*args) - return false; - - uint32 updateIndex; - uint32 value; - - char* pUpdateIndex = strtok((char*)args, " "); - - Unit* chr = handler->getSelectedUnit(); - if (chr == NULL) - { - handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + if (updateIndex >= PLAYER_END) return true; + } + else + { + if (updateIndex >= UNIT_END) return true; + } - if (!pUpdateIndex) - { - return true; - } - updateIndex = atoi(pUpdateIndex); - //check updateIndex - if (chr->GetTypeId() == TYPEID_PLAYER) - { - if (updateIndex >= PLAYER_END) return true; - } - else - { - if (updateIndex >= UNIT_END) return true; - } + char* pvalue = strtok(NULL, " "); + if (!pvalue) + { + value=chr->GetUInt32Value(updateIndex); - char* pvalue = strtok(NULL, " "); - if (!pvalue) - { - value=chr->GetUInt32Value(updateIndex); + handler->PSendSysMessage(LANG_UPDATE, chr->GetGUIDLow(),updateIndex,value); + return true; + } - handler->PSendSysMessage(LANG_UPDATE, chr->GetGUIDLow(),updateIndex,value); - return true; - } + value=atoi(pvalue); - value=atoi(pvalue); + handler->PSendSysMessage(LANG_UPDATE_CHANGE, chr->GetGUIDLow(),updateIndex,value); - handler->PSendSysMessage(LANG_UPDATE_CHANGE, chr->GetGUIDLow(),updateIndex,value); + chr->SetUInt32Value(updateIndex,value); - chr->SetUInt32Value(updateIndex,value); + return true; + } + static bool HandleDebugSet32BitCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - return true; + WorldObject* target = handler->getSelectedObject(); + if (!target) + { + handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + handler->SetSentErrorMessage(true); + return false; } -static bool HandleDebugSet32BitCommand(ChatHandler* handler, const char* args) -{ - if (!*args) - return false; - WorldObject* target = handler->getSelectedObject(); - if (!target) - { - handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); + if (!px || !py) + return false; - if (!px || !py) - return false; + uint32 Opcode = (uint32)atoi(px); + uint32 Value = (uint32)atoi(py); + if (Value > 32) //uint32 = 32 bits + return false; - uint32 Opcode = (uint32)atoi(px); - uint32 Value = (uint32)atoi(py); - if (Value > 32) //uint32 = 32 bits - return false; + sLog.outDebug(handler->GetTrinityString(LANG_SET_32BIT), Opcode, Value); - sLog.outDebug(handler->GetTrinityString(LANG_SET_32BIT), Opcode, Value); + uint32 iValue = Value ? 1 << (Value - 1) : 0; + target->SetUInt32Value(Opcode , iValue); - uint32 iValue = Value ? 1 << (Value - 1) : 0; - target->SetUInt32Value(Opcode , iValue); - - handler->PSendSysMessage(LANG_SET_32BIT_FIELD, Opcode, iValue); - return true; -} + handler->PSendSysMessage(LANG_SET_32BIT_FIELD, Opcode, iValue); + return true; + } }; void AddSC_debug_commandscript() diff --git a/src/server/scripts/Commands/cs_event.cpp b/src/server/scripts/Commands/cs_event.cpp index ed445fdccce..2ef88bf8738 100644 --- a/src/server/scripts/Commands/cs_event.cpp +++ b/src/server/scripts/Commands/cs_event.cpp @@ -28,187 +28,187 @@ EndScriptData */ class event_commandscript : public CommandScript { - public: - event_commandscript() : CommandScript("event_commandscript") { } +public: + event_commandscript() : CommandScript("event_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const + { + static ChatCommand eventCommandTable[] = { - static ChatCommand eventCommandTable[] = - { - { "activelist", SEC_GAMEMASTER, true, &HandleEventActiveListCommand, "", NULL }, - { "start", SEC_GAMEMASTER, true, &HandleEventStartCommand, "", NULL }, - { "stop", SEC_GAMEMASTER, true, &HandleEventStopCommand, "", NULL }, - { "", SEC_GAMEMASTER, true, &HandleEventInfoCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand commandTable[] = - { - { "event", SEC_GAMEMASTER, false, NULL, "", eventCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - return commandTable; - } + { "activelist", SEC_GAMEMASTER, true, &HandleEventActiveListCommand, "", NULL }, + { "start", SEC_GAMEMASTER, true, &HandleEventStartCommand, "", NULL }, + { "stop", SEC_GAMEMASTER, true, &HandleEventStopCommand, "", NULL }, + { "", SEC_GAMEMASTER, true, &HandleEventInfoCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "event", SEC_GAMEMASTER, false, NULL, "", eventCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } + + static bool HandleEventActiveListCommand(ChatHandler* handler, const char* /*args*/) + { + uint32 counter = 0; + + GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap(); + GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList(); - static bool HandleEventActiveListCommand(ChatHandler* handler, const char* /*args*/) + char const* active = handler->GetTrinityString(LANG_ACTIVE); + + for (GameEventMgr::ActiveEvents::const_iterator itr = activeEvents.begin(); itr != activeEvents.end(); ++itr) { - uint32 counter = 0; + uint32 event_id = *itr; + GameEventData const& eventData = events[event_id]; - GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap(); - GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList(); + if (handler->GetSession()) + handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT,event_id,event_id,eventData.description.c_str(),active); + else + handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE,event_id,eventData.description.c_str(),active); + + ++counter; + } - char const* active = handler->GetTrinityString(LANG_ACTIVE); + if (counter == 0) + handler->SendSysMessage(LANG_NOEVENTFOUND); + handler->SetSentErrorMessage(true); - for (GameEventMgr::ActiveEvents::const_iterator itr = activeEvents.begin(); itr != activeEvents.end(); ++itr) - { - uint32 event_id = *itr; - GameEventData const& eventData = events[event_id]; + return true; + } - if (handler->GetSession()) - handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT,event_id,event_id,eventData.description.c_str(),active); - else - handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE,event_id,eventData.description.c_str(),active); + static bool HandleEventInfoCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - ++counter; - } + // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hgameevent"); + if (!cId) + return false; - if (counter == 0) - handler->SendSysMessage(LANG_NOEVENTFOUND); - handler->SetSentErrorMessage(true); + uint32 event_id = atoi(cId); - return true; + GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap(); + + if (event_id >=events.size()) + { + handler->SendSysMessage(LANG_EVENT_NOT_EXIST); + handler->SetSentErrorMessage(true); + return false; } - static bool HandleEventInfoCommand(ChatHandler* handler, const char* args) + GameEventData const& eventData = events[event_id]; + if (!eventData.isValid()) { - if (!*args) - return false; + handler->SendSysMessage(LANG_EVENT_NOT_EXIST); + handler->SetSentErrorMessage(true); + return false; + } - // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args,"Hgameevent"); - if (!cId) - return false; + GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList(); + bool active = activeEvents.find(event_id) != activeEvents.end(); + char const* activeStr = active ? handler->GetTrinityString(LANG_ACTIVE) : ""; - uint32 event_id = atoi(cId); + std::string startTimeStr = TimeToTimestampStr(eventData.start); + std::string endTimeStr = TimeToTimestampStr(eventData.end); - GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap(); + uint32 delay = sGameEventMgr.NextCheck(event_id); + time_t nextTime = time(NULL)+delay; + std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(NULL)+delay) : "-"; - if (event_id >=events.size()) - { - handler->SendSysMessage(LANG_EVENT_NOT_EXIST); - handler->SetSentErrorMessage(true); - return false; - } + std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE); + std::string lengthStr = secsToTimeString(eventData.length * MINUTE); - GameEventData const& eventData = events[event_id]; - if (!eventData.isValid()) - { - handler->SendSysMessage(LANG_EVENT_NOT_EXIST); - handler->SetSentErrorMessage(true); - return false; - } - - GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList(); - bool active = activeEvents.find(event_id) != activeEvents.end(); - char const* activeStr = active ? handler->GetTrinityString(LANG_ACTIVE) : ""; - - std::string startTimeStr = TimeToTimestampStr(eventData.start); - std::string endTimeStr = TimeToTimestampStr(eventData.end); - - uint32 delay = sGameEventMgr.NextCheck(event_id); - time_t nextTime = time(NULL)+delay; - std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(NULL)+delay) : "-"; - - std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE); - std::string lengthStr = secsToTimeString(eventData.length * MINUTE); - - handler->PSendSysMessage(LANG_EVENT_INFO,event_id,eventData.description.c_str(),activeStr, - startTimeStr.c_str(),endTimeStr.c_str(),occurenceStr.c_str(),lengthStr.c_str(), - nextStr.c_str()); - return true; - } + handler->PSendSysMessage(LANG_EVENT_INFO,event_id,eventData.description.c_str(),activeStr, + startTimeStr.c_str(),endTimeStr.c_str(),occurenceStr.c_str(),lengthStr.c_str(), + nextStr.c_str()); + return true; + } - static bool HandleEventStartCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + static bool HandleEventStartCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args,"Hgameevent"); - if (!cId) - return false; + // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hgameevent"); + if (!cId) + return false; - int32 event_id = atoi(cId); + int32 event_id = atoi(cId); - GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap(); + GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap(); - if (event_id < 1 || uint32(event_id) >= events.size()) - { - handler->SendSysMessage(LANG_EVENT_NOT_EXIST); - handler->SetSentErrorMessage(true); - return false; - } + if (event_id < 1 || uint32(event_id) >= events.size()) + { + handler->SendSysMessage(LANG_EVENT_NOT_EXIST); + handler->SetSentErrorMessage(true); + return false; + } - GameEventData const& eventData = events[event_id]; - if (!eventData.isValid()) - { - handler->SendSysMessage(LANG_EVENT_NOT_EXIST); - handler->SetSentErrorMessage(true); - return false; - } - - GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList(); - if (activeEvents.find(event_id) != activeEvents.end()) - { - handler->PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE,event_id); - handler->SetSentErrorMessage(true); - return false; - } - - sGameEventMgr.StartEvent(event_id,true); - return true; + GameEventData const& eventData = events[event_id]; + if (!eventData.isValid()) + { + handler->SendSysMessage(LANG_EVENT_NOT_EXIST); + handler->SetSentErrorMessage(true); + return false; } - static bool HandleEventStopCommand(ChatHandler* handler, const char* args) + GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList(); + if (activeEvents.find(event_id) != activeEvents.end()) { - if (!*args) - return false; + handler->PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE,event_id); + handler->SetSentErrorMessage(true); + return false; + } - // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args,"Hgameevent"); - if (!cId) - return false; + sGameEventMgr.StartEvent(event_id,true); + return true; + } - int32 event_id = atoi(cId); + static bool HandleEventStopCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap(); + // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hgameevent"); + if (!cId) + return false; - if (event_id < 1 || uint32(event_id) >= events.size()) - { - handler->SendSysMessage(LANG_EVENT_NOT_EXIST); - handler->SetSentErrorMessage(true); - return false; - } + int32 event_id = atoi(cId); - GameEventData const& eventData = events[event_id]; - if (!eventData.isValid()) - { - handler->SendSysMessage(LANG_EVENT_NOT_EXIST); - handler->SetSentErrorMessage(true); - return false; - } - - GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList(); - - if (activeEvents.find(event_id) == activeEvents.end()) - { - handler->PSendSysMessage(LANG_EVENT_NOT_ACTIVE,event_id); - handler->SetSentErrorMessage(true); - return false; - } - - sGameEventMgr.StopEvent(event_id,true); - return true; + GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap(); + + if (event_id < 1 || uint32(event_id) >= events.size()) + { + handler->SendSysMessage(LANG_EVENT_NOT_EXIST); + handler->SetSentErrorMessage(true); + return false; } + + GameEventData const& eventData = events[event_id]; + if (!eventData.isValid()) + { + handler->SendSysMessage(LANG_EVENT_NOT_EXIST); + handler->SetSentErrorMessage(true); + return false; + } + + GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList(); + + if (activeEvents.find(event_id) == activeEvents.end()) + { + handler->PSendSysMessage(LANG_EVENT_NOT_ACTIVE,event_id); + handler->SetSentErrorMessage(true); + return false; + } + + sGameEventMgr.StopEvent(event_id,true); + return true; + } }; void AddSC_event_commandscript() diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp index 3bbd560ef0b..f6b699bdb5a 100644 --- a/src/server/scripts/Commands/cs_gm.cpp +++ b/src/server/scripts/Commands/cs_gm.cpp @@ -28,232 +28,232 @@ EndScriptData */ class gm_commandscript : public CommandScript { - public: - gm_commandscript() : CommandScript("gm_commandscript") { } +public: + gm_commandscript() : CommandScript("gm_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const + { + static ChatCommand gmCommandTable[] = { - static ChatCommand gmCommandTable[] = - { - { "chat", SEC_MODERATOR, false, &HandleGMChatCommand, "", NULL }, - { "fly", SEC_ADMINISTRATOR, false, &HandleGMFlyCommand, "", NULL }, - { "ingame", SEC_PLAYER, true, &HandleGMListIngameCommand, "", NULL }, - { "list", SEC_ADMINISTRATOR, true, &HandleGMListFullCommand, "", NULL }, - { "visible", SEC_MODERATOR, false, &HandleGMVisibleCommand, "", NULL }, - { "", SEC_MODERATOR, false, &HandleGMCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand commandTable[] = - { - { "gm", SEC_MODERATOR, false, NULL, "", gmCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - return commandTable; - } - - // Enables or disables hiding of the staff badge - static bool HandleGMChatCommand(ChatHandler* handler, const char* args) + { "chat", SEC_MODERATOR, false, &HandleGMChatCommand, "", NULL }, + { "fly", SEC_ADMINISTRATOR, false, &HandleGMFlyCommand, "", NULL }, + { "ingame", SEC_PLAYER, true, &HandleGMListIngameCommand, "", NULL }, + { "list", SEC_ADMINISTRATOR, true, &HandleGMListFullCommand, "", NULL }, + { "visible", SEC_MODERATOR, false, &HandleGMVisibleCommand, "", NULL }, + { "", SEC_MODERATOR, false, &HandleGMCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = { - if (!*args) - { - if (handler->GetSession()->GetPlayer()->isGMChat()) - handler->GetSession()->SendNotification(LANG_GM_CHAT_ON); - else - handler->GetSession()->SendNotification(LANG_GM_CHAT_OFF); - return true; - } - - std::string argstr = (char*)args; + { "gm", SEC_MODERATOR, false, NULL, "", gmCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } - if (argstr == "on") - { - handler->GetSession()->GetPlayer()->SetGMChat(true); + // Enables or disables hiding of the staff badge + static bool HandleGMChatCommand(ChatHandler* handler, const char* args) + { + if (!*args) + { + if (handler->GetSession()->GetPlayer()->isGMChat()) handler->GetSession()->SendNotification(LANG_GM_CHAT_ON); - return true; - } - - if (argstr == "off") - { - handler->GetSession()->GetPlayer()->SetGMChat(false); + else handler->GetSession()->SendNotification(LANG_GM_CHAT_OFF); - return true; - } - - handler->SendSysMessage(LANG_USE_BOL); - handler->SetSentErrorMessage(true); - return false; + return true; } - static bool HandleGMFlyCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; - - Player *target = handler->getSelectedPlayer(); - if (!target) - target = handler->GetSession()->GetPlayer(); + std::string argstr = (char*)args; - WorldPacket data(12); - if (strncmp(args, "on", 3) == 0) - data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); - else if (strncmp(args, "off", 4) == 0) - data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); - else - { - handler->SendSysMessage(LANG_USE_BOL); - return false; - } - data.append(target->GetPackGUID()); - data << uint32(0); // unknown - target->SendMessageToSet(&data, true); - handler->PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, handler->GetNameLink(target).c_str(), args); + if (argstr == "on") + { + handler->GetSession()->GetPlayer()->SetGMChat(true); + handler->GetSession()->SendNotification(LANG_GM_CHAT_ON); return true; } - static bool HandleGMListIngameCommand(ChatHandler* handler, const char* /*args*/) + if (argstr == "off") { - bool first = true; - bool footer = false; - - ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, *HashMapHolder<Player>::GetLock(), true); - HashMapHolder<Player>::MapType &m = sObjectAccessor.GetPlayers(); - for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) - { - AccountTypes itr_sec = itr->second->GetSession()->GetSecurity(); - if ((itr->second->isGameMaster() || (itr_sec > SEC_PLAYER && itr_sec <= AccountTypes(sWorld.getIntConfig(CONFIG_GM_LEVEL_IN_GM_LIST)))) && - (!handler->GetSession() || itr->second->IsVisibleGloballyFor(handler->GetSession()->GetPlayer()))) - { - if (first) - { - first = false; - footer = true; - handler->SendSysMessage(LANG_GMS_ON_SRV); - handler->SendSysMessage("========================"); - } - const char* name = itr->second->GetName(); - uint8 security = itr_sec; - uint8 max = ((16 - strlen(name)) / 2); - uint8 max2 = max; - if (((max)+(max2)+(strlen(name))) == 16) - max2 = ((max)-1); - if (handler->GetSession()) - handler->PSendSysMessage("| %s GMLevel %u", name, security); - else - handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security); - } - } - if (footer) - handler->SendSysMessage("========================"); - if (first) - handler->SendSysMessage(LANG_GMS_NOT_LOGGED); + handler->GetSession()->GetPlayer()->SetGMChat(false); + handler->GetSession()->SendNotification(LANG_GM_CHAT_OFF); return true; } - /// Display the list of GMs - static bool HandleGMListFullCommand(ChatHandler* handler, const char* /*args*/) + handler->SendSysMessage(LANG_USE_BOL); + handler->SetSentErrorMessage(true); + return false; + } + + static bool HandleGMFlyCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; + + Player *target = handler->getSelectedPlayer(); + if (!target) + target = handler->GetSession()->GetPlayer(); + + WorldPacket data(12); + if (strncmp(args, "on", 3) == 0) + data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); + else if (strncmp(args, "off", 4) == 0) + data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); + else + { + handler->SendSysMessage(LANG_USE_BOL); + return false; + } + data.append(target->GetPackGUID()); + data << uint32(0); // unknown + target->SendMessageToSet(&data, true); + handler->PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, handler->GetNameLink(target).c_str(), args); + return true; + } + + static bool HandleGMListIngameCommand(ChatHandler* handler, const char* /*args*/) + { + bool first = true; + bool footer = false; + + ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, *HashMapHolder<Player>::GetLock(), true); + HashMapHolder<Player>::MapType &m = sObjectAccessor.GetPlayers(); + for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) { - ///- Get the accounts with GM Level >0 - QueryResult result = LoginDatabase.Query("SELECT a.username,aa.gmlevel FROM account a, account_access aa WHERE a.id=aa.id AND aa.gmlevel > 0"); - if (result) + AccountTypes itr_sec = itr->second->GetSession()->GetSecurity(); + if ((itr->second->isGameMaster() || (itr_sec > SEC_PLAYER && itr_sec <= AccountTypes(sWorld.getIntConfig(CONFIG_GM_LEVEL_IN_GM_LIST)))) && + (!handler->GetSession() || itr->second->IsVisibleGloballyFor(handler->GetSession()->GetPlayer()))) { - handler->SendSysMessage(LANG_GMLIST); - handler->SendSysMessage("========================"); - ///- Cycle through them. Display username and GM level - do + if (first) { - Field *fields = result->Fetch(); - const char* name = fields[0].GetCString(); - uint8 security = fields[1].GetUInt8(); - uint8 max = ((16 - strlen(name)) / 2); - uint8 max2 = max; - if (((max)+(max2)+(strlen(name))) == 16) - max2 = ((max)-1); - if (handler->GetSession()) - handler->PSendSysMessage("| %s GMLevel %u", name, security); - else - handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security); + first = false; + footer = true; + handler->SendSysMessage(LANG_GMS_ON_SRV); + handler->SendSysMessage("========================"); } - while (result->NextRow()); - - handler->SendSysMessage("========================"); + const char* name = itr->second->GetName(); + uint8 security = itr_sec; + uint8 max = ((16 - strlen(name)) / 2); + uint8 max2 = max; + if (((max)+(max2)+(strlen(name))) == 16) + max2 = ((max)-1); + if (handler->GetSession()) + handler->PSendSysMessage("| %s GMLevel %u", name, security); + else + handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security); } - else - handler->PSendSysMessage(LANG_GMLIST_EMPTY); - return true; } + if (footer) + handler->SendSysMessage("========================"); + if (first) + handler->SendSysMessage(LANG_GMS_NOT_LOGGED); + return true; + } - //Enable\Disable Invisible mode - static bool HandleGMVisibleCommand(ChatHandler* handler, const char* args) + /// Display the list of GMs + static bool HandleGMListFullCommand(ChatHandler* handler, const char* /*args*/) + { + ///- Get the accounts with GM Level >0 + QueryResult result = LoginDatabase.Query("SELECT a.username,aa.gmlevel FROM account a, account_access aa WHERE a.id=aa.id AND aa.gmlevel > 0"); + if (result) { - if (!*args) + handler->SendSysMessage(LANG_GMLIST); + handler->SendSysMessage("========================"); + ///- Cycle through them. Display username and GM level + do { - handler->PSendSysMessage(LANG_YOU_ARE, handler->GetSession()->GetPlayer()->isGMVisible() ? handler->GetTrinityString(LANG_VISIBLE) : handler->GetTrinityString(LANG_INVISIBLE)); - return true; + Field *fields = result->Fetch(); + const char* name = fields[0].GetCString(); + uint8 security = fields[1].GetUInt8(); + uint8 max = ((16 - strlen(name)) / 2); + uint8 max2 = max; + if (((max)+(max2)+(strlen(name))) == 16) + max2 = ((max)-1); + if (handler->GetSession()) + handler->PSendSysMessage("| %s GMLevel %u", name, security); + else + handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security); } + while (result->NextRow()); - std::string argstr = (char*)args; + handler->SendSysMessage("========================"); + } + else + handler->PSendSysMessage(LANG_GMLIST_EMPTY); + return true; + } - if (argstr == "on") - { - handler->GetSession()->GetPlayer()->SetGMVisible(true); - handler->GetSession()->SendNotification(LANG_INVISIBLE_VISIBLE); - return true; - } + //Enable\Disable Invisible mode + static bool HandleGMVisibleCommand(ChatHandler* handler, const char* args) + { + if (!*args) + { + handler->PSendSysMessage(LANG_YOU_ARE, handler->GetSession()->GetPlayer()->isGMVisible() ? handler->GetTrinityString(LANG_VISIBLE) : handler->GetTrinityString(LANG_INVISIBLE)); + return true; + } - if (argstr == "off") - { - handler->GetSession()->SendNotification(LANG_INVISIBLE_INVISIBLE); - handler->GetSession()->GetPlayer()->SetGMVisible(false); - return true; - } + std::string argstr = (char*)args; - handler->SendSysMessage(LANG_USE_BOL); - handler->SetSentErrorMessage(true); - return false; + if (argstr == "on") + { + handler->GetSession()->GetPlayer()->SetGMVisible(true); + handler->GetSession()->SendNotification(LANG_INVISIBLE_VISIBLE); + return true; } - //Enable\Disable GM Mode - static bool HandleGMCommand(ChatHandler* handler, const char* args) + if (argstr == "off") { - if (!*args) - { - if (handler->GetSession()->GetPlayer()->isGameMaster()) - handler->GetSession()->SendNotification(LANG_GM_ON); - else - handler->GetSession()->SendNotification(LANG_GM_OFF); - return true; - } + handler->GetSession()->SendNotification(LANG_INVISIBLE_INVISIBLE); + handler->GetSession()->GetPlayer()->SetGMVisible(false); + return true; + } - std::string argstr = (char*)args; + handler->SendSysMessage(LANG_USE_BOL); + handler->SetSentErrorMessage(true); + return false; + } - if (argstr == "on") - { - handler->GetSession()->GetPlayer()->SetGameMaster(true); + //Enable\Disable GM Mode + static bool HandleGMCommand(ChatHandler* handler, const char* args) + { + if (!*args) + { + if (handler->GetSession()->GetPlayer()->isGameMaster()) handler->GetSession()->SendNotification(LANG_GM_ON); - handler->GetSession()->GetPlayer()->UpdateTriggerVisibility(); - #ifdef _DEBUG_VMAPS - VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); - vMapManager->processCommand("stoplog"); - #endif - return true; - } - - if (argstr == "off") - { - handler->GetSession()->GetPlayer()->SetGameMaster(false); + else handler->GetSession()->SendNotification(LANG_GM_OFF); - handler->GetSession()->GetPlayer()->UpdateTriggerVisibility(); - #ifdef _DEBUG_VMAPS - VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); - vMapManager->processCommand("startlog"); - #endif - return true; - } + return true; + } - handler->SendSysMessage(LANG_USE_BOL); - handler->SetSentErrorMessage(true); - return false; + std::string argstr = (char*)args; + + if (argstr == "on") + { + handler->GetSession()->GetPlayer()->SetGameMaster(true); + handler->GetSession()->SendNotification(LANG_GM_ON); + handler->GetSession()->GetPlayer()->UpdateTriggerVisibility(); +#ifdef _DEBUG_VMAPS + VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); + vMapManager->processCommand("stoplog"); +#endif + return true; } + + if (argstr == "off") + { + handler->GetSession()->GetPlayer()->SetGameMaster(false); + handler->GetSession()->SendNotification(LANG_GM_OFF); + handler->GetSession()->GetPlayer()->UpdateTriggerVisibility(); +#ifdef _DEBUG_VMAPS + VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); + vMapManager->processCommand("startlog"); +#endif + return true; + } + + handler->SendSysMessage(LANG_USE_BOL); + handler->SetSentErrorMessage(true); + return false; + } }; void AddSC_gm_commandscript() diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp index 08a7e992f8c..7d4591fe70b 100644 --- a/src/server/scripts/Commands/cs_go.cpp +++ b/src/server/scripts/Commands/cs_go.cpp @@ -30,587 +30,576 @@ EndScriptData */ class go_commandscript : public CommandScript { - public: - go_commandscript() : CommandScript("go_commandscript") { } +public: + go_commandscript() : CommandScript("go_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const + { + static ChatCommand goCommandTable[] = { - static ChatCommand goCommandTable[] = - { - { "creature", SEC_MODERATOR, false, &HandleGoCreatureCommand, "", NULL }, - { "graveyard", SEC_MODERATOR, false, &HandleGoGraveyardCommand, "", NULL }, - { "grid", SEC_MODERATOR, false, &HandleGoGridCommand, "", NULL }, - { "object", SEC_MODERATOR, false, &HandleGoObjectCommand, "", NULL }, - { "taxinode", SEC_MODERATOR, false, &HandleGoTaxinodeCommand, "", NULL }, - { "trigger", SEC_MODERATOR, false, &HandleGoTriggerCommand, "", NULL }, - { "zonexy", SEC_MODERATOR, false, &HandleGoZoneXYCommand, "", NULL }, - { "xy", SEC_MODERATOR, false, &HandleGoXYCommand, "", NULL }, - { "xyz", SEC_MODERATOR, false, &HandleGoXYZCommand, "", NULL }, - { "ticket", SEC_MODERATOR, false, &HandleGoTicketCommand, "", NULL }, - { "", SEC_MODERATOR, false, &HandleGoXYZCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - - static ChatCommand commandTable[] = - { - { "go", SEC_MODERATOR, false, NULL, "", goCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - return commandTable; - } - - /** \brief Teleport the GM to the specified creature - * - * .gocreature <GUID> --> TP using creature.guid - * .gocreature azuregos --> TP player to the mob with this name - * Warning: If there is more than one mob with this name - * you will be teleported to the first one that is found. - * .gocreature id 6109 --> TP player to the mob, that has this creature_template.entry - * Warning: If there is more than one mob with this "id" - * you will be teleported to the first one that is found. - */ - //teleport to creature - static bool HandleGoCreatureCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; - Player* _player = handler->GetSession()->GetPlayer(); + { "creature", SEC_MODERATOR, false, &HandleGoCreatureCommand, "", NULL }, + { "graveyard", SEC_MODERATOR, false, &HandleGoGraveyardCommand, "", NULL }, + { "grid", SEC_MODERATOR, false, &HandleGoGridCommand, "", NULL }, + { "object", SEC_MODERATOR, false, &HandleGoObjectCommand, "", NULL }, + { "taxinode", SEC_MODERATOR, false, &HandleGoTaxinodeCommand, "", NULL }, + { "trigger", SEC_MODERATOR, false, &HandleGoTriggerCommand, "", NULL }, + { "zonexy", SEC_MODERATOR, false, &HandleGoZoneXYCommand, "", NULL }, + { "xy", SEC_MODERATOR, false, &HandleGoXYCommand, "", NULL }, + { "xyz", SEC_MODERATOR, false, &HandleGoXYZCommand, "", NULL }, + { "ticket", SEC_MODERATOR, false, &HandleGoTicketCommand, "", NULL }, + { "", SEC_MODERATOR, false, &HandleGoXYZCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + + static ChatCommand commandTable[] = + { + { "go", SEC_MODERATOR, false, NULL, "", goCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } + /** \brief Teleport the GM to the specified creature + * + * .gocreature <GUID> --> TP using creature.guid + * .gocreature azuregos --> TP player to the mob with this name + * Warning: If there is more than one mob with this name + * you will be teleported to the first one that is found. + * .gocreature id 6109 --> TP player to the mob, that has this creature_template.entry + * Warning: If there is more than one mob with this "id" + * you will be teleported to the first one that is found. + */ + //teleport to creature + static bool HandleGoCreatureCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; + Player* _player = handler->GetSession()->GetPlayer(); + + // "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r + char* pParam1 = handler->extractKeyFromLink((char*)args,"Hcreature"); + if (!pParam1) + return false; + + std::ostringstream whereClause; + + // User wants to teleport to the NPC's template entry + if (strcmp(pParam1, "id") == 0) + { + //sLog.outError("DEBUG: ID found"); - // "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r - char* pParam1 = handler->extractKeyFromLink((char*)args,"Hcreature"); - if (!pParam1) + // Get the "creature_template.entry" + // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r + char* tail = strtok(NULL,""); + if (!tail) return false; - - std::ostringstream whereClause; - - // User wants to teleport to the NPC's template entry - if (strcmp(pParam1, "id") == 0) - { - //sLog.outError("DEBUG: ID found"); - - // Get the "creature_template.entry" - // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r - char* tail = strtok(NULL,""); - if (!tail) - return false; - char* cId = handler->extractKeyFromLink(tail,"Hcreature_entry"); - if (!cId) - return false; - - int32 tEntry = atoi(cId); - //sLog.outError("DEBUG: ID value: %d", tEntry); - if (!tEntry) - return false; - - whereClause << "WHERE id = '" << tEntry << "'"; - } - else - { - //sLog.outError("DEBUG: ID *not found*"); - - int32 guid = atoi(pParam1); - - // Number is invalid - maybe the user specified the mob's name - if (!guid) - { - std::string name = pParam1; - WorldDatabase.escape_string(name); - whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name "_LIKE_" '" << name << "'"; - } - else - { - whereClause << "WHERE guid = '" << guid << "'"; - } - } - //sLog.outError("DEBUG: %s", whereClause.c_str()); - - QueryResult result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map FROM creature %s", whereClause.str().c_str()); - if (!result) - { - handler->SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND); - handler->SetSentErrorMessage(true); + char* cId = handler->extractKeyFromLink(tail,"Hcreature_entry"); + if (!cId) return false; - } - if (result->GetRowCount() > 1) - handler->SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE); - - Field *fields = result->Fetch(); - float x = fields[0].GetFloat(); - float y = fields[1].GetFloat(); - float z = fields[2].GetFloat(); - float ort = fields[3].GetFloat(); - int mapid = fields[4].GetUInt16(); - if (!MapManager::IsValidMapCoord(mapid,x,y,z,ort)) - { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - handler->SetSentErrorMessage(true); + int32 tEntry = atoi(cId); + //sLog.outError("DEBUG: ID value: %d", tEntry); + if (!tEntry) return false; - } - - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - _player->TeleportTo(mapid, x, y, z, ort); - return true; + whereClause << "WHERE id = '" << tEntry << "'"; } - - static bool HandleGoGraveyardCommand(ChatHandler* handler, const char* args) + else { - Player* _player = handler->GetSession()->GetPlayer(); - - if (!*args) - return false; + //sLog.outError("DEBUG: ID *not found*"); - char *gyId = strtok((char*)args, " "); - if (!gyId) - return false; - - int32 i_gyId = atoi(gyId); - - if (!i_gyId) - return false; + int32 guid = atoi(pParam1); - WorldSafeLocsEntry const* gy = sWorldSafeLocsStore.LookupEntry(i_gyId); - if (!gy) - { - handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST,i_gyId); - handler->SetSentErrorMessage(true); - return false; - } - - if (!MapManager::IsValidMapCoord(gy->map_id,gy->x,gy->y,gy->z)) + // Number is invalid - maybe the user specified the mob's name + if (!guid) { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,gy->x,gy->y,gy->map_id); - handler->SetSentErrorMessage(true); - return false; + std::string name = pParam1; + WorldDatabase.escape_string(name); + whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name "_LIKE_" '" << name << "'"; } - - // stop flight if need - if (_player->isInFlight()) + else { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); + whereClause << "WHERE guid = '" << guid << "'"; } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - _player->TeleportTo(gy->map_id, gy->x, gy->y, gy->z, _player->GetOrientation()); - return true; } + //sLog.outError("DEBUG: %s", whereClause.c_str()); - //teleport to grid - static bool HandleGoGridCommand(ChatHandler* handler, const char* args) + QueryResult result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map FROM creature %s", whereClause.str().c_str()); + if (!result) { - if (!*args) return false; - Player* _player = handler->GetSession()->GetPlayer(); - - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* pmapid = strtok(NULL, " "); - - if (!px || !py) - return false; - - float grid_x = (float)atof(px); - float grid_y = (float)atof(py); - uint32 mapid; - if (pmapid) - mapid = (uint32)atoi(pmapid); - else mapid = _player->GetMapId(); - - // center of grid - float x = (grid_x-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; - float y = (grid_y-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; - - if (!MapManager::IsValidMapCoord(mapid,x,y)) - { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - handler->SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); + handler->SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND); + handler->SetSentErrorMessage(true); + return false; + } + if (result->GetRowCount() > 1) + handler->SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE); - Map const *map = sMapMgr.CreateBaseMap(mapid); - float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); - _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); + Field *fields = result->Fetch(); + float x = fields[0].GetFloat(); + float y = fields[1].GetFloat(); + float z = fields[2].GetFloat(); + float ort = fields[3].GetFloat(); + int mapid = fields[4].GetUInt16(); - return true; + if (!MapManager::IsValidMapCoord(mapid,x,y,z,ort)) + { + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); + handler->SetSentErrorMessage(true); + return false; } - //teleport to gameobject - static bool HandleGoObjectCommand(ChatHandler* handler, const char* args) + // stop flight if need + if (_player->isInFlight()) { - if (!*args) - return false; + _player->GetMotionMaster()->MovementExpired(); + _player->CleanupAfterTaxiFlight(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); - Player* _player = handler->GetSession()->GetPlayer(); + _player->TeleportTo(mapid, x, y, z, ort); + return true; + } + static bool HandleGoGraveyardCommand(ChatHandler* handler, const char* args) + { + Player* _player = handler->GetSession()->GetPlayer(); - // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); - if (!cId) - return false; + if (!*args) + return false; - int32 guid = atoi(cId); - if (!guid) - return false; + char *gyId = strtok((char*)args, " "); + if (!gyId) + return false; - float x, y, z, ort; - int mapid; + int32 i_gyId = atoi(gyId); - // by DB guid - if (GameObjectData const* go_data = sObjectMgr.GetGOData(guid)) - { - x = go_data->posX; - y = go_data->posY; - z = go_data->posZ; - ort = go_data->orientation; - mapid = go_data->mapid; - } - else - { - handler->SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND); - handler->SetSentErrorMessage(true); - return false; - } + if (!i_gyId) + return false; - if (!MapManager::IsValidMapCoord(mapid,x,y,z,ort)) - { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - handler->SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - _player->TeleportTo(mapid, x, y, z, ort); - return true; + WorldSafeLocsEntry const* gy = sWorldSafeLocsStore.LookupEntry(i_gyId); + if (!gy) + { + handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST,i_gyId); + handler->SetSentErrorMessage(true); + return false; } - static bool HandleGoTaxinodeCommand(ChatHandler* handler, const char* args) + if (!MapManager::IsValidMapCoord(gy->map_id,gy->x,gy->y,gy->z)) { - Player* _player = handler->GetSession()->GetPlayer(); - - if (!*args) - return false; - - char* cNodeId = handler->extractKeyFromLink((char*)args,"Htaxinode"); - if (!cNodeId) - return false; - - int32 i_nodeId = atoi(cNodeId); - if (!i_nodeId) - return false; - - TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i_nodeId); - if (!node) - { - handler->PSendSysMessage(LANG_COMMAND_GOTAXINODENOTFOUND,i_nodeId); - handler->SetSentErrorMessage(true); - return false; - } + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,gy->x,gy->y,gy->map_id); + handler->SetSentErrorMessage(true); + return false; + } - if ((node->x == 0.0f && node->y == 0.0f && node->z == 0.0f) || - !MapManager::IsValidMapCoord(node->map_id,node->x,node->y,node->z)) - { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,node->x,node->y,node->map_id); - handler->SetSentErrorMessage(true); - return false; - } + // stop flight if need + if (_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->CleanupAfterTaxiFlight(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); + + _player->TeleportTo(gy->map_id, gy->x, gy->y, gy->z, _player->GetOrientation()); + return true; + } + //teleport to grid + static bool HandleGoGridCommand(ChatHandler* handler, const char* args) + { + if (!*args) return false; + Player* _player = handler->GetSession()->GetPlayer(); + + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); + char* pmapid = strtok(NULL, " "); + + if (!px || !py) + return false; + + float grid_x = (float)atof(px); + float grid_y = (float)atof(py); + uint32 mapid; + if (pmapid) + mapid = (uint32)atoi(pmapid); + else mapid = _player->GetMapId(); + + // center of grid + float x = (grid_x-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; + float y = (grid_y-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; + + if (!MapManager::IsValidMapCoord(mapid,x,y)) + { + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); + handler->SetSentErrorMessage(true); + return false; + } - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); + // stop flight if need + if (_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->CleanupAfterTaxiFlight(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); + + Map const *map = sMapMgr.CreateBaseMap(mapid); + float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); + _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); + + return true; + } + //teleport to gameobject + static bool HandleGoObjectCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; + + Player* _player = handler->GetSession()->GetPlayer(); + + // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); + if (!cId) + return false; + + int32 guid = atoi(cId); + if (!guid) + return false; + + float x, y, z, ort; + int mapid; + + // by DB guid + if (GameObjectData const* go_data = sObjectMgr.GetGOData(guid)) + { + x = go_data->posX; + y = go_data->posY; + z = go_data->posZ; + ort = go_data->orientation; + mapid = go_data->mapid; + } + else + { + handler->SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND); + handler->SetSentErrorMessage(true); + return false; + } - _player->TeleportTo(node->map_id, node->x, node->y, node->z, _player->GetOrientation()); - return true; + if (!MapManager::IsValidMapCoord(mapid,x,y,z,ort)) + { + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); + handler->SetSentErrorMessage(true); + return false; } - static bool HandleGoTriggerCommand(ChatHandler* handler, const char* args) + // stop flight if need + if (_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->CleanupAfterTaxiFlight(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); + + _player->TeleportTo(mapid, x, y, z, ort); + return true; + } + static bool HandleGoTaxinodeCommand(ChatHandler* handler, const char* args) + { + Player* _player = handler->GetSession()->GetPlayer(); + + if (!*args) + return false; + + char* cNodeId = handler->extractKeyFromLink((char*)args,"Htaxinode"); + if (!cNodeId) + return false; + + int32 i_nodeId = atoi(cNodeId); + if (!i_nodeId) + return false; + + TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i_nodeId); + if (!node) { - Player* _player = handler->GetSession()->GetPlayer(); + handler->PSendSysMessage(LANG_COMMAND_GOTAXINODENOTFOUND,i_nodeId); + handler->SetSentErrorMessage(true); + return false; + } - if (!*args) - return false; + if ((node->x == 0.0f && node->y == 0.0f && node->z == 0.0f) || + !MapManager::IsValidMapCoord(node->map_id,node->x,node->y,node->z)) + { + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,node->x,node->y,node->map_id); + handler->SetSentErrorMessage(true); + return false; + } - char *atId = strtok((char*)args, " "); - if (!atId) - return false; + // stop flight if need + if (_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->CleanupAfterTaxiFlight(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); - int32 i_atId = atoi(atId); + _player->TeleportTo(node->map_id, node->x, node->y, node->z, _player->GetOrientation()); + return true; + } + static bool HandleGoTriggerCommand(ChatHandler* handler, const char* args) + { + Player* _player = handler->GetSession()->GetPlayer(); - if (!i_atId) - return false; + if (!*args) + return false; - AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(i_atId); - if (!at) - { - handler->PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND,i_atId); - handler->SetSentErrorMessage(true); - return false; - } + char *atId = strtok((char*)args, " "); + if (!atId) + return false; - if (!MapManager::IsValidMapCoord(at->mapid,at->x,at->y,at->z)) - { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,at->x,at->y,at->mapid); - handler->SetSentErrorMessage(true); - return false; - } + int32 i_atId = atoi(atId); - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); + if (!i_atId) + return false; - _player->TeleportTo(at->mapid, at->x, at->y, at->z, _player->GetOrientation()); - return true; + AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(i_atId); + if (!at) + { + handler->PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND,i_atId); + handler->SetSentErrorMessage(true); + return false; } - //teleport at coordinates - static bool HandleGoZoneXYCommand(ChatHandler* handler, const char* args) + if (!MapManager::IsValidMapCoord(at->mapid,at->x,at->y,at->z)) { - if (!*args) - return false; + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,at->x,at->y,at->mapid); + handler->SetSentErrorMessage(true); + return false; + } - Player* _player = handler->GetSession()->GetPlayer(); + // stop flight if need + if (_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->CleanupAfterTaxiFlight(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* tail = strtok(NULL,""); + _player->TeleportTo(at->mapid, at->x, at->y, at->z, _player->GetOrientation()); + return true; + } + //teleport at coordinates + static bool HandleGoZoneXYCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - char* cAreaId = handler->extractKeyFromLink(tail,"Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r + Player* _player = handler->GetSession()->GetPlayer(); - if (!px || !py) - return false; + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); + char* tail = strtok(NULL,""); - float x = (float)atof(px); - float y = (float)atof(py); + char* cAreaId = handler->extractKeyFromLink(tail,"Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r - // prevent accept wrong numeric args - if ((x == 0.0f && *px != '0') || (y == 0.0f && *py != '0')) - return false; + if (!px || !py) + return false; - uint32 areaid = cAreaId ? (uint32)atoi(cAreaId) : _player->GetZoneId(); + float x = (float)atof(px); + float y = (float)atof(py); - AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaid); + // prevent accept wrong numeric args + if ((x == 0.0f && *px != '0') || (y == 0.0f && *py != '0')) + return false; - if (x < 0 || x > 100 || y < 0 || y > 100 || !areaEntry) - { - handler->PSendSysMessage(LANG_INVALID_ZONE_COORD,x,y,areaid); - handler->SetSentErrorMessage(true); - return false; - } + uint32 areaid = cAreaId ? (uint32)atoi(cAreaId) : _player->GetZoneId(); - // update to parent zone if exist (client map show only zones without parents) - AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry; + AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaid); - Map const *map = sMapMgr.CreateBaseMap(zoneEntry->mapid); - - if (map->Instanceable()) - { - handler->PSendSysMessage(LANG_INVALID_ZONE_MAP,areaEntry->ID,areaEntry->area_name[handler->GetSessionDbcLocale()],map->GetId(),map->GetMapName()); - handler->SetSentErrorMessage(true); - return false; - } + if (x < 0 || x > 100 || y < 0 || y > 100 || !areaEntry) + { + handler->PSendSysMessage(LANG_INVALID_ZONE_COORD,x,y,areaid); + handler->SetSentErrorMessage(true); + return false; + } - Zone2MapCoordinates(x,y,zoneEntry->ID); + // update to parent zone if exist (client map show only zones without parents) + AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry; - if (!MapManager::IsValidMapCoord(zoneEntry->mapid,x,y)) - { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,zoneEntry->mapid); - handler->SetSentErrorMessage(true); - return false; - } + Map const *map = sMapMgr.CreateBaseMap(zoneEntry->mapid); - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); + if (map->Instanceable()) + { + handler->PSendSysMessage(LANG_INVALID_ZONE_MAP,areaEntry->ID,areaEntry->area_name[handler->GetSessionDbcLocale()],map->GetId(),map->GetMapName()); + handler->SetSentErrorMessage(true); + return false; + } - float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); - _player->TeleportTo(zoneEntry->mapid, x, y, z, _player->GetOrientation()); + Zone2MapCoordinates(x,y,zoneEntry->ID); - return true; + if (!MapManager::IsValidMapCoord(zoneEntry->mapid,x,y)) + { + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,zoneEntry->mapid); + handler->SetSentErrorMessage(true); + return false; } - //teleport at coordinates - static bool HandleGoXYCommand(ChatHandler* handler, const char* args) + // stop flight if need + if (_player->isInFlight()) { - if (!*args) - return false; - - Player* _player = handler->GetSession()->GetPlayer(); - - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* pmapid = strtok(NULL, " "); - - if (!px || !py) - return false; - - float x = (float)atof(px); - float y = (float)atof(py); - uint32 mapid; - if (pmapid) - mapid = (uint32)atoi(pmapid); - else - mapid = _player->GetMapId(); - - if (!MapManager::IsValidMapCoord(mapid,x,y)) - { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - handler->SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - Map const *map = sMapMgr.CreateBaseMap(mapid); - float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); - - _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); - - return true; + _player->GetMotionMaster()->MovementExpired(); + _player->CleanupAfterTaxiFlight(); } - - //teleport at coordinates, including Z - static bool HandleGoXYZCommand(ChatHandler* handler, const char* args) + // save only in non-flight case + else + _player->SaveRecallPosition(); + + float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); + _player->TeleportTo(zoneEntry->mapid, x, y, z, _player->GetOrientation()); + + return true; + } + //teleport at coordinates + static bool HandleGoXYCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; + + Player* _player = handler->GetSession()->GetPlayer(); + + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); + char* pmapid = strtok(NULL, " "); + + if (!px || !py) + return false; + + float x = (float)atof(px); + float y = (float)atof(py); + uint32 mapid; + if (pmapid) + mapid = (uint32)atoi(pmapid); + else + mapid = _player->GetMapId(); + + if (!MapManager::IsValidMapCoord(mapid,x,y)) { - if (!*args) - return false; + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); + handler->SetSentErrorMessage(true); + return false; + } - Player* _player = handler->GetSession()->GetPlayer(); + // stop flight if need + if (_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->CleanupAfterTaxiFlight(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); + + Map const *map = sMapMgr.CreateBaseMap(mapid); + float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); + + _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); + + return true; + } + //teleport at coordinates, including Z + static bool HandleGoXYZCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; + + Player* _player = handler->GetSession()->GetPlayer(); + + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); + char* pz = strtok(NULL, " "); + char* pmapid = strtok(NULL, " "); + + if (!px || !py || !pz) + return false; + + float x = (float)atof(px); + float y = (float)atof(py); + float z = (float)atof(pz); + uint32 mapid; + if (pmapid) + mapid = (uint32)atoi(pmapid); + else + mapid = _player->GetMapId(); + + if (!MapManager::IsValidMapCoord(mapid,x,y,z)) + { + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); + handler->SetSentErrorMessage(true); + return false; + } - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* pz = strtok(NULL, " "); - char* pmapid = strtok(NULL, " "); + // stop flight if need + if (_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->CleanupAfterTaxiFlight(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); - if (!px || !py || !pz) - return false; + _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); - float x = (float)atof(px); - float y = (float)atof(py); - float z = (float)atof(pz); - uint32 mapid; - if (pmapid) - mapid = (uint32)atoi(pmapid); - else - mapid = _player->GetMapId(); + return true; + } + static bool HandleGoTicketCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - if (!MapManager::IsValidMapCoord(mapid,x,y,z)) - { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - handler->SetSentErrorMessage(true); - return false; - } + char *cstrticket_id = strtok((char*)args, " "); - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); + if (!cstrticket_id) + return false; - _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); + uint64 ticket_id = atoi(cstrticket_id); + if (!ticket_id) + return false; + GM_Ticket *ticket = sTicketMgr.GetGMTicket(ticket_id); + if (!ticket) + { + handler->SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } - static bool HandleGoTicketCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; - - char *cstrticket_id = strtok((char*)args, " "); + float x, y, z; + int mapid; - if (!cstrticket_id) - return false; - - uint64 ticket_id = atoi(cstrticket_id); - if (!ticket_id) - return false; - - GM_Ticket *ticket = sTicketMgr.GetGMTicket(ticket_id); - if (!ticket) - { - handler->SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); - return true; - } - - float x, y, z; - int mapid; + x = ticket->pos_x; + y = ticket->pos_y; + z = ticket->pos_z; + mapid = ticket->map; - x = ticket->pos_x; - y = ticket->pos_y; - z = ticket->pos_z; - mapid = ticket->map; - - Player* _player = handler->GetSession()->GetPlayer(); - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - else - _player->SaveRecallPosition(); - - _player->TeleportTo(mapid, x, y, z, 1, 0); - return true; + Player* _player = handler->GetSession()->GetPlayer(); + if (_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->CleanupAfterTaxiFlight(); } + else + _player->SaveRecallPosition(); + _player->TeleportTo(mapid, x, y, z, 1, 0); + return true; + } }; void AddSC_go_commandscript() diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index 8940005bbb9..5a6f91d7c5d 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -31,644 +31,641 @@ EndScriptData */ class gobject_commandscript : public CommandScript { - public: - gobject_commandscript() : CommandScript("gobject_commandscript") { } +public: + gobject_commandscript() : CommandScript("gobject_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const + { + static ChatCommand gobjectAddCommandTable[] = { - static ChatCommand gobjectAddCommandTable[] = - { - { "temp", SEC_GAMEMASTER, false, &HandleGameObjectAddTempCommand, "", NULL }, - { "", SEC_GAMEMASTER, false, &HandleGameObjectAddCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand gobjectSetCommandTable[] = - { - { "phase", SEC_GAMEMASTER, false, &HandleGameObjectSetPhaseCommand, "", NULL }, - { "state", SEC_GAMEMASTER, false, &HandleGameObjectSetStateCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand gobjectCommandTable[] = - { - { "activate", SEC_GAMEMASTER, false, &HandleGameObjectActivateCommand, "", NULL }, - { "delete", SEC_GAMEMASTER, false, &HandleGameObjectDeleteCommand, "", NULL }, - { "info", SEC_GAMEMASTER, false, &HandleGameObjectInfoCommand, "", NULL }, - { "move", SEC_GAMEMASTER, false, &HandleGameObjectMoveCommand, "", NULL }, - { "near", SEC_GAMEMASTER, false, &HandleGameObjectNearCommand, "", NULL }, - { "target", SEC_GAMEMASTER, false, &HandleGameObjectTargetCommand, "", NULL }, - { "turn", SEC_GAMEMASTER, false, &HandleGameObjectTurnCommand, "", NULL }, - { "add", SEC_GAMEMASTER, false, NULL, "", gobjectAddCommandTable }, - { "set", SEC_GAMEMASTER, false, NULL, "", gobjectSetCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand commandTable[] = - { - { "gobject", SEC_GAMEMASTER, false, NULL, "", gobjectCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - return commandTable; - } + { "temp", SEC_GAMEMASTER, false, &HandleGameObjectAddTempCommand, "", NULL }, + { "", SEC_GAMEMASTER, false, &HandleGameObjectAddCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand gobjectSetCommandTable[] = + { + { "phase", SEC_GAMEMASTER, false, &HandleGameObjectSetPhaseCommand, "", NULL }, + { "state", SEC_GAMEMASTER, false, &HandleGameObjectSetStateCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand gobjectCommandTable[] = + { + { "activate", SEC_GAMEMASTER, false, &HandleGameObjectActivateCommand, "", NULL }, + { "delete", SEC_GAMEMASTER, false, &HandleGameObjectDeleteCommand, "", NULL }, + { "info", SEC_GAMEMASTER, false, &HandleGameObjectInfoCommand, "", NULL }, + { "move", SEC_GAMEMASTER, false, &HandleGameObjectMoveCommand, "", NULL }, + { "near", SEC_GAMEMASTER, false, &HandleGameObjectNearCommand, "", NULL }, + { "target", SEC_GAMEMASTER, false, &HandleGameObjectTargetCommand, "", NULL }, + { "turn", SEC_GAMEMASTER, false, &HandleGameObjectTurnCommand, "", NULL }, + { "add", SEC_GAMEMASTER, false, NULL, "", gobjectAddCommandTable }, + { "set", SEC_GAMEMASTER, false, NULL, "", gobjectSetCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "gobject", SEC_GAMEMASTER, false, NULL, "", gobjectCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } -static bool HandleGameObjectActivateCommand(ChatHandler* handler, const char* args) -{ - if (!*args) - return false; + static bool HandleGameObjectActivateCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); - if (!cId) - return false; + char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); + if (!cId) + return false; - uint32 lowguid = atoi(cId); - if (!lowguid) - return false; + uint32 lowguid = atoi(cId); + if (!lowguid) + return false; - GameObject* obj = NULL; + GameObject* obj = NULL; - // by DB guid - if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) - obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); + // by DB guid + if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) + obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); - if (!obj) - { - handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - handler->SetSentErrorMessage(true); - return false; - } + if (!obj) + { + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + handler->SetSentErrorMessage(true); + return false; + } - // Activate - obj->SetLootState(GO_READY); - obj->UseDoorOrButton(10000); + // Activate + obj->SetLootState(GO_READY); + obj->UseDoorOrButton(10000); - handler->PSendSysMessage("Object activated!"); + handler->PSendSysMessage("Object activated!"); - return true; -} + return true; + } -//spawn go -static bool HandleGameObjectAddCommand(ChatHandler* handler, const char* args) -{ - if (!*args) - return false; + //spawn go + static bool HandleGameObjectAddCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject_entry"); - if (!cId) - return false; + // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject_entry"); + if (!cId) + return false; - uint32 id = atol(cId); - if (!id) - return false; + uint32 id = atol(cId); + if (!id) + return false; - char* spawntimeSecs = strtok(NULL, " "); + char* spawntimeSecs = strtok(NULL, " "); - const GameObjectInfo *gInfo = sObjectMgr.GetGameObjectInfo(id); + const GameObjectInfo *gInfo = sObjectMgr.GetGameObjectInfo(id); - if (!gInfo) - { - handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); - handler->SetSentErrorMessage(true); - return false; - } + if (!gInfo) + { + handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); + handler->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); - handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA,id); - handler->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); + handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA,id); + handler->SetSentErrorMessage(true); + return false; + } - Player *chr = handler->GetSession()->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(); + Player *chr = handler->GetSession()->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); + 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 (!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); - } + 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()); + // 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; - } + // 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(handler->GetTrinityString(LANG_GAMEOBJECT_CURRENT), gInfo->name, db_lowGUID, x, y, z, o); + sLog.outDebug(handler->GetTrinityString(LANG_GAMEOBJECT_CURRENT), gInfo->name, db_lowGUID, x, y, z, o); - map->Add(pGameObj); + 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)); + // TODO: is it really necessary to add both the real and DB table guid here ? + sObjectMgr.AddGameobjectToGrid(db_lowGUID, sObjectMgr.GetGOData(db_lowGUID)); - handler->PSendSysMessage(LANG_GAMEOBJECT_ADD,id,gInfo->name,db_lowGUID,x,y,z); - return true; -} + handler->PSendSysMessage(LANG_GAMEOBJECT_ADD,id,gInfo->name,db_lowGUID,x,y,z); + return true; + } -// add go, temp only -static bool HandleGameObjectAddTempCommand(ChatHandler* handler, const char* args) -{ - if (!*args) - return false; - char* charID = strtok((char*)args, " "); - if (!charID) - return false; + // add go, temp only + static bool HandleGameObjectAddTempCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; + char* charID = strtok((char*)args, " "); + if (!charID) + return false; - Player *chr = handler->GetSession()->GetPlayer(); + Player *chr = handler->GetSession()->GetPlayer(); - char* spawntime = strtok(NULL, " "); - uint32 spawntm = 300; + char* spawntime = strtok(NULL, " "); + uint32 spawntm = 300; - if (spawntime) - spawntm = atoi((char*)spawntime); + if (spawntime) + spawntm = atoi((char*)spawntime); - float x = chr->GetPositionX(); - float y = chr->GetPositionY(); - float z = chr->GetPositionZ(); - float ang = chr->GetOrientation(); + 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); + float rot2 = sin(ang/2); + float rot3 = cos(ang/2); - uint32 id = atoi(charID); + uint32 id = atoi(charID); - chr->SummonGameObject(id,x,y,z,ang,0,0,rot2,rot3,spawntm); + chr->SummonGameObject(id,x,y,z,ang,0,0,rot2,rot3,spawntm); - return true; -} + return true; + } -static bool HandleGameObjectTargetCommand(ChatHandler* handler, const char* args) -{ - Player* pl = handler->GetSession()->GetPlayer(); - QueryResult result; - GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr.GetActiveEventList(); - if (*args) + static bool HandleGameObjectTargetCommand(ChatHandler* handler, const char* args) { - // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject_entry"); - if (!cId) - return false; + Player* pl = handler->GetSession()->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 = handler->extractKeyFromLink((char*)args,"Hgameobject_entry"); + if (!cId) + return false; - uint32 id = atol(cId); + 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", + 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::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; + 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) + for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr) { - eventFilter << "OR event IN (" <<*itr; - initString =false; + if (initString) + { + eventFilter << "OR event IN (" <<*itr; + initString =false; + } + else + eventFilter << "," << *itr; } - else - eventFilter << "," << *itr; - } - if (!initString) - eventFilter << "))"; - else - eventFilter << ")"; + 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", - handler->GetSession()->GetPlayer()->GetPositionX(), handler->GetSession()->GetPlayer()->GetPositionY(), handler->GetSession()->GetPlayer()->GetPositionZ(), handler->GetSession()->GetPlayer()->GetMapId(),eventFilter.str().c_str()); - } + 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", + handler->GetSession()->GetPlayer()->GetPositionX(), handler->GetSession()->GetPlayer()->GetPositionY(), handler->GetSession()->GetPlayer()->GetPositionZ(), handler->GetSession()->GetPlayer()->GetMapId(),eventFilter.str().c_str()); + } - if (!result) - { - handler->SendSysMessage(LANG_COMMAND_TARGETOBJNOTFOUND); - return true; - } + if (!result) + { + handler->SendSysMessage(LANG_COMMAND_TARGETOBJNOTFOUND); + return true; + } - bool found = false; - float x, y, z, o; - uint32 lowguid, id; - uint16 mapid, phase; - uint32 pool_id; + 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) - { - handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); - return false; - } + 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) + { + handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); + return false; + } - GameObjectInfo const* goI = sObjectMgr.GetGameObjectInfo(id); + GameObjectInfo const* goI = sObjectMgr.GetGameObjectInfo(id); - if (!goI) - { - handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); - return false; - } + if (!goI) + { + handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); + return false; + } - GameObject* target = handler->GetSession()->GetPlayer()->GetMap()->GetGameObject(MAKE_NEW_GUID(lowguid,id,HIGHGUID_GAMEOBJECT)); + GameObject* target = handler->GetSession()->GetPlayer()->GetMap()->GetGameObject(MAKE_NEW_GUID(lowguid,id,HIGHGUID_GAMEOBJECT)); - handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, lowguid, goI->name, lowguid, id, x, y, z, mapid, o, phase); + handler->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; + 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); + std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true); + std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); - handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); + handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); + } + return true; } - return true; -} -//delete object by selection or guid -static bool HandleGameObjectDeleteCommand(ChatHandler* handler, const char* args) -{ - // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); - if (!cId) - return false; - - uint32 lowguid = atoi(cId); - if (!lowguid) - return false; + //delete object by selection or guid + static bool HandleGameObjectDeleteCommand(ChatHandler* handler, const char* args) + { + // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); + if (!cId) + return false; - GameObject* obj = NULL; + uint32 lowguid = atoi(cId); + if (!lowguid) + return false; - // by DB guid - if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) - obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); + GameObject* obj = NULL; - if (!obj) - { - handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - handler->SetSentErrorMessage(true); - return false; - } + // by DB guid + if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) + obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); - uint64 owner_guid = obj->GetOwnerGUID(); - if (owner_guid) - { - Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(),owner_guid); - if (!owner || !IS_PLAYER_GUID(owner_guid)) + if (!obj) { - handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow()); + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); handler->SetSentErrorMessage(true); return false; } - owner->RemoveGameObject(obj,false); - } - - obj->SetRespawnTime(0); // not save respawn time - obj->Delete(); - obj->DeleteFromDB(); - - handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, obj->GetGUIDLow()); - - return true; -} - -//turn selected object -static bool HandleGameObjectTurnCommand(ChatHandler* handler, const char* args) -{ - // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); - if (!cId) - return false; + uint64 owner_guid = obj->GetOwnerGUID(); + if (owner_guid) + { + Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(),owner_guid); + if (!owner || !IS_PLAYER_GUID(owner_guid)) + { + handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow()); + handler->SetSentErrorMessage(true); + return false; + } - uint32 lowguid = atoi(cId); - if (!lowguid) - return false; + owner->RemoveGameObject(obj,false); + } - GameObject* obj = NULL; + obj->SetRespawnTime(0); // not save respawn time + obj->Delete(); + obj->DeleteFromDB(); - // by DB guid - if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) - obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); + handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, obj->GetGUIDLow()); - if (!obj) - { - handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - handler->SetSentErrorMessage(true); - return false; + return true; } - char* po = strtok(NULL, " "); - float o; - - if (po) + //turn selected object + static bool HandleGameObjectTurnCommand(ChatHandler* handler, const char* args) { - o = (float)atof(po); - } - else - { - Player *chr = handler->GetSession()->GetPlayer(); - o = chr->GetOrientation(); - } + // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); + if (!cId) + return false; - obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o); - obj->UpdateRotationFields(); - obj->DestroyForNearbyPlayers(); - obj->UpdateObjectVisibility(); + uint32 lowguid = atoi(cId); + if (!lowguid) + return false; - obj->SaveToDB(); - obj->Refresh(); + GameObject* obj = NULL; - handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow(), o); + // by DB guid + if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) + obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); - return true; -} - -//move selected object -static bool HandleGameObjectMoveCommand(ChatHandler* handler, const char* args) -{ - // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); - if (!cId) - return false; + if (!obj) + { + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + handler->SetSentErrorMessage(true); + return false; + } - uint32 lowguid = atoi(cId); - if (!lowguid) - return false; + char* po = strtok(NULL, " "); + float o; - GameObject* obj = NULL; + if (po) + { + o = (float)atof(po); + } + else + { + Player *chr = handler->GetSession()->GetPlayer(); + o = chr->GetOrientation(); + } - // by DB guid - if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) - obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); + obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o); + obj->UpdateRotationFields(); + obj->DestroyForNearbyPlayers(); + obj->UpdateObjectVisibility(); - if (!obj) - { - handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - handler->SetSentErrorMessage(true); - return false; - } + obj->SaveToDB(); + obj->Refresh(); - char* px = strtok(NULL, " "); - char* py = strtok(NULL, " "); - char* pz = strtok(NULL, " "); + handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow(), o); - if (!px) - { - Player *chr = handler->GetSession()->GetPlayer(); - obj->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), obj->GetOrientation()); - obj->DestroyForNearbyPlayers(); - obj->UpdateObjectVisibility(); + return true; } - else + + //move selected object + static bool HandleGameObjectMoveCommand(ChatHandler* handler, const char* args) { - if (!py || !pz) + // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); + if (!cId) return false; - float x = (float)atof(px); - float y = (float)atof(py); - float z = (float)atof(pz); + uint32 lowguid = atoi(cId); + if (!lowguid) + return false; - if (!MapManager::IsValidMapCoord(obj->GetMapId(),x,y,z)) + GameObject* obj = NULL; + + // by DB guid + if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) + obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); + + if (!obj) { - handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,obj->GetMapId()); + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); handler->SetSentErrorMessage(true); return false; } - obj->Relocate(x, y, z, obj->GetOrientation()); - obj->DestroyForNearbyPlayers(); - obj->UpdateObjectVisibility(); - } - - obj->SaveToDB(); - obj->Refresh(); + char* px = strtok(NULL, " "); + char* py = strtok(NULL, " "); + char* pz = strtok(NULL, " "); - handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow()); + if (!px) + { + Player *chr = handler->GetSession()->GetPlayer(); + obj->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), obj->GetOrientation()); + obj->DestroyForNearbyPlayers(); + obj->UpdateObjectVisibility(); + } + else + { + if (!py || !pz) + return false; - return true; -} + float x = (float)atof(px); + float y = (float)atof(py); + float z = (float)atof(pz); -//set pahsemask for selected object -static bool HandleGameObjectSetPhaseCommand(ChatHandler* handler, const char* args) -{ - // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); - if (!cId) - return false; + if (!MapManager::IsValidMapCoord(obj->GetMapId(),x,y,z)) + { + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,obj->GetMapId()); + handler->SetSentErrorMessage(true); + return false; + } - uint32 lowguid = atoi(cId); - if (!lowguid) - return false; + obj->Relocate(x, y, z, obj->GetOrientation()); + obj->DestroyForNearbyPlayers(); + obj->UpdateObjectVisibility(); + } - GameObject* obj = NULL; + obj->SaveToDB(); + obj->Refresh(); - // by DB guid - if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) - obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); + handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow()); - if (!obj) - { - handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - handler->SetSentErrorMessage(true); - return false; + return true; } - char* phaseStr = strtok (NULL, " "); - uint32 phasemask = phaseStr? atoi(phaseStr) : 0; - if (phasemask == 0) + //set pahsemask for selected object + static bool HandleGameObjectSetPhaseCommand(ChatHandler* handler, const char* args) { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); + if (!cId) + return false; - obj->SetPhaseMask(phasemask,true); - obj->SaveToDB(); - return true; -} + uint32 lowguid = atoi(cId); + if (!lowguid) + return false; -static bool HandleGameObjectNearCommand(ChatHandler* handler, const char* args) -{ - float distance = (!*args) ? 10.0f : (float)(atof(args)); - uint32 count = 0; + GameObject* obj = NULL; - Player* pl = handler->GetSession()->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); + // by DB guid + if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) + obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); - if (result) - { - do + if (!obj) { - 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(); + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + handler->SetSentErrorMessage(true); + return false; + } - GameObjectInfo const * gInfo = sObjectMgr.GetGameObjectInfo(entry); + char* phaseStr = strtok (NULL, " "); + uint32 phasemask = phaseStr? atoi(phaseStr) : 0; + if (phasemask == 0) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; + } - if (!gInfo) - continue; + obj->SetPhaseMask(phasemask,true); + obj->SaveToDB(); + return true; + } - handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name, x, y, z, mapid); + static bool HandleGameObjectNearCommand(ChatHandler* handler, const char* args) + { + float distance = (!*args) ? 10.0f : (float)(atof(args)); + uint32 count = 0; - ++count; - } while (result->NextRow()); - } + Player* pl = handler->GetSession()->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); - handler->PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE,distance,count); - return true; -} + 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(); -//show info of gameobject -static bool HandleGameObjectInfoCommand(ChatHandler* handler, const char* args) -{ - uint32 entry = 0; - uint32 type = 0; - uint32 displayid = 0; - std::string name; - uint32 lootId = 0; + GameObjectInfo const * gInfo = sObjectMgr.GetGameObjectInfo(entry); - if (!*args) - { - if (WorldObject * obj = handler->getSelectedObject()) - entry = obj->GetEntry(); - } - else - entry = atoi((char*)args); + if (!gInfo) + continue; - GameObjectInfo const* goinfo = sObjectMgr.GetGameObjectInfo(entry); + handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name, x, y, z, mapid); - if (!goinfo) - return false; + ++count; + } while (result->NextRow()); + } + + handler->PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE,distance,count); + return true; + } - 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; + //show info of gameobject + static bool HandleGameObjectInfoCommand(ChatHandler* handler, const char* args) + { + uint32 entry = 0; + uint32 type = 0; + uint32 displayid = 0; + std::string name; + uint32 lootId = 0; + + if (!*args) + if (WorldObject * obj = handler->getSelectedObject()) + entry = obj->GetEntry(); + else + entry = atoi((char*)args); - handler->PSendSysMessage(LANG_GOINFO_ENTRY, entry); - handler->PSendSysMessage(LANG_GOINFO_TYPE, type); - handler->PSendSysMessage(LANG_GOINFO_LOOTID, lootId); - handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayid); - handler->PSendSysMessage(LANG_GOINFO_NAME, name.c_str()); + GameObjectInfo const* goinfo = sObjectMgr.GetGameObjectInfo(entry); - return true; -} -static bool HandleGameObjectSetStateCommand(ChatHandler* handler, const char* args) -{ - // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); - if (!cId) - return false; + if (!goinfo) + return false; - uint32 lowguid = atoi(cId); - if (!lowguid) - 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; - GameObject* gobj = NULL; + handler->PSendSysMessage(LANG_GOINFO_ENTRY, entry); + handler->PSendSysMessage(LANG_GOINFO_TYPE, type); + handler->PSendSysMessage(LANG_GOINFO_LOOTID, lootId); + handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayid); + handler->PSendSysMessage(LANG_GOINFO_NAME, name.c_str()); - if (GameObjectData const* goData = sObjectMgr.GetGOData(lowguid)) - gobj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, goData->id); + return true; + } - if (!gobj) + static bool HandleGameObjectSetStateCommand(ChatHandler* handler, const char* args) { - handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - handler->SetSentErrorMessage(true); - return false; - } + // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); + if (!cId) + return false; + + uint32 lowguid = atoi(cId); + if (!lowguid) + return false; - char* ctype = strtok(NULL, " "); - if (!ctype) - return false; + GameObject* gobj = NULL; - int32 type = atoi(ctype); - if (type < 0) - { - if (type == -1) - gobj->SendObjectDeSpawnAnim(gobj->GetGUID()); - else if (type == -2) + if (GameObjectData const* goData = sObjectMgr.GetGOData(lowguid)) + gobj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, goData->id); + + if (!gobj) { + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + handler->SetSentErrorMessage(true); return false; } - return true; - } - char* cstate = strtok(NULL, " "); - if (!cstate) - return false; + char* ctype = strtok(NULL, " "); + if (!ctype) + return false; - int32 state = atoi(cstate); + int32 type = atoi(ctype); + if (type < 0) + { + if (type == -1) + gobj->SendObjectDeSpawnAnim(gobj->GetGUID()); + else if (type == -2) + { + return false; + } + return true; + } - 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); - } - handler->PSendSysMessage("Set gobject type %d state %d", type, state); + char* cstate = strtok(NULL, " "); + if (!cstate) + return false; - return true; -} + 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); + } + handler->PSendSysMessage("Set gobject type %d state %d", type, state); + return true; + } }; void AddSC_gobject_commandscript() diff --git a/src/server/scripts/Commands/cs_honor.cpp b/src/server/scripts/Commands/cs_honor.cpp index 211fdd30155..5f005aa6081 100644 --- a/src/server/scripts/Commands/cs_honor.cpp +++ b/src/server/scripts/Commands/cs_honor.cpp @@ -28,90 +28,85 @@ EndScriptData */ class honor_commandscript : public CommandScript { - public: - honor_commandscript() : CommandScript("honor_commandscript") { } +public: + honor_commandscript() : CommandScript("honor_commandscript") { } - ChatCommand* GetCommands() const - { - static ChatCommand honorAddCommandTable[] = - { - { "kill", SEC_GAMEMASTER, false, &HandleHonorAddKillCommand, "", NULL }, - { "", SEC_GAMEMASTER, false, &HandleHonorAddCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand honorCommandTable[] = - { - { "add", SEC_GAMEMASTER, false, NULL, "", honorAddCommandTable }, - { "update", SEC_GAMEMASTER, false, &HandleHonorUpdateCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand commandTable[] = - { - { "honor", SEC_GAMEMASTER, false, NULL, "", honorCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - return commandTable; - } - - -static bool HandleHonorAddCommand(ChatHandler* handler, const char* args) -{ - if (!*args) - return false; - - Player *target = handler->getSelectedPlayer(); - if (!target) + ChatCommand* GetCommands() const { - handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); - handler->SetSentErrorMessage(true); - return false; + static ChatCommand honorAddCommandTable[] = + { + { "kill", SEC_GAMEMASTER, false, &HandleHonorAddKillCommand, "", NULL }, + { "", SEC_GAMEMASTER, false, &HandleHonorAddCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand honorCommandTable[] = + { + { "add", SEC_GAMEMASTER, false, NULL, "", honorAddCommandTable }, + { "update", SEC_GAMEMASTER, false, &HandleHonorUpdateCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "honor", SEC_GAMEMASTER, false, NULL, "", honorCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; } + static bool HandleHonorAddCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + Player *target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + return false; + } - uint32 amount = (uint32)atoi(args); - target->RewardHonor(NULL, 1, amount); - return true; -} + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; -static bool HandleHonorAddKillCommand(ChatHandler* handler, const char* /*args*/) -{ - Unit *target = handler->getSelectedUnit(); - if (!target) - { - handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); - handler->SetSentErrorMessage(true); - return false; + uint32 amount = (uint32)atoi(args); + target->RewardHonor(NULL, 1, amount); + return true; } + static bool HandleHonorAddKillCommand(ChatHandler* handler, const char* /*args*/) + { + Unit *target = handler->getSelectedUnit(); + if (!target) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + return false; + } - // check online security - if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity((Player*)target, 0)) - return false; + // check online security + if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity((Player*)target, 0)) + return false; - handler->GetSession()->GetPlayer()->RewardHonor(target, 1); - return true; -} - -static bool HandleHonorUpdateCommand(ChatHandler* handler, const char* /*args*/) -{ - Player *target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); - handler->SetSentErrorMessage(true); - return false; + handler->GetSession()->GetPlayer()->RewardHonor(target, 1); + return true; } + static bool HandleHonorUpdateCommand(ChatHandler* handler, const char* /*args*/) + { + Player *target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + return false; + } - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; - - target->UpdateHonorFields(); - return true; -} + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; + target->UpdateHonorFields(); + return true; + } }; void AddSC_honor_commandscript() diff --git a/src/server/scripts/Commands/cs_learn.cpp b/src/server/scripts/Commands/cs_learn.cpp index e68800e85fa..750395ff67c 100644 --- a/src/server/scripts/Commands/cs_learn.cpp +++ b/src/server/scripts/Commands/cs_learn.cpp @@ -29,1085 +29,1083 @@ EndScriptData */ class learn_commandscript : public CommandScript { - public: - learn_commandscript() : CommandScript("learn_commandscript") { } +public: + learn_commandscript() : CommandScript("learn_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const + { + static ChatCommand learnAllMyCommandTable[] = { - static ChatCommand learnAllMyCommandTable[] = - { - { "class", SEC_ADMINISTRATOR, false, &HandleLearnAllMyClassCommand, "", NULL }, - { "pettalents", SEC_ADMINISTRATOR, false, &HandleLearnAllMyPetTalentsCommand,"", NULL }, - { "spells", SEC_ADMINISTRATOR, false, &HandleLearnAllMySpellsCommand, "", NULL }, - { "talents", SEC_ADMINISTRATOR, false, &HandleLearnAllMyTalentsCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand learnAllCommandTable[] = - { - { "my", SEC_ADMINISTRATOR, false, NULL, "", learnAllMyCommandTable }, - { "gm", SEC_GAMEMASTER, false, &HandleLearnAllGMCommand, "", NULL }, - { "crafts", SEC_GAMEMASTER, false, &HandleLearnAllCraftsCommand, "", NULL }, - { "default", SEC_MODERATOR, false, &HandleLearnAllDefaultCommand, "", NULL }, - { "lang", SEC_MODERATOR, false, &HandleLearnAllLangCommand, "", NULL }, - { "recipes", SEC_GAMEMASTER, false, &HandleLearnAllRecipesCommand, "", NULL }, - { "", SEC_ADMINISTRATOR, false, &HandleLearnAllCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - - static ChatCommand learnCommandTable[] = - { - { "all", SEC_ADMINISTRATOR, false, NULL, "", learnAllCommandTable }, - { "", SEC_ADMINISTRATOR, false, &HandleLearnCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - - static ChatCommand commandTable[] = - { - { "learn", SEC_MODERATOR, false, NULL, "", learnCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - return commandTable; - } - static bool HandleLearnCommand(ChatHandler* handler, const char* args) + { "class", SEC_ADMINISTRATOR, false, &HandleLearnAllMyClassCommand, "", NULL }, + { "pettalents", SEC_ADMINISTRATOR, false, &HandleLearnAllMyPetTalentsCommand,"", NULL }, + { "spells", SEC_ADMINISTRATOR, false, &HandleLearnAllMySpellsCommand, "", NULL }, + { "talents", SEC_ADMINISTRATOR, false, &HandleLearnAllMyTalentsCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand learnAllCommandTable[] = + { + { "my", SEC_ADMINISTRATOR, false, NULL, "", learnAllMyCommandTable }, + { "gm", SEC_GAMEMASTER, false, &HandleLearnAllGMCommand, "", NULL }, + { "crafts", SEC_GAMEMASTER, false, &HandleLearnAllCraftsCommand, "", NULL }, + { "default", SEC_MODERATOR, false, &HandleLearnAllDefaultCommand, "", NULL }, + { "lang", SEC_MODERATOR, false, &HandleLearnAllLangCommand, "", NULL }, + { "recipes", SEC_GAMEMASTER, false, &HandleLearnAllRecipesCommand, "", NULL }, + { "", SEC_ADMINISTRATOR, false, &HandleLearnAllCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + + static ChatCommand learnCommandTable[] = { - Player* targetPlayer = handler->getSelectedPlayer(); + { "all", SEC_ADMINISTRATOR, false, NULL, "", learnAllCommandTable }, + { "", SEC_ADMINISTRATOR, false, &HandleLearnCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; - if (!targetPlayer) - { - handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); - handler->SetSentErrorMessage(true); - return false; - } + static ChatCommand commandTable[] = + { + { "learn", SEC_MODERATOR, false, NULL, "", learnCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } + static bool HandleLearnCommand(ChatHandler* handler, const char* args) + { + Player* targetPlayer = handler->getSelectedPlayer(); + + if (!targetPlayer) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + return false; + } - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form - uint32 spell = handler->extractSpellIdFromLink((char*)args); - if (!spell || !sSpellStore.LookupEntry(spell)) - return false; + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form + uint32 spell = handler->extractSpellIdFromLink((char*)args); + if (!spell || !sSpellStore.LookupEntry(spell)) + return false; - char const* allStr = strtok(NULL," "); - bool allRanks = allStr ? (strncmp(allStr, "all", strlen(allStr)) == 0) : false; + char const* allStr = strtok(NULL," "); + bool allRanks = allStr ? (strncmp(allStr, "all", strlen(allStr)) == 0) : false; - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,handler->GetSession()->GetPlayer())) - { - handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); - handler->SetSentErrorMessage(true); - return false; - } - - if (!allRanks && targetPlayer->HasSpell(spell)) - { - if (targetPlayer == handler->GetSession()->GetPlayer()) - handler->SendSysMessage(LANG_YOU_KNOWN_SPELL); - else - handler->PSendSysMessage(LANG_TARGET_KNOWN_SPELL,handler->GetNameLink(targetPlayer).c_str()); - handler->SetSentErrorMessage(true); - return false; - } + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,handler->GetSession()->GetPlayer())) + { + handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); + handler->SetSentErrorMessage(true); + return false; + } - if (allRanks) - targetPlayer->learnSpellHighRank(spell); + if (!allRanks && targetPlayer->HasSpell(spell)) + { + if (targetPlayer == handler->GetSession()->GetPlayer()) + handler->SendSysMessage(LANG_YOU_KNOWN_SPELL); else - targetPlayer->learnSpell(spell, false); + handler->PSendSysMessage(LANG_TARGET_KNOWN_SPELL,handler->GetNameLink(targetPlayer).c_str()); + handler->SetSentErrorMessage(true); + return false; + } - uint32 first_spell = sSpellMgr.GetFirstSpellInChain(spell); - if (GetTalentSpellCost(first_spell)) - targetPlayer->SendTalentsInfoData(false); + if (allRanks) + targetPlayer->learnSpellHighRank(spell); + else + targetPlayer->learnSpell(spell, false); - return true; - } + uint32 first_spell = sSpellMgr.GetFirstSpellInChain(spell); + if (GetTalentSpellCost(first_spell)) + targetPlayer->SendTalentsInfoData(false); - static bool HandleLearnAllCommand(ChatHandler* handler, const char* /*args*/) + return true; + } + static bool HandleLearnAllCommand(ChatHandler* handler, const char* /*args*/) + { + static const char *allSpellList[] = { - static const char *allSpellList[] = - { - "3365", - "6233", - "6247", - "6246", - "6477", - "6478", - "22810", - "8386", - "21651", - "21652", - "522", - "7266", - "8597", - "2479", - "22027", - "6603", - "5019", - "133", - "168", - "227", - "5009", - "9078", - "668", - "203", - "20599", - "20600", - "81", - "20597", - "20598", - "20864", - "1459", - "5504", - "587", - "5143", - "118", - "5505", - "597", - "604", - "1449", - "1460", - "2855", - "1008", - "475", - "5506", - "1463", - "12824", - "8437", - "990", - "5145", - "8450", - "1461", - "759", - "8494", - "8455", - "8438", - "6127", - "8416", - "6129", - "8451", - "8495", - "8439", - "3552", - "8417", - "10138", - "12825", - "10169", - "10156", - "10144", - "10191", - "10201", - "10211", - "10053", - "10173", - "10139", - "10145", - "10192", - "10170", - "10202", - "10054", - "10174", - "10193", - "12826", - "2136", - "143", - "145", - "2137", - "2120", - "3140", - "543", - "2138", - "2948", - "8400", - "2121", - "8444", - "8412", - "8457", - "8401", - "8422", - "8445", - "8402", - "8413", - "8458", - "8423", - "8446", - "10148", - "10197", - "10205", - "10149", - "10215", - "10223", - "10206", - "10199", - "10150", - "10216", - "10207", - "10225", - "10151", - "116", - "205", - "7300", - "122", - "837", - "10", - "7301", - "7322", - "6143", - "120", - "865", - "8406", - "6141", - "7302", - "8461", - "8407", - "8492", - "8427", - "8408", - "6131", - "7320", - "10159", - "8462", - "10185", - "10179", - "10160", - "10180", - "10219", - "10186", - "10177", - "10230", - "10181", - "10161", - "10187", - "10220", - "2018", - "2663", - "12260", - "2660", - "3115", - "3326", - "2665", - "3116", - "2738", - "3293", - "2661", - "3319", - "2662", - "9983", - "8880", - "2737", - "2739", - "7408", - "3320", - "2666", - "3323", - "3324", - "3294", - "22723", - "23219", - "23220", - "23221", - "23228", - "23338", - "10788", - "10790", - "5611", - "5016", - "5609", - "2060", - "10963", - "10964", - "10965", - "22593", - "22594", - "596", - "996", - "499", - "768", - "17002", - "1448", - "1082", - "16979", - "1079", - "5215", - "20484", - "5221", - "15590", - "17007", - "6795", - "6807", - "5487", - "1446", - "1066", - "5421", - "3139", - "779", - "6811", - "6808", - "1445", - "5216", - "1737", - "5222", - "5217", - "1432", - "6812", - "9492", - "5210", - "3030", - "1441", - "783", - "6801", - "20739", - "8944", - "9491", - "22569", - "5226", - "6786", - "1433", - "8973", - "1828", - "9495", - "9006", - "6794", - "8993", - "5203", - "16914", - "6784", - "9635", - "22830", - "20722", - "9748", - "6790", - "9753", - "9493", - "9752", - "9831", - "9825", - "9822", - "5204", - "5401", - "22831", - "6793", - "9845", - "17401", - "9882", - "9868", - "20749", - "9893", - "9899", - "9895", - "9832", - "9902", - "9909", - "22832", - "9828", - "9851", - "9883", - "9869", - "17406", - "17402", - "9914", - "20750", - "9897", - "9848", - "3127", - "107", - "204", - "9116", - "2457", - "78", - "18848", - "331", - "403", - "2098", - "1752", - "11278", - "11288", - "11284", - "6461", - "2344", - "2345", - "6463", - "2346", - "2352", - "775", - "1434", - "1612", - "71", - "2468", - "2458", - "2467", - "7164", - "7178", - "7367", - "7376", - "7381", - "21156", - "5209", - "3029", - "5201", - "9849", - "9850", - "20719", - "22568", - "22827", - "22828", - "22829", - "6809", - "8972", - "9005", - "9823", - "9827", - "6783", - "9913", - "6785", - "6787", - "9866", - "9867", - "9894", - "9896", - "6800", - "8992", - "9829", - "9830", - "780", - "769", - "6749", - "6750", - "9755", - "9754", - "9908", - "20745", - "20742", - "20747", - "20748", - "9746", - "9745", - "9880", - "9881", - "5391", - "842", - "3025", - "3031", - "3287", - "3329", - "1945", - "3559", - "4933", - "4934", - "4935", - "4936", - "5142", - "5390", - "5392", - "5404", - "5420", - "6405", - "7293", - "7965", - "8041", - "8153", - "9033", - "9034", - //"9036", problems with ghost state - "16421", - "21653", - "22660", - "5225", - "9846", - "2426", - "5916", - "6634", - //"6718", phasing stealth, annoying for learn all case. - "6719", - "8822", - "9591", - "9590", - "10032", - "17746", - "17747", - "8203", - "11392", - "12495", - "16380", - "23452", - "4079", - "4996", - "4997", - "4998", - "4999", - "5000", - "6348", - "6349", - "6481", - "6482", - "6483", - "6484", - "11362", - "11410", - "11409", - "12510", - "12509", - "12885", - "13142", - "21463", - "23460", - "11421", - "11416", - "11418", - "1851", - "10059", - "11423", - "11417", - "11422", - "11419", - "11424", - "11420", - "27", - "31", - "33", - "34", - "35", - "15125", - "21127", - "22950", - "1180", - "201", - "12593", - "16770", - "6057", - "12051", - "18468", - "12606", - "12605", - "18466", - "12502", - "12043", - "15060", - "12042", - "12341", - "12848", - "12344", - "12353", - "18460", - "11366", - "12350", - "12352", - "13043", - "11368", - "11113", - "12400", - "11129", - "16766", - "12573", - "12580", - "12472", - "12953", - "12488", - "11189", - "12985", - "12519", - "16758", - "11958", - "12490", - "11426", - "3565", - "3562", - "18960", - "3567", - "3561", - "3566", - "3563", - "1953", - "2139", - "12505", - "13018", - "12522", - "12523", - "5146", - "5144", - "5148", - "8419", - "8418", - "10213", - "10212", - "10157", - "12524", - "13019", - "12525", - "13020", - "12526", - "13021", - "18809", - "13031", - "13032", - "13033", - "4036", - "3920", - "3919", - "3918", - "7430", - "3922", - "3923", - "7411", - "7418", - "7421", - "13262", - "7412", - "7415", - "7413", - "7416", - "13920", - "13921", - "7745", - "7779", - "7428", - "7457", - "7857", - "7748", - "7426", - "13421", - "7454", - "13378", - "7788", - "14807", - "14293", - "7795", - "6296", - "20608", - "755", - "444", - "427", - "428", - "442", - "447", - "3578", - "3581", - "19027", - "3580", - "665", - "3579", - "3577", - "6755", - "3576", - "2575", - "2577", - "2578", - "2579", - "2580", - "2656", - "2657", - "2576", - "3564", - "10248", - "8388", - "2659", - "14891", - "3308", - "3307", - "10097", - "2658", - "3569", - "16153", - "3304", - "10098", - "4037", - "3929", - "3931", - "3926", - "3924", - "3930", - "3977", - "3925", - "136", - "228", - "5487", - "43", - "202", - "0" - }; - - int loop = 0; - while (strcmp(allSpellList[loop], "0")) - { - uint32 spell = atol((char*)allSpellList[loop++]); - - if (handler->GetSession()->GetPlayer()->HasSpell(spell)) - continue; + "3365", + "6233", + "6247", + "6246", + "6477", + "6478", + "22810", + "8386", + "21651", + "21652", + "522", + "7266", + "8597", + "2479", + "22027", + "6603", + "5019", + "133", + "168", + "227", + "5009", + "9078", + "668", + "203", + "20599", + "20600", + "81", + "20597", + "20598", + "20864", + "1459", + "5504", + "587", + "5143", + "118", + "5505", + "597", + "604", + "1449", + "1460", + "2855", + "1008", + "475", + "5506", + "1463", + "12824", + "8437", + "990", + "5145", + "8450", + "1461", + "759", + "8494", + "8455", + "8438", + "6127", + "8416", + "6129", + "8451", + "8495", + "8439", + "3552", + "8417", + "10138", + "12825", + "10169", + "10156", + "10144", + "10191", + "10201", + "10211", + "10053", + "10173", + "10139", + "10145", + "10192", + "10170", + "10202", + "10054", + "10174", + "10193", + "12826", + "2136", + "143", + "145", + "2137", + "2120", + "3140", + "543", + "2138", + "2948", + "8400", + "2121", + "8444", + "8412", + "8457", + "8401", + "8422", + "8445", + "8402", + "8413", + "8458", + "8423", + "8446", + "10148", + "10197", + "10205", + "10149", + "10215", + "10223", + "10206", + "10199", + "10150", + "10216", + "10207", + "10225", + "10151", + "116", + "205", + "7300", + "122", + "837", + "10", + "7301", + "7322", + "6143", + "120", + "865", + "8406", + "6141", + "7302", + "8461", + "8407", + "8492", + "8427", + "8408", + "6131", + "7320", + "10159", + "8462", + "10185", + "10179", + "10160", + "10180", + "10219", + "10186", + "10177", + "10230", + "10181", + "10161", + "10187", + "10220", + "2018", + "2663", + "12260", + "2660", + "3115", + "3326", + "2665", + "3116", + "2738", + "3293", + "2661", + "3319", + "2662", + "9983", + "8880", + "2737", + "2739", + "7408", + "3320", + "2666", + "3323", + "3324", + "3294", + "22723", + "23219", + "23220", + "23221", + "23228", + "23338", + "10788", + "10790", + "5611", + "5016", + "5609", + "2060", + "10963", + "10964", + "10965", + "22593", + "22594", + "596", + "996", + "499", + "768", + "17002", + "1448", + "1082", + "16979", + "1079", + "5215", + "20484", + "5221", + "15590", + "17007", + "6795", + "6807", + "5487", + "1446", + "1066", + "5421", + "3139", + "779", + "6811", + "6808", + "1445", + "5216", + "1737", + "5222", + "5217", + "1432", + "6812", + "9492", + "5210", + "3030", + "1441", + "783", + "6801", + "20739", + "8944", + "9491", + "22569", + "5226", + "6786", + "1433", + "8973", + "1828", + "9495", + "9006", + "6794", + "8993", + "5203", + "16914", + "6784", + "9635", + "22830", + "20722", + "9748", + "6790", + "9753", + "9493", + "9752", + "9831", + "9825", + "9822", + "5204", + "5401", + "22831", + "6793", + "9845", + "17401", + "9882", + "9868", + "20749", + "9893", + "9899", + "9895", + "9832", + "9902", + "9909", + "22832", + "9828", + "9851", + "9883", + "9869", + "17406", + "17402", + "9914", + "20750", + "9897", + "9848", + "3127", + "107", + "204", + "9116", + "2457", + "78", + "18848", + "331", + "403", + "2098", + "1752", + "11278", + "11288", + "11284", + "6461", + "2344", + "2345", + "6463", + "2346", + "2352", + "775", + "1434", + "1612", + "71", + "2468", + "2458", + "2467", + "7164", + "7178", + "7367", + "7376", + "7381", + "21156", + "5209", + "3029", + "5201", + "9849", + "9850", + "20719", + "22568", + "22827", + "22828", + "22829", + "6809", + "8972", + "9005", + "9823", + "9827", + "6783", + "9913", + "6785", + "6787", + "9866", + "9867", + "9894", + "9896", + "6800", + "8992", + "9829", + "9830", + "780", + "769", + "6749", + "6750", + "9755", + "9754", + "9908", + "20745", + "20742", + "20747", + "20748", + "9746", + "9745", + "9880", + "9881", + "5391", + "842", + "3025", + "3031", + "3287", + "3329", + "1945", + "3559", + "4933", + "4934", + "4935", + "4936", + "5142", + "5390", + "5392", + "5404", + "5420", + "6405", + "7293", + "7965", + "8041", + "8153", + "9033", + "9034", + //"9036", problems with ghost state + "16421", + "21653", + "22660", + "5225", + "9846", + "2426", + "5916", + "6634", + //"6718", phasing stealth, annoying for learn all case. + "6719", + "8822", + "9591", + "9590", + "10032", + "17746", + "17747", + "8203", + "11392", + "12495", + "16380", + "23452", + "4079", + "4996", + "4997", + "4998", + "4999", + "5000", + "6348", + "6349", + "6481", + "6482", + "6483", + "6484", + "11362", + "11410", + "11409", + "12510", + "12509", + "12885", + "13142", + "21463", + "23460", + "11421", + "11416", + "11418", + "1851", + "10059", + "11423", + "11417", + "11422", + "11419", + "11424", + "11420", + "27", + "31", + "33", + "34", + "35", + "15125", + "21127", + "22950", + "1180", + "201", + "12593", + "16770", + "6057", + "12051", + "18468", + "12606", + "12605", + "18466", + "12502", + "12043", + "15060", + "12042", + "12341", + "12848", + "12344", + "12353", + "18460", + "11366", + "12350", + "12352", + "13043", + "11368", + "11113", + "12400", + "11129", + "16766", + "12573", + "12580", + "12472", + "12953", + "12488", + "11189", + "12985", + "12519", + "16758", + "11958", + "12490", + "11426", + "3565", + "3562", + "18960", + "3567", + "3561", + "3566", + "3563", + "1953", + "2139", + "12505", + "13018", + "12522", + "12523", + "5146", + "5144", + "5148", + "8419", + "8418", + "10213", + "10212", + "10157", + "12524", + "13019", + "12525", + "13020", + "12526", + "13021", + "18809", + "13031", + "13032", + "13033", + "4036", + "3920", + "3919", + "3918", + "7430", + "3922", + "3923", + "7411", + "7418", + "7421", + "13262", + "7412", + "7415", + "7413", + "7416", + "13920", + "13921", + "7745", + "7779", + "7428", + "7457", + "7857", + "7748", + "7426", + "13421", + "7454", + "13378", + "7788", + "14807", + "14293", + "7795", + "6296", + "20608", + "755", + "444", + "427", + "428", + "442", + "447", + "3578", + "3581", + "19027", + "3580", + "665", + "3579", + "3577", + "6755", + "3576", + "2575", + "2577", + "2578", + "2579", + "2580", + "2656", + "2657", + "2576", + "3564", + "10248", + "8388", + "2659", + "14891", + "3308", + "3307", + "10097", + "2658", + "3569", + "16153", + "3304", + "10098", + "4037", + "3929", + "3931", + "3926", + "3924", + "3930", + "3977", + "3925", + "136", + "228", + "5487", + "43", + "202", + "0" + }; + + int loop = 0; + while (strcmp(allSpellList[loop], "0")) + { + uint32 spell = atol((char*)allSpellList[loop++]); - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,handler->GetSession()->GetPlayer())) - { - handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); - continue; - } + if (handler->GetSession()->GetPlayer()->HasSpell(spell)) + continue; - handler->GetSession()->GetPlayer()->learnSpell(spell, false); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,handler->GetSession()->GetPlayer())) + { + handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); + continue; } - handler->SendSysMessage(LANG_COMMAND_LEARN_MANY_SPELLS); - - return true; + handler->GetSession()->GetPlayer()->learnSpell(spell, false); } - static bool HandleLearnAllGMCommand(ChatHandler* handler, const char* /*args*/) - { - static const char *gmSpellList[] = - { - "24347", // Become A Fish, No Breath Bar - "35132", // Visual Boom - "38488", // Attack 4000-8000 AOE - "38795", // Attack 2000 AOE + Slow Down 90% - "15712", // Attack 200 - "1852", // GM Spell Silence - "31899", // Kill - "31924", // Kill - "29878", // Kill My Self - "26644", // More Kill - - "28550", //Invisible 24 - "23452", //Invisible + Target - "0" - }; - - uint16 gmSpellIter = 0; - while (strcmp(gmSpellList[gmSpellIter], "0")) - { - uint32 spell = atol((char*)gmSpellList[gmSpellIter++]); + handler->SendSysMessage(LANG_COMMAND_LEARN_MANY_SPELLS); - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,handler->GetSession()->GetPlayer())) - { - handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); - continue; - } + return true; + } + + static bool HandleLearnAllGMCommand(ChatHandler* handler, const char* /*args*/) + { + static const char *gmSpellList[] = + { + "24347", // Become A Fish, No Breath Bar + "35132", // Visual Boom + "38488", // Attack 4000-8000 AOE + "38795", // Attack 2000 AOE + Slow Down 90% + "15712", // Attack 200 + "1852", // GM Spell Silence + "31899", // Kill + "31924", // Kill + "29878", // Kill My Self + "26644", // More Kill + + "28550", //Invisible 24 + "23452", //Invisible + Target + "0" + }; + + uint16 gmSpellIter = 0; + while (strcmp(gmSpellList[gmSpellIter], "0")) + { + uint32 spell = atol((char*)gmSpellList[gmSpellIter++]); - handler->GetSession()->GetPlayer()->learnSpell(spell, false); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,handler->GetSession()->GetPlayer())) + { + handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); + continue; } - handler->SendSysMessage(LANG_LEARNING_GM_SKILLS); - return true; + handler->GetSession()->GetPlayer()->learnSpell(spell, false); } - static bool HandleLearnAllMyClassCommand(ChatHandler* handler, const char* /*args*/) - { - HandleLearnAllMySpellsCommand(handler, ""); - HandleLearnAllMyTalentsCommand(handler, ""); + handler->SendSysMessage(LANG_LEARNING_GM_SKILLS); + return true; + } + + static bool HandleLearnAllMyClassCommand(ChatHandler* handler, const char* /*args*/) + { + HandleLearnAllMySpellsCommand(handler, ""); + HandleLearnAllMyTalentsCommand(handler, ""); + return true; + } + + static bool HandleLearnAllMySpellsCommand(ChatHandler* handler, const char* /*args*/) + { + ChrClassesEntry const* clsEntry = sChrClassesStore.LookupEntry(handler->GetSession()->GetPlayer()->getClass()); + if (!clsEntry) return true; - } + uint32 family = clsEntry->spellfamily; - static bool HandleLearnAllMySpellsCommand(ChatHandler* handler, const char* /*args*/) + for (uint32 i = 0; i < sSpellStore.GetNumRows(); ++i) { - ChrClassesEntry const* clsEntry = sChrClassesStore.LookupEntry(handler->GetSession()->GetPlayer()->getClass()); - if (!clsEntry) - return true; - uint32 family = clsEntry->spellfamily; + SpellEntry const *spellInfo = sSpellStore.LookupEntry(i); + if (!spellInfo) + continue; - for (uint32 i = 0; i < sSpellStore.GetNumRows(); ++i) - { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(i); - if (!spellInfo) - continue; + // skip server-side/triggered spells + if (spellInfo->spellLevel == 0) + continue; - // skip server-side/triggered spells - if (spellInfo->spellLevel == 0) - continue; + // skip wrong class/race skills + if (!handler->GetSession()->GetPlayer()->IsSpellFitByClassAndRace(spellInfo->Id)) + continue; - // skip wrong class/race skills - if (!handler->GetSession()->GetPlayer()->IsSpellFitByClassAndRace(spellInfo->Id)) - continue; + // skip other spell families + if (spellInfo->SpellFamilyName != family) + continue; - // skip other spell families - if (spellInfo->SpellFamilyName != family) - continue; + // skip spells with first rank learned as talent (and all talents then also) + uint32 first_rank = sSpellMgr.GetFirstSpellInChain(spellInfo->Id); + if (GetTalentSpellCost(first_rank) > 0) + continue; - // skip spells with first rank learned as talent (and all talents then also) - uint32 first_rank = sSpellMgr.GetFirstSpellInChain(spellInfo->Id); - if (GetTalentSpellCost(first_rank) > 0) - continue; + // skip broken spells + if (!SpellMgr::IsSpellValid(spellInfo,handler->GetSession()->GetPlayer(),false)) + continue; - // skip broken spells - if (!SpellMgr::IsSpellValid(spellInfo,handler->GetSession()->GetPlayer(),false)) - continue; + handler->GetSession()->GetPlayer()->learnSpell(i, false); + } - handler->GetSession()->GetPlayer()->learnSpell(i, false); - } + handler->SendSysMessage(LANG_COMMAND_LEARN_CLASS_SPELLS); + return true; + } - handler->SendSysMessage(LANG_COMMAND_LEARN_CLASS_SPELLS); - return true; - } + static bool HandleLearnAllMyTalentsCommand(ChatHandler* handler, const char* /*args*/) + { + Player* player = handler->GetSession()->GetPlayer(); + uint32 classMask = player->getClassMask(); - static bool HandleLearnAllMyTalentsCommand(ChatHandler* handler, const char* /*args*/) + for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) { - Player* player = handler->GetSession()->GetPlayer(); - uint32 classMask = player->getClassMask(); - - for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) - { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - if (!talentInfo) - continue; + TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); + if (!talentInfo) + continue; - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); - if (!talentTabInfo) - continue; + TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); + if (!talentTabInfo) + continue; - if ((classMask & talentTabInfo->ClassMask) == 0) - continue; + if ((classMask & talentTabInfo->ClassMask) == 0) + continue; - // search highest talent rank - uint32 spellId = 0; - for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank) + // search highest talent rank + uint32 spellId = 0; + for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank) + { + if (talentInfo->RankID[rank] != 0) { - if (talentInfo->RankID[rank] != 0) - { - spellId = talentInfo->RankID[rank]; - break; - } + spellId = talentInfo->RankID[rank]; + break; } + } - if (!spellId) // ??? none spells in talent - continue; + if (!spellId) // ??? none spells in talent + continue; - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,handler->GetSession()->GetPlayer(),false)) - continue; + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,handler->GetSession()->GetPlayer(),false)) + continue; - // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree) - player->learnSpellHighRank(spellId); - player->AddTalent(spellId, player->GetActiveSpec(), true); - } + // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree) + player->learnSpellHighRank(spellId); + player->AddTalent(spellId, player->GetActiveSpec(), true); + } - player->SetFreeTalentPoints(0); + player->SetFreeTalentPoints(0); - handler->SendSysMessage(LANG_COMMAND_LEARN_CLASS_TALENTS); - return true; - } + handler->SendSysMessage(LANG_COMMAND_LEARN_CLASS_TALENTS); + return true; + } - static bool HandleLearnAllMyPetTalentsCommand(ChatHandler* handler, const char* /*args*/) - { - Player* player = handler->GetSession()->GetPlayer(); + static bool HandleLearnAllMyPetTalentsCommand(ChatHandler* handler, const char* /*args*/) + { + Player* player = handler->GetSession()->GetPlayer(); - Pet* pet = player->GetPet(); - if (!pet) - { - handler->SendSysMessage(LANG_NO_PET_FOUND); - handler->SetSentErrorMessage(true); - return false; - } + Pet* pet = player->GetPet(); + if (!pet) + { + handler->SendSysMessage(LANG_NO_PET_FOUND); + handler->SetSentErrorMessage(true); + return false; + } - CreatureInfo const *ci = pet->GetCreatureInfo(); - if (!ci) - { - handler->SendSysMessage(LANG_WRONG_PET_TYPE); - handler->SetSentErrorMessage(true); - return false; - } + CreatureInfo const *ci = pet->GetCreatureInfo(); + if (!ci) + { + handler->SendSysMessage(LANG_WRONG_PET_TYPE); + handler->SetSentErrorMessage(true); + return false; + } - CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(ci->family); - if (!pet_family) - { - handler->SendSysMessage(LANG_WRONG_PET_TYPE); - handler->SetSentErrorMessage(true); - return false; - } + CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(ci->family); + if (!pet_family) + { + handler->SendSysMessage(LANG_WRONG_PET_TYPE); + handler->SetSentErrorMessage(true); + return false; + } - if (pet_family->petTalentType < 0) // not hunter pet - { - handler->SendSysMessage(LANG_WRONG_PET_TYPE); - handler->SetSentErrorMessage(true); - return false; - } + if (pet_family->petTalentType < 0) // not hunter pet + { + handler->SendSysMessage(LANG_WRONG_PET_TYPE); + handler->SetSentErrorMessage(true); + return false; + } - for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) - { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - if (!talentInfo) - continue; + for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) + { + TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); + if (!talentInfo) + continue; - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); - if (!talentTabInfo) - continue; + TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); + if (!talentTabInfo) + continue; - // prevent learn talent for different family (cheating) - if (((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask) == 0) - continue; + // prevent learn talent for different family (cheating) + if (((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask) == 0) + continue; - // search highest talent rank - uint32 spellid = 0; + // search highest talent rank + uint32 spellid = 0; - for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank) + for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank) + { + if (talentInfo->RankID[rank] != 0) { - if (talentInfo->RankID[rank] != 0) - { - spellid = talentInfo->RankID[rank]; - break; - } + spellid = talentInfo->RankID[rank]; + break; } + } - if (!spellid) // ??? none spells in talent - continue; + if (!spellid) // ??? none spells in talent + continue; - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,handler->GetSession()->GetPlayer(),false)) - continue; + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid); + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,handler->GetSession()->GetPlayer(),false)) + continue; - // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree) - pet->learnSpellHighRank(spellid); - } + // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree) + pet->learnSpellHighRank(spellid); + } - pet->SetFreeTalentPoints(0); + pet->SetFreeTalentPoints(0); - handler->SendSysMessage(LANG_COMMAND_LEARN_PET_TALENTS); - return true; - } + handler->SendSysMessage(LANG_COMMAND_LEARN_PET_TALENTS); + return true; + } - static bool HandleLearnAllLangCommand(ChatHandler* handler, const char* /*args*/) - { - // skipping UNIVERSAL language (0) - for (uint8 i = 1; i < LANGUAGES_COUNT; ++i) - handler->GetSession()->GetPlayer()->learnSpell(lang_description[i].spell_id, false); + static bool HandleLearnAllLangCommand(ChatHandler* handler, const char* /*args*/) + { + // skipping UNIVERSAL language (0) + for (uint8 i = 1; i < LANGUAGES_COUNT; ++i) + handler->GetSession()->GetPlayer()->learnSpell(lang_description[i].spell_id, false); - handler->SendSysMessage(LANG_COMMAND_LEARN_ALL_LANG); - return true; - } + handler->SendSysMessage(LANG_COMMAND_LEARN_ALL_LANG); + return true; + } - static bool HandleLearnAllDefaultCommand(ChatHandler* handler, const char* args) - { - Player* target; - if (!handler->extractPlayerTarget((char*)args,&target)) - return false; + static bool HandleLearnAllDefaultCommand(ChatHandler* handler, const char* args) + { + Player* target; + if (!handler->extractPlayerTarget((char*)args,&target)) + return false; - target->learnDefaultSpells(); - target->learnQuestRewardedSpells(); + target->learnDefaultSpells(); + target->learnQuestRewardedSpells(); - handler->PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST,handler->GetNameLink(target).c_str()); - return true; - } + handler->PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST,handler->GetNameLink(target).c_str()); + return true; + } + + static bool HandleLearnAllCraftsCommand(ChatHandler* handler, const char* /*args*/) + { - static bool HandleLearnAllCraftsCommand(ChatHandler* handler, const char* /*args*/) + for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i) { + SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(i); + if (!skillInfo) + continue; - for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i) + if ((skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY) && + skillInfo->canLink) // only prof. with recipes have { - SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(i); - if (!skillInfo) - continue; - - if ((skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY) && - skillInfo->canLink) // only prof. with recipes have - { - HandleLearnSkillRecipesHelper(handler->GetSession()->GetPlayer(),skillInfo->id); - } + HandleLearnSkillRecipesHelper(handler->GetSession()->GetPlayer(),skillInfo->id); } - - handler->SendSysMessage(LANG_COMMAND_LEARN_ALL_CRAFT); - return true; } - static bool HandleLearnAllRecipesCommand(ChatHandler* handler, const char* args) - { - // Learns all recipes of specified profession and sets skill to max - // Example: .learn all_recipes enchanting + handler->SendSysMessage(LANG_COMMAND_LEARN_ALL_CRAFT); + return true; + } - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); - return false; - } + static bool HandleLearnAllRecipesCommand(ChatHandler* handler, const char* args) + { + // Learns all recipes of specified profession and sets skill to max + // Example: .learn all_recipes enchanting - if (!*args) - return false; + Player* target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + return false; + } - std::wstring wnamepart; + if (!*args) + return false; - if (!Utf8toWStr(args,wnamepart)) - return false; + std::wstring wnamepart; - // converting string that we try to find to lower case - wstrToLower(wnamepart); + if (!Utf8toWStr(args,wnamepart)) + return false; - std::string name; + // converting string that we try to find to lower case + wstrToLower(wnamepart); - SkillLineEntry const *targetSkillInfo = NULL; - for (uint32 i = 1; i < sSkillLineStore.GetNumRows(); ++i) - { - SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(i); - if (!skillInfo) - continue; + std::string name; + + SkillLineEntry const *targetSkillInfo = NULL; + for (uint32 i = 1; i < sSkillLineStore.GetNumRows(); ++i) + { + SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(i); + if (!skillInfo) + continue; - if ((skillInfo->categoryId != SKILL_CATEGORY_PROFESSION && - skillInfo->categoryId != SKILL_CATEGORY_SECONDARY) || - !skillInfo->canLink) // only prof with recipes have set - continue; + if ((skillInfo->categoryId != SKILL_CATEGORY_PROFESSION && + skillInfo->categoryId != SKILL_CATEGORY_SECONDARY) || + !skillInfo->canLink) // only prof with recipes have set + continue; - int loc = handler->GetSessionDbcLocale(); - name = skillInfo->name[loc]; - if (name.empty()) - continue; + int loc = handler->GetSessionDbcLocale(); + name = skillInfo->name[loc]; + if (name.empty()) + continue; - if (!Utf8FitTo(name, wnamepart)) + if (!Utf8FitTo(name, wnamepart)) + { + loc = 0; + for (; loc < TOTAL_LOCALES; ++loc) { - loc = 0; - for (; loc < TOTAL_LOCALES; ++loc) - { - if (loc == handler->GetSessionDbcLocale()) - continue; - - name = skillInfo->name[loc]; - if (name.empty()) - continue; - - if (Utf8FitTo(name, wnamepart)) - break; - } - } + if (loc == handler->GetSessionDbcLocale()) + continue; - if (loc < TOTAL_LOCALES) - { - targetSkillInfo = skillInfo; - break; + name = skillInfo->name[loc]; + if (name.empty()) + continue; + + if (Utf8FitTo(name, wnamepart)) + break; } } - if (!targetSkillInfo) - return false; + if (loc < TOTAL_LOCALES) + { + targetSkillInfo = skillInfo; + break; + } + } + + if (!targetSkillInfo) + return false; - HandleLearnSkillRecipesHelper(target,targetSkillInfo->id); + HandleLearnSkillRecipesHelper(target,targetSkillInfo->id); - uint16 maxLevel = target->GetPureMaxSkillValue(targetSkillInfo->id); - target->SetSkill(targetSkillInfo->id, target->GetSkillStep(targetSkillInfo->id), maxLevel, maxLevel); - handler->PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, name.c_str()); - return true; - } + uint16 maxLevel = target->GetPureMaxSkillValue(targetSkillInfo->id); + target->SetSkill(targetSkillInfo->id, target->GetSkillStep(targetSkillInfo->id), maxLevel, maxLevel); + handler->PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, name.c_str()); + return true; + } + static void HandleLearnSkillRecipesHelper(Player* player,uint32 skill_id) + { + uint32 classmask = player->getClassMask(); - static void HandleLearnSkillRecipesHelper(Player* player,uint32 skill_id) + for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) { - uint32 classmask = player->getClassMask(); - - for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) - { - SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); - if (!skillLine) - continue; + SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); + if (!skillLine) + continue; - // wrong skill - if (skillLine->skillId != skill_id) - continue; + // wrong skill + if (skillLine->skillId != skill_id) + continue; - // not high rank - if (skillLine->forward_spellid) - continue; + // not high rank + if (skillLine->forward_spellid) + continue; - // skip racial skills - if (skillLine->racemask != 0) - continue; + // skip racial skills + if (skillLine->racemask != 0) + continue; - // skip wrong class skills - if (skillLine->classmask && (skillLine->classmask & classmask) == 0) - continue; + // skip wrong class skills + if (skillLine->classmask && (skillLine->classmask & classmask) == 0) + continue; - SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,player,false)) - continue; + SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId); + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,player,false)) + continue; - player->learnSpell(skillLine->spellId, false); - } + player->learnSpell(skillLine->spellId, false); } + } }; void AddSC_learn_commandscript() diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index 41017573680..32586f0c9c6 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -28,1344 +28,1344 @@ EndScriptData */ class modify_commandscript : public CommandScript { - public: - modify_commandscript() : CommandScript("modify_commandscript") { } +public: + modify_commandscript() : CommandScript("modify_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const + { + static ChatCommand modifyCommandTable[] = { - static ChatCommand modifyCommandTable[] = - { - { "hp", SEC_MODERATOR, false, &HandleModifyHPCommand, "", NULL }, - { "mana", SEC_MODERATOR, false, &HandleModifyManaCommand, "", NULL }, - { "rage", SEC_MODERATOR, false, &HandleModifyRageCommand, "", NULL }, - { "runicpower", SEC_MODERATOR, false, &HandleModifyRunicPowerCommand, "", NULL }, - { "energy", SEC_MODERATOR, false, &HandleModifyEnergyCommand, "", NULL }, - { "money", SEC_MODERATOR, false, &HandleModifyMoneyCommand, "", NULL }, - { "speed", SEC_MODERATOR, false, &HandleModifySpeedCommand, "", NULL }, - { "swim", SEC_MODERATOR, false, &HandleModifySwimCommand, "", NULL }, - { "scale", SEC_MODERATOR, false, &HandleModifyScaleCommand, "", NULL }, - { "bit", SEC_MODERATOR, false, &HandleModifyBitCommand, "", NULL }, - { "bwalk", SEC_MODERATOR, false, &HandleModifyBWalkCommand, "", NULL }, - { "fly", SEC_MODERATOR, false, &HandleModifyFlyCommand, "", NULL }, - { "aspeed", SEC_MODERATOR, false, &HandleModifyASpeedCommand, "", NULL }, - { "faction", SEC_MODERATOR, false, &HandleModifyFactionCommand, "", NULL }, - { "spell", SEC_MODERATOR, false, &HandleModifySpellCommand, "", NULL }, - { "tp", SEC_MODERATOR, false, &HandleModifyTalentCommand, "", NULL }, - { "mount", SEC_MODERATOR, false, &HandleModifyMountCommand, "", NULL }, - { "honor", SEC_MODERATOR, false, &HandleModifyHonorCommand, "", NULL }, - { "rep", SEC_GAMEMASTER, false, &HandleModifyRepCommand, "", NULL }, - { "arena", SEC_MODERATOR, false, &HandleModifyArenaCommand, "", NULL }, - { "drunk", SEC_MODERATOR, false, &HandleModifyDrunkCommand, "", NULL }, - { "standstate", SEC_GAMEMASTER, false, &HandleModifyStandStateCommand, "", NULL }, - { "morph", SEC_GAMEMASTER, false, &HandleModifyMorphCommand, "", NULL }, - { "phase", SEC_ADMINISTRATOR, false, &HandleModifyPhaseCommand, "", NULL }, - { "gender", SEC_GAMEMASTER, false, &HandleModifyGenderCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand commandTable[] = - { - { "modify", SEC_MODERATOR, false, NULL, "", modifyCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - return commandTable; + { "hp", SEC_MODERATOR, false, &HandleModifyHPCommand, "", NULL }, + { "mana", SEC_MODERATOR, false, &HandleModifyManaCommand, "", NULL }, + { "rage", SEC_MODERATOR, false, &HandleModifyRageCommand, "", NULL }, + { "runicpower", SEC_MODERATOR, false, &HandleModifyRunicPowerCommand, "", NULL }, + { "energy", SEC_MODERATOR, false, &HandleModifyEnergyCommand, "", NULL }, + { "money", SEC_MODERATOR, false, &HandleModifyMoneyCommand, "", NULL }, + { "speed", SEC_MODERATOR, false, &HandleModifySpeedCommand, "", NULL }, + { "swim", SEC_MODERATOR, false, &HandleModifySwimCommand, "", NULL }, + { "scale", SEC_MODERATOR, false, &HandleModifyScaleCommand, "", NULL }, + { "bit", SEC_MODERATOR, false, &HandleModifyBitCommand, "", NULL }, + { "bwalk", SEC_MODERATOR, false, &HandleModifyBWalkCommand, "", NULL }, + { "fly", SEC_MODERATOR, false, &HandleModifyFlyCommand, "", NULL }, + { "aspeed", SEC_MODERATOR, false, &HandleModifyASpeedCommand, "", NULL }, + { "faction", SEC_MODERATOR, false, &HandleModifyFactionCommand, "", NULL }, + { "spell", SEC_MODERATOR, false, &HandleModifySpellCommand, "", NULL }, + { "tp", SEC_MODERATOR, false, &HandleModifyTalentCommand, "", NULL }, + { "mount", SEC_MODERATOR, false, &HandleModifyMountCommand, "", NULL }, + { "honor", SEC_MODERATOR, false, &HandleModifyHonorCommand, "", NULL }, + { "rep", SEC_GAMEMASTER, false, &HandleModifyRepCommand, "", NULL }, + { "arena", SEC_MODERATOR, false, &HandleModifyArenaCommand, "", NULL }, + { "drunk", SEC_MODERATOR, false, &HandleModifyDrunkCommand, "", NULL }, + { "standstate", SEC_GAMEMASTER, false, &HandleModifyStandStateCommand, "", NULL }, + { "morph", SEC_GAMEMASTER, false, &HandleModifyMorphCommand, "", NULL }, + { "phase", SEC_ADMINISTRATOR, false, &HandleModifyPhaseCommand, "", NULL }, + { "gender", SEC_GAMEMASTER, false, &HandleModifyGenderCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "modify", SEC_MODERATOR, false, NULL, "", modifyCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } + + //Edit Player HP + static bool HandleModifyHPCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; + + int32 hp = atoi((char*)args); + int32 hpm = atoi((char*)args); + + if (hp < 1 || hpm < 1 || hpm < hp) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; } - //Edit Player HP - static bool HandleModifyHPCommand(ChatHandler* handler, const char* args) + Player* target = handler->getSelectedPlayer(); + if (!target) { - if (!*args) - return false; + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - int32 hp = atoi((char*)args); - int32 hpm = atoi((char*)args); + if (handler->HasLowerSecurity(target, 0)) + return false; - if (hp < 1 || hpm < 1 || hpm < hp) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + handler->PSendSysMessage(LANG_YOU_CHANGE_HP, handler->GetNameLink(target).c_str(), hp, hpm); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_HP_CHANGED, handler->GetNameLink().c_str(), hp, hpm); - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + target->SetMaxHealth(hpm); + target->SetHealth(hp); - if (handler->HasLowerSecurity(target, 0)) - return false; + return true; + } - handler->PSendSysMessage(LANG_YOU_CHANGE_HP, handler->GetNameLink(target).c_str(), hp, hpm); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_HP_CHANGED, handler->GetNameLink().c_str(), hp, hpm); + //Edit Player Mana + static bool HandleModifyManaCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - target->SetMaxHealth(hpm); - target->SetHealth(hp); + int32 mana = atoi((char*)args); + int32 manam = atoi((char*)args); - return true; + if (mana <= 0 || manam <= 0 || manam < mana) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; } - //Edit Player Mana - static bool HandleModifyManaCommand(ChatHandler* handler, const char* args) + Player* target = handler->getSelectedPlayer(); + if (!target) { - if (!*args) - return false; + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - int32 mana = atoi((char*)args); - int32 manam = atoi((char*)args); + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - if (mana <= 0 || manam <= 0 || manam < mana) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + handler->PSendSysMessage(LANG_YOU_CHANGE_MANA, handler->GetNameLink(target).c_str(), mana, manam); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_MANA_CHANGED, handler->GetNameLink().c_str(), mana, manam); - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + target->SetMaxPower(POWER_MANA,manam); + target->SetPower(POWER_MANA, mana); - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + return true; + } - handler->PSendSysMessage(LANG_YOU_CHANGE_MANA, handler->GetNameLink(target).c_str(), mana, manam); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_MANA_CHANGED, handler->GetNameLink().c_str(), mana, manam); + //Edit Player Energy + static bool HandleModifyEnergyCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - target->SetMaxPower(POWER_MANA,manam); - target->SetPower(POWER_MANA, mana); + // char* pmana = strtok((char*)args, " "); + // if (!pmana) + // return false; - return true; + // char* pmanaMax = strtok(NULL, " "); + // if (!pmanaMax) + // return false; + + // int32 manam = atoi(pmanaMax); + // int32 mana = atoi(pmana); + + int32 energy = atoi((char*)args)*10; + int32 energym = atoi((char*)args)*10; + + if (energy <= 0 || energym <= 0 || energym < energy) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; } - //Edit Player Energy - static bool HandleModifyEnergyCommand(ChatHandler* handler, const char* args) + Player* target = handler->getSelectedPlayer(); + if (!target) { - if (!*args) - return false; + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - // char* pmana = strtok((char*)args, " "); - // if (!pmana) - // return false; + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - // char* pmanaMax = strtok(NULL, " "); - // if (!pmanaMax) - // return false; + handler->PSendSysMessage(LANG_YOU_CHANGE_ENERGY, handler->GetNameLink(target).c_str(), energy/10, energym/10); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, handler->GetNameLink().c_str(), energy/10, energym/10); - // int32 manam = atoi(pmanaMax); - // int32 mana = atoi(pmana); + target->SetMaxPower(POWER_ENERGY,energym); + target->SetPower(POWER_ENERGY, energy); - int32 energy = atoi((char*)args)*10; - int32 energym = atoi((char*)args)*10; + sLog.outDetail(handler->GetTrinityString(LANG_CURRENT_ENERGY),target->GetMaxPower(POWER_ENERGY)); - if (energy <= 0 || energym <= 0 || energym < energy) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + return true; + } - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + //Edit Player Rage + static bool HandleModifyRageCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + // char* pmana = strtok((char*)args, " "); + // if (!pmana) + // return false; - handler->PSendSysMessage(LANG_YOU_CHANGE_ENERGY, handler->GetNameLink(target).c_str(), energy/10, energym/10); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, handler->GetNameLink().c_str(), energy/10, energym/10); + // char* pmanaMax = strtok(NULL, " "); + // if (!pmanaMax) + // return false; - target->SetMaxPower(POWER_ENERGY,energym); - target->SetPower(POWER_ENERGY, energy); + // int32 manam = atoi(pmanaMax); + // int32 mana = atoi(pmana); - sLog.outDetail(handler->GetTrinityString(LANG_CURRENT_ENERGY),target->GetMaxPower(POWER_ENERGY)); + int32 rage = atoi((char*)args)*10; + int32 ragem = atoi((char*)args)*10; - return true; + if (rage <= 0 || ragem <= 0 || ragem < rage) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; } - //Edit Player Rage - static bool HandleModifyRageCommand(ChatHandler* handler, const char* args) + Player* target = handler->getSelectedPlayer(); + if (!target) { - if (!*args) - return false; - - // char* pmana = strtok((char*)args, " "); - // if (!pmana) - // return false; - - // char* pmanaMax = strtok(NULL, " "); - // if (!pmanaMax) - // return false; - - // int32 manam = atoi(pmanaMax); - // int32 mana = atoi(pmana); + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - int32 rage = atoi((char*)args)*10; - int32 ragem = atoi((char*)args)*10; + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - if (rage <= 0 || ragem <= 0 || ragem < rage) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + handler->PSendSysMessage(LANG_YOU_CHANGE_RAGE, handler->GetNameLink(target).c_str(), rage/10, ragem/10); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, handler->GetNameLink().c_str(), rage/10, ragem/10); - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + target->SetMaxPower(POWER_RAGE,ragem); + target->SetPower(POWER_RAGE, rage); - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + return true; + } - handler->PSendSysMessage(LANG_YOU_CHANGE_RAGE, handler->GetNameLink(target).c_str(), rage/10, ragem/10); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, handler->GetNameLink().c_str(), rage/10, ragem/10); + // Edit Player Runic Power + static bool HandleModifyRunicPowerCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - target->SetMaxPower(POWER_RAGE,ragem); - target->SetPower(POWER_RAGE, rage); + int32 rune = atoi((char*)args)*10; + int32 runem = atoi((char*)args)*10; - return true; + if (rune <= 0 || runem <= 0 || runem < rune) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; } - // Edit Player Runic Power - static bool HandleModifyRunicPowerCommand(ChatHandler* handler, const char* args) + Player* target = handler->getSelectedPlayer(); + if (!target) { - if (!*args) - return false; + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - int32 rune = atoi((char*)args)*10; - int32 runem = atoi((char*)args)*10; + handler->PSendSysMessage(LANG_YOU_CHANGE_RUNIC_POWER, handler->GetNameLink(target).c_str(), rune/10, runem/10); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, handler->GetNameLink().c_str(), rune/10, runem/10); - if (rune <= 0 || runem <= 0 || runem < rune) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + target->SetMaxPower(POWER_RUNIC_POWER,runem); + target->SetPower(POWER_RUNIC_POWER, rune); - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + return true; + } - handler->PSendSysMessage(LANG_YOU_CHANGE_RUNIC_POWER, handler->GetNameLink(target).c_str(), rune/10, runem/10); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, handler->GetNameLink().c_str(), rune/10, runem/10); + //Edit Player Faction + static bool HandleModifyFactionCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - target->SetMaxPower(POWER_RUNIC_POWER,runem); - target->SetPower(POWER_RUNIC_POWER, rune); + char* pfactionid = handler->extractKeyFromLink((char*)args,"Hfaction"); - return true; + Creature* target = handler->getSelectedCreature(); + if (!target) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; } - //Edit Player Faction - static bool HandleModifyFactionCommand(ChatHandler* handler, const char* args) + if (!pfactionid) { - if (!*args) - return false; - - char* pfactionid = handler->extractKeyFromLink((char*)args,"Hfaction"); - - Creature* target = handler->getSelectedCreature(); - if (!target) + if (target) { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; + uint32 factionid = target->getFaction(); + uint32 flag = target->GetUInt32Value(UNIT_FIELD_FLAGS); + uint32 npcflag = target->GetUInt32Value(UNIT_NPC_FLAGS); + uint32 dyflag = target->GetUInt32Value(UNIT_DYNAMIC_FLAGS); + handler->PSendSysMessage(LANG_CURRENT_FACTION,target->GetGUIDLow(),factionid,flag,npcflag,dyflag); } + return true; + } - if (!pfactionid) - { - if (target) - { - uint32 factionid = target->getFaction(); - uint32 flag = target->GetUInt32Value(UNIT_FIELD_FLAGS); - uint32 npcflag = target->GetUInt32Value(UNIT_NPC_FLAGS); - uint32 dyflag = target->GetUInt32Value(UNIT_DYNAMIC_FLAGS); - handler->PSendSysMessage(LANG_CURRENT_FACTION,target->GetGUIDLow(),factionid,flag,npcflag,dyflag); - } - return true; - } + if (!target) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + uint32 factionid = atoi(pfactionid); + uint32 flag; - uint32 factionid = atoi(pfactionid); - uint32 flag; + char *pflag = strtok(NULL, " "); + if (!pflag) + flag = target->GetUInt32Value(UNIT_FIELD_FLAGS); + else + flag = atoi(pflag); - char *pflag = strtok(NULL, " "); - if (!pflag) - flag = target->GetUInt32Value(UNIT_FIELD_FLAGS); - else - flag = atoi(pflag); + char* pnpcflag = strtok(NULL, " "); - char* pnpcflag = strtok(NULL, " "); + uint32 npcflag; + if (!pnpcflag) + npcflag = target->GetUInt32Value(UNIT_NPC_FLAGS); + else + npcflag = atoi(pnpcflag); - uint32 npcflag; - if (!pnpcflag) - npcflag = target->GetUInt32Value(UNIT_NPC_FLAGS); - else - npcflag = atoi(pnpcflag); + char* pdyflag = strtok(NULL, " "); - char* pdyflag = strtok(NULL, " "); + uint32 dyflag; + if (!pdyflag) + dyflag = target->GetUInt32Value(UNIT_DYNAMIC_FLAGS); + else + dyflag = atoi(pdyflag); - uint32 dyflag; - if (!pdyflag) - dyflag = target->GetUInt32Value(UNIT_DYNAMIC_FLAGS); - else - dyflag = atoi(pdyflag); + if (!sFactionTemplateStore.LookupEntry(factionid)) + { + handler->PSendSysMessage(LANG_WRONG_FACTION, factionid); + handler->SetSentErrorMessage(true); + return false; + } - if (!sFactionTemplateStore.LookupEntry(factionid)) - { - handler->PSendSysMessage(LANG_WRONG_FACTION, factionid); - handler->SetSentErrorMessage(true); - return false; - } + handler->PSendSysMessage(LANG_YOU_CHANGE_FACTION, target->GetGUIDLow(),factionid,flag,npcflag,dyflag); - handler->PSendSysMessage(LANG_YOU_CHANGE_FACTION, target->GetGUIDLow(),factionid,flag,npcflag,dyflag); + target->setFaction(factionid); + target->SetUInt32Value(UNIT_FIELD_FLAGS,flag); + target->SetUInt32Value(UNIT_NPC_FLAGS,npcflag); + target->SetUInt32Value(UNIT_DYNAMIC_FLAGS,dyflag); - target->setFaction(factionid); - target->SetUInt32Value(UNIT_FIELD_FLAGS,flag); - target->SetUInt32Value(UNIT_NPC_FLAGS,npcflag); - target->SetUInt32Value(UNIT_DYNAMIC_FLAGS,dyflag); + return true; + } - return true; - } + //Edit Player Spell + static bool HandleModifySpellCommand(ChatHandler* handler, const char* args) + { + if (!*args) return false; + char* pspellflatid = strtok((char*)args, " "); + if (!pspellflatid) + return false; - //Edit Player Spell - static bool HandleModifySpellCommand(ChatHandler* handler, const char* args) - { - if (!*args) return false; - char* pspellflatid = strtok((char*)args, " "); - if (!pspellflatid) - return false; + char* pop = strtok(NULL, " "); + if (!pop) + return false; - char* pop = strtok(NULL, " "); - if (!pop) - return false; + char* pval = strtok(NULL, " "); + if (!pval) + return false; - char* pval = strtok(NULL, " "); - if (!pval) - return false; + uint16 mark; - uint16 mark; + char* pmark = strtok(NULL, " "); - char* pmark = strtok(NULL, " "); + uint8 spellflatid = atoi(pspellflatid); + uint8 op = atoi(pop); + uint16 val = atoi(pval); + if (!pmark) + mark = 65535; + else + mark = atoi(pmark); - uint8 spellflatid = atoi(pspellflatid); - uint8 op = atoi(pop); - uint16 val = atoi(pval); - if (!pmark) - mark = 65535; - else - mark = atoi(pmark); + Player* target = handler->getSelectedPlayer(); + if (target == NULL) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - Player* target = handler->getSelectedPlayer(); - if (target == NULL) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + handler->PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellflatid, val, mark, handler->GetNameLink(target).c_str()); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, handler->GetNameLink().c_str(), spellflatid, val, mark); - handler->PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellflatid, val, mark, handler->GetNameLink(target).c_str()); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, handler->GetNameLink().c_str(), spellflatid, val, mark); + WorldPacket data(SMSG_SET_FLAT_SPELL_MODIFIER, (1+1+2+2)); + data << uint8(spellflatid); + data << uint8(op); + data << uint16(val); + data << uint16(mark); + target->GetSession()->SendPacket(&data); - WorldPacket data(SMSG_SET_FLAT_SPELL_MODIFIER, (1+1+2+2)); - data << uint8(spellflatid); - data << uint8(op); - data << uint16(val); - data << uint16(mark); - target->GetSession()->SendPacket(&data); + return true; + } - return true; - } + //Edit Player TP + static bool HandleModifyTalentCommand (ChatHandler* handler, const char* args) + { + if (!*args) + return false; - //Edit Player TP - static bool HandleModifyTalentCommand (ChatHandler* handler, const char* args) - { - if (!*args) - return false; + int tp = atoi((char*)args); + if (tp < 0) + return false; - int tp = atoi((char*)args); - if (tp < 0) - return false; + Unit* target = handler->getSelectedUnit(); + if (!target) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - Unit* target = handler->getSelectedUnit(); - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); + if (target->GetTypeId() == TYPEID_PLAYER) + { + // check online security + if (handler->HasLowerSecurity(target->ToPlayer(), 0)) return false; - } - - if (target->GetTypeId() == TYPEID_PLAYER) + target->ToPlayer()->SetFreeTalentPoints(tp); + target->ToPlayer()->SendTalentsInfoData(false); + return true; + } + else if (target->ToCreature()->isPet()) + { + Unit *owner = target->GetOwner(); + if (owner && owner->GetTypeId() == TYPEID_PLAYER && ((Pet *)target)->IsPermanentPetFor(owner->ToPlayer())) { // check online security - if (handler->HasLowerSecurity(target->ToPlayer(), 0)) + if (handler->HasLowerSecurity(owner->ToPlayer(), 0)) return false; - target->ToPlayer()->SetFreeTalentPoints(tp); - target->ToPlayer()->SendTalentsInfoData(false); + ((Pet *)target)->SetFreeTalentPoints(tp); + owner->ToPlayer()->SendTalentsInfoData(true); return true; } - else if (target->ToCreature()->isPet()) - { - Unit *owner = target->GetOwner(); - if (owner && owner->GetTypeId() == TYPEID_PLAYER && ((Pet *)target)->IsPermanentPetFor(owner->ToPlayer())) - { - // check online security - if (handler->HasLowerSecurity(owner->ToPlayer(), 0)) - return false; - ((Pet *)target)->SetFreeTalentPoints(tp); - owner->ToPlayer()->SendTalentsInfoData(true); - return true; - } - } + } - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } + + //Edit Player Aspeed + static bool HandleModifyASpeedCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; + + float ASpeed = (float)atof((char*)args); + + if (ASpeed > 50.0f || ASpeed < 0.1f) + { + handler->SendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); return false; } - //Edit Player Aspeed - static bool HandleModifyASpeedCommand(ChatHandler* handler, const char* args) + Player* target = handler->getSelectedPlayer(); + if (!target) { - if (!*args) - return false; - - float ASpeed = (float)atof((char*)args); - - if (ASpeed > 50.0f || ASpeed < 0.1f) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + std::string targetNameLink = handler->GetNameLink(target); - std::string targetNameLink = handler->GetNameLink(target); + if (target->isInFlight()) + { + handler->PSendSysMessage(LANG_CHAR_IN_FLIGHT,targetNameLink.c_str()); + handler->SetSentErrorMessage(true); + return false; + } - if (target->isInFlight()) - { - handler->PSendSysMessage(LANG_CHAR_IN_FLIGHT,targetNameLink.c_str()); - handler->SetSentErrorMessage(true); - return false; - } + handler->PSendSysMessage(LANG_YOU_CHANGE_ASPEED, ASpeed, targetNameLink.c_str()); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_ASPEED_CHANGED, handler->GetNameLink().c_str(), ASpeed); + + target->SetSpeed(MOVE_WALK, ASpeed,true); + target->SetSpeed(MOVE_RUN, ASpeed,true); + target->SetSpeed(MOVE_SWIM, ASpeed,true); + //target->SetSpeed(MOVE_TURN, ASpeed,true); + target->SetSpeed(MOVE_FLIGHT, ASpeed,true); + return true; + } + + //Edit Player Speed + static bool HandleModifySpeedCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - handler->PSendSysMessage(LANG_YOU_CHANGE_ASPEED, ASpeed, targetNameLink.c_str()); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_ASPEED_CHANGED, handler->GetNameLink().c_str(), ASpeed); + float Speed = (float)atof((char*)args); - target->SetSpeed(MOVE_WALK, ASpeed,true); - target->SetSpeed(MOVE_RUN, ASpeed,true); - target->SetSpeed(MOVE_SWIM, ASpeed,true); - //target->SetSpeed(MOVE_TURN, ASpeed,true); - target->SetSpeed(MOVE_FLIGHT, ASpeed,true); - return true; + if (Speed > 50.0f || Speed < 0.1f) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; } - //Edit Player Speed - static bool HandleModifySpeedCommand(ChatHandler* handler, const char* args) + Player* target = handler->getSelectedPlayer(); + if (!target) { - if (!*args) - return false; + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - float Speed = (float)atof((char*)args); + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - if (Speed > 50.0f || Speed < 0.1f) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + std::string targetNameLink = handler->GetNameLink(target); - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + if (target->isInFlight()) + { + handler->PSendSysMessage(LANG_CHAR_IN_FLIGHT,targetNameLink.c_str()); + handler->SetSentErrorMessage(true); + return false; + } - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + handler->PSendSysMessage(LANG_YOU_CHANGE_SPEED, Speed, targetNameLink.c_str()); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_SPEED_CHANGED, handler->GetNameLink().c_str(), Speed); - std::string targetNameLink = handler->GetNameLink(target); + target->SetSpeed(MOVE_RUN,Speed,true); - if (target->isInFlight()) - { - handler->PSendSysMessage(LANG_CHAR_IN_FLIGHT,targetNameLink.c_str()); - handler->SetSentErrorMessage(true); - return false; - } + return true; + } - handler->PSendSysMessage(LANG_YOU_CHANGE_SPEED, Speed, targetNameLink.c_str()); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_SPEED_CHANGED, handler->GetNameLink().c_str(), Speed); + //Edit Player Swim Speed + static bool HandleModifySwimCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - target->SetSpeed(MOVE_RUN,Speed,true); + float Swim = (float)atof((char*)args); - return true; + if (Swim > 50.0f || Swim < 0.1f) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; } - //Edit Player Swim Speed - static bool HandleModifySwimCommand(ChatHandler* handler, const char* args) + Player* target = handler->getSelectedPlayer(); + if (!target) { - if (!*args) - return false; + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - float Swim = (float)atof((char*)args); + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - if (Swim > 50.0f || Swim < 0.1f) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + std::string targetNameLink = handler->GetNameLink(target); - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + if (target->isInFlight()) + { + handler->PSendSysMessage(LANG_CHAR_IN_FLIGHT,targetNameLink.c_str()); + handler->SetSentErrorMessage(true); + return false; + } - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + handler->PSendSysMessage(LANG_YOU_CHANGE_SWIM_SPEED, Swim, targetNameLink.c_str()); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_SWIM_SPEED_CHANGED, handler->GetNameLink().c_str(), Swim); - std::string targetNameLink = handler->GetNameLink(target); + target->SetSpeed(MOVE_SWIM,Swim,true); - if (target->isInFlight()) - { - handler->PSendSysMessage(LANG_CHAR_IN_FLIGHT,targetNameLink.c_str()); - handler->SetSentErrorMessage(true); - return false; - } + return true; + } - handler->PSendSysMessage(LANG_YOU_CHANGE_SWIM_SPEED, Swim, targetNameLink.c_str()); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_SWIM_SPEED_CHANGED, handler->GetNameLink().c_str(), Swim); + //Edit Player Walk Speed + static bool HandleModifyBWalkCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - target->SetSpeed(MOVE_SWIM,Swim,true); + float BSpeed = (float)atof((char*)args); - return true; + if (BSpeed > 50.0f || BSpeed < 0.1f) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; } - //Edit Player Walk Speed - static bool HandleModifyBWalkCommand(ChatHandler* handler, const char* args) + Player* target = handler->getSelectedPlayer(); + if (!target) { - if (!*args) - return false; + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - float BSpeed = (float)atof((char*)args); + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - if (BSpeed > 50.0f || BSpeed < 0.1f) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + std::string targetNameLink = handler->GetNameLink(target); - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + if (target->isInFlight()) + { + handler->PSendSysMessage(LANG_CHAR_IN_FLIGHT,targetNameLink.c_str()); + handler->SetSentErrorMessage(true); + return false; + } - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + handler->PSendSysMessage(LANG_YOU_CHANGE_BACK_SPEED, BSpeed, targetNameLink.c_str()); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_BACK_SPEED_CHANGED, handler->GetNameLink().c_str(), BSpeed); - std::string targetNameLink = handler->GetNameLink(target); + target->SetSpeed(MOVE_RUN_BACK,BSpeed,true); - if (target->isInFlight()) - { - handler->PSendSysMessage(LANG_CHAR_IN_FLIGHT,targetNameLink.c_str()); - handler->SetSentErrorMessage(true); - return false; - } + return true; + } - handler->PSendSysMessage(LANG_YOU_CHANGE_BACK_SPEED, BSpeed, targetNameLink.c_str()); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_BACK_SPEED_CHANGED, handler->GetNameLink().c_str(), BSpeed); + //Edit Player Fly + static bool HandleModifyFlyCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - target->SetSpeed(MOVE_RUN_BACK,BSpeed,true); + float FSpeed = (float)atof((char*)args); - return true; + if (FSpeed > 50.0f || FSpeed < 0.1f) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; } - //Edit Player Fly - static bool HandleModifyFlyCommand(ChatHandler* handler, const char* args) + Player* target = handler->getSelectedPlayer(); + if (!target) { - if (!*args) - return false; - - float FSpeed = (float)atof((char*)args); + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - if (FSpeed > 50.0f || FSpeed < 0.1f) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + handler->PSendSysMessage(LANG_YOU_CHANGE_FLY_SPEED, FSpeed, handler->GetNameLink(target).c_str()); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_FLY_SPEED_CHANGED, handler->GetNameLink().c_str(), FSpeed); - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + target->SetSpeed(MOVE_FLIGHT,FSpeed,true); - handler->PSendSysMessage(LANG_YOU_CHANGE_FLY_SPEED, FSpeed, handler->GetNameLink(target).c_str()); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_FLY_SPEED_CHANGED, handler->GetNameLink().c_str(), FSpeed); + return true; + } - target->SetSpeed(MOVE_FLIGHT,FSpeed,true); + //Edit Player Scale + static bool HandleModifyScaleCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - return true; + float Scale = (float)atof((char*)args); + if (Scale > 10.0f || Scale < 0.1f) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; } - //Edit Player Scale - static bool HandleModifyScaleCommand(ChatHandler* handler, const char* args) + Player* target = handler->getSelectedPlayer(); + if (!target) { - if (!*args) - return false; - - float Scale = (float)atof((char*)args); - if (Scale > 10.0f || Scale < 0.1f) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } - - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } - - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; - - handler->PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, handler->GetNameLink(target).c_str()); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, handler->GetNameLink().c_str(), Scale); - - target->SetFloatValue(OBJECT_FIELD_SCALE_X, Scale); - - return true; + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; } - //Enable Player mount - static bool HandleModifyMountCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - uint16 mId = 1147; - float speed = (float)15; - uint32 num = 0; + handler->PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, handler->GetNameLink(target).c_str()); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, handler->GetNameLink().c_str(), Scale); - num = atoi((char*)args); - switch(num) - { - case 1: - mId=14340; - break; - case 2: - mId=4806; - break; - case 3: - mId=6471; - break; - case 4: - mId=12345; - break; - case 5: - mId=6472; - break; - case 6: - mId=6473; - break; - case 7: - mId=10670; - break; - case 8: - mId=10719; - break; - case 9: - mId=10671; - break; - case 10: - mId=10672; - break; - case 11: - mId=10720; - break; - case 12: - mId=14349; - break; - case 13: - mId=11641; - break; - case 14: - mId=12244; - break; - case 15: - mId=12242; - break; - case 16: - mId=14578; - break; - case 17: - mId=14579; - break; - case 18: - mId=14349; - break; - case 19: - mId=12245; - break; - case 20: - mId=14335; - break; - case 21: - mId=207; - break; - case 22: - mId=2328; - break; - case 23: - mId=2327; - break; - case 24: - mId=2326; - break; - case 25: - mId=14573; - break; - case 26: - mId=14574; - break; - case 27: - mId=14575; - break; - case 28: - mId=604; - break; - case 29: - mId=1166; - break; - case 30: - mId=2402; - break; - case 31: - mId=2410; - break; - case 32: - mId=2409; - break; - case 33: - mId=2408; - break; - case 34: - mId=2405; - break; - case 35: - mId=14337; - break; - case 36: - mId=6569; - break; - case 37: - mId=10661; - break; - case 38: - mId=10666; - break; - case 39: - mId=9473; - break; - case 40: - mId=9476; - break; - case 41: - mId=9474; - break; - case 42: - mId=14374; - break; - case 43: - mId=14376; - break; - case 44: - mId=14377; - break; - case 45: - mId=2404; - break; - case 46: - mId=2784; - break; - case 47: - mId=2787; - break; - case 48: - mId=2785; - break; - case 49: - mId=2736; - break; - case 50: - mId=2786; - break; - case 51: - mId=14347; - break; - case 52: - mId=14346; - break; - case 53: - mId=14576; - break; - case 54: - mId=9695; - break; - case 55: - mId=9991; - break; - case 56: - mId=6448; - break; - case 57: - mId=6444; - break; - case 58: - mId=6080; - break; - case 59: - mId=6447; - break; - case 60: - mId=4805; - break; - case 61: - mId=9714; - break; - case 62: - mId=6448; - break; - case 63: - mId=6442; - break; - case 64: - mId=14632; - break; - case 65: - mId=14332; - break; - case 66: - mId=14331; - break; - case 67: - mId=8469; - break; - case 68: - mId=2830; - break; - case 69: - mId=2346; - break; - default: - handler->SendSysMessage(LANG_NO_MOUNT); - handler->SetSentErrorMessage(true); - return false; - } + target->SetFloatValue(OBJECT_FIELD_SCALE_X, Scale); - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + return true; + } - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + //Enable Player mount + static bool HandleModifyMountCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - handler->PSendSysMessage(LANG_YOU_GIVE_MOUNT, handler->GetNameLink(target).c_str()); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_MOUNT_GIVED, handler->GetNameLink().c_str()); + uint16 mId = 1147; + float speed = (float)15; + uint32 num = 0; - target->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); - target->Mount(mId); + num = atoi((char*)args); + switch(num) + { + case 1: + mId=14340; + break; + case 2: + mId=4806; + break; + case 3: + mId=6471; + break; + case 4: + mId=12345; + break; + case 5: + mId=6472; + break; + case 6: + mId=6473; + break; + case 7: + mId=10670; + break; + case 8: + mId=10719; + break; + case 9: + mId=10671; + break; + case 10: + mId=10672; + break; + case 11: + mId=10720; + break; + case 12: + mId=14349; + break; + case 13: + mId=11641; + break; + case 14: + mId=12244; + break; + case 15: + mId=12242; + break; + case 16: + mId=14578; + break; + case 17: + mId=14579; + break; + case 18: + mId=14349; + break; + case 19: + mId=12245; + break; + case 20: + mId=14335; + break; + case 21: + mId=207; + break; + case 22: + mId=2328; + break; + case 23: + mId=2327; + break; + case 24: + mId=2326; + break; + case 25: + mId=14573; + break; + case 26: + mId=14574; + break; + case 27: + mId=14575; + break; + case 28: + mId=604; + break; + case 29: + mId=1166; + break; + case 30: + mId=2402; + break; + case 31: + mId=2410; + break; + case 32: + mId=2409; + break; + case 33: + mId=2408; + break; + case 34: + mId=2405; + break; + case 35: + mId=14337; + break; + case 36: + mId=6569; + break; + case 37: + mId=10661; + break; + case 38: + mId=10666; + break; + case 39: + mId=9473; + break; + case 40: + mId=9476; + break; + case 41: + mId=9474; + break; + case 42: + mId=14374; + break; + case 43: + mId=14376; + break; + case 44: + mId=14377; + break; + case 45: + mId=2404; + break; + case 46: + mId=2784; + break; + case 47: + mId=2787; + break; + case 48: + mId=2785; + break; + case 49: + mId=2736; + break; + case 50: + mId=2786; + break; + case 51: + mId=14347; + break; + case 52: + mId=14346; + break; + case 53: + mId=14576; + break; + case 54: + mId=9695; + break; + case 55: + mId=9991; + break; + case 56: + mId=6448; + break; + case 57: + mId=6444; + break; + case 58: + mId=6080; + break; + case 59: + mId=6447; + break; + case 60: + mId=4805; + break; + case 61: + mId=9714; + break; + case 62: + mId=6448; + break; + case 63: + mId=6442; + break; + case 64: + mId=14632; + break; + case 65: + mId=14332; + break; + case 66: + mId=14331; + break; + case 67: + mId=8469; + break; + case 68: + mId=2830; + break; + case 69: + mId=2346; + break; + default: + handler->SendSysMessage(LANG_NO_MOUNT); + handler->SetSentErrorMessage(true); + return false; + } - WorldPacket data(SMSG_FORCE_RUN_SPEED_CHANGE, (8+4+1+4)); - data.append(target->GetPackGUID()); - data << (uint32)0; - data << (uint8)0; //new 2.1.0 - data << float(speed); - target->SendMessageToSet(&data, true); + Player* target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - data.Initialize(SMSG_FORCE_SWIM_SPEED_CHANGE, (8+4+4)); - data.append(target->GetPackGUID()); - data << (uint32)0; - data << float(speed); - target->SendMessageToSet(&data, true); + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - return true; - } + handler->PSendSysMessage(LANG_YOU_GIVE_MOUNT, handler->GetNameLink(target).c_str()); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_MOUNT_GIVED, handler->GetNameLink().c_str()); + + target->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); + target->Mount(mId); + + WorldPacket data(SMSG_FORCE_RUN_SPEED_CHANGE, (8+4+1+4)); + data.append(target->GetPackGUID()); + data << (uint32)0; + data << (uint8)0; //new 2.1.0 + data << float(speed); + target->SendMessageToSet(&data, true); + + data.Initialize(SMSG_FORCE_SWIM_SPEED_CHANGE, (8+4+4)); + data.append(target->GetPackGUID()); + data << (uint32)0; + data << float(speed); + target->SendMessageToSet(&data, true); + + return true; + } + + //Edit Player money + static bool HandleModifyMoneyCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - //Edit Player money - static bool HandleModifyMoneyCommand(ChatHandler* handler, const char* args) + Player* target = handler->getSelectedPlayer(); + if (!target) { - if (!*args) - return false; + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + int32 addmoney = atoi((char*)args); - int32 addmoney = atoi((char*)args); + uint32 moneyuser = target->GetMoney(); - uint32 moneyuser = target->GetMoney(); + if (addmoney < 0) + { + int32 newmoney = int32(moneyuser) + addmoney; - if (addmoney < 0) + sLog.outDetail(handler->GetTrinityString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney); + if (newmoney <= 0) { - int32 newmoney = int32(moneyuser) + addmoney; - - sLog.outDetail(handler->GetTrinityString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney); - if (newmoney <= 0) - { - handler->PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, handler->GetNameLink(target).c_str()); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_ALL_MONEY_GONE, handler->GetNameLink().c_str()); - - target->SetMoney(0); - } - else - { - if (newmoney > MAX_MONEY_AMOUNT) - newmoney = MAX_MONEY_AMOUNT; + handler->PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, handler->GetNameLink(target).c_str()); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_ALL_MONEY_GONE, handler->GetNameLink().c_str()); - handler->PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(addmoney), handler->GetNameLink(target).c_str()); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink().c_str(), abs(addmoney)); - target->SetMoney(newmoney); - } + target->SetMoney(0); } else { - handler->PSendSysMessage(LANG_YOU_GIVE_MONEY, addmoney, handler->GetNameLink(target).c_str()); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, handler->GetNameLink().c_str(), addmoney); + if (newmoney > MAX_MONEY_AMOUNT) + newmoney = MAX_MONEY_AMOUNT; - if (addmoney >=MAX_MONEY_AMOUNT) - target->SetMoney(MAX_MONEY_AMOUNT); - else - target->ModifyMoney(addmoney); + handler->PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(addmoney), handler->GetNameLink(target).c_str()); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink().c_str(), abs(addmoney)); + target->SetMoney(newmoney); } + } + else + { + handler->PSendSysMessage(LANG_YOU_GIVE_MONEY, addmoney, handler->GetNameLink(target).c_str()); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, handler->GetNameLink().c_str(), addmoney); - sLog.outDetail(handler->GetTrinityString(LANG_NEW_MONEY), moneyuser, addmoney, target->GetMoney()); - - return true; + if (addmoney >=MAX_MONEY_AMOUNT) + target->SetMoney(MAX_MONEY_AMOUNT); + else + target->ModifyMoney(addmoney); } - //Edit Unit field - static bool HandleModifyBitCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + sLog.outDetail(handler->GetTrinityString(LANG_NEW_MONEY), moneyuser, addmoney, target->GetMoney()); - Unit* target = handler->getSelectedUnit(); - if (!target) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + return true; + } - // check online security - if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0)) - return false; + //Edit Unit field + static bool HandleModifyBitCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - char* pField = strtok((char*)args, " "); - if (!pField) - return false; + Unit* target = handler->getSelectedUnit(); + if (!target) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - char* pBit = strtok(NULL, " "); - if (!pBit) - return false; + // check online security + if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0)) + return false; - uint16 field = atoi(pField); - uint32 bit = atoi(pBit); + char* pField = strtok((char*)args, " "); + if (!pField) + return false; - if (field < OBJECT_END || field >= target->GetValuesCount()) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } - if (bit < 1 || bit > 32) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + char* pBit = strtok(NULL, " "); + if (!pBit) + return false; - if (target->HasFlag(field, (1<<(bit-1)))) - { - target->RemoveFlag(field, (1<<(bit-1))); - handler->PSendSysMessage(LANG_REMOVE_BIT, bit, field); - } - else - { - target->SetFlag(field, (1<<(bit-1))); - handler->PSendSysMessage(LANG_SET_BIT, bit, field); - } - return true; + uint16 field = atoi(pField); + uint32 bit = atoi(pBit); + + if (field < OBJECT_END || field >= target->GetValuesCount()) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; + } + if (bit < 1 || bit > 32) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; } - static bool HandleModifyHonorCommand (ChatHandler* handler, const char* args) + if (target->HasFlag(field, (1<<(bit-1)))) { - if (!*args) - return false; + target->RemoveFlag(field, (1<<(bit-1))); + handler->PSendSysMessage(LANG_REMOVE_BIT, bit, field); + } + else + { + target->SetFlag(field, (1<<(bit-1))); + handler->PSendSysMessage(LANG_SET_BIT, bit, field); + } + return true; + } - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); - handler->SetSentErrorMessage(true); - return false; - } + static bool HandleModifyHonorCommand (ChatHandler* handler, const char* args) + { + if (!*args) + return false; - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + Player* target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + return false; + } - int32 amount = (uint32)atoi(args); + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - target->ModifyHonorPoints(amount); + int32 amount = (uint32)atoi(args); - handler->PSendSysMessage(LANG_COMMAND_MODIFY_HONOR, handler->GetNameLink(target).c_str(), target->GetHonorPoints()); + target->ModifyHonorPoints(amount); - return true; - } + handler->PSendSysMessage(LANG_COMMAND_MODIFY_HONOR, handler->GetNameLink(target).c_str(), target->GetHonorPoints()); - static bool HandleModifyDrunkCommand(ChatHandler* handler, const char* args) - { - if (!*args) return false; + return true; + } - uint32 drunklevel = (uint32)atoi(args); - if (drunklevel > 100) - drunklevel = 100; + static bool HandleModifyDrunkCommand(ChatHandler* handler, const char* args) + { + if (!*args) return false; - uint16 drunkMod = drunklevel * 0xFFFF / 100; + uint32 drunklevel = (uint32)atoi(args); + if (drunklevel > 100) + drunklevel = 100; - handler->GetSession()->GetPlayer()->SetDrunkValue(drunkMod); + uint16 drunkMod = drunklevel * 0xFFFF / 100; - return true; - } + handler->GetSession()->GetPlayer()->SetDrunkValue(drunkMod); - static bool HandleModifyRepCommand(ChatHandler* handler, const char* args) - { - if (!*args) return false; + return true; + } - Player* target = handler->getSelectedPlayer(); + static bool HandleModifyRepCommand(ChatHandler* handler, const char* args) + { + if (!*args) return false; - if (!target) - { - handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); - handler->SetSentErrorMessage(true); - return false; - } + Player* target = handler->getSelectedPlayer(); - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + if (!target) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + return false; + } - char* factionTxt = handler->extractKeyFromLink((char*)args,"Hfaction"); - if (!factionTxt) - return false; + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; + + char* factionTxt = handler->extractKeyFromLink((char*)args,"Hfaction"); + if (!factionTxt) + return false; - uint32 factionId = atoi(factionTxt); + uint32 factionId = atoi(factionTxt); - int32 amount = 0; - char *rankTxt = strtok(NULL, " "); - if (!factionTxt || !rankTxt) + int32 amount = 0; + char *rankTxt = strtok(NULL, " "); + if (!factionTxt || !rankTxt) + return false; + + amount = atoi(rankTxt); + if ((amount == 0) && (rankTxt[0] != '-') && !isdigit(rankTxt[0])) + { + std::string rankStr = rankTxt; + std::wstring wrankStr; + if (!Utf8toWStr(rankStr,wrankStr)) return false; + wstrToLower(wrankStr); - amount = atoi(rankTxt); - if ((amount == 0) && (rankTxt[0] != '-') && !isdigit(rankTxt[0])) + int r = 0; + amount = -42000; + for (; r < MAX_REPUTATION_RANK; ++r) { - std::string rankStr = rankTxt; - std::wstring wrankStr; - if (!Utf8toWStr(rankStr,wrankStr)) - return false; - wstrToLower(wrankStr); - - int r = 0; - amount = -42000; - for (; r < MAX_REPUTATION_RANK; ++r) - { - std::string rank = handler->GetTrinityString(ReputationRankStrIndex[r]); - if (rank.empty()) - continue; + std::string rank = handler->GetTrinityString(ReputationRankStrIndex[r]); + if (rank.empty()) + continue; - std::wstring wrank; - if (!Utf8toWStr(rank,wrank)) - continue; + std::wstring wrank; + if (!Utf8toWStr(rank,wrank)) + continue; - wstrToLower(wrank); + wstrToLower(wrank); - if (wrank.substr(0,wrankStr.size()) == wrankStr) + if (wrank.substr(0,wrankStr.size()) == wrankStr) + { + char *deltaTxt = strtok(NULL, " "); + if (deltaTxt) { - char *deltaTxt = strtok(NULL, " "); - if (deltaTxt) + int32 delta = atoi(deltaTxt); + if ((delta < 0) || (delta > ReputationMgr::PointsInRank[r] -1)) { - int32 delta = atoi(deltaTxt); - if ((delta < 0) || (delta > ReputationMgr::PointsInRank[r] -1)) - { - handler->PSendSysMessage(LANG_COMMAND_FACTION_DELTA, (ReputationMgr::PointsInRank[r]-1)); - handler->SetSentErrorMessage(true); - return false; - } - amount += delta; + handler->PSendSysMessage(LANG_COMMAND_FACTION_DELTA, (ReputationMgr::PointsInRank[r]-1)); + handler->SetSentErrorMessage(true); + return false; } - break; + amount += delta; } - amount += ReputationMgr::PointsInRank[r]; - } - if (r >= MAX_REPUTATION_RANK) - { - handler->PSendSysMessage(LANG_COMMAND_FACTION_INVPARAM, rankTxt); - handler->SetSentErrorMessage(true); - return false; + break; } + amount += ReputationMgr::PointsInRank[r]; } - - FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionId); - - if (!factionEntry) + if (r >= MAX_REPUTATION_RANK) { - handler->PSendSysMessage(LANG_COMMAND_FACTION_UNKNOWN, factionId); + handler->PSendSysMessage(LANG_COMMAND_FACTION_INVPARAM, rankTxt); handler->SetSentErrorMessage(true); return false; } + } - if (factionEntry->reputationListID < 0) - { - handler->PSendSysMessage(LANG_COMMAND_FACTION_NOREP_ERROR, factionEntry->name[handler->GetSessionDbcLocale()], factionId); - handler->SetSentErrorMessage(true); - return false; - } + FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionId); - target->GetReputationMgr().SetReputation(factionEntry,amount); - handler->PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name[handler->GetSessionDbcLocale()], factionId, - handler->GetNameLink(target).c_str(), target->GetReputationMgr().GetReputation(factionEntry)); - return true; + if (!factionEntry) + { + handler->PSendSysMessage(LANG_COMMAND_FACTION_UNKNOWN, factionId); + handler->SetSentErrorMessage(true); + return false; } - //morph creature or player - static bool HandleModifyMorphCommand(ChatHandler* handler, const char* args) + if (factionEntry->reputationListID < 0) { - if (!*args) - return false; + handler->PSendSysMessage(LANG_COMMAND_FACTION_NOREP_ERROR, factionEntry->name[handler->GetSessionDbcLocale()], factionId); + handler->SetSentErrorMessage(true); + return false; + } - uint16 display_id = (uint16)atoi((char*)args); + target->GetReputationMgr().SetReputation(factionEntry,amount); + handler->PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name[handler->GetSessionDbcLocale()], factionId, + handler->GetNameLink(target).c_str(), target->GetReputationMgr().GetReputation(factionEntry)); + return true; + } - Unit* target = handler->getSelectedUnit(); - if (!target) - target = handler->GetSession()->GetPlayer(); + //morph creature or player + static bool HandleModifyMorphCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - // check online security - else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0)) - return false; + uint16 display_id = (uint16)atoi((char*)args); - target->SetDisplayId(display_id); + Unit* target = handler->getSelectedUnit(); + if (!target) + target = handler->GetSession()->GetPlayer(); - return true; - } + // check online security + else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0)) + return false; - //set temporary phase mask for player - static bool HandleModifyPhaseCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + target->SetDisplayId(display_id); - uint32 phasemask = (uint32)atoi((char*)args); + return true; + } - Unit* target = handler->getSelectedUnit(); - if (!target) - target = handler->GetSession()->GetPlayer(); + //set temporary phase mask for player + static bool HandleModifyPhaseCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - // check online security - else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0)) - return false; + uint32 phasemask = (uint32)atoi((char*)args); - target->SetPhaseMask(phasemask,true); + Unit* target = handler->getSelectedUnit(); + if (!target) + target = handler->GetSession()->GetPlayer(); - return true; - } + // check online security + else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), 0)) + return false; - //change standstate - static bool HandleModifyStandStateCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + target->SetPhaseMask(phasemask,true); - uint32 anim_id = atoi((char*)args); - handler->GetSession()->GetPlayer()->SetUInt32Value(UNIT_NPC_EMOTESTATE , anim_id); + return true; + } - return true; - } + //change standstate + static bool HandleModifyStandStateCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - static bool HandleModifyArenaCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + uint32 anim_id = atoi((char*)args); + handler->GetSession()->GetPlayer()->SetUInt32Value(UNIT_NPC_EMOTESTATE , anim_id); - Player* target = handler->getSelectedPlayer(); - if (!target) - { - handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); - handler->SetSentErrorMessage(true); - return false; - } + return true; + } - int32 amount = (uint32)atoi(args); + static bool HandleModifyArenaCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - target->ModifyArenaPoints(amount); + Player* target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + return false; + } - handler->PSendSysMessage(LANG_COMMAND_MODIFY_ARENA, handler->GetNameLink(target).c_str(), target->GetArenaPoints()); + int32 amount = (uint32)atoi(args); - return true; - } + target->ModifyArenaPoints(amount); - static bool HandleModifyGenderCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + handler->PSendSysMessage(LANG_COMMAND_MODIFY_ARENA, handler->GetNameLink(target).c_str(), target->GetArenaPoints()); - Player* target = handler->getSelectedPlayer(); + return true; + } - if (!target) - { - handler->PSendSysMessage(LANG_PLAYER_NOT_FOUND); - handler->SetSentErrorMessage(true); - return false; - } + static bool HandleModifyGenderCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - PlayerInfo const* info = sObjectMgr.GetPlayerInfo(target->getRace(), target->getClass()); - if (!info) - return false; + Player* target = handler->getSelectedPlayer(); - char const* gender_str = (char*)args; - int gender_len = strlen(gender_str); + if (!target) + { + handler->PSendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + return false; + } - Gender gender; + PlayerInfo const* info = sObjectMgr.GetPlayerInfo(target->getRace(), target->getClass()); + if (!info) + return false; - if (!strncmp(gender_str, "male", gender_len)) // MALE - { - if (target->getGender() == GENDER_MALE) - return true; + char const* gender_str = (char*)args; + int gender_len = strlen(gender_str); - gender = GENDER_MALE; - } - else if (!strncmp(gender_str, "female", gender_len)) // FEMALE - { - if (target->getGender() == GENDER_FEMALE) - return true; + Gender gender; - gender = GENDER_FEMALE; - } - else - { - handler->SendSysMessage(LANG_MUST_MALE_OR_FEMALE); - handler->SetSentErrorMessage(true); - return false; - } + if (!strncmp(gender_str, "male", gender_len)) // MALE + { + if (target->getGender() == GENDER_MALE) + return true; + + gender = GENDER_MALE; + } + else if (!strncmp(gender_str, "female", gender_len)) // FEMALE + { + if (target->getGender() == GENDER_FEMALE) + return true; + + gender = GENDER_FEMALE; + } + else + { + handler->SendSysMessage(LANG_MUST_MALE_OR_FEMALE); + handler->SetSentErrorMessage(true); + return false; + } - // Set gender - target->SetByteValue(UNIT_FIELD_BYTES_0, 2, gender); - target->SetByteValue(PLAYER_BYTES_3, 0, gender); + // Set gender + target->SetByteValue(UNIT_FIELD_BYTES_0, 2, gender); + target->SetByteValue(PLAYER_BYTES_3, 0, gender); - // Change display ID - target->InitDisplayIds(); + // Change display ID + target->InitDisplayIds(); - char const* gender_full = gender ? "female" : "male"; + char const* gender_full = gender ? "female" : "male"; - handler->PSendSysMessage(LANG_YOU_CHANGE_GENDER, handler->GetNameLink(target).c_str(), gender_full); + handler->PSendSysMessage(LANG_YOU_CHANGE_GENDER, handler->GetNameLink(target).c_str(), gender_full); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOUR_GENDER_CHANGED, gender_full, handler->GetNameLink().c_str()); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_YOUR_GENDER_CHANGED, gender_full, handler->GetNameLink().c_str()); - return true; - } + return true; + } }; void AddSC_modify_commandscript() diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 86c22807828..c4f85adce2a 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -31,1407 +31,1405 @@ EndScriptData */ class npc_commandscript : public CommandScript { - public: - npc_commandscript() : CommandScript("npc_commandscript") { } +public: + npc_commandscript() : CommandScript("npc_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const + { + static ChatCommand npcAddCommandTable[] = { - static ChatCommand npcAddCommandTable[] = - { - { "formation", SEC_MODERATOR, false, &HandleNpcAddFormationCommand, "", NULL }, - { "item", SEC_GAMEMASTER, false, &HandleNpcAddVendorItemCommand, "", NULL }, - { "move", SEC_GAMEMASTER, false, &HandleNpcAddMoveCommand, "", NULL }, - { "temp", SEC_GAMEMASTER, false, &HandleNpcAddTempSpawnCommand, "", NULL }, - //{ TODO: fix or remove this commands - { "weapon", SEC_ADMINISTRATOR, false, &HandleNpcAddWeaponCommand, "", NULL }, - //} - { "", SEC_GAMEMASTER, false, &HandleNpcAddCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand npcDeleteCommandTable[] = - { - { "item", SEC_GAMEMASTER, false, &HandleNpcDeleteVendorItemCommand, "", NULL }, - { "", SEC_GAMEMASTER, false, &HandleNpcDeleteCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand npcFollowCommandTable[] = - { - { "stop", SEC_GAMEMASTER, false, &HandleNpcUnFollowCommand, "", NULL }, - { "", SEC_GAMEMASTER, false, &HandleNpcFollowCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand npcSetCommandTable[] = - { - { "allowmove", SEC_ADMINISTRATOR, false, &HandleNpcSetAllowMovementCommand, "", NULL }, - { "deathstate", SEC_GAMEMASTER, false, &HandleNpcSetDeathStateCommand, "", NULL }, - { "entry", SEC_ADMINISTRATOR, false, &HandleNpcSetEntryCommand, "", NULL }, - { "factionid", SEC_GAMEMASTER, false, &HandleNpcSetFactionIdCommand, "", NULL }, - { "flag", SEC_GAMEMASTER, false, &HandleNpcSetFlagCommand, "", NULL }, - { "level", SEC_GAMEMASTER, false, &HandleNpcSetLevelCommand, "", NULL }, - { "link", SEC_GAMEMASTER, false, &HandleNpcSetLinkCommand, "", NULL }, - { "model", SEC_GAMEMASTER, false, &HandleNpcSetModelCommand, "", NULL }, - { "movetype", SEC_GAMEMASTER, false, &HandleNpcSetMoveTypeCommand, "", NULL }, - { "phase", SEC_GAMEMASTER, false, &HandleNpcSetPhaseCommand, "", NULL }, - { "spawndist", SEC_GAMEMASTER, false, &HandleNpcSetSpawnDistCommand, "", NULL }, - { "spawntime", SEC_GAMEMASTER, false, &HandleNpcSetSpawnTimeCommand, "", NULL }, - //{ TODO: fix or remove this commands - { "name", SEC_GAMEMASTER, false, &HandleNpcSetNameCommand, "", NULL }, - { "subname", SEC_GAMEMASTER, false, &HandleNpcSetSubNameCommand, "", NULL }, - //} - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand npcCommandTable[] = - { - { "info", SEC_ADMINISTRATOR, false, &HandleNpcInfoCommand, "", NULL }, - { "move", SEC_GAMEMASTER, false, &HandleNpcMoveCommand, "", NULL }, - { "playemote", SEC_ADMINISTRATOR, false, &HandleNpcPlayEmoteCommand, "", NULL }, - { "say", SEC_MODERATOR, false, &HandleNpcSayCommand, "", NULL }, - { "textemote", SEC_MODERATOR, false, &HandleNpcTextEmoteCommand, "", NULL }, - { "whisper", SEC_MODERATOR, false, &HandleNpcWhisperCommand, "", NULL }, - { "yell", SEC_MODERATOR, false, &HandleNpcYellCommand, "", NULL }, - { "tame", SEC_GAMEMASTER, false, &HandleNpcTameCommand, "", NULL }, - { "add", SEC_GAMEMASTER, false, NULL, "", npcAddCommandTable }, - { "delete", SEC_GAMEMASTER, false, NULL, "", npcDeleteCommandTable }, - { "follow", SEC_GAMEMASTER, false, NULL, "", npcFollowCommandTable }, - { "set", SEC_GAMEMASTER, false, NULL, "", npcSetCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand commandTable[] = - { - { "npc", SEC_MODERATOR, false, NULL, "", npcCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - return commandTable; + { "formation", SEC_MODERATOR, false, &HandleNpcAddFormationCommand, "", NULL }, + { "item", SEC_GAMEMASTER, false, &HandleNpcAddVendorItemCommand, "", NULL }, + { "move", SEC_GAMEMASTER, false, &HandleNpcAddMoveCommand, "", NULL }, + { "temp", SEC_GAMEMASTER, false, &HandleNpcAddTempSpawnCommand, "", NULL }, + //{ TODO: fix or remove this command + { "weapon", SEC_ADMINISTRATOR, false, &HandleNpcAddWeaponCommand, "", NULL }, + //} + { "", SEC_GAMEMASTER, false, &HandleNpcAddCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand npcDeleteCommandTable[] = + { + { "item", SEC_GAMEMASTER, false, &HandleNpcDeleteVendorItemCommand, "", NULL }, + { "", SEC_GAMEMASTER, false, &HandleNpcDeleteCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand npcFollowCommandTable[] = + { + { "stop", SEC_GAMEMASTER, false, &HandleNpcUnFollowCommand, "", NULL }, + { "", SEC_GAMEMASTER, false, &HandleNpcFollowCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand npcSetCommandTable[] = + { + { "allowmove", SEC_ADMINISTRATOR, false, &HandleNpcSetAllowMovementCommand, "", NULL }, + { "deathstate", SEC_GAMEMASTER, false, &HandleNpcSetDeathStateCommand, "", NULL }, + { "entry", SEC_ADMINISTRATOR, false, &HandleNpcSetEntryCommand, "", NULL }, + { "factionid", SEC_GAMEMASTER, false, &HandleNpcSetFactionIdCommand, "", NULL }, + { "flag", SEC_GAMEMASTER, false, &HandleNpcSetFlagCommand, "", NULL }, + { "level", SEC_GAMEMASTER, false, &HandleNpcSetLevelCommand, "", NULL }, + { "link", SEC_GAMEMASTER, false, &HandleNpcSetLinkCommand, "", NULL }, + { "model", SEC_GAMEMASTER, false, &HandleNpcSetModelCommand, "", NULL }, + { "movetype", SEC_GAMEMASTER, false, &HandleNpcSetMoveTypeCommand, "", NULL }, + { "phase", SEC_GAMEMASTER, false, &HandleNpcSetPhaseCommand, "", NULL }, + { "spawndist", SEC_GAMEMASTER, false, &HandleNpcSetSpawnDistCommand, "", NULL }, + { "spawntime", SEC_GAMEMASTER, false, &HandleNpcSetSpawnTimeCommand, "", NULL }, + //{ TODO: fix or remove these commands + { "name", SEC_GAMEMASTER, false, &HandleNpcSetNameCommand, "", NULL }, + { "subname", SEC_GAMEMASTER, false, &HandleNpcSetSubNameCommand, "", NULL }, + //} + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand npcCommandTable[] = + { + { "info", SEC_ADMINISTRATOR, false, &HandleNpcInfoCommand, "", NULL }, + { "move", SEC_GAMEMASTER, false, &HandleNpcMoveCommand, "", NULL }, + { "playemote", SEC_ADMINISTRATOR, false, &HandleNpcPlayEmoteCommand, "", NULL }, + { "say", SEC_MODERATOR, false, &HandleNpcSayCommand, "", NULL }, + { "textemote", SEC_MODERATOR, false, &HandleNpcTextEmoteCommand, "", NULL }, + { "whisper", SEC_MODERATOR, false, &HandleNpcWhisperCommand, "", NULL }, + { "yell", SEC_MODERATOR, false, &HandleNpcYellCommand, "", NULL }, + { "tame", SEC_GAMEMASTER, false, &HandleNpcTameCommand, "", NULL }, + { "add", SEC_GAMEMASTER, false, NULL, "", npcAddCommandTable }, + { "delete", SEC_GAMEMASTER, false, NULL, "", npcDeleteCommandTable }, + { "follow", SEC_GAMEMASTER, false, NULL, "", npcFollowCommandTable }, + { "set", SEC_GAMEMASTER, false, NULL, "", npcSetCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "npc", SEC_MODERATOR, false, NULL, "", npcCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } + + //add spawn of creature + static bool HandleNpcAddCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; + char* charID = handler->extractKeyFromLink((char*)args,"Hcreature_entry"); + if (!charID) + return false; + + char* team = strtok(NULL, " "); + int32 teamval = 0; + if (team) { teamval = atoi(team); } + if (teamval < 0) { teamval = 0; } + + uint32 id = atoi(charID); + + Player *chr = handler->GetSession()->GetPlayer(); + float x = chr->GetPositionX(); + float y = chr->GetPositionY(); + float z = chr->GetPositionZ(); + float o = chr->GetOrientation(); + Map *map = chr->GetMap(); + + if (chr->GetTransport()) + { + uint32 tguid = chr->GetTransport()->AddNPCPassenger(0, id, chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO()); + if (tguid > 0) + WorldDatabase.PQuery("INSERT INTO creature_transport (guid, npc_entry, transport_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO) values (%u, %u, %f, %f, %f, %f, %u)", tguid, id, chr->GetTransport()->GetEntry(), chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO()); + + return true; } - //add spawn of creature - static bool HandleNpcAddCommand(ChatHandler* handler, const char* args) + Creature* pCreature = new Creature; + if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, (uint32)teamval, x, y, z, o)) { - if (!*args) - return false; - char* charID = handler->extractKeyFromLink((char*)args,"Hcreature_entry"); - if (!charID) - return false; + delete pCreature; + return false; + } - char* team = strtok(NULL, " "); - int32 teamval = 0; - if (team) { teamval = atoi(team); } - if (teamval < 0) { teamval = 0; } + pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - uint32 id = atoi(charID); + uint32 db_guid = pCreature->GetDBTableGUIDLow(); - Player *chr = handler->GetSession()->GetPlayer(); - float x = chr->GetPositionX(); - float y = chr->GetPositionY(); - float z = chr->GetPositionZ(); - float o = chr->GetOrientation(); - Map *map = chr->GetMap(); + // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); + pCreature->LoadFromDB(db_guid, map); - if (chr->GetTransport()) - { - uint32 tguid = chr->GetTransport()->AddNPCPassenger(0, id, chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO()); - if (tguid > 0) - WorldDatabase.PQuery("INSERT INTO creature_transport (guid, npc_entry, transport_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO) values (%u, %u, %f, %f, %f, %f, %u)", tguid, id, chr->GetTransport()->GetEntry(), chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO()); + map->Add(pCreature); + sObjectMgr.AddCreatureToGrid(db_guid, sObjectMgr.GetCreatureData(db_guid)); + return true; + } - return true; - } + //add item in vendorlist + static bool HandleNpcAddVendorItemCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - Creature* pCreature = new Creature; - if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, (uint32)teamval, x, y, z, o)) - { - delete pCreature; - return false; - } + char* pitem = handler->extractKeyFromLink((char*)args,"Hitem"); + if (!pitem) + { + handler->SendSysMessage(LANG_COMMAND_NEEDITEMSEND); + handler->SetSentErrorMessage(true); + return false; + } - pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); + uint32 itemId = atol(pitem); - uint32 db_guid = pCreature->GetDBTableGUIDLow(); + char* fmaxcount = strtok(NULL, " "); //add maxcount, default: 0 + uint32 maxcount = 0; + if (fmaxcount) + maxcount = atol(fmaxcount); - // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); - pCreature->LoadFromDB(db_guid, map); + char* fincrtime = strtok(NULL, " "); //add incrtime, default: 0 + uint32 incrtime = 0; + if (fincrtime) + incrtime = atol(fincrtime); - map->Add(pCreature); - sObjectMgr.AddCreatureToGrid(db_guid, sObjectMgr.GetCreatureData(db_guid)); - return true; + char* fextendedcost = strtok(NULL, " "); //add ExtendedCost, default: 0 + uint32 extendedcost = fextendedcost ? atol(fextendedcost) : 0; + Creature* vendor = handler->getSelectedCreature(); + if (!vendor) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; } - //add item in vendorlist - static bool HandleNpcAddVendorItemCommand(ChatHandler* handler, const char* args) + uint32 vendor_entry = vendor ? vendor->GetEntry() : 0; + + if (!sObjectMgr.IsVendorItemValid(vendor_entry,itemId,maxcount,incrtime,extendedcost,handler->GetSession()->GetPlayer())) { - if (!*args) - return false; + handler->SetSentErrorMessage(true); + return false; + } - char* pitem = handler->extractKeyFromLink((char*)args,"Hitem"); - if (!pitem) - { - handler->SendSysMessage(LANG_COMMAND_NEEDITEMSEND); - handler->SetSentErrorMessage(true); - return false; - } + sObjectMgr.AddVendorItem(vendor_entry,itemId,maxcount,incrtime,extendedcost); - uint32 itemId = atol(pitem); + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(itemId); - char* fmaxcount = strtok(NULL, " "); //add maxcount, default: 0 - uint32 maxcount = 0; - if (fmaxcount) - maxcount = atol(fmaxcount); + handler->PSendSysMessage(LANG_ITEM_ADDED_TO_LIST,itemId,pProto->Name1,maxcount,incrtime,extendedcost); + return true; + } - char* fincrtime = strtok(NULL, " "); //add incrtime, default: 0 - uint32 incrtime = 0; - if (fincrtime) - incrtime = atol(fincrtime); + //add move for creature + static bool HandleNpcAddMoveCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - char* fextendedcost = strtok(NULL, " "); //add ExtendedCost, default: 0 - uint32 extendedcost = fextendedcost ? atol(fextendedcost) : 0; - Creature* vendor = handler->getSelectedCreature(); - if (!vendor) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + char* guid_str = strtok((char*)args, " "); + char* wait_str = strtok((char*)NULL, " "); + + uint32 lowguid = atoi((char*)guid_str); + + Creature* pCreature = NULL; - uint32 vendor_entry = vendor ? vendor->GetEntry() : 0; + /* FIXME: impossible without entry + if (lowguid) + pCreature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT)); + */ - if (!sObjectMgr.IsVendorItemValid(vendor_entry,itemId,maxcount,incrtime,extendedcost,handler->GetSession()->GetPlayer())) + // attempt check creature existence by DB data + if (!pCreature) + { + CreatureData const* data = sObjectMgr.GetCreatureData(lowguid); + if (!data) { + handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); handler->SetSentErrorMessage(true); return false; } - - sObjectMgr.AddVendorItem(vendor_entry,itemId,maxcount,incrtime,extendedcost); - - ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(itemId); - - handler->PSendSysMessage(LANG_ITEM_ADDED_TO_LIST,itemId,pProto->Name1,maxcount,incrtime,extendedcost); - return true; } - - //add move for creature - static bool HandleNpcAddMoveCommand(ChatHandler* handler, const char* args) + else { - if (!*args) - return false; + // obtain real GUID for DB operations + lowguid = pCreature->GetDBTableGUIDLow(); + } - char* guid_str = strtok((char*)args, " "); - char* wait_str = strtok((char*)NULL, " "); + int wait = wait_str ? atoi(wait_str) : 0; - uint32 lowguid = atoi((char*)guid_str); + if (wait < 0) + wait = 0; - Creature* pCreature = NULL; + //Player* player = handler->GetSession()->GetPlayer(); - /* FIXME: impossible without entry - if (lowguid) - pCreature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT)); - */ + //WaypointMgr.AddLastNode(lowguid, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), wait, 0); - // attempt check creature existence by DB data - if (!pCreature) - { - CreatureData const* data = sObjectMgr.GetCreatureData(lowguid); - if (!data) - { - handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); - handler->SetSentErrorMessage(true); - return false; - } - } - else + // update movement type + WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE,lowguid); + if (pCreature && pCreature->GetWaypointPath()) + { + pCreature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); + pCreature->GetMotionMaster()->Initialize(); + if (pCreature->isAlive()) // dead creature will reset movement generator at respawn { - // obtain real GUID for DB operations - lowguid = pCreature->GetDBTableGUIDLow(); + pCreature->setDeathState(JUST_DIED); + pCreature->Respawn(true); } + pCreature->SaveToDB(); + } - int wait = wait_str ? atoi(wait_str) : 0; - - if (wait < 0) - wait = 0; + handler->SendSysMessage(LANG_WAYPOINT_ADDED); - //Player* player = handler->GetSession()->GetPlayer(); + return true; + } - //WaypointMgr.AddLastNode(lowguid, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), wait, 0); + static bool HandleNpcSetAllowMovementCommand(ChatHandler* handler, const char* /*args*/) + { + if (sWorld.getAllowMovement()) + { + sWorld.SetAllowMovement(false); + handler->SendSysMessage(LANG_CREATURE_MOVE_DISABLED); + } + else + { + sWorld.SetAllowMovement(true); + handler->SendSysMessage(LANG_CREATURE_MOVE_ENABLED); + } + return true; + } - // update movement type - WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE,lowguid); - if (pCreature && pCreature->GetWaypointPath()) - { - pCreature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); - pCreature->GetMotionMaster()->Initialize(); - if (pCreature->isAlive()) // dead creature will reset movement generator at respawn - { - pCreature->setDeathState(JUST_DIED); - pCreature->Respawn(true); - } - pCreature->SaveToDB(); - } + static bool HandleNpcSetEntryCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - handler->SendSysMessage(LANG_WAYPOINT_ADDED); + uint32 newEntryNum = atoi(args); + if (!newEntryNum) + return false; - return true; + Unit* unit = handler->getSelectedUnit(); + if (!unit || unit->GetTypeId() != TYPEID_UNIT) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; } + Creature* creature = unit->ToCreature(); + if (creature->UpdateEntry(newEntryNum)) + handler->SendSysMessage(LANG_DONE); + else + handler->SendSysMessage(LANG_ERROR); + return true; + } + + //change level of creature or pet + static bool HandleNpcSetLevelCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - static bool HandleNpcSetAllowMovementCommand(ChatHandler* handler, const char* /*args*/) + uint8 lvl = (uint8) atoi((char*)args); + if (lvl < 1 || lvl > sWorld.getIntConfig(CONFIG_MAX_PLAYER_LEVEL) + 3) { - if (sWorld.getAllowMovement()) - { - sWorld.SetAllowMovement(false); - handler->SendSysMessage(LANG_CREATURE_MOVE_DISABLED); - } - else - { - sWorld.SetAllowMovement(true); - handler->SendSysMessage(LANG_CREATURE_MOVE_ENABLED); - } - return true; + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; } - static bool HandleNpcSetEntryCommand(ChatHandler* handler, const char* args) + Creature* pCreature = handler->getSelectedCreature(); + if (!pCreature) { - if (!*args) - return false; - - uint32 newEntryNum = atoi(args); - if (!newEntryNum) - return false; + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } - Unit* unit = handler->getSelectedUnit(); - if (!unit || unit->GetTypeId() != TYPEID_UNIT) + if (pCreature->isPet()) + { + if (((Pet*)pCreature)->getPetType() == HUNTER_PET) { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; + pCreature->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForLevel(lvl)/4); + pCreature->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); } - Creature* creature = unit->ToCreature(); - if (creature->UpdateEntry(newEntryNum)) - handler->SendSysMessage(LANG_DONE); - else - handler->SendSysMessage(LANG_ERROR); - return true; + ((Pet*)pCreature)->GivePetLevel(lvl); } - - //change level of creature or pet - static bool HandleNpcSetLevelCommand(ChatHandler* handler, const char* args) + else { - if (!*args) - return false; + pCreature->SetMaxHealth(100 + 30*lvl); + pCreature->SetHealth(100 + 30*lvl); + pCreature->SetLevel(lvl); + pCreature->SaveToDB(); + } - uint8 lvl = (uint8) atoi((char*)args); - if (lvl < 1 || lvl > sWorld.getIntConfig(CONFIG_MAX_PLAYER_LEVEL) + 3) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + return true; + } - Creature* pCreature = handler->getSelectedCreature(); - if (!pCreature) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); + static bool HandleNpcDeleteCommand(ChatHandler* handler, const char* args) + { + Creature* unit = NULL; + + if (*args) + { + // number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hcreature"); + if (!cId) return false; - } - if (pCreature->isPet()) - { - if (((Pet*)pCreature)->getPetType() == HUNTER_PET) - { - pCreature->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForLevel(lvl)/4); - pCreature->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); - } - ((Pet*)pCreature)->GivePetLevel(lvl); - } - else - { - pCreature->SetMaxHealth(100 + 30*lvl); - pCreature->SetHealth(100 + 30*lvl); - pCreature->SetLevel(lvl); - pCreature->SaveToDB(); - } + uint32 lowguid = atoi(cId); + if (!lowguid) + return false; - return true; + if (CreatureData const* cr_data = sObjectMgr.GetCreatureData(lowguid)) + unit = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(lowguid, cr_data->id, HIGHGUID_UNIT)); } + else + unit = handler->getSelectedCreature(); - static bool HandleNpcDeleteCommand(ChatHandler* handler, const char* args) + if (!unit || unit->isPet() || unit->isTotem()) { - Creature* unit = NULL; - - if (*args) - { - // number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args,"Hcreature"); - if (!cId) - return false; + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } - uint32 lowguid = atoi(cId); - if (!lowguid) - return false; + // Delete the creature + unit->CombatStop(); + unit->DeleteFromDB(); + unit->AddObjectToRemoveList(); - if (CreatureData const* cr_data = sObjectMgr.GetCreatureData(lowguid)) - unit = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(lowguid, cr_data->id, HIGHGUID_UNIT)); - } - else - unit = handler->getSelectedCreature(); + handler->SendSysMessage(LANG_COMMAND_DELCREATMESSAGE); - if (!unit || unit->isPet() || unit->isTotem()) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + return true; + } - // Delete the creature - unit->CombatStop(); - unit->DeleteFromDB(); - unit->AddObjectToRemoveList(); + //del item from vendor list + static bool HandleNpcDeleteVendorItemCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - handler->SendSysMessage(LANG_COMMAND_DELCREATMESSAGE); + Creature* vendor = handler->getSelectedCreature(); + if (!vendor || !vendor->isVendor()) + { + handler->SendSysMessage(LANG_COMMAND_VENDORSELECTION); + handler->SetSentErrorMessage(true); + return false; + } - return true; + char* pitem = handler->extractKeyFromLink((char*)args,"Hitem"); + if (!pitem) + { + handler->SendSysMessage(LANG_COMMAND_NEEDITEMSEND); + handler->SetSentErrorMessage(true); + return false; } + uint32 itemId = atol(pitem); - //del item from vendor list - static bool HandleNpcDeleteVendorItemCommand(ChatHandler* handler, const char* args) + if (!sObjectMgr.RemoveVendorItem(vendor->GetEntry(),itemId)) { - if (!*args) - return false; + handler->PSendSysMessage(LANG_ITEM_NOT_IN_LIST,itemId); + handler->SetSentErrorMessage(true); + return false; + } - Creature* vendor = handler->getSelectedCreature(); - if (!vendor || !vendor->isVendor()) - { - handler->SendSysMessage(LANG_COMMAND_VENDORSELECTION); - handler->SetSentErrorMessage(true); - return false; - } + ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(itemId); - char* pitem = handler->extractKeyFromLink((char*)args,"Hitem"); - if (!pitem) - { - handler->SendSysMessage(LANG_COMMAND_NEEDITEMSEND); - handler->SetSentErrorMessage(true); - return false; - } - uint32 itemId = atol(pitem); + handler->PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST,itemId,pProto->Name1); + return true; + } - if (!sObjectMgr.RemoveVendorItem(vendor->GetEntry(),itemId)) - { - handler->PSendSysMessage(LANG_ITEM_NOT_IN_LIST,itemId); - handler->SetSentErrorMessage(true); - return false; - } + //set faction of creature + static bool HandleNpcSetFactionIdCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(itemId); + uint32 factionId = (uint32) atoi((char*)args); - handler->PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST,itemId,pProto->Name1); - return true; + if (!sFactionTemplateStore.LookupEntry(factionId)) + { + handler->PSendSysMessage(LANG_WRONG_FACTION, factionId); + handler->SetSentErrorMessage(true); + return false; } - //set faction of creature - static bool HandleNpcSetFactionIdCommand(ChatHandler* handler, const char* args) + Creature* pCreature = handler->getSelectedCreature(); + + if (!pCreature) { - if (!*args) - return false; + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } - uint32 factionId = (uint32) atoi((char*)args); + pCreature->setFaction(factionId); - if (!sFactionTemplateStore.LookupEntry(factionId)) - { - handler->PSendSysMessage(LANG_WRONG_FACTION, factionId); - handler->SetSentErrorMessage(true); - return false; - } + // faction is set in creature_template - not inside creature - Creature* pCreature = handler->getSelectedCreature(); + // update in memory + if (CreatureInfo const *cinfo = pCreature->GetCreatureInfo()) + { + const_cast<CreatureInfo*>(cinfo)->faction_A = factionId; + const_cast<CreatureInfo*>(cinfo)->faction_H = factionId; + } - if (!pCreature) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + // and DB + WorldDatabase.PExecute("UPDATE creature_template SET faction_A = '%u', faction_H = '%u' WHERE entry = '%u'", factionId, factionId, pCreature->GetEntry()); - pCreature->setFaction(factionId); + return true; + } - // faction is set in creature_template - not inside creature + //set npcflag of creature + static bool HandleNpcSetFlagCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - // update in memory - if (CreatureInfo const *cinfo = pCreature->GetCreatureInfo()) - { - const_cast<CreatureInfo*>(cinfo)->faction_A = factionId; - const_cast<CreatureInfo*>(cinfo)->faction_H = factionId; - } + uint32 npcFlags = (uint32) atoi((char*)args); - // and DB - WorldDatabase.PExecute("UPDATE creature_template SET faction_A = '%u', faction_H = '%u' WHERE entry = '%u'", factionId, factionId, pCreature->GetEntry()); + Creature* pCreature = handler->getSelectedCreature(); - return true; + if (!pCreature) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; } - //set npcflag of creature - static bool HandleNpcSetFlagCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + pCreature->SetUInt32Value(UNIT_NPC_FLAGS, npcFlags); - uint32 npcFlags = (uint32) atoi((char*)args); + WorldDatabase.PExecute("UPDATE creature_template SET npcflag = '%u' WHERE entry = '%u'", npcFlags, pCreature->GetEntry()); - Creature* pCreature = handler->getSelectedCreature(); + handler->SendSysMessage(LANG_VALUE_SAVED_REJOIN); - if (!pCreature) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } - - pCreature->SetUInt32Value(UNIT_NPC_FLAGS, npcFlags); - - WorldDatabase.PExecute("UPDATE creature_template SET npcflag = '%u' WHERE entry = '%u'", npcFlags, pCreature->GetEntry()); + return true; + } - handler->SendSysMessage(LANG_VALUE_SAVED_REJOIN); + //npc follow handling + static bool HandleNpcFollowCommand(ChatHandler* handler, const char* /*args*/) + { + Player *player = handler->GetSession()->GetPlayer(); + Creature *creature = handler->getSelectedCreature(); - return true; + if (!creature) + { + handler->PSendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; } - //npc follow handling - static bool HandleNpcFollowCommand(ChatHandler* handler, const char* /*args*/) - { - Player *player = handler->GetSession()->GetPlayer(); - Creature *creature = handler->getSelectedCreature(); + // Follow player - Using pet's default dist and angle + creature->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, creature->GetFollowAngle()); - if (!creature) - { - handler->PSendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + handler->PSendSysMessage(LANG_CREATURE_FOLLOW_YOU_NOW, creature->GetName()); + return true; + } - // Follow player - Using pet's default dist and angle - creature->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, creature->GetFollowAngle()); + static bool HandleNpcInfoCommand(ChatHandler* handler, const char* /*args*/) + { + Creature* target = handler->getSelectedCreature(); - handler->PSendSysMessage(LANG_CREATURE_FOLLOW_YOU_NOW, creature->GetName()); - return true; + if (!target) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; } - static bool HandleNpcInfoCommand(ChatHandler* handler, const char* /*args*/) + uint32 faction = target->getFaction(); + uint32 npcflags = target->GetUInt32Value(UNIT_NPC_FLAGS); + uint32 displayid = target->GetDisplayId(); + uint32 nativeid = target->GetNativeDisplayId(); + uint32 Entry = target->GetEntry(); + CreatureInfo const* cInfo = target->GetCreatureInfo(); + + int64 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL); + if (curRespawnDelay < 0) + curRespawnDelay = 0; + std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay),true); + std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); + + handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetDBTableGUIDLow(), faction, npcflags, Entry, displayid, nativeid); + handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel()); + handler->PSendSysMessage(LANG_NPCINFO_HEALTH,target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth()); + handler->PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->getFaction()); + handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); + handler->PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid,cInfo->pickpocketLootId,cInfo->SkinLootId); + handler->PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId()); + handler->PSendSysMessage(LANG_NPCINFO_PHASEMASK, target->GetPhaseMask()); + handler->PSendSysMessage(LANG_NPCINFO_ARMOR, target->GetArmor()); + handler->PSendSysMessage(LANG_NPCINFO_POSITION,float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ())); + if (const CreatureData* const linked = target->GetLinkedRespawnCreatureData()) + if (CreatureInfo const *master = GetCreatureInfo(linked->id)) + handler->PSendSysMessage(LANG_NPCINFO_LINKGUID, sObjectMgr.GetLinkedRespawnGuid(target->GetDBTableGUIDLow()), linked->id, master->Name); + + if ((npcflags & UNIT_NPC_FLAG_VENDOR)) + { + handler->SendSysMessage(LANG_NPCINFO_VENDOR); + } + if ((npcflags & UNIT_NPC_FLAG_TRAINER)) { - Creature* target = handler->getSelectedCreature(); + handler->SendSysMessage(LANG_NPCINFO_TRAINER); + } - if (!target) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + return true; + } - uint32 faction = target->getFaction(); - uint32 npcflags = target->GetUInt32Value(UNIT_NPC_FLAGS); - uint32 displayid = target->GetDisplayId(); - uint32 nativeid = target->GetNativeDisplayId(); - uint32 Entry = target->GetEntry(); - CreatureInfo const* cInfo = target->GetCreatureInfo(); - - int64 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL); - if (curRespawnDelay < 0) - curRespawnDelay = 0; - std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay),true); - std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); - - handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetDBTableGUIDLow(), faction, npcflags, Entry, displayid, nativeid); - handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel()); - handler->PSendSysMessage(LANG_NPCINFO_HEALTH,target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth()); - handler->PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->getFaction()); - handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); - handler->PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid,cInfo->pickpocketLootId,cInfo->SkinLootId); - handler->PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId()); - handler->PSendSysMessage(LANG_NPCINFO_PHASEMASK, target->GetPhaseMask()); - handler->PSendSysMessage(LANG_NPCINFO_ARMOR, target->GetArmor()); - handler->PSendSysMessage(LANG_NPCINFO_POSITION,float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ())); - if (const CreatureData* const linked = target->GetLinkedRespawnCreatureData()) - if (CreatureInfo const *master = GetCreatureInfo(linked->id)) - handler->PSendSysMessage(LANG_NPCINFO_LINKGUID, sObjectMgr.GetLinkedRespawnGuid(target->GetDBTableGUIDLow()), linked->id, master->Name); - - if ((npcflags & UNIT_NPC_FLAG_VENDOR)) - { - handler->SendSysMessage(LANG_NPCINFO_VENDOR); - } - if ((npcflags & UNIT_NPC_FLAG_TRAINER)) - { - handler->SendSysMessage(LANG_NPCINFO_TRAINER); - } + //move selected creature + static bool HandleNpcMoveCommand(ChatHandler* handler, const char* args) + { + uint32 lowguid = 0; - return true; - } + Creature* pCreature = handler->getSelectedCreature(); - //move selected creature - static bool HandleNpcMoveCommand(ChatHandler* handler, const char* args) + if (!pCreature) { - uint32 lowguid = 0; + // number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hcreature"); + if (!cId) + return false; - Creature* pCreature = handler->getSelectedCreature(); + lowguid = atoi(cId); + + /* FIXME: impossible without entry + if (lowguid) + pCreature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT)); + */ + // Attempting creature load from DB data if (!pCreature) { - // number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args,"Hcreature"); - if (!cId) + CreatureData const* data = sObjectMgr.GetCreatureData(lowguid); + if (!data) + { + handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); + handler->SetSentErrorMessage(true); return false; + } - lowguid = atoi(cId); - - /* FIXME: impossibel without entry - if (lowguid) - pCreature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT)); - */ + uint32 map_id = data->mapid; - // Attempting creature load from DB data - if (!pCreature) + if (handler->GetSession()->GetPlayer()->GetMapId() != map_id) { - CreatureData const* data = sObjectMgr.GetCreatureData(lowguid); - if (!data) - { - handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); - handler->SetSentErrorMessage(true); - return false; - } - - uint32 map_id = data->mapid; - - if (handler->GetSession()->GetPlayer()->GetMapId() != map_id) - { - handler->PSendSysMessage(LANG_COMMAND_CREATUREATSAMEMAP, lowguid); - handler->SetSentErrorMessage(true); - return false; - } - } - else - { - lowguid = pCreature->GetDBTableGUIDLow(); + handler->PSendSysMessage(LANG_COMMAND_CREATUREATSAMEMAP, lowguid); + handler->SetSentErrorMessage(true); + return false; } } else { lowguid = pCreature->GetDBTableGUIDLow(); } + } + else + { + lowguid = pCreature->GetDBTableGUIDLow(); + } - float x = handler->GetSession()->GetPlayer()->GetPositionX(); - float y = handler->GetSession()->GetPlayer()->GetPositionY(); - float z = handler->GetSession()->GetPlayer()->GetPositionZ(); - float o = handler->GetSession()->GetPlayer()->GetOrientation(); + float x = handler->GetSession()->GetPlayer()->GetPositionX(); + float y = handler->GetSession()->GetPlayer()->GetPositionY(); + float z = handler->GetSession()->GetPlayer()->GetPositionZ(); + float o = handler->GetSession()->GetPlayer()->GetOrientation(); - if (pCreature) + if (pCreature) + { + if (CreatureData const* data = sObjectMgr.GetCreatureData(pCreature->GetDBTableGUIDLow())) { - if (CreatureData const* data = sObjectMgr.GetCreatureData(pCreature->GetDBTableGUIDLow())) - { - const_cast<CreatureData*>(data)->posX = x; - const_cast<CreatureData*>(data)->posY = y; - const_cast<CreatureData*>(data)->posZ = z; - const_cast<CreatureData*>(data)->orientation = o; - } - pCreature->GetMap()->CreatureRelocation(pCreature,x, y, z,o); - pCreature->GetMotionMaster()->Initialize(); - if (pCreature->isAlive()) // dead creature will reset movement generator at respawn - { - pCreature->setDeathState(JUST_DIED); - pCreature->Respawn(); - } + const_cast<CreatureData*>(data)->posX = x; + const_cast<CreatureData*>(data)->posY = y; + const_cast<CreatureData*>(data)->posZ = z; + const_cast<CreatureData*>(data)->orientation = o; } - - WorldDatabase.PExecute("UPDATE creature SET position_x = '%f', position_y = '%f', position_z = '%f', orientation = '%f' WHERE guid = '%u'", x, y, z, o, lowguid); - handler->PSendSysMessage(LANG_COMMAND_CREATUREMOVED); - return true; - } - - //play npc emote - static bool HandleNpcPlayEmoteCommand(ChatHandler* handler, const char* args) - { - uint32 emote = atoi((char*)args); - - Creature* target = handler->getSelectedCreature(); - if (!target) + pCreature->GetMap()->CreatureRelocation(pCreature,x, y, z,o); + pCreature->GetMotionMaster()->Initialize(); + if (pCreature->isAlive()) // dead creature will reset movement generator at respawn { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; + pCreature->setDeathState(JUST_DIED); + pCreature->Respawn(); } + } - if (target->GetTransport()) - if (target->GetGUIDTransport()) - WorldDatabase.PQuery("UPDATE creature_transport SET emote=%u WHERE transport_entry=%u AND guid=%u", emote, target->GetTransport()->GetEntry(), target->GetGUIDTransport()); + WorldDatabase.PExecute("UPDATE creature SET position_x = '%f', position_y = '%f', position_z = '%f', orientation = '%f' WHERE guid = '%u'", x, y, z, o, lowguid); + handler->PSendSysMessage(LANG_COMMAND_CREATUREMOVED); + return true; + } - target->SetUInt32Value(UNIT_NPC_EMOTESTATE,emote); + //play npc emote + static bool HandleNpcPlayEmoteCommand(ChatHandler* handler, const char* args) + { + uint32 emote = atoi((char*)args); - return true; + Creature* target = handler->getSelectedCreature(); + if (!target) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; } - //set model of creature - static bool HandleNpcSetModelCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + if (target->GetTransport()) + if (target->GetGUIDTransport()) + WorldDatabase.PQuery("UPDATE creature_transport SET emote=%u WHERE transport_entry=%u AND guid=%u", emote, target->GetTransport()->GetEntry(), target->GetGUIDTransport()); - uint32 displayId = (uint32) atoi((char*)args); + target->SetUInt32Value(UNIT_NPC_EMOTESTATE,emote); - Creature *pCreature = handler->getSelectedCreature(); + return true; + } - if (!pCreature || pCreature->isPet()) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + //set model of creature + static bool HandleNpcSetModelCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - pCreature->SetDisplayId(displayId); - pCreature->SetNativeDisplayId(displayId); + uint32 displayId = (uint32) atoi((char*)args); - pCreature->SaveToDB(); + Creature *pCreature = handler->getSelectedCreature(); - return true; + if (!pCreature || pCreature->isPet()) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; } - /**HandleNpcSetMoveTypeCommand - * Set the movement type for an NPC.<br/> - * <br/> - * Valid movement types are: - * <ul> - * <li> stay - NPC wont move </li> - * <li> random - NPC will move randomly according to the spawndist </li> - * <li> way - NPC will move with given waypoints set </li> - * </ul> - * additional parameter: NODEL - so no waypoints are deleted, if you - * change the movement type - */ - static bool HandleNpcSetMoveTypeCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; - - // 3 arguments: - // GUID (optional - you can also select the creature) - // stay|random|way (determines the kind of movement) - // NODEL (optional - tells the system NOT to delete any waypoints) - // this is very handy if you want to do waypoints, that are - // later switched on/off according to special events (like escort - // quests, etc) - char* guid_str = strtok((char*)args, " "); - char* type_str = strtok((char*)NULL, " "); - char* dontdel_str = strtok((char*)NULL, " "); + pCreature->SetDisplayId(displayId); + pCreature->SetNativeDisplayId(displayId); + + pCreature->SaveToDB(); + + return true; + } + + /**HandleNpcSetMoveTypeCommand + * Set the movement type for an NPC.<br/> + * <br/> + * Valid movement types are: + * <ul> + * <li> stay - NPC wont move </li> + * <li> random - NPC will move randomly according to the spawndist </li> + * <li> way - NPC will move with given waypoints set </li> + * </ul> + * additional parameter: NODEL - so no waypoints are deleted, if you + * change the movement type + */ + static bool HandleNpcSetMoveTypeCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - bool doNotDelete = false; + // 3 arguments: + // GUID (optional - you can also select the creature) + // stay|random|way (determines the kind of movement) + // NODEL (optional - tells the system NOT to delete any waypoints) + // this is very handy if you want to do waypoints, that are + // later switched on/off according to special events (like escort + // quests, etc) + char* guid_str = strtok((char*)args, " "); + char* type_str = strtok((char*)NULL, " "); + char* dontdel_str = strtok((char*)NULL, " "); - if (!guid_str) - return false; + bool doNotDelete = false; - uint32 lowguid = 0; - Creature* pCreature = NULL; + if (!guid_str) + return false; - if (dontdel_str) - { - //sLog.outError("DEBUG: All 3 params are set"); + uint32 lowguid = 0; + Creature* pCreature = NULL; - // All 3 params are set - // GUID - // type - // doNotDEL - if (stricmp(dontdel_str, "NODEL") == 0) - { - //sLog.outError("DEBUG: doNotDelete = true;"); - doNotDelete = true; - } - } - else - { - // Only 2 params - but maybe NODEL is set - if (type_str) - { - sLog.outError("DEBUG: Only 2 params "); - if (stricmp(type_str, "NODEL") == 0) - { - //sLog.outError("DEBUG: type_str, NODEL "); - doNotDelete = true; - type_str = NULL; - } - } - } + if (dontdel_str) + { + //sLog.outError("DEBUG: All 3 params are set"); - if (!type_str) // case .setmovetype $move_type (with selected creature) + // All 3 params are set + // GUID + // type + // doNotDEL + if (stricmp(dontdel_str, "NODEL") == 0) { - type_str = guid_str; - pCreature = handler->getSelectedCreature(); - if (!pCreature || pCreature->isPet()) - return false; - lowguid = pCreature->GetDBTableGUIDLow(); + //sLog.outError("DEBUG: doNotDelete = true;"); + doNotDelete = true; } - else // case .setmovetype #creature_guid $move_type (with selected creature) + } + else + { + // Only 2 params - but maybe NODEL is set + if (type_str) { - lowguid = atoi((char*)guid_str); - - /* impossible without entry - if (lowguid) - pCreature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT)); - */ - - // attempt check creature existence by DB data - if (!pCreature) - { - CreatureData const* data = sObjectMgr.GetCreatureData(lowguid); - if (!data) - { - handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); - handler->SetSentErrorMessage(true); - return false; - } - } - else + sLog.outError("DEBUG: Only 2 params "); + if (stricmp(type_str, "NODEL") == 0) { - lowguid = pCreature->GetDBTableGUIDLow(); + //sLog.outError("DEBUG: type_str, NODEL "); + doNotDelete = true; + type_str = NULL; } } + } - // now lowguid is low guid really existed creature - // and pCreature point (maybe) to this creature or NULL - - MovementGeneratorType move_type; - - std::string type = type_str; - - if (type == "stay") - move_type = IDLE_MOTION_TYPE; - else if (type == "random") - move_type = RANDOM_MOTION_TYPE; - else if (type == "way") - move_type = WAYPOINT_MOTION_TYPE; - else + if (!type_str) // case .setmovetype $move_type (with selected creature) + { + type_str = guid_str; + pCreature = handler->getSelectedCreature(); + if (!pCreature || pCreature->isPet()) return false; + lowguid = pCreature->GetDBTableGUIDLow(); + } + else // case .setmovetype #creature_guid $move_type (with selected creature) + { + lowguid = atoi((char*)guid_str); - // update movement type - //if (doNotDelete == false) - // WaypointMgr.DeletePath(lowguid); + /* impossible without entry + if (lowguid) + pCreature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT)); + */ - if (pCreature) + // attempt check creature existence by DB data + if (!pCreature) { - // update movement type - if (doNotDelete == false) - pCreature->LoadPath(0); - - pCreature->SetDefaultMovementType(move_type); - pCreature->GetMotionMaster()->Initialize(); - if (pCreature->isAlive()) // dead creature will reset movement generator at respawn + CreatureData const* data = sObjectMgr.GetCreatureData(lowguid); + if (!data) { - pCreature->setDeathState(JUST_DIED); - pCreature->Respawn(); + handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); + handler->SetSentErrorMessage(true); + return false; } - pCreature->SaveToDB(); - } - if (doNotDelete == false) - { - handler->PSendSysMessage(LANG_MOVE_TYPE_SET,type_str); } else { - handler->PSendSysMessage(LANG_MOVE_TYPE_SET_NODEL,type_str); + lowguid = pCreature->GetDBTableGUIDLow(); } - - return true; } - //npc phasemask handling - //change phasemask of creature or pet - static bool HandleNpcSetPhaseCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + // now lowguid is low guid really existed creature + // and pCreature point (maybe) to this creature or NULL - uint32 phasemask = (uint32) atoi((char*)args); - if (phasemask == 0) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + MovementGeneratorType move_type; - Creature* pCreature = handler->getSelectedCreature(); - if (!pCreature) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } - - pCreature->SetPhaseMask(phasemask,true); + std::string type = type_str; - if (!pCreature->isPet()) - pCreature->SaveToDB(); + if (type == "stay") + move_type = IDLE_MOTION_TYPE; + else if (type == "random") + move_type = RANDOM_MOTION_TYPE; + else if (type == "way") + move_type = WAYPOINT_MOTION_TYPE; + else + return false; - return true; - } + // update movement type + //if (doNotDelete == false) + // WaypointMgr.DeletePath(lowguid); - //set spawn dist of creature - static bool HandleNpcSetSpawnDistCommand(ChatHandler* handler, const char* args) + if (pCreature) { - if (!*args) - return false; - - float option = (float)(atof((char*)args)); - if (option < 0.0f) - { - handler->SendSysMessage(LANG_BAD_VALUE); - return false; - } - - MovementGeneratorType mtype = IDLE_MOTION_TYPE; - if (option >0.0f) - mtype = RANDOM_MOTION_TYPE; - - Creature *pCreature = handler->getSelectedCreature(); - uint32 u_guidlow = 0; - - if (pCreature) - u_guidlow = pCreature->GetDBTableGUIDLow(); - else - return false; + // update movement type + if (doNotDelete == false) + pCreature->LoadPath(0); - pCreature->SetRespawnRadius((float)option); - pCreature->SetDefaultMovementType(mtype); + pCreature->SetDefaultMovementType(move_type); pCreature->GetMotionMaster()->Initialize(); - if (pCreature->isAlive()) // dead creature will reset movement generator at respawn + if (pCreature->isAlive()) // dead creature will reset movement generator at respawn { pCreature->setDeathState(JUST_DIED); pCreature->Respawn(); } - - WorldDatabase.PExecute("UPDATE creature SET spawndist=%f, MovementType=%i WHERE guid=%u",option,mtype,u_guidlow); - handler->PSendSysMessage(LANG_COMMAND_SPAWNDIST,option); - return true; + pCreature->SaveToDB(); } - - //spawn time handling - static bool HandleNpcSetSpawnTimeCommand(ChatHandler* handler, const char* args) + if (doNotDelete == false) { - if (!*args) - return false; + handler->PSendSysMessage(LANG_MOVE_TYPE_SET,type_str); + } + else + { + handler->PSendSysMessage(LANG_MOVE_TYPE_SET_NODEL,type_str); + } - char* stime = strtok((char*)args, " "); + return true; + } - if (!stime) - return false; + //npc phasemask handling + //change phasemask of creature or pet + static bool HandleNpcSetPhaseCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - int i_stime = atoi((char*)stime); + uint32 phasemask = (uint32) atoi((char*)args); + if (phasemask == 0) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; + } - if (i_stime < 0) - { - handler->SendSysMessage(LANG_BAD_VALUE); - handler->SetSentErrorMessage(true); - return false; - } + Creature* pCreature = handler->getSelectedCreature(); + if (!pCreature) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } - Creature *pCreature = handler->getSelectedCreature(); - uint32 u_guidlow = 0; + pCreature->SetPhaseMask(phasemask,true); - if (pCreature) - u_guidlow = pCreature->GetDBTableGUIDLow(); - else - return false; + if (!pCreature->isPet()) + pCreature->SaveToDB(); - WorldDatabase.PExecute("UPDATE creature SET spawntimesecs=%i WHERE guid=%u",i_stime,u_guidlow); - pCreature->SetRespawnDelay((uint32)i_stime); - handler->PSendSysMessage(LANG_COMMAND_SPAWNTIME,i_stime); + return true; + } - return true; - } + //set spawn dist of creature + static bool HandleNpcSetSpawnDistCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - static bool HandleNpcSayCommand(ChatHandler* handler, const char* args) + float option = (float)(atof((char*)args)); + if (option < 0.0f) { - if (!*args) - return false; + handler->SendSysMessage(LANG_BAD_VALUE); + return false; + } - Creature* pCreature = handler->getSelectedCreature(); - if (!pCreature) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + MovementGeneratorType mtype = IDLE_MOTION_TYPE; + if (option >0.0f) + mtype = RANDOM_MOTION_TYPE; - pCreature->MonsterSay(args, LANG_UNIVERSAL, 0); + Creature *pCreature = handler->getSelectedCreature(); + uint32 u_guidlow = 0; - // make some emotes - char lastchar = args[strlen(args) - 1]; - switch(lastchar) - { - case '?': pCreature->HandleEmoteCommand(EMOTE_ONESHOT_QUESTION); break; - case '!': pCreature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); break; - default: pCreature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); break; - } + if (pCreature) + u_guidlow = pCreature->GetDBTableGUIDLow(); + else + return false; - return true; + pCreature->SetRespawnRadius((float)option); + pCreature->SetDefaultMovementType(mtype); + pCreature->GetMotionMaster()->Initialize(); + if (pCreature->isAlive()) // dead creature will reset movement generator at respawn + { + pCreature->setDeathState(JUST_DIED); + pCreature->Respawn(); } - //show text emote by creature in chat - static bool HandleNpcTextEmoteCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; + WorldDatabase.PExecute("UPDATE creature SET spawndist=%f, MovementType=%i WHERE guid=%u",option,mtype,u_guidlow); + handler->PSendSysMessage(LANG_COMMAND_SPAWNDIST,option); + return true; + } - Creature* pCreature = handler->getSelectedCreature(); + //spawn time handling + static bool HandleNpcSetSpawnTimeCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - if (!pCreature) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + char* stime = strtok((char*)args, " "); - pCreature->MonsterTextEmote(args, 0); + if (!stime) + return false; - return true; - } + int i_stime = atoi((char*)stime); - //npc unfollow handling - static bool HandleNpcUnFollowCommand(ChatHandler* handler, const char* /*args*/) + if (i_stime < 0) { - Player *player = handler->GetSession()->GetPlayer(); - Creature *creature = handler->getSelectedCreature(); + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; + } - if (!creature) - { - handler->PSendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + Creature *pCreature = handler->getSelectedCreature(); + uint32 u_guidlow = 0; - if (/*creature->GetMotionMaster()->empty() ||*/ - creature->GetMotionMaster()->GetCurrentMovementGeneratorType () != TARGETED_MOTION_TYPE) - { - handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName()); - handler->SetSentErrorMessage(true); - return false; - } + if (pCreature) + u_guidlow = pCreature->GetDBTableGUIDLow(); + else + return false; - TargetedMovementGenerator<Creature> const* mgen - = static_cast<TargetedMovementGenerator<Creature> const*>((creature->GetMotionMaster()->top())); + WorldDatabase.PExecute("UPDATE creature SET spawntimesecs=%i WHERE guid=%u",i_stime,u_guidlow); + pCreature->SetRespawnDelay((uint32)i_stime); + handler->PSendSysMessage(LANG_COMMAND_SPAWNTIME,i_stime); - if (mgen->GetTarget() != player) - { - handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName()); - handler->SetSentErrorMessage(true); - return false; - } + return true; + } - // reset movement - creature->GetMotionMaster()->MovementExpired(true); + static bool HandleNpcSayCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName()); - return true; + Creature* pCreature = handler->getSelectedCreature(); + if (!pCreature) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; } - // make npc whisper to player - static bool HandleNpcWhisperCommand(ChatHandler* handler, const char* args) + pCreature->MonsterSay(args, LANG_UNIVERSAL, 0); + + // make some emotes + char lastchar = args[strlen(args) - 1]; + switch(lastchar) { - if (!*args) - return false; + case '?': pCreature->HandleEmoteCommand(EMOTE_ONESHOT_QUESTION); break; + case '!': pCreature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); break; + default: pCreature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); break; + } - char* receiver_str = strtok((char*)args, " "); - char* text = strtok(NULL, ""); + return true; + } - uint64 guid = handler->GetSession()->GetPlayer()->GetSelection(); - Creature* pCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(guid); + //show text emote by creature in chat + static bool HandleNpcTextEmoteCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - if (!pCreature || !receiver_str || !text) - { - return false; - } + Creature* pCreature = handler->getSelectedCreature(); - uint64 receiver_guid= atol(receiver_str); + if (!pCreature) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } - // check online security - if (handler->HasLowerSecurity(sObjectMgr.GetPlayer(receiver_guid), 0)) - return false; + pCreature->MonsterTextEmote(args, 0); - pCreature->MonsterWhisper(text,receiver_guid); + return true; + } - return true; - } + //npc unfollow handling + static bool HandleNpcUnFollowCommand(ChatHandler* handler, const char* /*args*/) + { + Player *player = handler->GetSession()->GetPlayer(); + Creature *creature = handler->getSelectedCreature(); - static bool HandleNpcYellCommand(ChatHandler* handler, const char* args) + if (!creature) { - if (!*args) - return false; - - Creature* pCreature = handler->getSelectedCreature(); - if (!pCreature) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + handler->PSendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } - pCreature->MonsterYell(args, LANG_UNIVERSAL, 0); + if (/*creature->GetMotionMaster()->empty() ||*/ + creature->GetMotionMaster()->GetCurrentMovementGeneratorType () != TARGETED_MOTION_TYPE) + { + handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName()); + handler->SetSentErrorMessage(true); + return false; + } - // make an emote - pCreature->HandleEmoteCommand(EMOTE_ONESHOT_SHOUT); + TargetedMovementGenerator<Creature> const* mgen + = static_cast<TargetedMovementGenerator<Creature> const*>((creature->GetMotionMaster()->top())); - return true; + if (mgen->GetTarget() != player) + { + handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName()); + handler->SetSentErrorMessage(true); + return false; } - // add creature, temp only - static bool HandleNpcAddTempSpawnCommand(ChatHandler* handler, const char* args) - { - if (!*args) - return false; - char* charID = strtok((char*)args, " "); - if (!charID) - return false; + // reset movement + creature->GetMotionMaster()->MovementExpired(true); - Player *chr = handler->GetSession()->GetPlayer(); + handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName()); + return true; + } - uint32 id = atoi(charID); - if (!id) - return false; + // make npc whisper to player + static bool HandleNpcWhisperCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - chr->SummonCreature(id, *chr, TEMPSUMMON_CORPSE_DESPAWN, 120); + char* receiver_str = strtok((char*)args, " "); + char* text = strtok(NULL, ""); - return true; - } + uint64 guid = handler->GetSession()->GetPlayer()->GetSelection(); + Creature* pCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(guid); - //npc tame handling - static bool HandleNpcTameCommand(ChatHandler* handler, const char* /*args*/) + if (!pCreature || !receiver_str || !text) { - Creature *creatureTarget = handler->getSelectedCreature (); - if (!creatureTarget || creatureTarget->isPet ()) - { - handler->PSendSysMessage (LANG_SELECT_CREATURE); - handler->SetSentErrorMessage (true); - return false; - } + return false; + } - Player *player = handler->GetSession()->GetPlayer (); + uint64 receiver_guid= atol(receiver_str); - if (player->GetPetGUID ()) - { - handler->SendSysMessage (LANG_YOU_ALREADY_HAVE_PET); - handler->SetSentErrorMessage (true); - return false; - } + // check online security + if (handler->HasLowerSecurity(sObjectMgr.GetPlayer(receiver_guid), 0)) + return false; - CreatureInfo const* cInfo = creatureTarget->GetCreatureInfo(); + pCreature->MonsterWhisper(text,receiver_guid); - if (!cInfo->isTameable (player->CanTameExoticPets())) - { - handler->PSendSysMessage (LANG_CREATURE_NON_TAMEABLE,cInfo->Entry); - handler->SetSentErrorMessage (true); - return false; - } + return true; + } - // Everything looks OK, create new pet - Pet* pet = player->CreateTamedPetFrom (creatureTarget); - if (!pet) - { - handler->PSendSysMessage (LANG_CREATURE_NON_TAMEABLE,cInfo->Entry); - handler->SetSentErrorMessage (true); - return false; - } + static bool HandleNpcYellCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - // place pet before player - float x,y,z; - player->GetClosePoint (x,y,z,creatureTarget->GetObjectSize (),CONTACT_DISTANCE); - pet->Relocate (x,y,z,M_PI-player->GetOrientation ()); + Creature* pCreature = handler->getSelectedCreature(); + if (!pCreature) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } - // set pet to defensive mode by default (some classes can't control controlled pets in fact). - pet->SetReactState(REACT_DEFENSIVE); + pCreature->MonsterYell(args, LANG_UNIVERSAL, 0); - // calculate proper level - uint8 level = (creatureTarget->getLevel() < (player->getLevel() - 5)) ? (player->getLevel() - 5) : creatureTarget->getLevel(); + // make an emote + pCreature->HandleEmoteCommand(EMOTE_ONESHOT_SHOUT); - // prepare visual effect for levelup - pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1); + return true; + } - // add to world - pet->GetMap()->Add(pet->ToCreature()); + // add creature, temp only + static bool HandleNpcAddTempSpawnCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; + char* charID = strtok((char*)args, " "); + if (!charID) + return false; - // visual effect for levelup - pet->SetUInt32Value(UNIT_FIELD_LEVEL, level); + Player *chr = handler->GetSession()->GetPlayer(); - // caster have pet now - player->SetMinion(pet, true); + uint32 id = atoi(charID); + if (!id) + return false; - pet->SavePetToDB(PET_SAVE_AS_CURRENT); - player->PetSpellInitialize(); + chr->SummonCreature(id, *chr, TEMPSUMMON_CORPSE_DESPAWN, 120); - return true; - } + return true; + } - //npc deathstate handling - static bool HandleNpcSetDeathStateCommand(ChatHandler* handler, const char* args) + //npc tame handling + static bool HandleNpcTameCommand(ChatHandler* handler, const char* /*args*/) + { + Creature *creatureTarget = handler->getSelectedCreature (); + if (!creatureTarget || creatureTarget->isPet ()) { - if (!*args) - return false; + handler->PSendSysMessage (LANG_SELECT_CREATURE); + handler->SetSentErrorMessage (true); + return false; + } - Creature* pCreature = handler->getSelectedCreature(); - if (!pCreature || pCreature->isPet()) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + Player *player = handler->GetSession()->GetPlayer (); - if (strncmp(args, "on", 3) == 0) - pCreature->SetDeadByDefault(true); - else if (strncmp(args, "off", 4) == 0) - pCreature->SetDeadByDefault(false); - else - { - handler->SendSysMessage(LANG_USE_BOL); - handler->SetSentErrorMessage(true); - return false; - } + if (player->GetPetGUID ()) + { + handler->SendSysMessage (LANG_YOU_ALREADY_HAVE_PET); + handler->SetSentErrorMessage (true); + return false; + } - pCreature->SaveToDB(); - pCreature->Respawn(); + CreatureInfo const* cInfo = creatureTarget->GetCreatureInfo(); - return true; + if (!cInfo->isTameable (player->CanTameExoticPets())) + { + handler->PSendSysMessage (LANG_CREATURE_NON_TAMEABLE,cInfo->Entry); + handler->SetSentErrorMessage (true); + return false; } - static bool HandleNpcAddFormationCommand(ChatHandler* handler, const char* args) + // Everything looks OK, create new pet + Pet* pet = player->CreateTamedPetFrom (creatureTarget); + if (!pet) { - if (!*args) - return false; + handler->PSendSysMessage (LANG_CREATURE_NON_TAMEABLE,cInfo->Entry); + handler->SetSentErrorMessage (true); + return false; + } - uint32 leaderGUID = (uint32) atoi((char*)args); - Creature *pCreature = handler->getSelectedCreature(); + // place pet before player + float x,y,z; + player->GetClosePoint (x,y,z,creatureTarget->GetObjectSize (),CONTACT_DISTANCE); + pet->Relocate (x,y,z,M_PI-player->GetOrientation ()); - if (!pCreature || !pCreature->GetDBTableGUIDLow()) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + // set pet to defensive mode by default (some classes can't control controlled pets in fact). + pet->SetReactState(REACT_DEFENSIVE); - uint32 lowguid = pCreature->GetDBTableGUIDLow(); - if (pCreature->GetFormation()) - { - handler->PSendSysMessage("Selected creature is already member of group %u", pCreature->GetFormation()->GetId()); - return false; - } + // calculate proper level + uint8 level = (creatureTarget->getLevel() < (player->getLevel() - 5)) ? (player->getLevel() - 5) : creatureTarget->getLevel(); - if (!lowguid) - return false; + // prepare visual effect for levelup + pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1); - Player *chr = handler->GetSession()->GetPlayer(); - FormationInfo *group_member; + // add to world + pet->GetMap()->Add(pet->ToCreature()); - group_member = new FormationInfo; - group_member->follow_angle = (pCreature->GetAngle(chr) - chr->GetOrientation()) * 180 / M_PI; - group_member->follow_dist = sqrtf(pow(chr->GetPositionX() - pCreature->GetPositionX(),int(2))+pow(chr->GetPositionY()-pCreature->GetPositionY(),int(2))); - group_member->leaderGUID = leaderGUID; - group_member->groupAI = 0; + // visual effect for levelup + pet->SetUInt32Value(UNIT_FIELD_LEVEL, level); - CreatureGroupMap[lowguid] = group_member; - pCreature->SearchFormation(); + // caster have pet now + player->SetMinion(pet, true); - WorldDatabase.PExecute("INSERT INTO creature_formations (leaderGUID, memberGUID, dist, angle, groupAI) VALUES ('%u','%u','%f', '%f', '%u')", - leaderGUID, lowguid, group_member->follow_dist, group_member->follow_angle, group_member->groupAI); + pet->SavePetToDB(PET_SAVE_AS_CURRENT); + player->PetSpellInitialize(); - handler->PSendSysMessage("Creature %u added to formation with leader %u", lowguid, leaderGUID); + return true; + } - return true; - } + //npc deathstate handling + static bool HandleNpcSetDeathStateCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - static bool HandleNpcSetLinkCommand(ChatHandler* handler, const char* args) + Creature* pCreature = handler->getSelectedCreature(); + if (!pCreature || pCreature->isPet()) { - if (!*args) - return false; + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } - uint32 linkguid = (uint32) atoi((char*)args); + if (strncmp(args, "on", 3) == 0) + pCreature->SetDeadByDefault(true); + else if (strncmp(args, "off", 4) == 0) + pCreature->SetDeadByDefault(false); + else + { + handler->SendSysMessage(LANG_USE_BOL); + handler->SetSentErrorMessage(true); + return false; + } - Creature* pCreature = handler->getSelectedCreature(); + pCreature->SaveToDB(); + pCreature->Respawn(); - if (!pCreature) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + return true; + } - if (!pCreature->GetDBTableGUIDLow()) - { - handler->PSendSysMessage("Selected creature %u isn't in creature table", pCreature->GetGUIDLow()); - handler->SetSentErrorMessage(true); - return false; - } + static bool HandleNpcAddFormationCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - if (!sObjectMgr.SetCreatureLinkedRespawn(pCreature->GetDBTableGUIDLow(), linkguid)) - { - handler->PSendSysMessage("Selected creature can't link with guid '%u'", linkguid); - handler->SetSentErrorMessage(true); - return false; - } + uint32 leaderGUID = (uint32) atoi((char*)args); + Creature *pCreature = handler->getSelectedCreature(); - handler->PSendSysMessage("LinkGUID '%u' added to creature with DBTableGUID: '%u'", linkguid, pCreature->GetDBTableGUIDLow()); - return true; + if (!pCreature || !pCreature->GetDBTableGUIDLow()) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; } - //TODO: NpcCommands that needs to be fixed : - static bool HandleNpcAddWeaponCommand(ChatHandler* /*handler*/, const char* /*args*/) + uint32 lowguid = pCreature->GetDBTableGUIDLow(); + if (pCreature->GetFormation()) { - /*if (!*args) + handler->PSendSysMessage("Selected creature is already member of group %u", pCreature->GetFormation()->GetId()); return false; + } - uint64 guid = handler->GetSession()->GetPlayer()->GetSelection(); - if (guid == 0) - { - handler->SendSysMessage(LANG_NO_SELECTION); - return true; - } + if (!lowguid) + return false; - Creature *pCreature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), guid); + Player *chr = handler->GetSession()->GetPlayer(); + FormationInfo *group_member; - if (!pCreature) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - return true; - } + group_member = new FormationInfo; + group_member->follow_angle = (pCreature->GetAngle(chr) - chr->GetOrientation()) * 180 / M_PI; + group_member->follow_dist = sqrtf(pow(chr->GetPositionX() - pCreature->GetPositionX(),int(2))+pow(chr->GetPositionY()-pCreature->GetPositionY(),int(2))); + group_member->leaderGUID = leaderGUID; + group_member->groupAI = 0; - char* pSlotID = strtok((char*)args, " "); - if (!pSlotID) - return false; + CreatureGroupMap[lowguid] = group_member; + pCreature->SearchFormation(); - char* pItemID = strtok(NULL, " "); - if (!pItemID) - return false; + WorldDatabase.PExecute("INSERT INTO creature_formations (leaderGUID, memberGUID, dist, angle, groupAI) VALUES ('%u','%u','%f', '%f', '%u')", + leaderGUID, lowguid, group_member->follow_dist, group_member->follow_angle, group_member->groupAI); - uint32 ItemID = atoi(pItemID); - uint32 SlotID = atoi(pSlotID); + handler->PSendSysMessage("Creature %u added to formation with leader %u", lowguid, leaderGUID); - ItemPrototype* tmpItem = sObjectMgr.GetItemPrototype(ItemID); + return true; + } - bool added = false; - if (tmpItem) - { - switch(SlotID) - { - case 1: - pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, ItemID); - added = true; - break; - case 2: - pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, ItemID); - added = true; - break; - case 3: - pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_02, ItemID); - added = true; - break; - default: - handler->PSendSysMessage(LANG_ITEM_SLOT_NOT_EXIST,SlotID); - added = false; - break; - } + static bool HandleNpcSetLinkCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - if (added) - handler->PSendSysMessage(LANG_ITEM_ADDED_TO_SLOT,ItemID,tmpItem->Name1,SlotID); - } - else - { - handler->PSendSysMessage(LANG_ITEM_NOT_FOUND,ItemID); - return true; - } - */ + uint32 linkguid = (uint32) atoi((char*)args); + + Creature* pCreature = handler->getSelectedCreature(); + + if (!pCreature) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } + + if (!pCreature->GetDBTableGUIDLow()) + { + handler->PSendSysMessage("Selected creature %u isn't in creature table", pCreature->GetGUIDLow()); + handler->SetSentErrorMessage(true); + return false; + } + + if (!sObjectMgr.SetCreatureLinkedRespawn(pCreature->GetDBTableGUIDLow(), linkguid)) + { + handler->PSendSysMessage("Selected creature can't link with guid '%u'", linkguid); + handler->SetSentErrorMessage(true); + return false; + } + + handler->PSendSysMessage("LinkGUID '%u' added to creature with DBTableGUID: '%u'", linkguid, pCreature->GetDBTableGUIDLow()); + return true; + } + + //TODO: NpcCommands that need to be fixed : + static bool HandleNpcAddWeaponCommand(ChatHandler* /*handler*/, const char* /*args*/) + { + /*if (!*args) + return false; + + uint64 guid = handler->GetSession()->GetPlayer()->GetSelection(); + if (guid == 0) + { + handler->SendSysMessage(LANG_NO_SELECTION); return true; } - static bool HandleNpcSetNameCommand(ChatHandler* /*handler*/, const char* /*args*/) + Creature *pCreature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), guid); + + if (!pCreature) { - /* Temp. disabled - if (!*args) - return false; + handler->SendSysMessage(LANG_SELECT_CREATURE); + return true; + } - if (strlen((char*)args)>75) - { - handler->PSendSysMessage(LANG_TOO_LONG_NAME, strlen((char*)args)-75); - return true; - } + char* pSlotID = strtok((char*)args, " "); + if (!pSlotID) + return false; - for (uint8 i = 0; i < strlen(args); ++i) - { - if (!isalpha(args[i]) && args[i] != ' ') - { - handler->SendSysMessage(LANG_CHARS_ONLY); - return false; - } - } + char* pItemID = strtok(NULL, " "); + if (!pItemID) + return false; - uint64 guid; - guid = handler->GetSession()->GetPlayer()->GetSelection(); - if (guid == 0) - { - handler->SendSysMessage(LANG_NO_SELECTION); - return true; - } + uint32 ItemID = atoi(pItemID); + uint32 SlotID = atoi(pSlotID); - Creature* pCreature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), guid); + ItemPrototype* tmpItem = sObjectMgr.GetItemPrototype(ItemID); - if (!pCreature) + bool added = false; + if (tmpItem) + { + switch(SlotID) + { + case 1: + pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, ItemID); + added = true; + break; + case 2: + pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, ItemID); + added = true; + break; + case 3: + pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_02, ItemID); + added = true; + break; + default: + handler->PSendSysMessage(LANG_ITEM_SLOT_NOT_EXIST,SlotID); + added = false; + break; + } + + if (added) + handler->PSendSysMessage(LANG_ITEM_ADDED_TO_SLOT,ItemID,tmpItem->Name1,SlotID); + } + else + { + handler->PSendSysMessage(LANG_ITEM_NOT_FOUND,ItemID); + return true; + } + */ + return true; + } + + static bool HandleNpcSetNameCommand(ChatHandler* /*handler*/, const char* /*args*/) + { + /* Temp. disabled + if (!*args) + return false; + + if (strlen((char*)args)>75) + { + handler->PSendSysMessage(LANG_TOO_LONG_NAME, strlen((char*)args)-75); + return true; + } + + for (uint8 i = 0; i < strlen(args); ++i) + { + if (!isalpha(args[i]) && args[i] != ' ') { - handler->SendSysMessage(LANG_SELECT_CREATURE); - return true; + handler->SendSysMessage(LANG_CHARS_ONLY); + return false; } + } - pCreature->SetName(args); - uint32 idname = sObjectMgr.AddCreatureTemplate(pCreature->GetName()); - pCreature->SetUInt32Value(OBJECT_FIELD_ENTRY, idname); + uint64 guid; + guid = handler->GetSession()->GetPlayer()->GetSelection(); + if (guid == 0) + { + handler->SendSysMessage(LANG_NO_SELECTION); + return true; + } - pCreature->SaveToDB(); - */ + Creature* pCreature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), guid); + if (!pCreature) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); return true; } - static bool HandleNpcSetSubNameCommand(ChatHandler* /*handler*/, const char* /*args*/) - { - /* Temp. disabled + pCreature->SetName(args); + uint32 idname = sObjectMgr.AddCreatureTemplate(pCreature->GetName()); + pCreature->SetUInt32Value(OBJECT_FIELD_ENTRY, idname); - if (!*args) - args = ""; + pCreature->SaveToDB(); + */ - if (strlen((char*)args)>75) - { + return true; + } - handler->PSendSysMessage(LANG_TOO_LONG_SUBNAME, strlen((char*)args)-75); - return true; - } + static bool HandleNpcSetSubNameCommand(ChatHandler* /*handler*/, const char* /*args*/) + { + /* Temp. disabled - for (uint8 i = 0; i < strlen(args); i++) - { - if (!isalpha(args[i]) && args[i] != ' ') - { - handler->SendSysMessage(LANG_CHARS_ONLY); - return false; - } - } - uint64 guid; - guid = handler->GetSession()->GetPlayer()->GetSelection(); - if (guid == 0) - { - handler->SendSysMessage(LANG_NO_SELECTION); - return true; - } + if (!*args) + args = ""; - Creature* pCreature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), guid); + if (strlen((char*)args)>75) + { + handler->PSendSysMessage(LANG_TOO_LONG_SUBNAME, strlen((char*)args)-75); + return true; + } - if (!pCreature) + for (uint8 i = 0; i < strlen(args); i++) + { + if (!isalpha(args[i]) && args[i] != ' ') { - handler->SendSysMessage(LANG_SELECT_CREATURE); - return true; + handler->SendSysMessage(LANG_CHARS_ONLY); + return false; } + } + uint64 guid; + guid = handler->GetSession()->GetPlayer()->GetSelection(); + if (guid == 0) + { + handler->SendSysMessage(LANG_NO_SELECTION); + return true; + } - uint32 idname = sObjectMgr.AddCreatureSubName(pCreature->GetName(),args,pCreature->GetUInt32Value(UNIT_FIELD_DISPLAYID)); - pCreature->SetUInt32Value(OBJECT_FIELD_ENTRY, idname); + Creature* pCreature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), guid); - pCreature->SaveToDB(); - */ + if (!pCreature) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); return true; } - //---------------------------------------------------------- + + uint32 idname = sObjectMgr.AddCreatureSubName(pCreature->GetName(),args,pCreature->GetUInt32Value(UNIT_FIELD_DISPLAYID)); + pCreature->SetUInt32Value(OBJECT_FIELD_ENTRY, idname); + + pCreature->SaveToDB(); + */ + return true; + } }; void AddSC_npc_commandscript() diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp index 07dbaee0855..9cff431ef3e 100644 --- a/src/server/scripts/Commands/cs_quest.cpp +++ b/src/server/scripts/Commands/cs_quest.cpp @@ -28,230 +28,229 @@ EndScriptData */ class quest_commandscript : public CommandScript { - public: - quest_commandscript() : CommandScript("quest_commandscript") { } +public: + quest_commandscript() : CommandScript("quest_commandscript") { } - ChatCommand* GetCommands() const - { - static ChatCommand questCommandTable[] = - { - { "add", SEC_ADMINISTRATOR, false, &HandleQuestAdd, "", NULL }, - { "complete", SEC_ADMINISTRATOR, false, &HandleQuestComplete, "", NULL }, - { "remove", SEC_ADMINISTRATOR, false, &HandleQuestRemove, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand commandTable[] = - { - { "quest", SEC_ADMINISTRATOR, false, NULL, "", questCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - return commandTable; - } - -static bool HandleQuestAdd(ChatHandler* handler, const char* args) -{ - Player* player = handler->getSelectedPlayer(); - if (!player) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } - - // .addquest #entry' - // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args,"Hquest"); - if (!cId) - return false; - - uint32 entry = atol(cId); - - Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); - - if (!pQuest) + ChatCommand* GetCommands() const { - handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND,entry); - handler->SetSentErrorMessage(true); - return false; + static ChatCommand questCommandTable[] = + { + { "add", SEC_ADMINISTRATOR, false, &HandleQuestAdd, "", NULL }, + { "complete", SEC_ADMINISTRATOR, false, &HandleQuestComplete, "", NULL }, + { "remove", SEC_ADMINISTRATOR, false, &HandleQuestRemove, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "quest", SEC_ADMINISTRATOR, false, NULL, "", questCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; } - // check item starting quest (it can work incorrectly if added without item in inventory) - for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) + static bool HandleQuestAdd(ChatHandler* handler, const char* args) { - ItemPrototype const *pProto = sItemStorage.LookupEntry<ItemPrototype>(id); - if (!pProto) - continue; - - if (pProto->StartQuest == entry) + Player* player = handler->getSelectedPlayer(); + if (!player) { - handler->PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, pProto->ItemId); + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); handler->SetSentErrorMessage(true); return false; } - } - // ok, normal (creature/GO starting) quest - if (player->CanAddQuest(pQuest, true)) - { - player->AddQuest(pQuest, NULL); + // .addquest #entry' + // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hquest"); + if (!cId) + return false; - if (player->CanCompleteQuest(entry)) - player->CompleteQuest(entry); - } + uint32 entry = atol(cId); - return true; -} + Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); -static bool HandleQuestRemove(ChatHandler* handler, const char* args) -{ - Player* player = handler->getSelectedPlayer(); - if (!player) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + if (!pQuest) + { + handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND,entry); + handler->SetSentErrorMessage(true); + return false; + } - // .removequest #entry' - // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r - char* cId = handler->extractKeyFromLink((char*)args,"Hquest"); - if (!cId) - 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; - uint32 entry = atol(cId); + if (pProto->StartQuest == entry) + { + handler->PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, pProto->ItemId); + handler->SetSentErrorMessage(true); + return false; + } + } - Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); + // ok, normal (creature/GO starting) quest + if (player->CanAddQuest(pQuest, true)) + { + player->AddQuest(pQuest, NULL); - if (!pQuest) - { - handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); - handler->SetSentErrorMessage(true); - return false; + if (player->CanCompleteQuest(entry)) + player->CompleteQuest(entry); + } + + return true; } - // remove all quest entries for 'entry' from quest log - for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot) + static bool HandleQuestRemove(ChatHandler* handler, const char* args) { - uint32 quest = player->GetQuestSlotQuestId(slot); - if (quest == entry) + Player* player = handler->getSelectedPlayer(); + if (!player) { - player->SetQuestSlot(slot,0); - - // we ignore unequippable quest items in this case, its' still be equipped - player->TakeQuestSourceItem(quest, false); + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; } - } - // set quest status to not started (will updated in DB at next save) - player->SetQuestStatus(entry, QUEST_STATUS_NONE); + // .removequest #entry' + // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hquest"); + if (!cId) + return false; - // reset rewarded for restart repeatable quest - player->getQuestStatusMap()[entry].m_rewarded = false; + uint32 entry = atol(cId); - handler->SendSysMessage(LANG_COMMAND_QUEST_REMOVED); - return true; -} + Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); -static bool HandleQuestComplete(ChatHandler* handler, const char* args) -{ - Player* player = handler->getSelectedPlayer(); - if (!player) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + if (!pQuest) + { + handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); + handler->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 = handler->extractKeyFromLink((char*)args,"Hquest"); - if (!cId) - 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); - uint32 entry = atol(cId); + // we ignore unequippable quest items in this case, its' still be equipped + player->TakeQuestSourceItem(quest, false); + } + } - Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); + // set quest status to not started (will updated in DB at next save) + player->SetQuestStatus(entry, QUEST_STATUS_NONE); - // If player doesn't have the quest - if (!pQuest || player->GetQuestStatus(entry) == QUEST_STATUS_NONE) - { - handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); - handler->SetSentErrorMessage(true); - return false; + // reset rewarded for restart repeatable quest + player->getQuestStatusMap()[entry].m_rewarded = false; + + handler->SendSysMessage(LANG_COMMAND_QUEST_REMOVED); + return true; } - // Add quest items for quests that require items - for (uint8 x = 0; x < QUEST_ITEM_OBJECTIVES_COUNT; ++x) + static bool HandleQuestComplete(ChatHandler* handler, const char* args) { - uint32 id = pQuest->ReqItemId[x]; - uint32 count = pQuest->ReqItemCount[x]; - if (!id || !count) - continue; + Player* player = handler->getSelectedPlayer(); + if (!player) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->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 = handler->extractKeyFromLink((char*)args,"Hquest"); + if (!cId) + return false; + + uint32 entry = atol(cId); - uint32 curItemCount = player->GetItemCount(id,true); + Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); - ItemPosCountVec dest; - uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, id, count-curItemCount); - if (msg == EQUIP_ERR_OK) + // If player doesn't have the quest + if (!pQuest || player->GetQuestStatus(entry) == QUEST_STATUS_NONE) { - Item* item = player->StoreNewItem(dest, id, true); - player->SendNewItem(item,count-curItemCount,true,false); + handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); + handler->SetSentErrorMessage(true); + return 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]) + // Add quest items for quests that require items + for (uint8 x = 0; x < QUEST_ITEM_OBJECTIVES_COUNT; ++x) { - for (uint16 z = 0; z < creaturecount; ++z) - player->CastedCreatureOrGO(creature,0,spell_id); + 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); + } } - else if (creature > 0) + + // 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) { - if (CreatureInfo const* cInfo = sObjectMgr.GetCreatureTemplate(creature)) + 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->KilledMonster(cInfo,0); + 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); + } } - else if (creature < 0) + + // If the quest requires reputation to complete + if (uint32 repFaction = pQuest->GetRepObjectiveFaction()) { - for (uint16 z = 0; z < creaturecount; ++z) - player->CastedCreatureOrGO(creature,0,0); + 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 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 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; -} + // If the quest requires money + int32 ReqOrRewMoney = pQuest->GetRewOrReqMoney(); + if (ReqOrRewMoney < 0) + player->ModifyMoney(-ReqOrRewMoney); + player->CompleteQuest(entry); + return true; + } }; void AddSC_quest_commandscript() diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index 85e2f5a0965..cf60f49cea9 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -39,1261 +39,1260 @@ EndScriptData */ class reload_commandscript : public CommandScript { - public: - reload_commandscript() : CommandScript("reload_commandscript") { } +public: + reload_commandscript() : CommandScript("reload_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const + { + static ChatCommand reloadAllCommandTable[] = { - static ChatCommand reloadAllCommandTable[] = - { - { "achievement",SEC_ADMINISTRATOR, true, &HandleReloadAllAchievementCommand,"", NULL }, - { "area", SEC_ADMINISTRATOR, true, &HandleReloadAllAreaCommand, "", NULL }, - { "eventai", SEC_ADMINISTRATOR, true, &HandleReloadAllEventAICommand, "", NULL }, - { "gossips", SEC_ADMINISTRATOR, true, &HandleReloadAllGossipsCommand, "", NULL }, - { "item", SEC_ADMINISTRATOR, true, &HandleReloadAllItemCommand, "", NULL }, - { "locales", SEC_ADMINISTRATOR, true, &HandleReloadAllLocalesCommand, "", NULL }, - { "loot", SEC_ADMINISTRATOR, true, &HandleReloadAllLootCommand, "", NULL }, - { "npc", SEC_ADMINISTRATOR, true, &HandleReloadAllNpcCommand, "", NULL }, - { "quest", SEC_ADMINISTRATOR, true, &HandleReloadAllQuestCommand, "", NULL }, - { "scripts", SEC_ADMINISTRATOR, true, &HandleReloadAllScriptsCommand, "", NULL }, - { "spell", SEC_ADMINISTRATOR, true, &HandleReloadAllSpellCommand, "", NULL }, - { "", SEC_ADMINISTRATOR, true, &HandleReloadAllCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand reloadCommandTable[] = - { - { "auctions", SEC_ADMINISTRATOR, true, &HandleReloadAuctionsCommand, "", NULL }, - { "access_requirement", SEC_ADMINISTRATOR, true, &HandleReloadAccessRequirementCommand, "", NULL }, - { "achievement_criteria_data", SEC_ADMINISTRATOR, true, &HandleReloadAchievementCriteriaDataCommand, "", NULL }, - { "achievement_reward", SEC_ADMINISTRATOR, true, &HandleReloadAchievementRewardCommand, "", NULL }, - { "all", SEC_ADMINISTRATOR, true, NULL, "", reloadAllCommandTable }, - { "areatrigger_involvedrelation", SEC_ADMINISTRATOR, true, &HandleReloadQuestAreaTriggersCommand, "", NULL }, - { "areatrigger_tavern", SEC_ADMINISTRATOR, true, &HandleReloadAreaTriggerTavernCommand, "", NULL }, - { "areatrigger_teleport", SEC_ADMINISTRATOR, true, &HandleReloadAreaTriggerTeleportCommand, "", NULL }, - { "autobroadcast", SEC_ADMINISTRATOR, true, &HandleReloadAutobroadcastCommand, "", NULL }, - { "command", SEC_ADMINISTRATOR, true, &HandleReloadCommandCommand, "", NULL }, - { "conditions", SEC_ADMINISTRATOR, true, &HandleReloadConditions, "", NULL }, - { "config", SEC_ADMINISTRATOR, true, &HandleReloadConfigCommand, "", NULL }, - { "creature_text", SEC_ADMINISTRATOR, true, &HandleReloadCreatureText, "", NULL }, - { "creature_ai_scripts", SEC_ADMINISTRATOR, true, &HandleReloadEventAIScriptsCommand, "", NULL }, - { "creature_ai_summons", SEC_ADMINISTRATOR, true, &HandleReloadEventAISummonsCommand, "", NULL }, - { "creature_ai_texts", SEC_ADMINISTRATOR, true, &HandleReloadEventAITextsCommand, "", NULL }, - { "creature_involvedrelation", SEC_ADMINISTRATOR, true, &HandleReloadCreatureQuestInvRelationsCommand, "",NULL }, - { "creature_linked_respawn", SEC_GAMEMASTER, true, &HandleReloadCreatureLinkedRespawnCommand, "", NULL }, - { "creature_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesCreatureCommand, "", NULL }, - { "creature_onkill_reputation", SEC_ADMINISTRATOR, true, &HandleReloadOnKillReputationCommand, "", NULL }, - { "creature_questrelation", SEC_ADMINISTRATOR, true, &HandleReloadCreatureQuestRelationsCommand, "", NULL }, - { "creature_template", SEC_ADMINISTRATOR, true, &HandleReloadCreatureTemplateCommand, "", NULL }, - //{ "db_script_string", SEC_ADMINISTRATOR, true, &HandleReloadDbScriptStringCommand, "", NULL }, - { "disables", SEC_ADMINISTRATOR, true, &HandleReloadDisablesCommand, "", NULL }, - { "disenchant_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesDisenchantCommand, "", NULL }, - { "event_scripts", SEC_ADMINISTRATOR, true, &HandleReloadEventScriptsCommand, "", NULL }, - { "fishing_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesFishingCommand, "", NULL }, - { "game_graveyard_zone", SEC_ADMINISTRATOR, true, &HandleReloadGameGraveyardZoneCommand, "", NULL }, - { "game_tele", SEC_ADMINISTRATOR, true, &HandleReloadGameTeleCommand, "", NULL }, - { "gameobject_involvedrelation", SEC_ADMINISTRATOR, true, &HandleReloadGOQuestInvRelationsCommand, "", NULL }, - { "gameobject_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesGameobjectCommand, "", NULL }, - { "gameobject_questrelation", SEC_ADMINISTRATOR, true, &HandleReloadGOQuestRelationsCommand, "", NULL }, - { "gameobject_scripts", SEC_ADMINISTRATOR, true, &HandleReloadGameObjectScriptsCommand, "", NULL }, - { "gm_tickets", SEC_ADMINISTRATOR, true, &HandleReloadGMTicketsCommand, "", NULL }, - { "gossip_menu", SEC_ADMINISTRATOR, true, &HandleReloadGossipMenuCommand, "", NULL }, - { "gossip_menu_option", SEC_ADMINISTRATOR, true, &HandleReloadGossipMenuOptionCommand, "", NULL }, - { "gossip_scripts", SEC_ADMINISTRATOR, true, &HandleReloadGossipScriptsCommand, "", NULL }, - { "item_enchantment_template", SEC_ADMINISTRATOR, true, &HandleReloadItemEnchantementsCommand, "", NULL }, - { "item_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesItemCommand, "", NULL }, - { "item_set_names", SEC_ADMINISTRATOR, true, &HandleReloadItemSetNamesCommand, "", NULL }, - { "lfg_dungeon_encounters", SEC_ADMINISTRATOR, true, &HandleReloadLfgEncountersCommand, "", NULL }, - { "lfg_dungeon_rewards", SEC_ADMINISTRATOR, true, &HandleReloadLfgRewardsCommand, "", NULL }, - { "locales_achievement_reward", SEC_ADMINISTRATOR, true, &HandleReloadLocalesAchievementRewardCommand, "", NULL }, - { "locales_creature", SEC_ADMINISTRATOR, true, &HandleReloadLocalesCreatureCommand, "", NULL }, - { "locales_gameobject", SEC_ADMINISTRATOR, true, &HandleReloadLocalesGameobjectCommand, "", NULL }, - { "locales_gossip_menu_option", SEC_ADMINISTRATOR, true, &HandleReloadLocalesGossipMenuOptionCommand, "", NULL }, - { "locales_item", SEC_ADMINISTRATOR, true, &HandleReloadLocalesItemCommand, "", NULL }, - { "locales_item_set_name", SEC_ADMINISTRATOR, true, &HandleReloadLocalesItemSetNameCommand, "", NULL }, - { "locales_npc_text", SEC_ADMINISTRATOR, true, &HandleReloadLocalesNpcTextCommand, "", NULL }, - { "locales_page_text", SEC_ADMINISTRATOR, true, &HandleReloadLocalesPageTextCommand, "", NULL }, - { "locales_points_of_interest", SEC_ADMINISTRATOR, true, &HandleReloadLocalesPointsOfInterestCommand, "", NULL }, - { "locales_quest", SEC_ADMINISTRATOR, true, &HandleReloadLocalesQuestCommand, "", NULL }, - { "mail_level_reward", SEC_ADMINISTRATOR, true, &HandleReloadMailLevelRewardCommand, "", NULL }, - { "mail_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesMailCommand, "", NULL }, - { "milling_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesMillingCommand, "", NULL }, - { "npc_gossip", SEC_ADMINISTRATOR, true, &HandleReloadNpcGossipCommand, "", NULL }, - { "npc_spellclick_spells", SEC_ADMINISTRATOR, true, &HandleReloadSpellClickSpellsCommand, "",NULL}, - { "npc_trainer", SEC_ADMINISTRATOR, true, &HandleReloadNpcTrainerCommand, "", NULL }, - { "npc_vendor", SEC_ADMINISTRATOR, true, &HandleReloadNpcVendorCommand, "", NULL }, - { "page_text", SEC_ADMINISTRATOR, true, &HandleReloadPageTextsCommand, "", NULL }, - { "pickpocketing_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesPickpocketingCommand, "",NULL}, - { "points_of_interest", SEC_ADMINISTRATOR, true, &HandleReloadPointsOfInterestCommand, "", NULL }, - { "prospecting_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesProspectingCommand, "", NULL }, - { "quest_end_scripts", SEC_ADMINISTRATOR, true, &HandleReloadQuestEndScriptsCommand, "", NULL }, - { "quest_poi", SEC_ADMINISTRATOR, true, &HandleReloadQuestPOICommand, "", NULL }, - { "quest_start_scripts", SEC_ADMINISTRATOR, true, &HandleReloadQuestStartScriptsCommand, "", NULL }, - { "quest_template", SEC_ADMINISTRATOR, true, &HandleReloadQuestTemplateCommand, "", NULL }, - { "reference_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesReferenceCommand, "", NULL }, - { "reserved_name", SEC_ADMINISTRATOR, true, &HandleReloadReservedNameCommand, "", NULL }, - { "reputation_reward_rate", SEC_ADMINISTRATOR, true, &HandleReloadReputationRewardRateCommand, "", NULL }, - { "reputation_spillover_template",SEC_ADMINISTRATOR, true, &HandleReloadReputationRewardRateCommand, "", NULL }, - { "skill_discovery_template", SEC_ADMINISTRATOR, true, &HandleReloadSkillDiscoveryTemplateCommand, "", NULL }, - { "skill_extra_item_template", SEC_ADMINISTRATOR, true, &HandleReloadSkillExtraItemTemplateCommand, "", NULL }, - { "skill_fishing_base_level", SEC_ADMINISTRATOR, true, &HandleReloadSkillFishingBaseLevelCommand, "", NULL }, - { "skinning_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesSkinningCommand, "", NULL }, - { "smart_scripts", SEC_ADMINISTRATOR, true, &HandleReloadSmartScripts, "", NULL }, - { "spell_required", SEC_ADMINISTRATOR, true, &HandleReloadSpellRequiredCommand, "", NULL }, - { "spell_area", SEC_ADMINISTRATOR, true, &HandleReloadSpellAreaCommand, "", NULL }, - { "spell_bonus_data", SEC_ADMINISTRATOR, true, &HandleReloadSpellBonusesCommand, "", NULL }, - { "spell_group", SEC_ADMINISTRATOR, true, &HandleReloadSpellGroupsCommand, "", NULL }, - { "spell_learn_spell", SEC_ADMINISTRATOR, true, &HandleReloadSpellLearnSpellCommand, "", NULL }, - { "spell_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesSpellCommand, "", NULL }, - { "spell_linked_spell", SEC_ADMINISTRATOR, true, &HandleReloadSpellLinkedSpellCommand, "", NULL }, - { "spell_pet_auras", SEC_ADMINISTRATOR, true, &HandleReloadSpellPetAurasCommand, "", NULL }, - { "spell_proc_event", SEC_ADMINISTRATOR, true, &HandleReloadSpellProcEventCommand, "", NULL }, - { "spell_scripts", SEC_ADMINISTRATOR, true, &HandleReloadSpellScriptsCommand, "", NULL }, - { "spell_target_position", SEC_ADMINISTRATOR, true, &HandleReloadSpellTargetPositionCommand, "", NULL }, - { "spell_threats", SEC_ADMINISTRATOR, true, &HandleReloadSpellThreatsCommand, "", NULL }, - { "spell_group_stack_rules", SEC_ADMINISTRATOR, true, &HandleReloadSpellGroupStackRulesCommand, "", NULL }, - { "trinity_string", SEC_ADMINISTRATOR, true, &HandleReloadTrinityStringCommand, "", NULL }, - { "waypoint_scripts", SEC_ADMINISTRATOR, true, &HandleReloadWpScriptsCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand commandTable[] = - { - { "reload", SEC_ADMINISTRATOR, true, NULL, "", reloadCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - return commandTable; - } - -//reload commands -static bool HandleReloadGMTicketsCommand(ChatHandler* handler, const char* /*args*/) -{ - sTicketMgr.LoadGMTickets(); - return true; -} - -static bool HandleReloadAllCommand(ChatHandler* handler, const char* /*args*/) -{ - HandleReloadSkillFishingBaseLevelCommand(handler,""); - - HandleReloadAllAchievementCommand(handler,""); - HandleReloadAllAreaCommand(handler,""); - HandleReloadAllEventAICommand(handler,""); - HandleReloadAllLootCommand(handler,""); - HandleReloadAllNpcCommand(handler,""); - HandleReloadAllQuestCommand(handler,""); - HandleReloadAllSpellCommand(handler,""); - HandleReloadAllItemCommand(handler,""); - HandleReloadAllGossipsCommand(handler,""); - HandleReloadAllLocalesCommand(handler,""); - - HandleReloadAccessRequirementCommand(handler,""); - HandleReloadMailLevelRewardCommand(handler,""); - HandleReloadCommandCommand(handler,""); - HandleReloadReservedNameCommand(handler,""); - HandleReloadTrinityStringCommand(handler,""); - HandleReloadGameTeleCommand(handler,""); - - HandleReloadAutobroadcastCommand(handler,""); - return true; -} + { "achievement",SEC_ADMINISTRATOR, true, &HandleReloadAllAchievementCommand,"", NULL }, + { "area", SEC_ADMINISTRATOR, true, &HandleReloadAllAreaCommand, "", NULL }, + { "eventai", SEC_ADMINISTRATOR, true, &HandleReloadAllEventAICommand, "", NULL }, + { "gossips", SEC_ADMINISTRATOR, true, &HandleReloadAllGossipsCommand, "", NULL }, + { "item", SEC_ADMINISTRATOR, true, &HandleReloadAllItemCommand, "", NULL }, + { "locales", SEC_ADMINISTRATOR, true, &HandleReloadAllLocalesCommand, "", NULL }, + { "loot", SEC_ADMINISTRATOR, true, &HandleReloadAllLootCommand, "", NULL }, + { "npc", SEC_ADMINISTRATOR, true, &HandleReloadAllNpcCommand, "", NULL }, + { "quest", SEC_ADMINISTRATOR, true, &HandleReloadAllQuestCommand, "", NULL }, + { "scripts", SEC_ADMINISTRATOR, true, &HandleReloadAllScriptsCommand, "", NULL }, + { "spell", SEC_ADMINISTRATOR, true, &HandleReloadAllSpellCommand, "", NULL }, + { "", SEC_ADMINISTRATOR, true, &HandleReloadAllCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand reloadCommandTable[] = + { + { "auctions", SEC_ADMINISTRATOR, true, &HandleReloadAuctionsCommand, "", NULL }, + { "access_requirement", SEC_ADMINISTRATOR, true, &HandleReloadAccessRequirementCommand, "", NULL }, + { "achievement_criteria_data", SEC_ADMINISTRATOR, true, &HandleReloadAchievementCriteriaDataCommand, "", NULL }, + { "achievement_reward", SEC_ADMINISTRATOR, true, &HandleReloadAchievementRewardCommand, "", NULL }, + { "all", SEC_ADMINISTRATOR, true, NULL, "", reloadAllCommandTable }, + { "areatrigger_involvedrelation", SEC_ADMINISTRATOR, true, &HandleReloadQuestAreaTriggersCommand, "", NULL }, + { "areatrigger_tavern", SEC_ADMINISTRATOR, true, &HandleReloadAreaTriggerTavernCommand, "", NULL }, + { "areatrigger_teleport", SEC_ADMINISTRATOR, true, &HandleReloadAreaTriggerTeleportCommand, "", NULL }, + { "autobroadcast", SEC_ADMINISTRATOR, true, &HandleReloadAutobroadcastCommand, "", NULL }, + { "command", SEC_ADMINISTRATOR, true, &HandleReloadCommandCommand, "", NULL }, + { "conditions", SEC_ADMINISTRATOR, true, &HandleReloadConditions, "", NULL }, + { "config", SEC_ADMINISTRATOR, true, &HandleReloadConfigCommand, "", NULL }, + { "creature_text", SEC_ADMINISTRATOR, true, &HandleReloadCreatureText, "", NULL }, + { "creature_ai_scripts", SEC_ADMINISTRATOR, true, &HandleReloadEventAIScriptsCommand, "", NULL }, + { "creature_ai_summons", SEC_ADMINISTRATOR, true, &HandleReloadEventAISummonsCommand, "", NULL }, + { "creature_ai_texts", SEC_ADMINISTRATOR, true, &HandleReloadEventAITextsCommand, "", NULL }, + { "creature_involvedrelation", SEC_ADMINISTRATOR, true, &HandleReloadCreatureQuestInvRelationsCommand, "",NULL }, + { "creature_linked_respawn", SEC_GAMEMASTER, true, &HandleReloadCreatureLinkedRespawnCommand, "", NULL }, + { "creature_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesCreatureCommand, "", NULL }, + { "creature_onkill_reputation", SEC_ADMINISTRATOR, true, &HandleReloadOnKillReputationCommand, "", NULL }, + { "creature_questrelation", SEC_ADMINISTRATOR, true, &HandleReloadCreatureQuestRelationsCommand, "", NULL }, + { "creature_template", SEC_ADMINISTRATOR, true, &HandleReloadCreatureTemplateCommand, "", NULL }, + //{ "db_script_string", SEC_ADMINISTRATOR, true, &HandleReloadDbScriptStringCommand, "", NULL }, + { "disables", SEC_ADMINISTRATOR, true, &HandleReloadDisablesCommand, "", NULL }, + { "disenchant_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesDisenchantCommand, "", NULL }, + { "event_scripts", SEC_ADMINISTRATOR, true, &HandleReloadEventScriptsCommand, "", NULL }, + { "fishing_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesFishingCommand, "", NULL }, + { "game_graveyard_zone", SEC_ADMINISTRATOR, true, &HandleReloadGameGraveyardZoneCommand, "", NULL }, + { "game_tele", SEC_ADMINISTRATOR, true, &HandleReloadGameTeleCommand, "", NULL }, + { "gameobject_involvedrelation", SEC_ADMINISTRATOR, true, &HandleReloadGOQuestInvRelationsCommand, "", NULL }, + { "gameobject_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesGameobjectCommand, "", NULL }, + { "gameobject_questrelation", SEC_ADMINISTRATOR, true, &HandleReloadGOQuestRelationsCommand, "", NULL }, + { "gameobject_scripts", SEC_ADMINISTRATOR, true, &HandleReloadGameObjectScriptsCommand, "", NULL }, + { "gm_tickets", SEC_ADMINISTRATOR, true, &HandleReloadGMTicketsCommand, "", NULL }, + { "gossip_menu", SEC_ADMINISTRATOR, true, &HandleReloadGossipMenuCommand, "", NULL }, + { "gossip_menu_option", SEC_ADMINISTRATOR, true, &HandleReloadGossipMenuOptionCommand, "", NULL }, + { "gossip_scripts", SEC_ADMINISTRATOR, true, &HandleReloadGossipScriptsCommand, "", NULL }, + { "item_enchantment_template", SEC_ADMINISTRATOR, true, &HandleReloadItemEnchantementsCommand, "", NULL }, + { "item_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesItemCommand, "", NULL }, + { "item_set_names", SEC_ADMINISTRATOR, true, &HandleReloadItemSetNamesCommand, "", NULL }, + { "lfg_dungeon_encounters", SEC_ADMINISTRATOR, true, &HandleReloadLfgEncountersCommand, "", NULL }, + { "lfg_dungeon_rewards", SEC_ADMINISTRATOR, true, &HandleReloadLfgRewardsCommand, "", NULL }, + { "locales_achievement_reward", SEC_ADMINISTRATOR, true, &HandleReloadLocalesAchievementRewardCommand, "", NULL }, + { "locales_creature", SEC_ADMINISTRATOR, true, &HandleReloadLocalesCreatureCommand, "", NULL }, + { "locales_gameobject", SEC_ADMINISTRATOR, true, &HandleReloadLocalesGameobjectCommand, "", NULL }, + { "locales_gossip_menu_option", SEC_ADMINISTRATOR, true, &HandleReloadLocalesGossipMenuOptionCommand, "", NULL }, + { "locales_item", SEC_ADMINISTRATOR, true, &HandleReloadLocalesItemCommand, "", NULL }, + { "locales_item_set_name", SEC_ADMINISTRATOR, true, &HandleReloadLocalesItemSetNameCommand, "", NULL }, + { "locales_npc_text", SEC_ADMINISTRATOR, true, &HandleReloadLocalesNpcTextCommand, "", NULL }, + { "locales_page_text", SEC_ADMINISTRATOR, true, &HandleReloadLocalesPageTextCommand, "", NULL }, + { "locales_points_of_interest", SEC_ADMINISTRATOR, true, &HandleReloadLocalesPointsOfInterestCommand, "", NULL }, + { "locales_quest", SEC_ADMINISTRATOR, true, &HandleReloadLocalesQuestCommand, "", NULL }, + { "mail_level_reward", SEC_ADMINISTRATOR, true, &HandleReloadMailLevelRewardCommand, "", NULL }, + { "mail_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesMailCommand, "", NULL }, + { "milling_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesMillingCommand, "", NULL }, + { "npc_gossip", SEC_ADMINISTRATOR, true, &HandleReloadNpcGossipCommand, "", NULL }, + { "npc_spellclick_spells", SEC_ADMINISTRATOR, true, &HandleReloadSpellClickSpellsCommand, "",NULL}, + { "npc_trainer", SEC_ADMINISTRATOR, true, &HandleReloadNpcTrainerCommand, "", NULL }, + { "npc_vendor", SEC_ADMINISTRATOR, true, &HandleReloadNpcVendorCommand, "", NULL }, + { "page_text", SEC_ADMINISTRATOR, true, &HandleReloadPageTextsCommand, "", NULL }, + { "pickpocketing_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesPickpocketingCommand, "",NULL}, + { "points_of_interest", SEC_ADMINISTRATOR, true, &HandleReloadPointsOfInterestCommand, "", NULL }, + { "prospecting_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesProspectingCommand, "", NULL }, + { "quest_end_scripts", SEC_ADMINISTRATOR, true, &HandleReloadQuestEndScriptsCommand, "", NULL }, + { "quest_poi", SEC_ADMINISTRATOR, true, &HandleReloadQuestPOICommand, "", NULL }, + { "quest_start_scripts", SEC_ADMINISTRATOR, true, &HandleReloadQuestStartScriptsCommand, "", NULL }, + { "quest_template", SEC_ADMINISTRATOR, true, &HandleReloadQuestTemplateCommand, "", NULL }, + { "reference_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesReferenceCommand, "", NULL }, + { "reserved_name", SEC_ADMINISTRATOR, true, &HandleReloadReservedNameCommand, "", NULL }, + { "reputation_reward_rate", SEC_ADMINISTRATOR, true, &HandleReloadReputationRewardRateCommand, "", NULL }, + { "reputation_spillover_template",SEC_ADMINISTRATOR, true, &HandleReloadReputationRewardRateCommand, "", NULL }, + { "skill_discovery_template", SEC_ADMINISTRATOR, true, &HandleReloadSkillDiscoveryTemplateCommand, "", NULL }, + { "skill_extra_item_template", SEC_ADMINISTRATOR, true, &HandleReloadSkillExtraItemTemplateCommand, "", NULL }, + { "skill_fishing_base_level", SEC_ADMINISTRATOR, true, &HandleReloadSkillFishingBaseLevelCommand, "", NULL }, + { "skinning_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesSkinningCommand, "", NULL }, + { "smart_scripts", SEC_ADMINISTRATOR, true, &HandleReloadSmartScripts, "", NULL }, + { "spell_required", SEC_ADMINISTRATOR, true, &HandleReloadSpellRequiredCommand, "", NULL }, + { "spell_area", SEC_ADMINISTRATOR, true, &HandleReloadSpellAreaCommand, "", NULL }, + { "spell_bonus_data", SEC_ADMINISTRATOR, true, &HandleReloadSpellBonusesCommand, "", NULL }, + { "spell_group", SEC_ADMINISTRATOR, true, &HandleReloadSpellGroupsCommand, "", NULL }, + { "spell_learn_spell", SEC_ADMINISTRATOR, true, &HandleReloadSpellLearnSpellCommand, "", NULL }, + { "spell_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesSpellCommand, "", NULL }, + { "spell_linked_spell", SEC_ADMINISTRATOR, true, &HandleReloadSpellLinkedSpellCommand, "", NULL }, + { "spell_pet_auras", SEC_ADMINISTRATOR, true, &HandleReloadSpellPetAurasCommand, "", NULL }, + { "spell_proc_event", SEC_ADMINISTRATOR, true, &HandleReloadSpellProcEventCommand, "", NULL }, + { "spell_scripts", SEC_ADMINISTRATOR, true, &HandleReloadSpellScriptsCommand, "", NULL }, + { "spell_target_position", SEC_ADMINISTRATOR, true, &HandleReloadSpellTargetPositionCommand, "", NULL }, + { "spell_threats", SEC_ADMINISTRATOR, true, &HandleReloadSpellThreatsCommand, "", NULL }, + { "spell_group_stack_rules", SEC_ADMINISTRATOR, true, &HandleReloadSpellGroupStackRulesCommand, "", NULL }, + { "trinity_string", SEC_ADMINISTRATOR, true, &HandleReloadTrinityStringCommand, "", NULL }, + { "waypoint_scripts", SEC_ADMINISTRATOR, true, &HandleReloadWpScriptsCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "reload", SEC_ADMINISTRATOR, true, NULL, "", reloadCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } -static bool HandleReloadAllAchievementCommand(ChatHandler* handler, const char* /*args*/) -{ - HandleReloadAchievementCriteriaDataCommand(handler,""); - HandleReloadAchievementRewardCommand(handler,""); - return true; -} + //reload commands + static bool HandleReloadGMTicketsCommand(ChatHandler* handler, const char* /*args*/) + { + sTicketMgr.LoadGMTickets(); + return true; + } -static bool HandleReloadAllAreaCommand(ChatHandler* handler, const char* /*args*/) -{ - //HandleReloadQuestAreaTriggersCommand(handler,""); -- reloaded in HandleReloadAllQuestCommand - HandleReloadAreaTriggerTeleportCommand(handler,""); - HandleReloadAreaTriggerTavernCommand(handler,""); - HandleReloadGameGraveyardZoneCommand(handler,""); - return true; -} + static bool HandleReloadAllCommand(ChatHandler* handler, const char* /*args*/) + { + HandleReloadSkillFishingBaseLevelCommand(handler,""); + + HandleReloadAllAchievementCommand(handler,""); + HandleReloadAllAreaCommand(handler,""); + HandleReloadAllEventAICommand(handler,""); + HandleReloadAllLootCommand(handler,""); + HandleReloadAllNpcCommand(handler,""); + HandleReloadAllQuestCommand(handler,""); + HandleReloadAllSpellCommand(handler,""); + HandleReloadAllItemCommand(handler,""); + HandleReloadAllGossipsCommand(handler,""); + HandleReloadAllLocalesCommand(handler,""); + + HandleReloadAccessRequirementCommand(handler,""); + HandleReloadMailLevelRewardCommand(handler,""); + HandleReloadCommandCommand(handler,""); + HandleReloadReservedNameCommand(handler,""); + HandleReloadTrinityStringCommand(handler,""); + HandleReloadGameTeleCommand(handler,""); + + HandleReloadAutobroadcastCommand(handler,""); + return true; + } -static bool HandleReloadAllLootCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Loot Tables..."); - LoadLootTables(); - handler->SendGlobalGMSysMessage("DB tables `*_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} + static bool HandleReloadAllAchievementCommand(ChatHandler* handler, const char* /*args*/) + { + HandleReloadAchievementCriteriaDataCommand(handler,""); + HandleReloadAchievementRewardCommand(handler,""); + return true; + } -static bool HandleReloadAllNpcCommand(ChatHandler* handler, const char* args) -{ - if(*args != 'a') // will be reloaded from all_gossips - HandleReloadNpcGossipCommand(handler,"a"); - HandleReloadNpcTrainerCommand(handler,"a"); - HandleReloadNpcVendorCommand(handler,"a"); - HandleReloadPointsOfInterestCommand(handler,"a"); - HandleReloadSpellClickSpellsCommand(handler,"a"); - return true; -} + static bool HandleReloadAllAreaCommand(ChatHandler* handler, const char* /*args*/) + { + //HandleReloadQuestAreaTriggersCommand(handler,""); -- reloaded in HandleReloadAllQuestCommand + HandleReloadAreaTriggerTeleportCommand(handler,""); + HandleReloadAreaTriggerTavernCommand(handler,""); + HandleReloadGameGraveyardZoneCommand(handler,""); + return true; + } -static bool HandleReloadAllQuestCommand(ChatHandler* handler, const char* /*args*/) -{ - HandleReloadQuestAreaTriggersCommand(handler,"a"); - HandleReloadQuestPOICommand(handler,"a"); - HandleReloadQuestTemplateCommand(handler,"a"); - - sLog.outString("Re-Loading Quests Relations..."); - sObjectMgr.LoadQuestRelations(); - handler->SendGlobalGMSysMessage("DB tables `*_questrelation` and `*_involvedrelation` reloaded."); - return true; -} + static bool HandleReloadAllLootCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Loot Tables..."); + LoadLootTables(); + handler->SendGlobalGMSysMessage("DB tables `*_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; + } -static bool HandleReloadAllScriptsCommand(ChatHandler* handler, const char* /*args*/) -{ - if (sWorld.IsScriptScheduled()) - { - handler->PSendSysMessage("DB scripts used currently, please attempt reload later."); - handler->SetSentErrorMessage(true); - return false; - } - - sLog.outString("Re-Loading Scripts..."); - HandleReloadGameObjectScriptsCommand(handler,"a"); - HandleReloadGossipScriptsCommand(handler,"a"); - HandleReloadEventScriptsCommand(handler,"a"); - HandleReloadQuestEndScriptsCommand(handler,"a"); - HandleReloadQuestStartScriptsCommand(handler,"a"); - HandleReloadSpellScriptsCommand(handler,"a"); - handler->SendGlobalGMSysMessage("DB tables `*_scripts` reloaded."); - HandleReloadDbScriptStringCommand(handler,"a"); - HandleReloadWpScriptsCommand(handler,"a"); - return true; -} + static bool HandleReloadAllNpcCommand(ChatHandler* handler, const char* args) + { + if(*args != 'a') // will be reloaded from all_gossips + HandleReloadNpcGossipCommand(handler,"a"); + HandleReloadNpcTrainerCommand(handler,"a"); + HandleReloadNpcVendorCommand(handler,"a"); + HandleReloadPointsOfInterestCommand(handler,"a"); + HandleReloadSpellClickSpellsCommand(handler,"a"); + return true; + } -static bool HandleReloadAllEventAICommand(ChatHandler* handler, const char* /*args*/) -{ - HandleReloadEventAITextsCommand(handler,"a"); - HandleReloadEventAISummonsCommand(handler,"a"); - HandleReloadEventAIScriptsCommand(handler,"a"); - return true; -} + static bool HandleReloadAllQuestCommand(ChatHandler* handler, const char* /*args*/) + { + HandleReloadQuestAreaTriggersCommand(handler,"a"); + HandleReloadQuestPOICommand(handler,"a"); + HandleReloadQuestTemplateCommand(handler,"a"); + + sLog.outString("Re-Loading Quests Relations..."); + sObjectMgr.LoadQuestRelations(); + handler->SendGlobalGMSysMessage("DB tables `*_questrelation` and `*_involvedrelation` reloaded."); + return true; + } -static bool HandleReloadAllSpellCommand(ChatHandler* handler, const char* /*args*/) -{ - HandleReloadSkillDiscoveryTemplateCommand(handler,"a"); - HandleReloadSkillExtraItemTemplateCommand(handler,"a"); - HandleReloadSpellRequiredCommand(handler,"a"); - HandleReloadSpellAreaCommand(handler,"a"); - HandleReloadSpellGroupsCommand(handler,"a"); - HandleReloadSpellLearnSpellCommand(handler,"a"); - HandleReloadSpellLinkedSpellCommand(handler,"a"); - HandleReloadSpellProcEventCommand(handler,"a"); - HandleReloadSpellBonusesCommand(handler,"a"); - HandleReloadSpellTargetPositionCommand(handler,"a"); - HandleReloadSpellThreatsCommand(handler,"a"); - HandleReloadSpellGroupStackRulesCommand(handler,"a"); - HandleReloadSpellPetAurasCommand(handler,"a"); - return true; -} + static bool HandleReloadAllScriptsCommand(ChatHandler* handler, const char* /*args*/) + { + if (sWorld.IsScriptScheduled()) + { + handler->PSendSysMessage("DB scripts used currently, please attempt reload later."); + handler->SetSentErrorMessage(true); + return false; + } -static bool HandleReloadAllGossipsCommand(ChatHandler* handler, const char* args) -{ - HandleReloadGossipMenuCommand(handler,"a"); - HandleReloadGossipMenuOptionCommand(handler,"a"); - if(*args != 'a') // already reload from all_scripts - HandleReloadGossipScriptsCommand(handler,"a"); - HandleReloadNpcGossipCommand(handler,"a"); - HandleReloadPointsOfInterestCommand(handler,"a"); - return true; -} + sLog.outString("Re-Loading Scripts..."); + HandleReloadGameObjectScriptsCommand(handler,"a"); + HandleReloadGossipScriptsCommand(handler,"a"); + HandleReloadEventScriptsCommand(handler,"a"); + HandleReloadQuestEndScriptsCommand(handler,"a"); + HandleReloadQuestStartScriptsCommand(handler,"a"); + HandleReloadSpellScriptsCommand(handler,"a"); + handler->SendGlobalGMSysMessage("DB tables `*_scripts` reloaded."); + HandleReloadDbScriptStringCommand(handler,"a"); + HandleReloadWpScriptsCommand(handler,"a"); + return true; + } -static bool HandleReloadAllItemCommand(ChatHandler* handler, const char* /*args*/) -{ - HandleReloadPageTextsCommand(handler,"a"); - HandleReloadItemEnchantementsCommand(handler,"a"); - return true; -} + static bool HandleReloadAllEventAICommand(ChatHandler* handler, const char* /*args*/) + { + HandleReloadEventAITextsCommand(handler,"a"); + HandleReloadEventAISummonsCommand(handler,"a"); + HandleReloadEventAIScriptsCommand(handler,"a"); + return true; + } -static bool HandleReloadAllLocalesCommand(ChatHandler* handler, const char* /*args*/) -{ - HandleReloadLocalesAchievementRewardCommand(handler,"a"); - HandleReloadLocalesCreatureCommand(handler,"a"); - HandleReloadLocalesGameobjectCommand(handler,"a"); - HandleReloadLocalesGossipMenuOptionCommand(handler,"a"); - HandleReloadLocalesItemCommand(handler,"a"); - HandleReloadLocalesNpcTextCommand(handler,"a"); - HandleReloadLocalesPageTextCommand(handler,"a"); - HandleReloadLocalesPointsOfInterestCommand(handler,"a"); - HandleReloadLocalesQuestCommand(handler,"a"); - return true; -} + static bool HandleReloadAllSpellCommand(ChatHandler* handler, const char* /*args*/) + { + HandleReloadSkillDiscoveryTemplateCommand(handler,"a"); + HandleReloadSkillExtraItemTemplateCommand(handler,"a"); + HandleReloadSpellRequiredCommand(handler,"a"); + HandleReloadSpellAreaCommand(handler,"a"); + HandleReloadSpellGroupsCommand(handler,"a"); + HandleReloadSpellLearnSpellCommand(handler,"a"); + HandleReloadSpellLinkedSpellCommand(handler,"a"); + HandleReloadSpellProcEventCommand(handler,"a"); + HandleReloadSpellBonusesCommand(handler,"a"); + HandleReloadSpellTargetPositionCommand(handler,"a"); + HandleReloadSpellThreatsCommand(handler,"a"); + HandleReloadSpellGroupStackRulesCommand(handler,"a"); + HandleReloadSpellPetAurasCommand(handler,"a"); + return true; + } -static bool HandleReloadConfigCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading config settings..."); - sWorld.LoadConfigSettings(true); - sMapMgr.InitializeVisibilityDistanceInfo(); - handler->SendGlobalGMSysMessage("World config settings reloaded."); - return true; -} + static bool HandleReloadAllGossipsCommand(ChatHandler* handler, const char* args) + { + HandleReloadGossipMenuCommand(handler,"a"); + HandleReloadGossipMenuOptionCommand(handler,"a"); + if(*args != 'a') // already reload from all_scripts + HandleReloadGossipScriptsCommand(handler,"a"); + HandleReloadNpcGossipCommand(handler,"a"); + HandleReloadPointsOfInterestCommand(handler,"a"); + return true; + } -static bool HandleReloadAccessRequirementCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Access Requirement definitions..."); - sObjectMgr.LoadAccessRequirements(); - handler->SendGlobalGMSysMessage("DB table `access_requirement` reloaded."); - return true; -} + static bool HandleReloadAllItemCommand(ChatHandler* handler, const char* /*args*/) + { + HandleReloadPageTextsCommand(handler,"a"); + HandleReloadItemEnchantementsCommand(handler,"a"); + return true; + } -static bool HandleReloadAchievementCriteriaDataCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Additional Achievement Criteria Data..."); - sAchievementMgr.LoadAchievementCriteriaData(); - handler->SendGlobalGMSysMessage("DB table `achievement_criteria_data` reloaded."); - return true; -} + static bool HandleReloadAllLocalesCommand(ChatHandler* handler, const char* /*args*/) + { + HandleReloadLocalesAchievementRewardCommand(handler,"a"); + HandleReloadLocalesCreatureCommand(handler,"a"); + HandleReloadLocalesGameobjectCommand(handler,"a"); + HandleReloadLocalesGossipMenuOptionCommand(handler,"a"); + HandleReloadLocalesItemCommand(handler,"a"); + HandleReloadLocalesNpcTextCommand(handler,"a"); + HandleReloadLocalesPageTextCommand(handler,"a"); + HandleReloadLocalesPointsOfInterestCommand(handler,"a"); + HandleReloadLocalesQuestCommand(handler,"a"); + return true; + } -static bool HandleReloadAchievementRewardCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Achievement Reward Data..."); - sAchievementMgr.LoadRewards(); - handler->SendGlobalGMSysMessage("DB table `achievement_reward` reloaded."); - return true; -} + static bool HandleReloadConfigCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading config settings..."); + sWorld.LoadConfigSettings(true); + sMapMgr.InitializeVisibilityDistanceInfo(); + handler->SendGlobalGMSysMessage("World config settings reloaded."); + return true; + } -static bool HandleReloadAreaTriggerTavernCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Tavern Area Triggers..."); - sObjectMgr.LoadTavernAreaTriggers(); - handler->SendGlobalGMSysMessage("DB table `areatrigger_tavern` reloaded."); - return true; -} + static bool HandleReloadAccessRequirementCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Access Requirement definitions..."); + sObjectMgr.LoadAccessRequirements(); + handler->SendGlobalGMSysMessage("DB table `access_requirement` reloaded."); + return true; + } -static bool HandleReloadAreaTriggerTeleportCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading AreaTrigger teleport definitions..."); - sObjectMgr.LoadAreaTriggerTeleports(); - handler->SendGlobalGMSysMessage("DB table `areatrigger_teleport` reloaded."); - return true; -} + static bool HandleReloadAchievementCriteriaDataCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Additional Achievement Criteria Data..."); + sAchievementMgr.LoadAchievementCriteriaData(); + handler->SendGlobalGMSysMessage("DB table `achievement_criteria_data` reloaded."); + return true; + } -static bool HandleReloadAutobroadcastCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Autobroadcast..."); - sWorld.LoadAutobroadcasts(); - handler->SendGlobalGMSysMessage("DB table `autobroadcast` reloaded."); - return true; -} + static bool HandleReloadAchievementRewardCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Achievement Reward Data..."); + sAchievementMgr.LoadRewards(); + handler->SendGlobalGMSysMessage("DB table `achievement_reward` reloaded."); + return true; + } -static bool HandleReloadCommandCommand(ChatHandler* handler, const char* /*args*/) -{ - handler->SetLoadCommandTable(true); - handler->SendGlobalGMSysMessage("DB table `command` will be reloaded at next chat command use."); - return true; -} + static bool HandleReloadAreaTriggerTavernCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Tavern Area Triggers..."); + sObjectMgr.LoadTavernAreaTriggers(); + handler->SendGlobalGMSysMessage("DB table `areatrigger_tavern` reloaded."); + return true; + } -static bool HandleReloadOnKillReputationCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading creature award reputation definitions..."); - sObjectMgr.LoadReputationOnKill(); - handler->SendGlobalGMSysMessage("DB table `creature_onkill_reputation` reloaded."); - return true; -} + static bool HandleReloadAreaTriggerTeleportCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading AreaTrigger teleport definitions..."); + sObjectMgr.LoadAreaTriggerTeleports(); + handler->SendGlobalGMSysMessage("DB table `areatrigger_teleport` reloaded."); + return true; + } -static bool HandleReloadCreatureTemplateCommand(ChatHandler* handler, 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) - { - handler->PSendSysMessage(LANG_COMMAND_CREATURETEMPLATE_NOTFOUND, entry); - handler->SetSentErrorMessage(true); - return false; - } - - CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(entry); - if (!cInfo) - { - handler->PSendSysMessage(LANG_COMMAND_CREATURESTORAGE_NOTFOUND, entry); - handler->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); - - handler->SendGlobalGMSysMessage("Creature template reloaded."); - return true; -} + static bool HandleReloadAutobroadcastCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Autobroadcast..."); + sWorld.LoadAutobroadcasts(); + handler->SendGlobalGMSysMessage("DB table `autobroadcast` reloaded."); + return true; + } -static bool HandleReloadCreatureQuestRelationsCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Loading Quests Relations... (`creature_questrelation`)"); - sObjectMgr.LoadCreatureQuestRelations(); - handler->SendGlobalGMSysMessage("DB table `creature_questrelation` (creature quest givers) reloaded."); - return true; -} + static bool HandleReloadCommandCommand(ChatHandler* handler, const char* /*args*/) + { + handler->SetLoadCommandTable(true); + handler->SendGlobalGMSysMessage("DB table `command` will be reloaded at next chat command use."); + return true; + } -static bool HandleReloadCreatureLinkedRespawnCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Loading Linked Respawns... (`creature_linked_respawn`)"); - sObjectMgr.LoadCreatureLinkedRespawn(); - handler->SendGlobalGMSysMessage("DB table `creature_linked_respawn` (creature linked respawns) reloaded."); - return true; -} + static bool HandleReloadOnKillReputationCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading creature award reputation definitions..."); + sObjectMgr.LoadReputationOnKill(); + handler->SendGlobalGMSysMessage("DB table `creature_onkill_reputation` reloaded."); + return true; + } -static bool HandleReloadCreatureQuestInvRelationsCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Loading Quests Relations... (`creature_involvedrelation`)"); - sObjectMgr.LoadCreatureInvolvedRelations(); - handler->SendGlobalGMSysMessage("DB table `creature_involvedrelation` (creature quest takers) reloaded."); - return true; -} + static bool HandleReloadCreatureTemplateCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; -static bool HandleReloadGossipMenuCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading `gossip_menu` Table!"); - sObjectMgr.LoadGossipMenu(); - handler->SendGlobalGMSysMessage("DB table `gossip_menu` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} + 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) + { + handler->PSendSysMessage(LANG_COMMAND_CREATURETEMPLATE_NOTFOUND, entry); + handler->SetSentErrorMessage(true); + return false; + } -static bool HandleReloadGossipMenuOptionCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading `gossip_menu_option` Table!"); - sObjectMgr.LoadGossipMenuItems(); - handler->SendGlobalGMSysMessage("DB table `gossip_menu_option` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} + CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(entry); + if (!cInfo) + { + handler->PSendSysMessage(LANG_COMMAND_CREATURESTORAGE_NOTFOUND, entry); + handler->SetSentErrorMessage(true); + return false; + } -static bool HandleReloadGOQuestRelationsCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Loading Quests Relations... (`gameobject_questrelation`)"); - sObjectMgr.LoadGameobjectQuestRelations(); - handler->SendGlobalGMSysMessage("DB table `gameobject_questrelation` (gameobject quest givers) reloaded."); - return true; -} + 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); + + handler->SendGlobalGMSysMessage("Creature template reloaded."); + return true; + } -static bool HandleReloadGOQuestInvRelationsCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Loading Quests Relations... (`gameobject_involvedrelation`)"); - sObjectMgr.LoadGameobjectInvolvedRelations(); - handler->SendGlobalGMSysMessage("DB table `gameobject_involvedrelation` (gameobject quest takers) reloaded."); - return true; -} + static bool HandleReloadCreatureQuestRelationsCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Loading Quests Relations... (`creature_questrelation`)"); + sObjectMgr.LoadCreatureQuestRelations(); + handler->SendGlobalGMSysMessage("DB table `creature_questrelation` (creature quest givers) reloaded."); + return true; + } -static bool HandleReloadQuestAreaTriggersCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Quest Area Triggers..."); - sObjectMgr.LoadQuestAreaTriggers(); - handler->SendGlobalGMSysMessage("DB table `areatrigger_involvedrelation` (quest area triggers) reloaded."); - return true; -} + static bool HandleReloadCreatureLinkedRespawnCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Loading Linked Respawns... (`creature_linked_respawn`)"); + sObjectMgr.LoadCreatureLinkedRespawn(); + handler->SendGlobalGMSysMessage("DB table `creature_linked_respawn` (creature linked respawns) reloaded."); + return true; + } -static bool HandleReloadQuestTemplateCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Quest Templates..."); - sObjectMgr.LoadQuests(); - handler->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(); - handler->SendGlobalGMSysMessage("Data GameObjects for quests reloaded."); - return true; -} + static bool HandleReloadCreatureQuestInvRelationsCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Loading Quests Relations... (`creature_involvedrelation`)"); + sObjectMgr.LoadCreatureInvolvedRelations(); + handler->SendGlobalGMSysMessage("DB table `creature_involvedrelation` (creature quest takers) reloaded."); + return true; + } -static bool HandleReloadLootTemplatesCreatureCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Loot Tables... (`creature_loot_template`)"); - LoadLootTemplates_Creature(); - LootTemplates_Creature.CheckLootRefs(); - handler->SendGlobalGMSysMessage("DB table `creature_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} + static bool HandleReloadGossipMenuCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading `gossip_menu` Table!"); + sObjectMgr.LoadGossipMenu(); + handler->SendGlobalGMSysMessage("DB table `gossip_menu` reloaded."); + sConditionMgr.LoadConditions(true); + return true; + } -static bool HandleReloadLootTemplatesDisenchantCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Loot Tables... (`disenchant_loot_template`)"); - LoadLootTemplates_Disenchant(); - LootTemplates_Disenchant.CheckLootRefs(); - handler->SendGlobalGMSysMessage("DB table `disenchant_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} + static bool HandleReloadGossipMenuOptionCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading `gossip_menu_option` Table!"); + sObjectMgr.LoadGossipMenuItems(); + handler->SendGlobalGMSysMessage("DB table `gossip_menu_option` reloaded."); + sConditionMgr.LoadConditions(true); + return true; + } -static bool HandleReloadLootTemplatesFishingCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Loot Tables... (`fishing_loot_template`)"); - LoadLootTemplates_Fishing(); - LootTemplates_Fishing.CheckLootRefs(); - handler->SendGlobalGMSysMessage("DB table `fishing_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} + static bool HandleReloadGOQuestRelationsCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Loading Quests Relations... (`gameobject_questrelation`)"); + sObjectMgr.LoadGameobjectQuestRelations(); + handler->SendGlobalGMSysMessage("DB table `gameobject_questrelation` (gameobject quest givers) reloaded."); + return true; + } -static bool HandleReloadLootTemplatesGameobjectCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Loot Tables... (`gameobject_loot_template`)"); - LoadLootTemplates_Gameobject(); - LootTemplates_Gameobject.CheckLootRefs(); - handler->SendGlobalGMSysMessage("DB table `gameobject_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} + static bool HandleReloadGOQuestInvRelationsCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Loading Quests Relations... (`gameobject_involvedrelation`)"); + sObjectMgr.LoadGameobjectInvolvedRelations(); + handler->SendGlobalGMSysMessage("DB table `gameobject_involvedrelation` (gameobject quest takers) reloaded."); + return true; + } -static bool HandleReloadLootTemplatesItemCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Loot Tables... (`item_loot_template`)"); - LoadLootTemplates_Item(); - LootTemplates_Item.CheckLootRefs(); - handler->SendGlobalGMSysMessage("DB table `item_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} + static bool HandleReloadQuestAreaTriggersCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Quest Area Triggers..."); + sObjectMgr.LoadQuestAreaTriggers(); + handler->SendGlobalGMSysMessage("DB table `areatrigger_involvedrelation` (quest area triggers) reloaded."); + return true; + } -static bool HandleReloadLootTemplatesMillingCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Loot Tables... (`milling_loot_template`)"); - LoadLootTemplates_Milling(); - LootTemplates_Milling.CheckLootRefs(); - handler->SendGlobalGMSysMessage("DB table `milling_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} + static bool HandleReloadQuestTemplateCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Quest Templates..."); + sObjectMgr.LoadQuests(); + handler->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(); + handler->SendGlobalGMSysMessage("Data GameObjects for quests reloaded."); + return true; + } -static bool HandleReloadLootTemplatesPickpocketingCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Loot Tables... (`pickpocketing_loot_template`)"); - LoadLootTemplates_Pickpocketing(); - LootTemplates_Pickpocketing.CheckLootRefs(); - handler->SendGlobalGMSysMessage("DB table `pickpocketing_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} + static bool HandleReloadLootTemplatesCreatureCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Loot Tables... (`creature_loot_template`)"); + LoadLootTemplates_Creature(); + LootTemplates_Creature.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `creature_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; + } -static bool HandleReloadLootTemplatesProspectingCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Loot Tables... (`prospecting_loot_template`)"); - LoadLootTemplates_Prospecting(); - LootTemplates_Prospecting.CheckLootRefs(); - handler->SendGlobalGMSysMessage("DB table `prospecting_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} + static bool HandleReloadLootTemplatesDisenchantCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Loot Tables... (`disenchant_loot_template`)"); + LoadLootTemplates_Disenchant(); + LootTemplates_Disenchant.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `disenchant_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; + } -static bool HandleReloadLootTemplatesMailCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Loot Tables... (`mail_loot_template`)"); - LoadLootTemplates_Mail(); - LootTemplates_Mail.CheckLootRefs(); - handler->SendGlobalGMSysMessage("DB table `mail_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} + static bool HandleReloadLootTemplatesFishingCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Loot Tables... (`fishing_loot_template`)"); + LoadLootTemplates_Fishing(); + LootTemplates_Fishing.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `fishing_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; + } -static bool HandleReloadLootTemplatesReferenceCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Loot Tables... (`reference_loot_template`)"); - LoadLootTemplates_Reference(); - handler->SendGlobalGMSysMessage("DB table `reference_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} + static bool HandleReloadLootTemplatesGameobjectCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Loot Tables... (`gameobject_loot_template`)"); + LoadLootTemplates_Gameobject(); + LootTemplates_Gameobject.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `gameobject_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; + } -static bool HandleReloadLootTemplatesSkinningCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Loot Tables... (`skinning_loot_template`)"); - LoadLootTemplates_Skinning(); - LootTemplates_Skinning.CheckLootRefs(); - handler->SendGlobalGMSysMessage("DB table `skinning_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} + static bool HandleReloadLootTemplatesItemCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Loot Tables... (`item_loot_template`)"); + LoadLootTemplates_Item(); + LootTemplates_Item.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `item_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; + } -static bool HandleReloadLootTemplatesSpellCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Loot Tables... (`spell_loot_template`)"); - LoadLootTemplates_Spell(); - LootTemplates_Spell.CheckLootRefs(); - handler->SendGlobalGMSysMessage("DB table `spell_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} + static bool HandleReloadLootTemplatesMillingCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Loot Tables... (`milling_loot_template`)"); + LoadLootTemplates_Milling(); + LootTemplates_Milling.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `milling_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; + } -static bool HandleReloadTrinityStringCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading trinity_string Table!"); - sObjectMgr.LoadTrinityStrings(); - handler->SendGlobalGMSysMessage("DB table `trinity_string` reloaded."); - return true; -} + static bool HandleReloadLootTemplatesPickpocketingCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Loot Tables... (`pickpocketing_loot_template`)"); + LoadLootTemplates_Pickpocketing(); + LootTemplates_Pickpocketing.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `pickpocketing_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; + } -static bool HandleReloadNpcGossipCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading `npc_gossip` Table!"); - sObjectMgr.LoadNpcTextId(); - handler->SendGlobalGMSysMessage("DB table `npc_gossip` reloaded."); - return true; -} + static bool HandleReloadLootTemplatesProspectingCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Loot Tables... (`prospecting_loot_template`)"); + LoadLootTemplates_Prospecting(); + LootTemplates_Prospecting.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `prospecting_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; + } -static bool HandleReloadNpcTrainerCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading `npc_trainer` Table!"); - sObjectMgr.LoadTrainerSpell(); - handler->SendGlobalGMSysMessage("DB table `npc_trainer` reloaded."); - return true; -} + static bool HandleReloadLootTemplatesMailCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Loot Tables... (`mail_loot_template`)"); + LoadLootTemplates_Mail(); + LootTemplates_Mail.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `mail_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; + } -static bool HandleReloadNpcVendorCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading `npc_vendor` Table!"); - sObjectMgr.LoadVendors(); - handler->SendGlobalGMSysMessage("DB table `npc_vendor` reloaded."); - return true; -} + static bool HandleReloadLootTemplatesReferenceCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Loot Tables... (`reference_loot_template`)"); + LoadLootTemplates_Reference(); + handler->SendGlobalGMSysMessage("DB table `reference_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; + } -static bool HandleReloadPointsOfInterestCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading `points_of_interest` Table!"); - sObjectMgr.LoadPointsOfInterest(); - handler->SendGlobalGMSysMessage("DB table `points_of_interest` reloaded."); - return true; -} + static bool HandleReloadLootTemplatesSkinningCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Loot Tables... (`skinning_loot_template`)"); + LoadLootTemplates_Skinning(); + LootTemplates_Skinning.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `skinning_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; + } -static bool HandleReloadQuestPOICommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString( "Re-Loading Quest POI ..." ); - sObjectMgr.LoadQuestPOI(); - handler->SendGlobalGMSysMessage("DB Table `quest_poi` and `quest_poi_points` reloaded."); - return true; -} + static bool HandleReloadLootTemplatesSpellCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Loot Tables... (`spell_loot_template`)"); + LoadLootTemplates_Spell(); + LootTemplates_Spell.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `spell_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; + } -static bool HandleReloadSpellClickSpellsCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading `npc_spellclick_spells` Table!"); - sObjectMgr.LoadNPCSpellClickSpells(); - handler->SendGlobalGMSysMessage("DB table `npc_spellclick_spells` reloaded."); - return true; -} + static bool HandleReloadTrinityStringCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading trinity_string Table!"); + sObjectMgr.LoadTrinityStrings(); + handler->SendGlobalGMSysMessage("DB table `trinity_string` reloaded."); + return true; + } -static bool HandleReloadReservedNameCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Loading ReservedNames... (`reserved_name`)"); - sObjectMgr.LoadReservedPlayersNames(); - handler->SendGlobalGMSysMessage("DB table `reserved_name` (player reserved names) reloaded."); - return true; -} + static bool HandleReloadNpcGossipCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading `npc_gossip` Table!"); + sObjectMgr.LoadNpcTextId(); + handler->SendGlobalGMSysMessage("DB table `npc_gossip` reloaded."); + return true; + } -static bool HandleReloadReputationRewardRateCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString( "Re-Loading `reputation_reward_rate` Table!" ); - sObjectMgr.LoadReputationRewardRate(); - handler->SendGlobalSysMessage("DB table `reputation_reward_rate` reloaded."); - return true; -} + static bool HandleReloadNpcTrainerCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading `npc_trainer` Table!"); + sObjectMgr.LoadTrainerSpell(); + handler->SendGlobalGMSysMessage("DB table `npc_trainer` reloaded."); + return true; + } -static bool HandleReloadReputationSpilloverTemplateCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString( "Re-Loading `reputation_spillover_template` Table!" ); - sObjectMgr.LoadReputationSpilloverTemplate(); - handler->SendGlobalSysMessage("DB table `reputation_spillover_template` reloaded."); - return true; -} + static bool HandleReloadNpcVendorCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading `npc_vendor` Table!"); + sObjectMgr.LoadVendors(); + handler->SendGlobalGMSysMessage("DB table `npc_vendor` reloaded."); + return true; + } -static bool HandleReloadSkillDiscoveryTemplateCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Skill Discovery Table..."); - LoadSkillDiscoveryTable(); - handler->SendGlobalGMSysMessage("DB table `skill_discovery_template` (recipes discovered at crafting) reloaded."); - return true; -} + static bool HandleReloadPointsOfInterestCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading `points_of_interest` Table!"); + sObjectMgr.LoadPointsOfInterest(); + handler->SendGlobalGMSysMessage("DB table `points_of_interest` reloaded."); + return true; + } -static bool HandleReloadSkillExtraItemTemplateCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Skill Extra Item Table..."); - LoadSkillExtraItemTable(); - handler->SendGlobalGMSysMessage("DB table `skill_extra_item_template` (extra item creation when crafting) reloaded."); - return true; -} + static bool HandleReloadQuestPOICommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString( "Re-Loading Quest POI ..." ); + sObjectMgr.LoadQuestPOI(); + handler->SendGlobalGMSysMessage("DB Table `quest_poi` and `quest_poi_points` reloaded."); + return true; + } -static bool HandleReloadSkillFishingBaseLevelCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Skill Fishing base level requirements..."); - sObjectMgr.LoadFishingBaseSkillLevel(); - handler->SendGlobalGMSysMessage("DB table `skill_fishing_base_level` (fishing base level for zone/subzone) reloaded."); - return true; -} + static bool HandleReloadSpellClickSpellsCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading `npc_spellclick_spells` Table!"); + sObjectMgr.LoadNPCSpellClickSpells(); + handler->SendGlobalGMSysMessage("DB table `npc_spellclick_spells` reloaded."); + return true; + } -static bool HandleReloadSpellAreaCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading SpellArea Data..."); - sSpellMgr.LoadSpellAreas(); - handler->SendGlobalGMSysMessage("DB table `spell_area` (spell dependences from area/quest/auras state) reloaded."); - return true; -} + static bool HandleReloadReservedNameCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Loading ReservedNames... (`reserved_name`)"); + sObjectMgr.LoadReservedPlayersNames(); + handler->SendGlobalGMSysMessage("DB table `reserved_name` (player reserved names) reloaded."); + return true; + } -static bool HandleReloadSpellRequiredCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Spell Required Data... "); - sSpellMgr.LoadSpellRequired(); - handler->SendGlobalGMSysMessage("DB table `spell_required` reloaded."); - return true; -} + static bool HandleReloadReputationRewardRateCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString( "Re-Loading `reputation_reward_rate` Table!" ); + sObjectMgr.LoadReputationRewardRate(); + handler->SendGlobalSysMessage("DB table `reputation_reward_rate` reloaded."); + return true; + } -static bool HandleReloadSpellGroupsCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Spell Groups..."); - sSpellMgr.LoadSpellGroups(); - handler->SendGlobalGMSysMessage("DB table `spell_group` (spell groups) reloaded."); - return true; -} + static bool HandleReloadReputationSpilloverTemplateCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString( "Re-Loading `reputation_spillover_template` Table!" ); + sObjectMgr.LoadReputationSpilloverTemplate(); + handler->SendGlobalSysMessage("DB table `reputation_spillover_template` reloaded."); + return true; + } -static bool HandleReloadSpellLearnSpellCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Spell Learn Spells..."); - sSpellMgr.LoadSpellLearnSpells(); - handler->SendGlobalGMSysMessage("DB table `spell_learn_spell` reloaded."); - return true; -} + static bool HandleReloadSkillDiscoveryTemplateCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Skill Discovery Table..."); + LoadSkillDiscoveryTable(); + handler->SendGlobalGMSysMessage("DB table `skill_discovery_template` (recipes discovered at crafting) reloaded."); + return true; + } -static bool HandleReloadSpellLinkedSpellCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Spell Linked Spells..."); - sSpellMgr.LoadSpellLinked(); - handler->SendGlobalGMSysMessage("DB table `spell_linked_spell` reloaded."); - return true; -} + static bool HandleReloadSkillExtraItemTemplateCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Skill Extra Item Table..."); + LoadSkillExtraItemTable(); + handler->SendGlobalGMSysMessage("DB table `skill_extra_item_template` (extra item creation when crafting) reloaded."); + return true; + } -static bool HandleReloadSpellProcEventCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Spell Proc Event conditions..."); - sSpellMgr.LoadSpellProcEvents(); - handler->SendGlobalGMSysMessage("DB table `spell_proc_event` (spell proc trigger requirements) reloaded."); - return true; -} + static bool HandleReloadSkillFishingBaseLevelCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Skill Fishing base level requirements..."); + sObjectMgr.LoadFishingBaseSkillLevel(); + handler->SendGlobalGMSysMessage("DB table `skill_fishing_base_level` (fishing base level for zone/subzone) reloaded."); + return true; + } -static bool HandleReloadSpellBonusesCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Spell Bonus Data..."); - sSpellMgr.LoadSpellBonusess(); - handler->SendGlobalGMSysMessage("DB table `spell_bonus_data` (spell damage/healing coefficients) reloaded."); - return true; -} + static bool HandleReloadSpellAreaCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading SpellArea Data..."); + sSpellMgr.LoadSpellAreas(); + handler->SendGlobalGMSysMessage("DB table `spell_area` (spell dependences from area/quest/auras state) reloaded."); + return true; + } -static bool HandleReloadSpellTargetPositionCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Spell target coordinates..."); - sSpellMgr.LoadSpellTargetPositions(); - handler->SendGlobalGMSysMessage("DB table `spell_target_position` (destination coordinates for spell targets) reloaded."); - return true; -} + static bool HandleReloadSpellRequiredCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Spell Required Data... "); + sSpellMgr.LoadSpellRequired(); + handler->SendGlobalGMSysMessage("DB table `spell_required` reloaded."); + return true; + } -static bool HandleReloadSpellThreatsCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Aggro Spells Definitions..."); - sSpellMgr.LoadSpellThreats(); - handler->SendGlobalGMSysMessage("DB table `spell_threat` (spell aggro definitions) reloaded."); - return true; -} + static bool HandleReloadSpellGroupsCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Spell Groups..."); + sSpellMgr.LoadSpellGroups(); + handler->SendGlobalGMSysMessage("DB table `spell_group` (spell groups) reloaded."); + return true; + } -static bool HandleReloadSpellGroupStackRulesCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Spell Group Stack Rules..."); - sSpellMgr.LoadSpellGroupStackRules(); - handler->SendGlobalGMSysMessage("DB table `spell_group_stack_rules` (spell stacking definitions) reloaded."); - return true; -} + static bool HandleReloadSpellLearnSpellCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Spell Learn Spells..."); + sSpellMgr.LoadSpellLearnSpells(); + handler->SendGlobalGMSysMessage("DB table `spell_learn_spell` reloaded."); + return true; + } -static bool HandleReloadSpellPetAurasCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Spell pet auras..."); - sSpellMgr.LoadSpellPetAuras(); - handler->SendGlobalGMSysMessage("DB table `spell_pet_auras` reloaded."); - return true; -} + static bool HandleReloadSpellLinkedSpellCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Spell Linked Spells..."); + sSpellMgr.LoadSpellLinked(); + handler->SendGlobalGMSysMessage("DB table `spell_linked_spell` reloaded."); + return true; + } -static bool HandleReloadPageTextsCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Page Texts..."); - sObjectMgr.LoadPageTexts(); - handler->SendGlobalGMSysMessage("DB table `page_texts` reloaded."); - return true; -} + static bool HandleReloadSpellProcEventCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Spell Proc Event conditions..."); + sSpellMgr.LoadSpellProcEvents(); + handler->SendGlobalGMSysMessage("DB table `spell_proc_event` (spell proc trigger requirements) reloaded."); + return true; + } -static bool HandleReloadItemEnchantementsCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Item Random Enchantments Table..."); - LoadRandomEnchantmentsTable(); - handler->SendGlobalGMSysMessage("DB table `item_enchantment_template` reloaded."); - return true; -} + static bool HandleReloadSpellBonusesCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Spell Bonus Data..."); + sSpellMgr.LoadSpellBonusess(); + handler->SendGlobalGMSysMessage("DB table `spell_bonus_data` (spell damage/healing coefficients) reloaded."); + return true; + } -static bool HandleReloadItemSetNamesCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Item set names..."); - LoadRandomEnchantmentsTable(); - handler->SendGlobalGMSysMessage("DB table `item_set_names` reloaded."); - return true; -} + static bool HandleReloadSpellTargetPositionCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Spell target coordinates..."); + sSpellMgr.LoadSpellTargetPositions(); + handler->SendGlobalGMSysMessage("DB table `spell_target_position` (destination coordinates for spell targets) reloaded."); + return true; + } -static bool HandleReloadGossipScriptsCommand(ChatHandler* handler, const char* args) -{ - if (sWorld.IsScriptScheduled()) + static bool HandleReloadSpellThreatsCommand(ChatHandler* handler, const char* /*args*/) { - handler->SendSysMessage("DB scripts used currently, please attempt reload later."); - handler->SetSentErrorMessage(true); - return false; + sLog.outString("Re-Loading Aggro Spells Definitions..."); + sSpellMgr.LoadSpellThreats(); + handler->SendGlobalGMSysMessage("DB table `spell_threat` (spell aggro definitions) reloaded."); + return true; } - if (*args != 'a') - sLog.outString("Re-Loading Scripts from `gossip_scripts`..."); + static bool HandleReloadSpellGroupStackRulesCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Spell Group Stack Rules..."); + sSpellMgr.LoadSpellGroupStackRules(); + handler->SendGlobalGMSysMessage("DB table `spell_group_stack_rules` (spell stacking definitions) reloaded."); + return true; + } - sObjectMgr.LoadGossipScripts(); + static bool HandleReloadSpellPetAurasCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Spell pet auras..."); + sSpellMgr.LoadSpellPetAuras(); + handler->SendGlobalGMSysMessage("DB table `spell_pet_auras` reloaded."); + return true; + } - if (*args != 'a') - handler->SendGlobalGMSysMessage("DB table `gossip_scripts` reloaded."); + static bool HandleReloadPageTextsCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Page Texts..."); + sObjectMgr.LoadPageTexts(); + handler->SendGlobalGMSysMessage("DB table `page_texts` reloaded."); + return true; + } - return true; -} + static bool HandleReloadItemEnchantementsCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Item Random Enchantments Table..."); + LoadRandomEnchantmentsTable(); + handler->SendGlobalGMSysMessage("DB table `item_enchantment_template` reloaded."); + return true; + } -static bool HandleReloadGameObjectScriptsCommand(ChatHandler* handler, const char* args) -{ - if (sWorld.IsScriptScheduled()) + static bool HandleReloadItemSetNamesCommand(ChatHandler* handler, const char* /*args*/) { - handler->SendSysMessage("DB scripts used currently, please attempt reload later."); - handler->SetSentErrorMessage(true); - return false; + sLog.outString("Re-Loading Item set names..."); + LoadRandomEnchantmentsTable(); + handler->SendGlobalGMSysMessage("DB table `item_set_names` reloaded."); + return true; } - if (*args != 'a') - sLog.outString("Re-Loading Scripts from `gameobject_scripts`..."); + static bool HandleReloadGossipScriptsCommand(ChatHandler* handler, const char* args) + { + if (sWorld.IsScriptScheduled()) + { + handler->SendSysMessage("DB scripts used currently, please attempt reload later."); + handler->SetSentErrorMessage(true); + return false; + } - sObjectMgr.LoadGameObjectScripts(); + if (*args != 'a') + sLog.outString("Re-Loading Scripts from `gossip_scripts`..."); - if (*args != 'a') - handler->SendGlobalGMSysMessage("DB table `gameobject_scripts` reloaded."); + sObjectMgr.LoadGossipScripts(); - return true; -} + if (*args != 'a') + handler->SendGlobalGMSysMessage("DB table `gossip_scripts` reloaded."); -static bool HandleReloadEventScriptsCommand(ChatHandler* handler, const char* args) -{ - if (sWorld.IsScriptScheduled()) - { - handler->SendSysMessage("DB scripts used currently, please attempt reload later."); - handler->SetSentErrorMessage(true); - return false; + return true; } - if (*args != 'a') - sLog.outString("Re-Loading Scripts from `event_scripts`..."); + static bool HandleReloadGameObjectScriptsCommand(ChatHandler* handler, const char* args) + { + if (sWorld.IsScriptScheduled()) + { + handler->SendSysMessage("DB scripts used currently, please attempt reload later."); + handler->SetSentErrorMessage(true); + return false; + } - sObjectMgr.LoadEventScripts(); + if (*args != 'a') + sLog.outString("Re-Loading Scripts from `gameobject_scripts`..."); - if (*args != 'a') - handler->SendGlobalGMSysMessage("DB table `event_scripts` reloaded."); + sObjectMgr.LoadGameObjectScripts(); - return true; -} + if (*args != 'a') + handler->SendGlobalGMSysMessage("DB table `gameobject_scripts` reloaded."); -static bool HandleReloadWpScriptsCommand(ChatHandler* handler, const char* args) -{ - if (sWorld.IsScriptScheduled()) + return true; + } + + static bool HandleReloadEventScriptsCommand(ChatHandler* handler, const char* args) { - handler->SendSysMessage("DB scripts used currently, please attempt reload later."); - handler->SetSentErrorMessage(true); - return false; + if (sWorld.IsScriptScheduled()) + { + handler->SendSysMessage("DB scripts used currently, please attempt reload later."); + handler->SetSentErrorMessage(true); + return false; + } + + if (*args != 'a') + sLog.outString("Re-Loading Scripts from `event_scripts`..."); + + sObjectMgr.LoadEventScripts(); + + if (*args != 'a') + handler->SendGlobalGMSysMessage("DB table `event_scripts` reloaded."); + + return true; } - if (*args != 'a') - sLog.outString("Re-Loading Scripts from `waypoint_scripts`..."); + static bool HandleReloadWpScriptsCommand(ChatHandler* handler, const char* args) + { + if (sWorld.IsScriptScheduled()) + { + handler->SendSysMessage("DB scripts used currently, please attempt reload later."); + handler->SetSentErrorMessage(true); + return false; + } - sObjectMgr.LoadWaypointScripts(); + if (*args != 'a') + sLog.outString("Re-Loading Scripts from `waypoint_scripts`..."); - if (*args != 'a') - handler->SendGlobalGMSysMessage("DB table `waypoint_scripts` reloaded."); + sObjectMgr.LoadWaypointScripts(); - return true; -} + if (*args != 'a') + handler->SendGlobalGMSysMessage("DB table `waypoint_scripts` reloaded."); -static bool HandleReloadEventAITextsCommand(ChatHandler* handler, const char* /*args*/) -{ + return true; + } - sLog.outString("Re-Loading Texts from `creature_ai_texts`..."); - sEventAIMgr.LoadCreatureEventAI_Texts(); - handler->SendGlobalGMSysMessage("DB table `creature_ai_texts` reloaded."); - return true; -} + static bool HandleReloadEventAITextsCommand(ChatHandler* handler, const char* /*args*/) + { -static bool HandleReloadEventAISummonsCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Summons from `creature_ai_summons`..."); - sEventAIMgr.LoadCreatureEventAI_Summons(); - handler->SendGlobalGMSysMessage("DB table `creature_ai_summons` reloaded."); - return true; -} + sLog.outString("Re-Loading Texts from `creature_ai_texts`..."); + sEventAIMgr.LoadCreatureEventAI_Texts(); + handler->SendGlobalGMSysMessage("DB table `creature_ai_texts` reloaded."); + return true; + } -static bool HandleReloadEventAIScriptsCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Scripts from `creature_ai_scripts`..."); - sEventAIMgr.LoadCreatureEventAI_Scripts(); - handler->SendGlobalGMSysMessage("DB table `creature_ai_scripts` reloaded."); - return true; -} + static bool HandleReloadEventAISummonsCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Summons from `creature_ai_summons`..."); + sEventAIMgr.LoadCreatureEventAI_Summons(); + handler->SendGlobalGMSysMessage("DB table `creature_ai_summons` reloaded."); + return true; + } -static bool HandleReloadQuestEndScriptsCommand(ChatHandler* handler, const char* args) -{ - if (sWorld.IsScriptScheduled()) + static bool HandleReloadEventAIScriptsCommand(ChatHandler* handler, const char* /*args*/) { - handler->SendSysMessage("DB scripts used currently, please attempt reload later."); - handler->SetSentErrorMessage(true); - return false; + sLog.outString("Re-Loading Scripts from `creature_ai_scripts`..."); + sEventAIMgr.LoadCreatureEventAI_Scripts(); + handler->SendGlobalGMSysMessage("DB table `creature_ai_scripts` reloaded."); + return true; } - if (*args != 'a') - sLog.outString("Re-Loading Scripts from `quest_end_scripts`..."); + static bool HandleReloadQuestEndScriptsCommand(ChatHandler* handler, const char* args) + { + if (sWorld.IsScriptScheduled()) + { + handler->SendSysMessage("DB scripts used currently, please attempt reload later."); + handler->SetSentErrorMessage(true); + return false; + } - sObjectMgr.LoadQuestEndScripts(); + if (*args != 'a') + sLog.outString("Re-Loading Scripts from `quest_end_scripts`..."); - if (*args != 'a') - handler->SendGlobalGMSysMessage("DB table `quest_end_scripts` reloaded."); + sObjectMgr.LoadQuestEndScripts(); - return true; -} + if (*args != 'a') + handler->SendGlobalGMSysMessage("DB table `quest_end_scripts` reloaded."); -static bool HandleReloadQuestStartScriptsCommand(ChatHandler* handler, const char* args) -{ - if (sWorld.IsScriptScheduled()) - { - handler->SendSysMessage("DB scripts used currently, please attempt reload later."); - handler->SetSentErrorMessage(true); - return false; + return true; } - if (*args != 'a') - sLog.outString("Re-Loading Scripts from `quest_start_scripts`..."); + static bool HandleReloadQuestStartScriptsCommand(ChatHandler* handler, const char* args) + { + if (sWorld.IsScriptScheduled()) + { + handler->SendSysMessage("DB scripts used currently, please attempt reload later."); + handler->SetSentErrorMessage(true); + return false; + } - sObjectMgr.LoadQuestStartScripts(); + if (*args != 'a') + sLog.outString("Re-Loading Scripts from `quest_start_scripts`..."); - if (*args != 'a') - handler->SendGlobalGMSysMessage("DB table `quest_start_scripts` reloaded."); + sObjectMgr.LoadQuestStartScripts(); - return true; -} + if (*args != 'a') + handler->SendGlobalGMSysMessage("DB table `quest_start_scripts` reloaded."); -static bool HandleReloadSpellScriptsCommand(ChatHandler* handler, const char* args) -{ - if (sWorld.IsScriptScheduled()) - { - handler->SendSysMessage("DB scripts used currently, please attempt reload later."); - handler->SetSentErrorMessage(true); - return false; + return true; } - if (*args != 'a') - sLog.outString("Re-Loading Scripts from `spell_scripts`..."); + static bool HandleReloadSpellScriptsCommand(ChatHandler* handler, const char* args) + { + if (sWorld.IsScriptScheduled()) + { + handler->SendSysMessage("DB scripts used currently, please attempt reload later."); + handler->SetSentErrorMessage(true); + return false; + } - sObjectMgr.LoadSpellScripts(); + if (*args != 'a') + sLog.outString("Re-Loading Scripts from `spell_scripts`..."); - if (*args != 'a') - handler->SendGlobalGMSysMessage("DB table `spell_scripts` reloaded."); + sObjectMgr.LoadSpellScripts(); - return true; -} + if (*args != 'a') + handler->SendGlobalGMSysMessage("DB table `spell_scripts` reloaded."); -static bool HandleReloadDbScriptStringCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Script strings from `db_script_string`..."); - sObjectMgr.LoadDbScriptStrings(); - handler->SendGlobalGMSysMessage("DB table `db_script_string` reloaded."); - return true; -} + return true; + } -static bool HandleReloadGameGraveyardZoneCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Graveyard-zone links..."); + static bool HandleReloadDbScriptStringCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Script strings from `db_script_string`..."); + sObjectMgr.LoadDbScriptStrings(); + handler->SendGlobalGMSysMessage("DB table `db_script_string` reloaded."); + return true; + } - sObjectMgr.LoadGraveyardZones(); + static bool HandleReloadGameGraveyardZoneCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Graveyard-zone links..."); - handler->SendGlobalGMSysMessage("DB table `game_graveyard_zone` reloaded."); + sObjectMgr.LoadGraveyardZones(); - return true; -} + handler->SendGlobalGMSysMessage("DB table `game_graveyard_zone` reloaded."); -static bool HandleReloadGameTeleCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Game Tele coordinates..."); + return true; + } - sObjectMgr.LoadGameTele(); + static bool HandleReloadGameTeleCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Game Tele coordinates..."); - handler->SendGlobalGMSysMessage("DB table `game_tele` reloaded."); + sObjectMgr.LoadGameTele(); - return true; -} + handler->SendGlobalGMSysMessage("DB table `game_tele` reloaded."); -static bool HandleReloadDisablesCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading disables table..."); - sDisableMgr.LoadDisables(); - sLog.outString("Checking quest disables..."); - sDisableMgr.CheckQuestDisables(); - handler->SendGlobalGMSysMessage("DB table `disables` reloaded."); - return true; -} + return true; + } -static bool HandleReloadLocalesAchievementRewardCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Locales Achievement Reward Data..."); - sAchievementMgr.LoadRewardLocales(); - handler->SendGlobalGMSysMessage("DB table `locales_achievement_reward` reloaded."); - return true; -} + static bool HandleReloadDisablesCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading disables table..."); + sDisableMgr.LoadDisables(); + sLog.outString("Checking quest disables..."); + sDisableMgr.CheckQuestDisables(); + handler->SendGlobalGMSysMessage("DB table `disables` reloaded."); + return true; + } -static bool HandleReloadLfgEncountersCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading dungeon encounter lfg associations..."); - sLFGMgr.LoadDungeonEncounters(); - handler->SendGlobalGMSysMessage("DB table `lfg_dungeon_encounters` reloaded."); - return true; -} + static bool HandleReloadLocalesAchievementRewardCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Locales Achievement Reward Data..."); + sAchievementMgr.LoadRewardLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_achievement_reward` reloaded."); + return true; + } -static bool HandleReloadLfgRewardsCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading lfg dungeon rewards..."); - sLFGMgr.LoadRewards(); - handler->SendGlobalGMSysMessage("DB table `lfg_dungeon_rewards` reloaded."); - return true; -} + static bool HandleReloadLfgEncountersCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading dungeon encounter lfg associations..."); + sLFGMgr.LoadDungeonEncounters(); + handler->SendGlobalGMSysMessage("DB table `lfg_dungeon_encounters` reloaded."); + return true; + } -static bool HandleReloadLocalesCreatureCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Locales Creature ..."); - sObjectMgr.LoadCreatureLocales(); - handler->SendGlobalGMSysMessage("DB table `locales_creature` reloaded."); - return true; -} + static bool HandleReloadLfgRewardsCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading lfg dungeon rewards..."); + sLFGMgr.LoadRewards(); + handler->SendGlobalGMSysMessage("DB table `lfg_dungeon_rewards` reloaded."); + return true; + } -static bool HandleReloadLocalesGameobjectCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Locales Gameobject ... "); - sObjectMgr.LoadGameObjectLocales(); - handler->SendGlobalGMSysMessage("DB table `locales_gameobject` reloaded."); - return true; -} + static bool HandleReloadLocalesCreatureCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Locales Creature ..."); + sObjectMgr.LoadCreatureLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_creature` reloaded."); + return true; + } -static bool HandleReloadLocalesGossipMenuOptionCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString( "Re-Loading Locales Gossip Menu Option ... "); - sObjectMgr.LoadGossipMenuItemsLocales(); - handler->SendGlobalGMSysMessage("DB table `locales_gossip_menu_option` reloaded."); - return true; -} + static bool HandleReloadLocalesGameobjectCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Locales Gameobject ... "); + sObjectMgr.LoadGameObjectLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_gameobject` reloaded."); + return true; + } -static bool HandleReloadLocalesItemCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Locales Item ... "); - sObjectMgr.LoadItemLocales(); - handler->SendGlobalGMSysMessage("DB table `locales_item` reloaded."); - return true; -} + static bool HandleReloadLocalesGossipMenuOptionCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString( "Re-Loading Locales Gossip Menu Option ... "); + sObjectMgr.LoadGossipMenuItemsLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_gossip_menu_option` reloaded."); + return true; + } -static bool HandleReloadLocalesItemSetNameCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Locales Item set name... "); - sObjectMgr.LoadItemSetNameLocales(); - handler->SendGlobalGMSysMessage("DB table `locales_item_set_name` reloaded."); - return true; -} + static bool HandleReloadLocalesItemCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Locales Item ... "); + sObjectMgr.LoadItemLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_item` reloaded."); + return true; + } -static bool HandleReloadLocalesNpcTextCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Locales NPC Text ... "); - sObjectMgr.LoadNpcTextLocales(); - handler->SendGlobalGMSysMessage("DB table `locales_npc_text` reloaded."); - return true; -} + static bool HandleReloadLocalesItemSetNameCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Locales Item set name... "); + sObjectMgr.LoadItemSetNameLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_item_set_name` reloaded."); + return true; + } -static bool HandleReloadLocalesPageTextCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Locales Page Text ... "); - sObjectMgr.LoadPageTextLocales(); - handler->SendGlobalGMSysMessage("DB table `locales_page_text` reloaded."); - return true; -} + static bool HandleReloadLocalesNpcTextCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Locales NPC Text ... "); + sObjectMgr.LoadNpcTextLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_npc_text` reloaded."); + return true; + } -static bool HandleReloadLocalesPointsOfInterestCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Locales Points Of Interest ... "); - sObjectMgr.LoadPointOfInterestLocales(); - handler->SendGlobalGMSysMessage("DB table `locales_points_of_interest` reloaded."); - return true; -} + static bool HandleReloadLocalesPageTextCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Locales Page Text ... "); + sObjectMgr.LoadPageTextLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_page_text` reloaded."); + return true; + } -static bool HandleReloadLocalesQuestCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Locales Quest ... "); - sObjectMgr.LoadQuestLocales(); - handler->SendGlobalGMSysMessage("DB table `locales_quest` reloaded."); - return true; -} + static bool HandleReloadLocalesPointsOfInterestCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Locales Points Of Interest ... "); + sObjectMgr.LoadPointOfInterestLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_points_of_interest` reloaded."); + return true; + } -static bool HandleReloadMailLevelRewardCommand(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Player level dependent mail rewards..."); - sObjectMgr.LoadMailLevelRewards(); - handler->SendGlobalGMSysMessage("DB table `mail_level_reward` reloaded."); - return true; -} + static bool HandleReloadLocalesQuestCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Locales Quest ... "); + sObjectMgr.LoadQuestLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_quest` reloaded."); + return true; + } -static bool HandleReloadAuctionsCommand(ChatHandler* handler, const char* /*args*/) -{ - ///- Reload dynamic data tables from the database - sLog.outString("Re-Loading Auctions..."); - sAuctionMgr.LoadAuctionItems(); - sAuctionMgr.LoadAuctions(); - handler->SendGlobalGMSysMessage("Auctions reloaded."); - return true; -} + static bool HandleReloadMailLevelRewardCommand(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Player level dependent mail rewards..."); + sObjectMgr.LoadMailLevelRewards(); + handler->SendGlobalGMSysMessage("DB table `mail_level_reward` reloaded."); + return true; + } -static bool HandleReloadConditions(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Conditions..."); - sConditionMgr.LoadConditions(true); - handler->SendGlobalGMSysMessage("Conditions reloaded."); - return true; -} + static bool HandleReloadAuctionsCommand(ChatHandler* handler, const char* /*args*/) + { + ///- Reload dynamic data tables from the database + sLog.outString("Re-Loading Auctions..."); + sAuctionMgr.LoadAuctionItems(); + sAuctionMgr.LoadAuctions(); + handler->SendGlobalGMSysMessage("Auctions reloaded."); + return true; + } -static bool HandleReloadCreatureText(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Creature Texts..."); - sCreatureTextMgr.LoadCreatureTexts(); - handler->SendGlobalGMSysMessage("Creature Texts reloaded."); - return true; -} + static bool HandleReloadConditions(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Conditions..."); + sConditionMgr.LoadConditions(true); + handler->SendGlobalGMSysMessage("Conditions reloaded."); + return true; + } -static bool HandleReloadSmartScripts(ChatHandler* handler, const char* /*args*/) -{ - sLog.outString("Re-Loading Smart Scripts..."); - sSmartScriptMgr.LoadSmartAIFromDB(); - handler->SendGlobalGMSysMessage("Smart Scripts reloaded."); - return true; -} + static bool HandleReloadCreatureText(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Creature Texts..."); + sCreatureTextMgr.LoadCreatureTexts(); + handler->SendGlobalGMSysMessage("Creature Texts reloaded."); + return true; + } + static bool HandleReloadSmartScripts(ChatHandler* handler, const char* /*args*/) + { + sLog.outString("Re-Loading Smart Scripts..."); + sSmartScriptMgr.LoadSmartAIFromDB(); + handler->SendGlobalGMSysMessage("Smart Scripts reloaded."); + return true; + } }; void AddSC_reload_commandscript() diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp index aa096bb698e..5ee1d25af91 100644 --- a/src/server/scripts/Commands/cs_tele.cpp +++ b/src/server/scripts/Commands/cs_tele.cpp @@ -29,286 +29,286 @@ EndScriptData */ class tele_commandscript : public CommandScript { - public: - tele_commandscript() : CommandScript("tele_commandscript") { } +public: + tele_commandscript() : CommandScript("tele_commandscript") { } - ChatCommand* GetCommands() const + ChatCommand* GetCommands() const + { + static ChatCommand teleCommandTable[] = { - static ChatCommand teleCommandTable[] = - { - { "add", SEC_ADMINISTRATOR, false, &HandleTeleAddCommand, "", NULL }, - { "del", SEC_ADMINISTRATOR, true, &HandleTeleDelCommand, "", NULL }, - { "name", SEC_MODERATOR, true, &HandleTeleNameCommand, "", NULL }, - { "group", SEC_MODERATOR, false, &HandleTeleGroupCommand, "", NULL }, - { "", SEC_MODERATOR, false, &HandleTeleCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand commandTable[] = - { - { "tele", SEC_MODERATOR, false, NULL, "", teleCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - return commandTable; - } - - static bool HandleTeleAddCommand(ChatHandler* handler, const char* args) + { "add", SEC_ADMINISTRATOR, false, &HandleTeleAddCommand, "", NULL }, + { "del", SEC_ADMINISTRATOR, true, &HandleTeleDelCommand, "", NULL }, + { "name", SEC_MODERATOR, true, &HandleTeleNameCommand, "", NULL }, + { "group", SEC_MODERATOR, false, &HandleTeleGroupCommand, "", NULL }, + { "", SEC_MODERATOR, false, &HandleTeleCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = { - if (!*args) - return false; + { "tele", SEC_MODERATOR, false, NULL, "", teleCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } - Player *player = handler->GetSession()->GetPlayer(); - if (!player) - return false; + static bool HandleTeleAddCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - std::string name = args; + Player *player = handler->GetSession()->GetPlayer(); + if (!player) + return false; - if (sObjectMgr.GetGameTele(name)) - { - handler->SendSysMessage(LANG_COMMAND_TP_ALREADYEXIST); - handler->SetSentErrorMessage(true); - return false; - } + std::string name = args; - GameTele tele; - tele.position_x = player->GetPositionX(); - tele.position_y = player->GetPositionY(); - tele.position_z = player->GetPositionZ(); - tele.orientation = player->GetOrientation(); - tele.mapId = player->GetMapId(); - tele.name = name; + if (sObjectMgr.GetGameTele(name)) + { + handler->SendSysMessage(LANG_COMMAND_TP_ALREADYEXIST); + handler->SetSentErrorMessage(true); + return false; + } - if (sObjectMgr.AddGameTele(tele)) - { - handler->SendSysMessage(LANG_COMMAND_TP_ADDED); - } - else - { - handler->SendSysMessage(LANG_COMMAND_TP_ADDEDERR); - handler->SetSentErrorMessage(true); - return false; - } + GameTele tele; + tele.position_x = player->GetPositionX(); + tele.position_y = player->GetPositionY(); + tele.position_z = player->GetPositionZ(); + tele.orientation = player->GetOrientation(); + tele.mapId = player->GetMapId(); + tele.name = name; - return true; + if (sObjectMgr.AddGameTele(tele)) + { + handler->SendSysMessage(LANG_COMMAND_TP_ADDED); } - - static bool HandleTeleDelCommand(ChatHandler* handler, const char* args) + else { - if (!*args) - return false; + handler->SendSysMessage(LANG_COMMAND_TP_ADDEDERR); + handler->SetSentErrorMessage(true); + return false; + } - std::string name = args; + return true; + } - if (!sObjectMgr.DeleteGameTele(name)) - { - handler->SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); - handler->SetSentErrorMessage(true); - return false; - } + static bool HandleTeleDelCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - handler->SendSysMessage(LANG_COMMAND_TP_DELETED); - return true; + std::string name = args; + + if (!sObjectMgr.DeleteGameTele(name)) + { + handler->SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); + handler->SetSentErrorMessage(true); + return false; } - // teleport player to given game_tele.entry - static bool HandleTeleNameCommand(ChatHandler* handler, const char* args) + handler->SendSysMessage(LANG_COMMAND_TP_DELETED); + return true; + } + + // teleport player to given game_tele.entry + static bool HandleTeleNameCommand(ChatHandler* handler, const char* args) + { + char* nameStr; + char* teleStr; + handler->extractOptFirstArg((char*)args,&nameStr,&teleStr); + if (!teleStr) + return false; + + Player* target; + uint64 target_guid; + std::string target_name; + if (!handler->extractPlayerTarget(nameStr,&target,&target_guid,&target_name)) + return false; + + // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r + GameTele const* tele = handler->extractGameTeleFromLink(teleStr); + if (!tele) { - char* nameStr; - char* teleStr; - handler->extractOptFirstArg((char*)args,&nameStr,&teleStr); - if (!teleStr) - return false; + handler->SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); + handler->SetSentErrorMessage(true); + return false; + } - Player* target; - uint64 target_guid; - std::string target_name; - if (!handler->extractPlayerTarget(nameStr,&target,&target_guid,&target_name)) + if (target) + { + // check online security + if (handler->HasLowerSecurity(target, 0)) return false; - // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r - GameTele const* tele = handler->extractGameTeleFromLink(teleStr); - if (!tele) + std::string chrNameLink = handler->playerLink(target_name); + + if (target->IsBeingTeleported() == true) { - handler->SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); + handler->PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str()); handler->SetSentErrorMessage(true); return false; } - if (target) + handler->PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink.c_str(),"", tele->name.c_str()); + if (handler->needReportToTarget(target)) + (ChatHandler(target)).PSendSysMessage(LANG_TELEPORTED_TO_BY, handler->GetNameLink().c_str()); + + // stop flight if need + if (target->isInFlight()) { - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; - - std::string chrNameLink = handler->playerLink(target_name); - - if (target->IsBeingTeleported() == true) - { - handler->PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str()); - handler->SetSentErrorMessage(true); - return false; - } - - handler->PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink.c_str(),"", tele->name.c_str()); - if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_TELEPORTED_TO_BY, handler->GetNameLink().c_str()); - - // stop flight if need - if (target->isInFlight()) - { - target->GetMotionMaster()->MovementExpired(); - target->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - target->SaveRecallPosition(); - - target->TeleportTo(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation); + target->GetMotionMaster()->MovementExpired(); + target->CleanupAfterTaxiFlight(); } + // save only in non-flight case else - { - // check offline security - if (handler->HasLowerSecurity(NULL, target_guid)) - return false; + target->SaveRecallPosition(); - std::string nameLink = handler->playerLink(target_name); - - handler->PSendSysMessage(LANG_TELEPORTING_TO, nameLink.c_str(), handler->GetTrinityString(LANG_OFFLINE), tele->name.c_str()); - Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation, - sMapMgr.GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z),target_guid); - } - - return true; + target->TeleportTo(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation); } - - //Teleport group to given game_tele.entry - static bool HandleTeleGroupCommand(ChatHandler* handler, const char* args) + else { - if (!*args) + // check offline security + if (handler->HasLowerSecurity(NULL, target_guid)) return false; - Player *player = handler->getSelectedPlayer(); - if (!player) - { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + std::string nameLink = handler->playerLink(target_name); - // check online security - if (handler->HasLowerSecurity(player, 0)) - return false; + handler->PSendSysMessage(LANG_TELEPORTING_TO, nameLink.c_str(), handler->GetTrinityString(LANG_OFFLINE), tele->name.c_str()); + Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation, + sMapMgr.GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z),target_guid); + } - // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r - GameTele const* tele = handler->extractGameTeleFromLink((char*)args); - if (!tele) - { - handler->SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); - handler->SetSentErrorMessage(true); - return false; - } + return true; + } - MapEntry const * map = sMapStore.LookupEntry(tele->mapId); - if (!map || map->IsBattlegroundOrArena()) - { - handler->SendSysMessage(LANG_CANNOT_TELE_TO_BG); - handler->SetSentErrorMessage(true); - return false; - } + //Teleport group to given game_tele.entry + static bool HandleTeleGroupCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; - std::string nameLink = handler->GetNameLink(player); + Player *player = handler->getSelectedPlayer(); + if (!player) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - Group *grp = player->GetGroup(); - if (!grp) - { - handler->PSendSysMessage(LANG_NOT_IN_GROUP,nameLink.c_str()); - handler->SetSentErrorMessage(true); - return false; - } + // check online security + if (handler->HasLowerSecurity(player, 0)) + return false; - for (GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) - { - Player *pl = itr->getSource(); - - if (!pl || !pl->GetSession()) - continue; - - // check online security - if (handler->HasLowerSecurity(pl, 0)) - return false; - - std::string plNameLink = handler->GetNameLink(pl); - - if (pl->IsBeingTeleported()) - { - handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str()); - continue; - } - - handler->PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(),"", tele->name.c_str()); - if (handler->needReportToTarget(pl)) - (ChatHandler(pl)).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str()); - - // stop flight if need - if (pl->isInFlight()) - { - pl->GetMotionMaster()->MovementExpired(); - pl->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - pl->SaveRecallPosition(); - - pl->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation); - } + // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r + GameTele const* tele = handler->extractGameTeleFromLink((char*)args); + if (!tele) + { + handler->SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); + handler->SetSentErrorMessage(true); + return false; + } - return true; + MapEntry const * map = sMapStore.LookupEntry(tele->mapId); + if (!map || map->IsBattlegroundOrArena()) + { + handler->SendSysMessage(LANG_CANNOT_TELE_TO_BG); + handler->SetSentErrorMessage(true); + return false; } - static bool HandleTeleCommand(ChatHandler* handler, const char* args) + std::string nameLink = handler->GetNameLink(player); + + Group *grp = player->GetGroup(); + if (!grp) { - if (!*args) - return false; + handler->PSendSysMessage(LANG_NOT_IN_GROUP,nameLink.c_str()); + handler->SetSentErrorMessage(true); + return false; + } - Player* me = handler->GetSession()->GetPlayer(); + for (GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) + { + Player *pl = itr->getSource(); - // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r - GameTele const* tele = handler->extractGameTeleFromLink((char*)args); + if (!pl || !pl->GetSession()) + continue; - if (!tele) - { - handler->SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); - handler->SetSentErrorMessage(true); + // check online security + if (handler->HasLowerSecurity(pl, 0)) return false; - } - if (me->isInCombat()) - { - handler->SendSysMessage(LANG_YOU_IN_COMBAT); - handler->SetSentErrorMessage(true); - return false; - } + std::string plNameLink = handler->GetNameLink(pl); - MapEntry const * map = sMapStore.LookupEntry(tele->mapId); - if (!map || map->IsBattlegroundOrArena()) + if (pl->IsBeingTeleported()) { - handler->SendSysMessage(LANG_CANNOT_TELE_TO_BG); - handler->SetSentErrorMessage(true); - return false; + handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str()); + continue; } + handler->PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(),"", tele->name.c_str()); + if (handler->needReportToTarget(pl)) + (ChatHandler(pl)).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str()); + // stop flight if need - if (me->isInFlight()) + if (pl->isInFlight()) { - me->GetMotionMaster()->MovementExpired(); - me->CleanupAfterTaxiFlight(); + pl->GetMotionMaster()->MovementExpired(); + pl->CleanupAfterTaxiFlight(); } // save only in non-flight case else - me->SaveRecallPosition(); + pl->SaveRecallPosition(); - me->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation); - return true; + pl->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation); } + + return true; + } + + static bool HandleTeleCommand(ChatHandler* handler, const char* args) + { + if (!*args) + return false; + + Player* me = handler->GetSession()->GetPlayer(); + + // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r + GameTele const* tele = handler->extractGameTeleFromLink((char*)args); + + if (!tele) + { + handler->SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); + handler->SetSentErrorMessage(true); + return false; + } + + if (me->isInCombat()) + { + handler->SendSysMessage(LANG_YOU_IN_COMBAT); + handler->SetSentErrorMessage(true); + return false; + } + + MapEntry const * map = sMapStore.LookupEntry(tele->mapId); + if (!map || map->IsBattlegroundOrArena()) + { + handler->SendSysMessage(LANG_CANNOT_TELE_TO_BG); + handler->SetSentErrorMessage(true); + return false; + } + + // stop flight if need + if (me->isInFlight()) + { + me->GetMotionMaster()->MovementExpired(); + me->CleanupAfterTaxiFlight(); + } + // save only in non-flight case + else + me->SaveRecallPosition(); + + me->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation); + return true; + } }; void AddSC_tele_commandscript() diff --git a/src/server/scripts/Commands/cs_titles.cpp b/src/server/scripts/Commands/cs_titles.cpp index cf7bb4f828d..c7215d13d99 100644 --- a/src/server/scripts/Commands/cs_titles.cpp +++ b/src/server/scripts/Commands/cs_titles.cpp @@ -28,220 +28,219 @@ EndScriptData */ class titles_commandscript : public CommandScript { - public: - titles_commandscript() : CommandScript("titles_commandscript") { } +public: + titles_commandscript() : CommandScript("titles_commandscript") { } - ChatCommand* GetCommands() const - { - static ChatCommand titlesSetCommandTable[] = - { - { "mask", SEC_GAMEMASTER, false, &HandleTitlesSetMaskCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand titlesCommandTable[] = - { - { "add", SEC_GAMEMASTER, false, &HandleTitlesAddCommand, "", NULL }, - { "current", SEC_GAMEMASTER, false, &HandleTitlesCurrentCommand, "", NULL }, - { "remove", SEC_GAMEMASTER, false, &HandleTitlesRemoveCommand, "", NULL }, - { "set", SEC_GAMEMASTER, false, NULL, "", titlesSetCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand commandTable[] = - { - { "titles", SEC_GAMEMASTER, false, NULL, "", titlesCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - return commandTable; - } - -static bool HandleTitlesCurrentCommand(ChatHandler* handler, const char* args) -{ - // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r - char* id_p = handler->extractKeyFromLink((char*)args,"Htitle"); - if (!id_p) - return false; - - int32 id = atoi(id_p); - if (id <= 0) + ChatCommand* GetCommands() const { - handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); - handler->SetSentErrorMessage(true); - return false; + static ChatCommand titlesSetCommandTable[] = + { + { "mask", SEC_GAMEMASTER, false, &HandleTitlesSetMaskCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand titlesCommandTable[] = + { + { "add", SEC_GAMEMASTER, false, &HandleTitlesAddCommand, "", NULL }, + { "current", SEC_GAMEMASTER, false, &HandleTitlesCurrentCommand, "", NULL }, + { "remove", SEC_GAMEMASTER, false, &HandleTitlesRemoveCommand, "", NULL }, + { "set", SEC_GAMEMASTER, false, NULL, "", titlesSetCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "titles", SEC_GAMEMASTER, false, NULL, "", titlesCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; } - Player * target = handler->getSelectedPlayer(); - if (!target) + static bool HandleTitlesCurrentCommand(ChatHandler* handler, const char* args) { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r + char* id_p = handler->extractKeyFromLink((char*)args,"Htitle"); + if (!id_p) + return false; - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + int32 id = atoi(id_p); + if (id <= 0) + { + handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); + handler->SetSentErrorMessage(true); + return false; + } - CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); - if (!titleInfo) - { - handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); - handler->SetSentErrorMessage(true); - return false; - } + Player * target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - std::string tNameLink = handler->GetNameLink(target); + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - target->SetTitle(titleInfo); // to be sure that title now known - target->SetUInt32Value(PLAYER_CHOSEN_TITLE,titleInfo->bit_index); + CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); + if (!titleInfo) + { + handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); + handler->SetSentErrorMessage(true); + return false; + } - handler->PSendSysMessage(LANG_TITLE_CURRENT_RES, id, titleInfo->name[handler->GetSessionDbcLocale()], tNameLink.c_str()); + std::string tNameLink = handler->GetNameLink(target); - return true; -} + target->SetTitle(titleInfo); // to be sure that title now known + target->SetUInt32Value(PLAYER_CHOSEN_TITLE,titleInfo->bit_index); -static bool HandleTitlesAddCommand(ChatHandler* handler, const char* args) -{ - // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r - char* id_p = handler->extractKeyFromLink((char*)args,"Htitle"); - if (!id_p) - return false; + handler->PSendSysMessage(LANG_TITLE_CURRENT_RES, id, titleInfo->name[handler->GetSessionDbcLocale()], tNameLink.c_str()); - int32 id = atoi(id_p); - if (id <= 0) - { - handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); - handler->SetSentErrorMessage(true); - return false; + return true; } - Player * target = handler->getSelectedPlayer(); - if (!target) + static bool HandleTitlesAddCommand(ChatHandler* handler, const char* args) { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r + char* id_p = handler->extractKeyFromLink((char*)args,"Htitle"); + if (!id_p) + return false; - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + int32 id = atoi(id_p); + if (id <= 0) + { + handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); + handler->SetSentErrorMessage(true); + return false; + } - CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); - if (!titleInfo) - { - handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); - handler->SetSentErrorMessage(true); - return false; - } + Player * target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - std::string tNameLink = handler->GetNameLink(target); + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - char const* targetName = target->GetName(); - char titleNameStr[80]; - snprintf(titleNameStr,80,titleInfo->name[handler->GetSessionDbcLocale()],targetName); + CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); + if (!titleInfo) + { + handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); + handler->SetSentErrorMessage(true); + return false; + } - target->SetTitle(titleInfo); - handler->PSendSysMessage(LANG_TITLE_ADD_RES, id, titleNameStr, tNameLink.c_str()); + std::string tNameLink = handler->GetNameLink(target); - return true; -} + char const* targetName = target->GetName(); + char titleNameStr[80]; + snprintf(titleNameStr,80,titleInfo->name[handler->GetSessionDbcLocale()],targetName); -static bool HandleTitlesRemoveCommand(ChatHandler* handler, const char* args) -{ - // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r - char* id_p = handler->extractKeyFromLink((char*)args,"Htitle"); - if (!id_p) - return false; + target->SetTitle(titleInfo); + handler->PSendSysMessage(LANG_TITLE_ADD_RES, id, titleNameStr, tNameLink.c_str()); - int32 id = atoi(id_p); - if (id <= 0) - { - handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); - handler->SetSentErrorMessage(true); - return false; + return true; } - Player * target = handler->getSelectedPlayer(); - if (!target) + static bool HandleTitlesRemoveCommand(ChatHandler* handler, const char* args) { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } - - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r + char* id_p = handler->extractKeyFromLink((char*)args,"Htitle"); + if (!id_p) + return false; - CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); - if (!titleInfo) - { - handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); - handler->SetSentErrorMessage(true); - return false; - } + int32 id = atoi(id_p); + if (id <= 0) + { + handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); + handler->SetSentErrorMessage(true); + return false; + } - target->SetTitle(titleInfo,true); + Player * target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - std::string tNameLink = handler->GetNameLink(target); + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - char const* targetName = target->GetName(); - char titleNameStr[80]; - snprintf(titleNameStr,80,titleInfo->name[handler->GetSessionDbcLocale()],targetName); + CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); + if (!titleInfo) + { + handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); + handler->SetSentErrorMessage(true); + return false; + } - handler->PSendSysMessage(LANG_TITLE_REMOVE_RES, id, titleNameStr, tNameLink.c_str()); + target->SetTitle(titleInfo,true); - if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE))) - { - target->SetUInt32Value(PLAYER_CHOSEN_TITLE,0); - handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET, tNameLink.c_str()); - } + std::string tNameLink = handler->GetNameLink(target); - return true; -} + char const* targetName = target->GetName(); + char titleNameStr[80]; + snprintf(titleNameStr,80,titleInfo->name[handler->GetSessionDbcLocale()],targetName); -//Edit Player KnownTitles -static bool HandleTitlesSetMaskCommand(ChatHandler* handler, const char* args) -{ - if (!*args) - return false; + handler->PSendSysMessage(LANG_TITLE_REMOVE_RES, id, titleNameStr, tNameLink.c_str()); - uint64 titles = 0; + if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE))) + { + target->SetUInt32Value(PLAYER_CHOSEN_TITLE,0); + handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET, tNameLink.c_str()); + } - sscanf((char*)args, UI64FMTD, &titles); + return true; + } - Player *target = handler->getSelectedPlayer(); - if (!target) + //Edit Player KnownTitles + static bool HandleTitlesSetMaskCommand(ChatHandler* handler, const char* args) { - handler->SendSysMessage(LANG_NO_CHAR_SELECTED); - handler->SetSentErrorMessage(true); - return false; - } + if (!*args) + return false; - // check online security - if (handler->HasLowerSecurity(target, 0)) - return false; + uint64 titles = 0; - uint64 titles2 = titles; + sscanf((char*)args, UI64FMTD, &titles); - for (uint32 i = 1; i < sCharTitlesStore.GetNumRows(); ++i) - if (CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i)) - titles2 &= ~(uint64(1) << tEntry->bit_index); + Player *target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } - titles &= ~titles2; // remove not existed titles + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; - target->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles); - handler->SendSysMessage(LANG_DONE); + uint64 titles2 = titles; - if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE))) - { - target->SetUInt32Value(PLAYER_CHOSEN_TITLE,0); - handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET,handler->GetNameLink(target).c_str()); - } + for (uint32 i = 1; i < sCharTitlesStore.GetNumRows(); ++i) + if (CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i)) + titles2 &= ~(uint64(1) << tEntry->bit_index); - return true; -} + titles &= ~titles2; // remove not existed titles + target->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles); + handler->SendSysMessage(LANG_DONE); + + if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE))) + { + target->SetUInt32Value(PLAYER_CHOSEN_TITLE,0); + handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET,handler->GetNameLink(target).c_str()); + } + + return true; + } }; void AddSC_titles_commandscript() diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index 3aac13b5911..ed09879e1b1 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -29,950 +29,948 @@ EndScriptData */ class wp_commandscript : public CommandScript { - public: - wp_commandscript() : CommandScript("wp_commandscript") { } +public: + wp_commandscript() : CommandScript("wp_commandscript") { } - ChatCommand* GetCommands() const - { - static ChatCommand wpCommandTable[] = - { - { "add", SEC_GAMEMASTER, false, &HandleWpAddCommand, "", NULL }, - { "event", SEC_GAMEMASTER, false, &HandleWpEventCommand, "", NULL }, - { "load", SEC_GAMEMASTER, false, &HandleWpLoadCommand, "", NULL }, - { "modify", SEC_GAMEMASTER, false, &HandleWpModifyCommand, "", NULL }, - { "unload", SEC_GAMEMASTER, false, &HandleWpUnLoadCommand, "", NULL }, - { "reload", SEC_ADMINISTRATOR, false, &HandleWpReloadCommand, "", NULL }, - { "show", SEC_GAMEMASTER, false, &HandleWpShowCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand commandTable[] = - { - { "wp", SEC_GAMEMASTER, false, NULL, "", wpCommandTable }, - { NULL, 0, false, NULL, "", NULL } - }; - return commandTable; - } - -/** - * 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 - */ -static bool HandleWpAddCommand(ChatHandler* handler, 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 = handler->getSelectedCreature(); - - if (!path_number) + ChatCommand* GetCommands() const { - 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."); - handler->PSendSysMessage("%s%s|r", "|cff00ff00", "New path started."); - } + static ChatCommand wpCommandTable[] = + { + { "add", SEC_GAMEMASTER, false, &HandleWpAddCommand, "", NULL }, + { "event", SEC_GAMEMASTER, false, &HandleWpEventCommand, "", NULL }, + { "load", SEC_GAMEMASTER, false, &HandleWpLoadCommand, "", NULL }, + { "modify", SEC_GAMEMASTER, false, &HandleWpModifyCommand, "", NULL }, + { "unload", SEC_GAMEMASTER, false, &HandleWpUnLoadCommand, "", NULL }, + { "reload", SEC_ADMINISTRATOR, false, &HandleWpReloadCommand, "", NULL }, + { "show", SEC_GAMEMASTER, false, &HandleWpShowCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "wp", SEC_GAMEMASTER, false, NULL, "", wpCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; } - else - pathid = atoi(path_number); - - // path_id -> ID of the Path - // point -> number of the waypoint (if not 0) - - if (!pathid) + /** + * 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 + */ + static bool HandleWpAddCommand(ChatHandler* handler, const char* args) { - sLog.outDebug("DEBUG: HandleWpAddCommand - Current creature haven't loaded path."); - handler->PSendSysMessage("%s%s|r", "|cffff33ff", "Current creature haven't loaded path."); - return true; - } + sLog.outDebug("DEBUG: HandleWpAddCommand"); - sLog.outDebug("DEBUG: HandleWpAddCommand - point == 0"); + // optional + char* path_number = NULL; + uint32 pathid = 0; - QueryResult result = WorldDatabase.PQuery("SELECT MAX(point) FROM waypoint_data WHERE id = '%u'",pathid); + if (*args) + path_number = strtok((char*)args, " "); - if (result) - point = (*result)[0].GetUInt32(); + uint32 point = 0; + Creature* target = handler->getSelectedCreature(); - Player* player = handler->GetSession()->GetPlayer(); - //Map *map = player->GetMap(); + 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."); + handler->PSendSysMessage("%s%s|r", "|cff00ff00", "New path started."); + } + } + else + pathid = atoi(path_number); - 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()); + // path_id -> ID of the Path + // point -> number of the waypoint (if not 0) - handler->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 + if (!pathid) + { + sLog.outDebug("DEBUG: HandleWpAddCommand - Current creature haven't loaded path."); + handler->PSendSysMessage("%s%s|r", "|cffff33ff", "Current creature haven't loaded path."); + return true; + } -static bool HandleWpLoadCommand(ChatHandler* handler, const char* args) -{ - if (!*args) - return false; + sLog.outDebug("DEBUG: HandleWpAddCommand - point == 0"); - // optional - char* path_number = NULL; + QueryResult result = WorldDatabase.PQuery("SELECT MAX(point) FROM waypoint_data WHERE id = '%u'",pathid); - if (*args) - path_number = strtok((char*)args, " "); + if (result) + point = (*result)[0].GetUInt32(); - uint32 pathid = 0; - uint32 guidlow = 0; - Creature* target = handler->getSelectedCreature(); + Player* player = handler->GetSession()->GetPlayer(); + //Map *map = player->GetMap(); - // Did player provide a path_id? - if (!path_number) - sLog.outDebug("DEBUG: HandleWpLoadPathCommand - No path number provided"); + 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()); - if (!target) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } + handler->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 - if (target->GetEntry() == 1) + static bool HandleWpLoadCommand(ChatHandler* handler, const char* args) { - handler->PSendSysMessage("%s%s|r", "|cffff33ff", "You want to load path to a waypoint? Aren't you?"); - handler->SetSentErrorMessage(true); - return false; - } + if (!*args) + return false; - pathid = atoi(path_number); + // optional + char* path_number = NULL; - if (!pathid) - { - handler->PSendSysMessage("%s%s|r", "|cffff33ff", "No vallid path number provided."); - return true; - } + if (*args) + path_number = strtok((char*)args, " "); - guidlow = target->GetDBTableGUIDLow(); - QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature_addon WHERE guid = '%u'",guidlow); + uint32 pathid = 0; + uint32 guidlow = 0; + Creature* target = handler->getSelectedCreature(); - 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); + // Did player provide a path_id? + if (!path_number) + sLog.outDebug("DEBUG: HandleWpLoadPathCommand - No path number provided"); - WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE, guidlow); + if (!target) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } - target->LoadPath(pathid); - target->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); - target->GetMotionMaster()->Initialize(); - target->MonsterSay("Path loaded.",0,0); + if (target->GetEntry() == 1) + { + handler->PSendSysMessage("%s%s|r", "|cffff33ff", "You want to load path to a waypoint? Aren't you?"); + handler->SetSentErrorMessage(true); + return false; + } - return true; -} + pathid = atoi(path_number); -static bool HandleWpReloadCommand(ChatHandler* handler, const char* args) -{ - if (!*args) - return false; + if (!pathid) + { + handler->PSendSysMessage("%s%s|r", "|cffff33ff", "No vallid path number provided."); + return true; + } - uint32 id = atoi(args); + guidlow = target->GetDBTableGUIDLow(); + QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature_addon WHERE guid = '%u'",guidlow); - if (!id) - return false; + 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); - handler->PSendSysMessage("%s%s|r|cff00ffff%u|r", "|cff00ff00", "Loading Path: ", id); - sWaypointMgr->UpdatePath(id); - return true; -} -static bool HandleWpUnLoadCommand(ChatHandler* handler, const char* /*args*/) -{ - uint32 guidlow = 0; - Creature* target = handler->getSelectedCreature(); + 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); - if (!target) - { - handler->PSendSysMessage("%s%s|r", "|cff33ffff", "You must select target."); return true; } - if (target->GetCreatureAddon()) + static bool HandleWpReloadCommand(ChatHandler* handler, const char* args) { - 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; - } - handler->PSendSysMessage("%s%s|r", "|cffff33ff", "Target have no loaded path."); - } - return true; -} - -static bool HandleWpEventCommand(ChatHandler* handler, const char* args) -{ - if (!*args) - return false; - - char* show_str = strtok((char*)args, " "); - std::string show = show_str; + if (!*args) + return false; - // Check - if ((show != "add") && (show != "mod") && (show != "del") && (show != "listid")) return false; + uint32 id = atoi(args); - char* arg_id = strtok(NULL, " "); - uint32 id = 0; + if (!id) + return false; - if (show == "add") + handler->PSendSysMessage("%s%s|r|cff00ffff%u|r", "|cff00ff00", "Loading Path: ", id); + sWaypointMgr->UpdatePath(id); + return true; + } + static bool HandleWpUnLoadCommand(ChatHandler* handler, const char* /*args*/) { - if (arg_id) - id = atoi(arg_id); + uint32 guidlow = 0; + Creature* target = handler->getSelectedCreature(); - if (id) + if (!target) { - QueryResult result = WorldDatabase.PQuery("SELECT id FROM waypoint_scripts WHERE guid = %u", id); + handler->PSendSysMessage("%s%s|r", "|cff33ffff", "You must select target."); + return true; + } - if (!result) + if (target->GetCreatureAddon()) + { + if (target->GetCreatureAddon()->path_id != 0) { - WorldDatabase.PExecute("INSERT INTO waypoint_scripts(guid)VALUES(%u)", id); - handler->PSendSysMessage("%s%s%u|r", "|cff00ff00", "Wp Event: New waypoint event added: ", id); + 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; } - else - handler->PSendSysMessage("|cff00ff00Wp Event: You have choosed an existing waypoint script guid: %u|r", id); + handler->PSendSysMessage("%s%s|r", "|cffff33ff", "Target have no loaded path."); } - 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); - handler->PSendSysMessage("%s%s%u|r", "|cff00ff00","Wp Event: New waypoint event added: |r|cff00ffff", id+1); - } - return true; } - if (show == "listid") + static bool HandleWpEventCommand(ChatHandler* handler, const char* args) { - if (!arg_id) - { - handler->PSendSysMessage("%s%s|r", "|cff33ffff","Wp Event: You must provide waypoint script id."); - return true; - } + if (!*args) + return false; - id = atoi(arg_id); + char* show_str = strtok((char*)args, " "); + std::string show = show_str; - uint32 a2, a3, a4, a5, a6; - float a8, a9, a10, a11; - char const* a7; + // Check + if ((show != "add") && (show != "mod") && (show != "del") && (show != "listid")) return false; - QueryResult result = WorldDatabase.PQuery("SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = %u", id); + char* arg_id = strtok(NULL, " "); + uint32 id = 0; - if (!result) + if (show == "add") { - handler->PSendSysMessage("%s%s%u|r", "|cff33ffff", "Wp Event: No waypoint scripts found on id: ", id); - return true; - } - - Field *fields; + if (arg_id) + id = atoi(arg_id); - 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(); - - handler->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 (id) + { + QueryResult result = WorldDatabase.PQuery("SELECT id FROM waypoint_scripts WHERE guid = %u", id); - if (show == "del") - { - id = atoi(arg_id); + if (!result) + { + WorldDatabase.PExecute("INSERT INTO waypoint_scripts(guid)VALUES(%u)", id); + handler->PSendSysMessage("%s%s%u|r", "|cff00ff00", "Wp Event: New waypoint event added: ", id); + } + else + handler->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); + handler->PSendSysMessage("%s%s%u|r", "|cff00ff00","Wp Event: New waypoint event added: |r|cff00ffff", id+1); + } - QueryResult result = WorldDatabase.PQuery("SELECT guid FROM waypoint_scripts WHERE guid = %u", id); + return true; + } - if (result) + if (show == "listid") { - WorldDatabase.PExecute("DELETE FROM waypoint_scripts WHERE guid = %u", id); - handler->PSendSysMessage("%s%s%u|r","|cff00ff00","Wp Event: Waypoint script removed: ", id); - } - else - handler->PSendSysMessage("|cffff33ffWp Event: ERROR: you have selected a non existing script: %u|r", id); + if (!arg_id) + { + handler->PSendSysMessage("%s%s|r", "|cff33ffff","Wp Event: You must provide waypoint script id."); + return true; + } - return true; - } + id = atoi(arg_id); - if (show == "mod") - { - if (!arg_id) - { - handler->SendSysMessage("|cffff33ffERROR: Waypoint script guid not present.|r"); - return true; - } + uint32 a2, a3, a4, a5, a6; + float a8, a9, a10, a11; + char const* a7; - id = atoi(arg_id); + QueryResult result = WorldDatabase.PQuery("SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = %u", id); - if (!id) - { - handler->SendSysMessage("|cffff33ffERROR: No vallid waypoint script id not present.|r"); - return true; - } + if (!result) + { + handler->PSendSysMessage("%s%s%u|r", "|cff33ffff", "Wp Event: No waypoint scripts found on id: ", id); + return true; + } - char* arg_2 = strtok(NULL," "); + Field *fields; - if (!arg_2) - { - handler->SendSysMessage("|cffff33ffERROR: No argument present.|r"); - return true; + 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(); + + handler->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()); } - 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")) + if (show == "del") { - handler->SendSysMessage("|cffff33ffERROR: No valid argument present.|r"); - return true; - } + id = atoi(arg_id); - char* arg_3; - std::string arg_str_2 = arg_2; - arg_3 = strtok(NULL," "); + 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); + handler->PSendSysMessage("%s%s%u|r","|cff00ff00","Wp Event: Waypoint script removed: ", id); + } + else + handler->PSendSysMessage("|cffff33ffWp Event: ERROR: you have selected a non existing script: %u|r", id); - if (!arg_3) - { - handler->SendSysMessage("|cffff33ffERROR: No additional argument present.|r"); return true; } - float coord; - - if (arg_str_2 == "setid") + if (show == "mod") { - uint32 newid = atoi(arg_3); - handler->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) + if (!arg_id) { - handler->SendSysMessage("|cffff33ffERROR: You have selected an non existing waypoint script guid.|r"); + handler->SendSysMessage("|cffff33ffERROR: Waypoint script guid not present.|r"); return true; } - if (arg_str_2 == "posx") + id = atoi(arg_id); + + if (!id) { - coord = (float)(atof(arg_3)); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET x='%f' WHERE guid='%u'", - coord, id); - handler->PSendSysMessage("|cff00ff00Waypoint script:|r|cff00ffff %u|r|cff00ff00 position_x updated.|r", id); + handler->SendSysMessage("|cffff33ffERROR: No vallid waypoint script id not present.|r"); return true; } - else if (arg_str_2 == "posy") + + char* arg_2 = strtok(NULL," "); + + if (!arg_2) { - coord = (float)(atof(arg_3)); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET y='%f' WHERE guid='%u'", - coord, id); - handler->PSendSysMessage("|cff00ff00Waypoint script: %u position_y updated.|r", id); + handler->SendSysMessage("|cffff33ffERROR: No argument present.|r"); return true; } - else if (arg_str_2 == "posz") + + 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")) { - coord = (float)(atof(arg_3)); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET z='%f' WHERE guid='%u'", - coord, id); - handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 position_z updated.|r", id); + handler->SendSysMessage("|cffff33ffERROR: No valid argument present.|r"); return true; } - else if (arg_str_2 == "orientation") + + char* arg_3; + std::string arg_str_2 = arg_2; + arg_3 = strtok(NULL," "); + + if (!arg_3) { - coord = (float)(atof(arg_3)); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET o='%f' WHERE guid='%u'", - coord, id); - handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 orientation updated.|r", id); + handler->SendSysMessage("|cffff33ffERROR: No additional argument present.|r"); return true; } - else if (arg_str_2 == "dataint") + + float coord; + + if (arg_str_2 == "setid") { - WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%u' WHERE guid='%u'", - arg_2, atoi(arg_3), id); - handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 dataint updated.|r", id); - return true; + uint32 newid = atoi(arg_3); + handler->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) + { + handler->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); + handler->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); + handler->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); + handler->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); + handler->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); + handler->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); + arg_2, arg_str_3.c_str(), id); + } } + handler->PSendSysMessage("%s%s|r|cff00ffff%u:|r|cff00ff00 %s %s|r","|cff00ff00","Waypoint script:", id, arg_2,"updated."); } - handler->PSendSysMessage("%s%s|r|cff00ffff%u:|r|cff00ff00 %s %s|r","|cff00ff00","Waypoint script:", id, arg_2,"updated."); + return true; } - return true; -} - -static bool HandleWpModifyCommand(ChatHandler* handler, 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) + static bool HandleWpModifyCommand(ChatHandler* handler, const char* args) { - return false; - } + sLog.outDebug("DEBUG: HandleWpModifyCommand"); - 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; - } + if (!*args) + return false; - // Next arg is: <PATHID> <WPNUM> <ARGUMENT> - char* arg_str = NULL; + // first arg: add del text emote spell waittime move + char* show_str = strtok((char*)args, " "); + if (!show_str) + { + return false; + } - // 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 = handler->getSelectedCreature(); + 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; + } - if (!target || target->GetEntry() != VISUAL_WAYPOINT) - { - handler->SendSysMessage("|cffff33ffERROR: You must select a waypoint.|r"); - return false; - } + // Next arg is: <PATHID> <WPNUM> <ARGUMENT> + char* arg_str = NULL; - sLog.outDebug("DEBUG: HandleWpModifyCommand - User did select an NPC"); - // The visual waypoint - Creature* wpCreature = NULL; - wpGuid = target->GetGUIDLow(); + // 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 = handler->getSelectedCreature(); - // Did the user select a visual spawnpoint? - if (wpGuid) - wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - // attempt check creature existence by DB data - else - { - handler->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 (!target || target->GetEntry() != VISUAL_WAYPOINT) + { + handler->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(); - if (!result) + // Did the user select a visual spawnpoint? + if (wpGuid) + wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); + // attempt check creature existence by DB data + else + { + handler->PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, wpGuid); + return false; + } + // User did select a visual waypoint? + // Check the creature + if (wpCreature->GetEntry() == VISUAL_WAYPOINT) { - sLog.outDebug("DEBUG: HandleWpModifyCommand - No waypoint found - used 'wpguid'"); - - handler->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); + 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'"); + + handler->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) + { handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid); return true; + } } - } - sLog.outDebug("DEBUG: HandleWpModifyCommand - After getting wpGuid"); + 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) - { - handler->PSendSysMessage(LANG_WAYPOINT_ARGUMENTREQ, show_str); - return false; - } + do + { + Field *fields = result->Fetch(); + pathid = fields[0].GetUInt32(); + point = fields[1].GetUInt32(); + } + while (result->NextRow()); - if (show == "del" && target) - { - handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid); + // 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, " "); + } - // wpCreature - Creature* wpCreature = NULL; + sLog.outDebug("DEBUG: HandleWpModifyCommand - Parameters parsed - now execute the command"); - if (wpGuid != 0) + // Check for argument + if (show != "del" && show != "move" && arg_str == NULL) { - wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - wpCreature->CombatStop(); - wpCreature->DeleteFromDB(); - wpCreature->AddObjectToRemoveList(); + handler->PSendSysMessage(LANG_WAYPOINT_ARGUMENTREQ, show_str); + return false; } - 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); - - handler->PSendSysMessage(LANG_WAYPOINT_REMOVED); - return true; - } // del - - if (show == "move" && target) - { - handler->PSendSysMessage("|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff%u|r", pathid); - - Player *chr = handler->GetSession()->GetPlayer(); - Map *map = chr->GetMap(); + if (show == "del" && target) { + handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid); + // wpCreature Creature* wpCreature = NULL; - // What to do: - // Move the visual spawnpoint - // Respawn the owner of the waypoints + if (wpGuid != 0) { wpCreature = handler->GetSession()->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())) + } + + 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); + + handler->PSendSysMessage(LANG_WAYPOINT_REMOVED); + return true; + } // del + + if (show == "move" && target) + { + handler->PSendSysMessage("|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff%u|r", pathid); + + Player *chr = handler->GetSession()->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) { - handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); - delete wpCreature2; - return false; + wpCreature = handler->GetSession()->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())) + { + handler->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); } - 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); + + handler->PSendSysMessage(LANG_WAYPOINT_CHANGED); } + return true; + } // move - 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); + const char *text = arg_str; - handler->PSendSysMessage(LANG_WAYPOINT_CHANGED); + 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); } - 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); + handler->PSendSysMessage(LANG_WAYPOINT_CHANGED_NO, show_str); + return true; } - handler->PSendSysMessage(LANG_WAYPOINT_CHANGED_NO, show_str); - return true; -} + static bool HandleWpShowCommand(ChatHandler* handler, const char* args) + { + sLog.outDebug("DEBUG: HandleWpShowCommand"); -static bool HandleWpShowCommand(ChatHandler* handler, const char* args) -{ - sLog.outDebug("DEBUG: HandleWpShowCommand"); + if (!*args) + return false; - if (!*args) - return false; + // first arg: on, off, first, last + char* show_str = strtok((char*)args, " "); + if (!show_str) + 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); - // 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 = handler->getSelectedCreature(); - uint32 pathid = 0; - Creature* target = handler->getSelectedCreature(); + // Did player provide a PathID? - // Did player provide a PathID? + if (!guid_str) + { + sLog.outDebug("DEBUG: HandleWpShowCommand: !guid_str"); + // No PathID provided + // -> Player must have selected a creature - if (!guid_str) - { - sLog.outDebug("DEBUG: HandleWpShowCommand: !guid_str"); - // No PathID provided - // -> Player must have selected a creature + if (!target) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } - if (!target) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - handler->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) + handler->SendSysMessage(LANG_WAYPOINT_CREATSELECTED); - 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) - handler->SendSysMessage(LANG_WAYPOINT_CREATSELECTED); - - pathid = atoi((char*)guid_str); - } + pathid = atoi((char*)guid_str); + } - sLog.outDebug("DEBUG: HandleWpShowCommand: danach"); + sLog.outDebug("DEBUG: HandleWpShowCommand: danach"); - std::string show = show_str; - uint32 Maxpoint; + std::string show = show_str; + uint32 Maxpoint; - sLog.outDebug("DEBUG: HandleWpShowCommand: PathID: %u", pathid); + sLog.outDebug("DEBUG: HandleWpShowCommand: PathID: %u", pathid); - //handler->PSendSysMessage("wpshow - show: %s", show); + //handler->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) + // Show info for the selected waypoint + if (show == "info") { - handler->PSendSysMessage(LANG_WAYPOINT_VP_SELECT); - handler->SetSentErrorMessage(true); - return false; - } + // Check if the user did specify a visual waypoint + if (target->GetEntry() != VISUAL_WAYPOINT) + { + handler->PSendSysMessage(LANG_WAYPOINT_VP_SELECT); + handler->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()); + QueryResult result = WorldDatabase.PQuery("SELECT id, point, delay, move_flag, action, action_chance FROM waypoint_data WHERE wpguid = %u", target->GetGUIDLow()); + + if (!result) + { + handler->SendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM); + return true; + } + + handler->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(); + + handler->PSendSysMessage("|cff00ff00Show info: for current point: |r|cff00ffff%u|r|cff00ff00, Path ID: |r|cff00ffff%u|r", point, pathid); + handler->PSendSysMessage("|cff00ff00Show info: delay: |r|cff00ffff%u|r", delay); + handler->PSendSysMessage("|cff00ff00Show info: Move flag: |r|cff00ffff%u|r", flag); + handler->PSendSysMessage("|cff00ff00Show info: Waypoint event: |r|cff00ffff%u|r", ev_id); + handler->PSendSysMessage("|cff00ff00Show info: Event chance: |r|cff00ffff%u|r", ev_chance); + } + while (result->NextRow()); - if (!result) - { - handler->SendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM); return true; } - handler->SendSysMessage("|cff00ffffDEBUG: wp show info:|r"); - do + if (show == "on") { - 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(); - - handler->PSendSysMessage("|cff00ff00Show info: for current point: |r|cff00ffff%u|r|cff00ff00, Path ID: |r|cff00ffff%u|r", point, pathid); - handler->PSendSysMessage("|cff00ff00Show info: delay: |r|cff00ffff%u|r", delay); - handler->PSendSysMessage("|cff00ff00Show info: Move flag: |r|cff00ffff%u|r", flag); - handler->PSendSysMessage("|cff00ff00Show info: Waypoint event: |r|cff00ffff%u|r", ev_id); - handler->PSendSysMessage("|cff00ff00Show info: Event chance: |r|cff00ffff%u|r", ev_chance); + QueryResult result = WorldDatabase.PQuery("SELECT point, position_x,position_y,position_z FROM waypoint_data WHERE id = '%u'", pathid); + + if (!result) + { + handler->SendSysMessage("|cffff33ffPath no found.|r"); + handler->SetSentErrorMessage(true); + return false; } - while (result->NextRow()); - return true; - } + handler->PSendSysMessage("|cff00ff00DEBUG: wp on, PathID: |cff00ffff%u|r", pathid); - if (show == "on") - { - QueryResult result = WorldDatabase.PQuery("SELECT point, position_x,position_y,position_z FROM waypoint_data WHERE id = '%u'", pathid); + // Delete all visuals for this NPC + QueryResult result2 = WorldDatabase.PQuery("SELECT wpguid FROM waypoint_data WHERE id = '%u' and wpguid <> 0", pathid); - if (!result) - { - handler->SendSysMessage("|cffff33ffPath no found.|r"); - handler->SetSentErrorMessage(true); - return false; - } + if (result2) + { + bool hasError = false; + do + { + Field *fields = result2->Fetch(); + uint32 wpguid = fields[0].GetUInt32(); + Creature* pCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpguid,VISUAL_WAYPOINT,HIGHGUID_UNIT)); + + if (!pCreature) + { + handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpguid); + hasError = true; + WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", wpguid); + } + else + { + pCreature->CombatStop(); + pCreature->DeleteFromDB(); + pCreature->AddObjectToRemoveList(); + } - handler->PSendSysMessage("|cff00ff00DEBUG: wp on, PathID: |cff00ffff%u|r", pathid); + } + while (result2->NextRow()); - // Delete all visuals for this NPC - QueryResult result2 = WorldDatabase.PQuery("SELECT wpguid FROM waypoint_data WHERE id = '%u' and wpguid <> 0", pathid); + if (hasError) + { + handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR1); + handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR2); + handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR3); + } + } - if (result2) - { - bool hasError = false; do { - Field *fields = result2->Fetch(); - uint32 wpguid = fields[0].GetUInt32(); - Creature* pCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpguid,VISUAL_WAYPOINT,HIGHGUID_UNIT)); + Field *fields = result->Fetch(); + uint32 point = fields[0].GetUInt32(); + float x = fields[1].GetFloat(); + float y = fields[2].GetFloat(); + float z = fields[3].GetFloat(); - if (!pCreature) + uint32 id = VISUAL_WAYPOINT; + + Player *chr = handler->GetSession()->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)) { - handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpguid); - hasError = true; - WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", wpguid); + handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); + delete wpCreature; + return false; } - else + + 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) { - pCreature->CombatStop(); - pCreature->DeleteFromDB(); - pCreature->AddObjectToRemoveList(); + wpCreature->SetDisplayId(target->GetDisplayId()); + wpCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); + wpCreature->SetLevel(point > STRONG_MAX_LEVEL ? STRONG_MAX_LEVEL : point); } - } - while (result2->NextRow()); + while (result->NextRow()); - if (hasError) - { - handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR1); - handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR2); - handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR3); - } + handler->SendSysMessage("|cff00ff00Showing the current creature's path.|r"); + return true; } - do + if (show == "first") { - Field *fields = result->Fetch(); - uint32 point = fields[0].GetUInt32(); - float x = fields[1].GetFloat(); - float y = fields[2].GetFloat(); - float z = fields[3].GetFloat(); + handler->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) + { + handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUND, pathid); + handler->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 = handler->GetSession()->GetPlayer(); - Map *map = chr->GetMap(); float o = chr->GetOrientation(); + Map *map = chr->GetMap(); - Creature* wpCreature = new Creature; - if (!wpCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o)) + Creature* pCreature = new Creature; + if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT),map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o)) { handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); - delete wpCreature; + delete pCreature; 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); + pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); + pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map); + map->Add(pCreature); if (target) { - wpCreature->SetDisplayId(target->GetDisplayId()); - wpCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); - wpCreature->SetLevel(point > STRONG_MAX_LEVEL ? STRONG_MAX_LEVEL : point); + pCreature->SetDisplayId(target->GetDisplayId()); + pCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); } - } - while (result->NextRow()); - handler->SendSysMessage("|cff00ff00Showing the current creature's path.|r"); - return true; - } - - if (show == "first") - { - handler->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) - { - handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUND, pathid); - handler->SetSentErrorMessage(true); - return false; + return true; } - 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 = handler->GetSession()->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)) + if (show == "last") { - handler->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); + handler->PSendSysMessage("|cff00ff00DEBUG: wp last, PathID: |r|cff00ffff%u|r", pathid); - if (target) - { - pCreature->SetDisplayId(target->GetDisplayId()); - pCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); - } + QueryResult result = WorldDatabase.PQuery("SELECT MAX(point) FROM waypoint_data WHERE id = '%u'",pathid); + if (result) + Maxpoint = (*result)[0].GetUInt32(); + else + Maxpoint = 0; - return true; - } + result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z FROM waypoint_data WHERE point ='%u' AND id = '%u'",Maxpoint, pathid); + if (!result) + { + handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDLAST, pathid); + handler->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; - if (show == "last") - { - handler->PSendSysMessage("|cff00ff00DEBUG: wp last, PathID: |r|cff00ffff%u|r", pathid); + Player *chr = handler->GetSession()->GetPlayer(); + float o = chr->GetOrientation(); + Map *map = chr->GetMap(); - QueryResult result = WorldDatabase.PQuery("SELECT MAX(point) FROM waypoint_data WHERE id = '%u'",pathid); - if (result) - Maxpoint = (*result)[0].GetUInt32(); - else - Maxpoint = 0; + Creature* pCreature = new Creature; + if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o)) + { + handler->PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id); + delete pCreature; + return false; + } - result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z FROM waypoint_data WHERE point ='%u' AND id = '%u'",Maxpoint, pathid); - if (!result) - { - handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDLAST, pathid); - handler->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 = handler->GetSession()->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)) - { - handler->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); - 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); + } - if (target) - { - pCreature->SetDisplayId(target->GetDisplayId()); - pCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); + return true; } - return true; - } - - if (show == "off") - { - QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE id = '%u'", 1); - if (!result) + if (show == "off") { - handler->SendSysMessage(LANG_WAYPOINT_VP_NOTFOUND); - handler->SetSentErrorMessage(true); - return false; - } - bool hasError = false; - do - { - Field *fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); - Creature* pCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(guid,VISUAL_WAYPOINT,HIGHGUID_UNIT)); - if (!pCreature) + QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE id = '%u'", 1); + if (!result) { - handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid); - hasError = true; - WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", guid); + handler->SendSysMessage(LANG_WAYPOINT_VP_NOTFOUND); + handler->SetSentErrorMessage(true); + return false; } - else + bool hasError = false; + do + { + Field *fields = result->Fetch(); + uint32 guid = fields[0].GetUInt32(); + Creature* pCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(guid,VISUAL_WAYPOINT,HIGHGUID_UNIT)); + if (!pCreature) + { + handler->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) { - pCreature->CombatStop(); - pCreature->DeleteFromDB(); - pCreature->AddObjectToRemoveList(); + handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR1); + handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR2); + handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR3); } - } - 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) - { - handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR1); - handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR2); - handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR3); + handler->SendSysMessage(LANG_WAYPOINT_VP_ALLREMOVED); + return true; } - handler->SendSysMessage(LANG_WAYPOINT_VP_ALLREMOVED); + handler->PSendSysMessage("|cffff33ffDEBUG: wpshow - no valid command found|r"); return true; } - - handler->PSendSysMessage("|cffff33ffDEBUG: wpshow - no valid command found|r"); - return true; -} - }; void AddSC_wp_commandscript() |