Merge pull request #3436 from Fredi/cleanup

Script/Commands: Codestyle and cleanups
This commit is contained in:
Machiavelli
2011-10-10 10:38:50 -07:00
7 changed files with 825 additions and 798 deletions
+92 -93
View File
@@ -60,7 +60,7 @@ public:
return commandTable; return commandTable;
} }
static bool HandleAccountAddonCommand(ChatHandler* handler, const char* args) static bool HandleAccountAddonCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
{ {
@@ -69,11 +69,11 @@ public:
return false; return false;
} }
char *szExp = strtok((char*)args, " "); char* exp = strtok((char*)args, " ");
uint32 account_id = handler->GetSession()->GetAccountId(); uint32 accountId = handler->GetSession()->GetAccountId();
int expansion = atoi(szExp); //get int anyway (0 if error) int expansion = atoi(exp); //get int anyway (0 if error)
if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION)) if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION))
{ {
handler->SendSysMessage(LANG_IMPROPER_VALUE); handler->SendSysMessage(LANG_IMPROPER_VALUE);
@@ -82,32 +82,28 @@ public:
} }
// No SQL injection // No SQL injection
LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, account_id); LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, accountId);
handler->PSendSysMessage(LANG_ACCOUNT_ADDON, expansion); handler->PSendSysMessage(LANG_ACCOUNT_ADDON, expansion);
return true; return true;
} }
/// Create an account /// Create an account
static bool HandleAccountCreateCommand(ChatHandler* handler, const char* args) static bool HandleAccountCreateCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
///- %Parse the command line arguments ///- %Parse the command line arguments
char *szAcc = strtok((char*)args, " "); char* accountName = strtok((char*)args, " ");
char *szPassword = strtok(NULL, " "); char* password = strtok(NULL, " ");
if (!szAcc || !szPassword) if (!accountName || !password)
return false; return false;
// normalized in AccountMgr::CreateAccount AccountOpResult result = AccountMgr::CreateAccount(std::string(accountName), std::string(password));
std::string account_name = szAcc;
std::string password = szPassword;
AccountOpResult result = AccountMgr::CreateAccount(account_name, password);
switch (result) switch (result)
{ {
case AOR_OK: case AOR_OK:
handler->PSendSysMessage(LANG_ACCOUNT_CREATED, account_name.c_str()); handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName);
break; break;
case AOR_NAME_TOO_LONG: case AOR_NAME_TOO_LONG:
handler->SendSysMessage(LANG_ACCOUNT_TOO_LONG); handler->SendSysMessage(LANG_ACCOUNT_TOO_LONG);
@@ -118,11 +114,11 @@ public:
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
case AOR_DB_INTERNAL_ERROR: case AOR_DB_INTERNAL_ERROR:
handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED_SQL_ERROR, account_name.c_str()); handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED_SQL_ERROR, accountName);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
default: default:
handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED, account_name.c_str()); handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED, accountName);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
@@ -131,29 +127,29 @@ public:
} }
/// Delete a user account and all associated characters in this realm /// 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 /// \todo This function has to be enhanced to respect the login/realm split (delete char, delete account chars in realm then delete account)
static bool HandleAccountDeleteCommand(ChatHandler* handler, const char* args) static bool HandleAccountDeleteCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
///- Get the account name from the command line ///- Get the account name from the command line
char *account_name_str=strtok ((char*)args, " "); char* account = strtok((char*)args, " ");
if (!account_name_str) if (!account)
return false; return false;
std::string account_name = account_name_str; std::string accountName = account;
if (!AccountMgr::normalizeString(account_name)) if (!AccountMgr::normalizeString(accountName))
{ {
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
uint32 account_id = AccountMgr::GetId(account_name); uint32 accountId = AccountMgr::GetId(accountName);
if (!account_id) if (!accountId)
{ {
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
@@ -161,25 +157,25 @@ public:
/// Commands not recommended call from chat, but support anyway /// Commands not recommended call from chat, but support anyway
/// can delete only for account with less security /// can delete only for account with less security
/// This is also reject self apply in fact /// This is also reject self apply in fact
if (handler->HasLowerSecurityAccount (NULL, account_id, true)) if (handler->HasLowerSecurityAccount(NULL, accountId, true))
return false; return false;
AccountOpResult result = AccountMgr::DeleteAccount(account_id); AccountOpResult result = AccountMgr::DeleteAccount(accountId);
switch (result) switch (result)
{ {
case AOR_OK: case AOR_OK:
handler->PSendSysMessage(LANG_ACCOUNT_DELETED, account_name.c_str()); handler->PSendSysMessage(LANG_ACCOUNT_DELETED, accountName.c_str());
break; break;
case AOR_NAME_NOT_EXIST: case AOR_NAME_NOT_EXIST:
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
case AOR_DB_INTERNAL_ERROR: case AOR_DB_INTERNAL_ERROR:
handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED_SQL_ERROR, account_name.c_str()); handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED_SQL_ERROR, accountName.c_str());
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
default: default:
handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED, account_name.c_str()); handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED, accountName.c_str());
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
@@ -188,7 +184,7 @@ public:
} }
/// Display info on users currently in the realm /// Display info on users currently in the realm
static bool HandleAccountOnlineListCommand(ChatHandler* handler, const char* /*args*/) static bool HandleAccountOnlineListCommand(ChatHandler* handler, char const* /*args*/)
{ {
///- Get the list of accounts ID logged to the realm ///- Get the list of accounts ID logged to the realm
QueryResult resultDB = CharacterDatabase.Query("SELECT name, account, map, zone FROM characters WHERE online > 0"); QueryResult resultDB = CharacterDatabase.Query("SELECT name, account, map, zone FROM characters WHERE online > 0");
@@ -218,6 +214,7 @@ public:
"LEFT JOIN account_access aa " "LEFT JOIN account_access aa "
"ON (a.id = aa.id) " "ON (a.id = aa.id) "
"WHERE a.id = '%u'", account); "WHERE a.id = '%u'", account);
if (resultLogin) if (resultLogin)
{ {
Field* fieldsLogin = resultLogin->Fetch(); Field* fieldsLogin = resultLogin->Fetch();
@@ -229,13 +226,13 @@ public:
else else
handler->PSendSysMessage(LANG_ACCOUNT_LIST_ERROR, name.c_str()); handler->PSendSysMessage(LANG_ACCOUNT_LIST_ERROR, name.c_str());
}while (resultDB->NextRow()); } while (resultDB->NextRow());
handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR); handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR);
return true; return true;
} }
static bool HandleAccountLockCommand(ChatHandler* handler, const char* args) static bool HandleAccountLockCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
{ {
@@ -244,15 +241,15 @@ public:
return false; return false;
} }
std::string argstr = (char*)args; std::string param = (char*)args;
if (argstr == "on") if (param == "on")
{ {
LoginDatabase.PExecute("UPDATE account SET locked = '1' WHERE id = '%d'", handler->GetSession()->GetAccountId()); LoginDatabase.PExecute("UPDATE account SET locked = '1' WHERE id = '%d'", handler->GetSession()->GetAccountId());
handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED); handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
return true; return true;
} }
if (argstr == "off") if (param == "off")
{ {
LoginDatabase.PExecute("UPDATE account SET locked = '0' WHERE id = '%d'", handler->GetSession()->GetAccountId()); LoginDatabase.PExecute("UPDATE account SET locked = '0' WHERE id = '%d'", handler->GetSession()->GetAccountId());
handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED); handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
@@ -264,7 +261,7 @@ public:
return false; return false;
} }
static bool HandleAccountPasswordCommand(ChatHandler* handler, const char* args) static bool HandleAccountPasswordCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
{ {
@@ -273,32 +270,32 @@ public:
return false; return false;
} }
char *old_pass = strtok((char*)args, " "); char* oldPassword = strtok((char*)args, " ");
char *new_pass = strtok(NULL, " "); char* newPassword = strtok(NULL, " ");
char *new_pass_c = strtok(NULL, " "); char* passwordConfirmation = strtok(NULL, " ");
if (!old_pass || !new_pass || !new_pass_c) if (!oldPassword || !newPassword || !passwordConfirmation)
{ {
handler->SendSysMessage(LANG_CMD_SYNTAX); handler->SendSysMessage(LANG_CMD_SYNTAX);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
if (!AccountMgr::CheckPassword(handler->GetSession()->GetAccountId(), std::string(old_pass))) if (!AccountMgr::CheckPassword(handler->GetSession()->GetAccountId(), std::string(oldPassword)))
{ {
handler->SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD); handler->SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
if (strcmp(new_pass, new_pass_c) != 0) if (strcmp(newPassword, passwordConfirmation) != 0)
{ {
handler->SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH); handler->SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
AccountOpResult result = AccountMgr::ChangePassword(handler->GetSession()->GetAccountId(), std::string(new_pass)); AccountOpResult result = AccountMgr::ChangePassword(handler->GetSession()->GetAccountId(), std::string(newPassword));
switch (result) switch (result)
{ {
case AOR_OK: case AOR_OK:
@@ -317,51 +314,51 @@ public:
return true; return true;
} }
static bool HandleAccountCommand(ChatHandler* handler, const char* /*args*/) static bool HandleAccountCommand(ChatHandler* handler, char const* /*args*/)
{ {
AccountTypes gmlevel = handler->GetSession()->GetSecurity(); AccountTypes gmLevel = handler->GetSession()->GetSecurity();
handler->PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(gmlevel)); handler->PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(gmLevel));
return true; return true;
} }
/// Set/Unset the expansion level for an account /// Set/Unset the expansion level for an account
static bool HandleAccountSetAddonCommand(ChatHandler* handler, const char *args) static bool HandleAccountSetAddonCommand(ChatHandler* handler, char const* args)
{ {
///- Get the command line arguments ///- Get the command line arguments
char *szAcc = strtok((char*)args, " "); char* account = strtok((char*)args, " ");
char *szExp = strtok(NULL, " "); char* exp = strtok(NULL, " ");
if (!szAcc) if (!account)
return false; return false;
std::string account_name; std::string accountName;
uint32 account_id; uint32 accountId;
if (!szExp) if (!exp)
{ {
Player* player = handler->getSelectedPlayer(); Player* player = handler->getSelectedPlayer();
if (!player) if (!player)
return false; return false;
account_id = player->GetSession()->GetAccountId(); accountId = player->GetSession()->GetAccountId();
AccountMgr::GetName(account_id, account_name); AccountMgr::GetName(accountId, accountName);
szExp = szAcc; exp = account;
} }
else else
{ {
///- Convert Account name to Upper Format ///- Convert Account name to Upper Format
account_name = szAcc; accountName = account;
if (!AccountMgr::normalizeString(account_name)) if (!AccountMgr::normalizeString(accountName))
{ {
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
account_id = AccountMgr::GetId(account_name); accountId = AccountMgr::GetId(accountName);
if (!account_id) if (!accountId)
{ {
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
@@ -370,21 +367,21 @@ public:
// Let set addon state only for lesser (strong) security level // Let set addon state only for lesser (strong) security level
// or to self account // or to self account
if (handler->GetSession() && handler->GetSession()->GetAccountId () != account_id && if (handler->GetSession() && handler->GetSession()->GetAccountId () != accountId &&
handler->HasLowerSecurityAccount (NULL, account_id, true)) handler->HasLowerSecurityAccount(NULL, accountId, true))
return false; return false;
int expansion = atoi(szExp); //get int anyway (0 if error) int expansion = atoi(exp); //get int anyway (0 if error)
if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION)) if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION))
return false; return false;
// No SQL injection // No SQL injection
LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, account_id); LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, accountId);
handler->PSendSysMessage(LANG_ACCOUNT_SETADDON, account_name.c_str(), account_id, expansion); handler->PSendSysMessage(LANG_ACCOUNT_SETADDON, accountName.c_str(), accountId, expansion);
return true; return true;
} }
static bool HandleAccountSetGmLevelCommand(ChatHandler* handler, const char *args) static bool HandleAccountSetGmLevelCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
@@ -433,16 +430,16 @@ public:
// handler->getSession() == NULL only for console // handler->getSession() == NULL only for console
targetAccountId = (isAccountNameGiven) ? AccountMgr::GetId(targetAccountName) : handler->getSelectedPlayer()->GetSession()->GetAccountId(); targetAccountId = (isAccountNameGiven) ? AccountMgr::GetId(targetAccountName) : handler->getSelectedPlayer()->GetSession()->GetAccountId();
int32 gmRealmID = (isAccountNameGiven) ? atoi(arg3) : atoi(arg2); int32 gmRealmID = (isAccountNameGiven) ? atoi(arg3) : atoi(arg2);
uint32 plSecurity; uint32 playerSecurity;
if (handler->GetSession()) if (handler->GetSession())
plSecurity = AccountMgr::GetSecurity(handler->GetSession()->GetAccountId(), gmRealmID); playerSecurity = AccountMgr::GetSecurity(handler->GetSession()->GetAccountId(), gmRealmID);
else else
plSecurity = SEC_CONSOLE; playerSecurity = SEC_CONSOLE;
// can set security level only for target with less security and to less security that we have // 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 // This is also reject self apply in fact
targetSecurity = AccountMgr::GetSecurity(targetAccountId, gmRealmID); targetSecurity = AccountMgr::GetSecurity(targetAccountId, gmRealmID);
if (targetSecurity >= plSecurity || gm >= plSecurity) if (targetSecurity >= playerSecurity || gm >= playerSecurity)
{ {
handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
@@ -450,7 +447,7 @@ public:
} }
// Check and abort if the target gm has a higher rank on one of the realms and the new realm is -1 // 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 && !AccountMgr::IsConsoleAccount(plSecurity)) if (gmRealmID == -1 && !AccountMgr::IsConsoleAccount(playerSecurity))
{ {
QueryResult result = LoginDatabase.PQuery("SELECT * FROM account_access WHERE id = '%u' AND gmlevel > '%d'", targetAccountId, gm); QueryResult result = LoginDatabase.PQuery("SELECT * FROM account_access WHERE id = '%u' AND gmlevel > '%d'", targetAccountId, gm);
if (result) if (result)
@@ -477,53 +474,54 @@ public:
if (gm != 0) if (gm != 0)
LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u', '%d', '%d')", targetAccountId, gm, realmID); LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u', '%d', '%d')", targetAccountId, gm, realmID);
handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm);
return true; return true;
} }
/// Set password for account /// Set password for account
static bool HandleAccountSetPasswordCommand(ChatHandler* handler, const char *args) static bool HandleAccountSetPasswordCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
///- Get the command line arguments ///- Get the command line arguments
char *szAccount = strtok ((char*)args, " "); char* account = strtok((char*)args, " ");
char *szPassword1 = strtok (NULL, " "); char* password = strtok(NULL, " ");
char *szPassword2 = strtok (NULL, " "); char* passwordConfirmation = strtok(NULL, " ");
if (!szAccount||!szPassword1 || !szPassword2) if (!account || !password || !passwordConfirmation)
return false; return false;
std::string account_name = szAccount; std::string accountName = account;
if (!AccountMgr::normalizeString(account_name)) if (!AccountMgr::normalizeString(accountName))
{ {
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
uint32 targetAccountId = AccountMgr::GetId(account_name); uint32 targetAccountId = AccountMgr::GetId(accountName);
if (!targetAccountId) if (!targetAccountId)
{ {
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
/// can set password only for target with less security /// can set password only for target with less security
/// This is also reject self apply in fact /// This is also reject self apply in fact
if (handler->HasLowerSecurityAccount (NULL, targetAccountId, true)) if (handler->HasLowerSecurityAccount(NULL, targetAccountId, true))
return false; return false;
if (strcmp(szPassword1, szPassword2)) if (strcmp(password, passwordConfirmation))
{ {
handler->SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH); handler->SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH);
handler->SetSentErrorMessage (true); handler->SetSentErrorMessage(true);
return false; return false;
} }
AccountOpResult result = AccountMgr::ChangePassword(targetAccountId, szPassword1); AccountOpResult result = AccountMgr::ChangePassword(targetAccountId, password);
switch (result) switch (result)
{ {
@@ -531,7 +529,7 @@ public:
handler->SendSysMessage(LANG_COMMAND_PASSWORD); handler->SendSysMessage(LANG_COMMAND_PASSWORD);
break; break;
case AOR_NAME_NOT_EXIST: case AOR_NAME_NOT_EXIST:
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
case AOR_PASS_TOO_LONG: case AOR_PASS_TOO_LONG:
@@ -543,6 +541,7 @@ public:
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
return true; return true;
} }
}; };
@@ -45,7 +45,7 @@ public:
return commandTable; return commandTable;
} }
static bool HandleAchievementAddCommand(ChatHandler* handler, const char *args) static bool HandleAchievementAddCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
@@ -53,8 +53,8 @@ public:
uint32 achievementId = atoi((char*)args); uint32 achievementId = atoi((char*)args);
if (!achievementId) if (!achievementId)
{ {
if (char* cId = handler->extractKeyFromLink((char*)args, "Hachievement")) if (char* id = handler->extractKeyFromLink((char*)args, "Hachievement"))
achievementId = atoi(cId); achievementId = atoi(id);
if (!achievementId) if (!achievementId)
return false; return false;
} }
@@ -67,8 +67,8 @@ public:
return false; return false;
} }
if (AchievementEntry const* pAE = GetAchievementStore()->LookupEntry(achievementId)) if (AchievementEntry const* achievementEntry = GetAchievementStore()->LookupEntry(achievementId))
target->CompletedAchievement(pAE); target->CompletedAchievement(achievementEntry);
return true; return true;
} }
+242 -197
View File
@@ -98,7 +98,7 @@ public:
return commandTable; return commandTable;
} }
static bool HandleDebugPlayCinematicCommand(ChatHandler* handler, const char* args) static bool HandleDebugPlayCinematicCommand(ChatHandler* handler, char const* args)
{ {
// USAGE: .debug play cinematic #cinematicid // USAGE: .debug play cinematic #cinematicid
// #cinematicid - ID decimal number from CinemaicSequences.dbc (1st column) // #cinematicid - ID decimal number from CinemaicSequences.dbc (1st column)
@@ -109,20 +109,20 @@ public:
return false; return false;
} }
uint32 dwId = atoi((char*)args); uint32 id = atoi((char*)args);
if (!sCinematicSequencesStore.LookupEntry(dwId)) if (!sCinematicSequencesStore.LookupEntry(id))
{ {
handler->PSendSysMessage(LANG_CINEMATIC_NOT_EXIST, dwId); handler->PSendSysMessage(LANG_CINEMATIC_NOT_EXIST, id);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
handler->GetSession()->GetPlayer()->SendCinematicStart(dwId); handler->GetSession()->GetPlayer()->SendCinematicStart(id);
return true; return true;
} }
static bool HandleDebugPlayMovieCommand(ChatHandler* handler, const char* args) static bool HandleDebugPlayMovieCommand(ChatHandler* handler, char const* args)
{ {
// USAGE: .debug play movie #movieid // USAGE: .debug play movie #movieid
// #movieid - ID decimal number from Movie.dbc (1st column) // #movieid - ID decimal number from Movie.dbc (1st column)
@@ -133,21 +133,21 @@ public:
return false; return false;
} }
uint32 dwId = atoi((char*)args); uint32 id = atoi((char*)args);
if (!sMovieStore.LookupEntry(dwId)) if (!sMovieStore.LookupEntry(id))
{ {
handler->PSendSysMessage(LANG_MOVIE_NOT_EXIST, dwId); handler->PSendSysMessage(LANG_MOVIE_NOT_EXIST, id);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
handler->GetSession()->GetPlayer()->SendMovieStart(dwId); handler->GetSession()->GetPlayer()->SendMovieStart(id);
return true; return true;
} }
//Play sound //Play sound
static bool HandleDebugPlaySoundCommand(ChatHandler* handler, const char* args) static bool HandleDebugPlaySoundCommand(ChatHandler* handler, char const* args)
{ {
// USAGE: .debug playsound #soundid // USAGE: .debug playsound #soundid
// #soundid - ID decimal number from SoundEntries.dbc (1st column) // #soundid - ID decimal number from SoundEntries.dbc (1st column)
@@ -158,11 +158,11 @@ public:
return false; return false;
} }
uint32 dwSoundId = atoi((char*)args); uint32 soundId = atoi((char*)args);
if (!sSoundEntriesStore.LookupEntry(dwSoundId)) if (!sSoundEntriesStore.LookupEntry(soundId))
{ {
handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId); handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
@@ -176,48 +176,48 @@ public:
} }
if (handler->GetSession()->GetPlayer()->GetSelection()) if (handler->GetSession()->GetPlayer()->GetSelection())
unit->PlayDistanceSound(dwSoundId, handler->GetSession()->GetPlayer()); unit->PlayDistanceSound(soundId, handler->GetSession()->GetPlayer());
else else
unit->PlayDirectSound(dwSoundId, handler->GetSession()->GetPlayer()); unit->PlayDirectSound(soundId, handler->GetSession()->GetPlayer());
handler->PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId); handler->PSendSysMessage(LANG_YOU_HEAR_SOUND, soundId);
return true; return true;
} }
static bool HandleDebugSendSpellFailCommand(ChatHandler* handler, const char* args) static bool HandleDebugSendSpellFailCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
char* px = strtok((char*)args, " "); char* result = strtok((char*)args, " ");
if (!px) if (!result)
return false; return false;
uint8 failnum = (uint8)atoi(px); uint8 failNum = (uint8)atoi(result);
if (failnum == 0 && *px != '0') if (failNum == 0 && *result != '0')
return false; return false;
char* p1 = strtok(NULL, " "); char* fail1 = strtok(NULL, " ");
uint8 failarg1 = p1 ? (uint8)atoi(p1) : 0; uint8 failArg1 = fail1 ? (uint8)atoi(fail1) : 0;
char* p2 = strtok(NULL, " "); char* fail2 = strtok(NULL, " ");
uint8 failarg2 = p2 ? (uint8)atoi(p2) : 0; uint8 failArg2 = fail2 ? (uint8)atoi(fail2) : 0;
WorldPacket data(SMSG_CAST_FAILED, 5); WorldPacket data(SMSG_CAST_FAILED, 5);
data << uint8(0); data << uint8(0);
data << uint32(133); data << uint32(133);
data << uint8(failnum); data << uint8(failNum);
if (p1 || p2) if (fail1 || fail2)
data << uint32(failarg1); data << uint32(failArg1);
if (p2) if (fail2)
data << uint32(failarg2); data << uint32(failArg2);
handler->GetSession()->SendPacket(&data); handler->GetSession()->SendPacket(&data);
return true; return true;
} }
static bool HandleDebugSendEquipErrorCommand(ChatHandler* handler, const char* args) static bool HandleDebugSendEquipErrorCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
@@ -227,7 +227,7 @@ public:
return true; return true;
} }
static bool HandleDebugSendSellErrorCommand(ChatHandler* handler, const char* args) static bool HandleDebugSendSellErrorCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
@@ -237,7 +237,7 @@ public:
return true; return true;
} }
static bool HandleDebugSendBuyErrorCommand(ChatHandler* handler, const char* args) static bool HandleDebugSendBuyErrorCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
@@ -247,7 +247,7 @@ public:
return true; return true;
} }
static bool HandleDebugSendOpcodeCommand(ChatHandler* handler, const char* /*args*/) static bool HandleDebugSendOpcodeCommand(ChatHandler* handler, char const* /*args*/)
{ {
Unit* unit = handler->getSelectedUnit(); Unit* unit = handler->getSelectedUnit();
Player* player = NULL; Player* player = NULL;
@@ -255,7 +255,9 @@ public:
player = handler->GetSession()->GetPlayer(); player = handler->GetSession()->GetPlayer();
else else
player = (Player*)unit; player = (Player*)unit;
if (!unit) unit = player;
if (!unit)
unit = player;
std::ifstream ifs("opcode.txt"); std::ifstream ifs("opcode.txt");
if (ifs.bad()) if (ifs.bad())
@@ -296,10 +298,8 @@ public:
} }
// regular data // regular data
else else
{
ifs.putback(commentToken[1]); ifs.putback(commentToken[1]);
} }
}
parsedStream.put(commentToken[0]); parsedStream.put(commentToken[0]);
} }
ifs.close(); ifs.close();
@@ -418,7 +418,7 @@ public:
return true; return true;
} }
static bool HandleDebugUpdateWorldStateCommand(ChatHandler* handler, const char* args) static bool HandleDebugUpdateWorldStateCommand(ChatHandler* handler, char const* args)
{ {
char* w = strtok((char*)args, " "); char* w = strtok((char*)args, " ");
char* s = strtok(NULL, " "); char* s = strtok(NULL, " ");
@@ -432,14 +432,16 @@ public:
return true; return true;
} }
static bool HandleDebugAreaTriggersCommand(ChatHandler* handler, const char* /*args*/) static bool HandleDebugAreaTriggersCommand(ChatHandler* handler, char const* /*args*/)
{ {
Player* player = handler->GetSession()->GetPlayer(); Player* player = handler->GetSession()->GetPlayer();
if (!player->isDebugAreaTriggers) if (!player->isDebugAreaTriggers)
{ {
handler->PSendSysMessage(LANG_DEBUG_AREATRIGGER_ON); handler->PSendSysMessage(LANG_DEBUG_AREATRIGGER_ON);
player->isDebugAreaTriggers = true; player->isDebugAreaTriggers = true;
} else { }
else
{
handler->PSendSysMessage(LANG_DEBUG_AREATRIGGER_OFF); handler->PSendSysMessage(LANG_DEBUG_AREATRIGGER_OFF);
player->isDebugAreaTriggers = false; player->isDebugAreaTriggers = false;
} }
@@ -447,12 +449,12 @@ public:
} }
//Send notification in channel //Send notification in channel
static bool HandleDebugSendChannelNotifyCommand(ChatHandler* handler, const char* args) static bool HandleDebugSendChannelNotifyCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
const char *name = "test"; char const* name = "test";
uint8 code = atoi(args); uint8 code = atoi(args);
WorldPacket data(SMSG_CHANNEL_NOTIFY, (1+10)); WorldPacket data(SMSG_CHANNEL_NOTIFY, (1+10));
@@ -465,12 +467,12 @@ public:
} }
//Send notification in chat //Send notification in chat
static bool HandleDebugSendChatMsgCommand(ChatHandler* handler, const char* args) static bool HandleDebugSendChatMsgCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
const char *msg = "testtest"; char const* msg = "testtest";
uint8 type = atoi(args); uint8 type = atoi(args);
WorldPacket data; WorldPacket data;
ChatHandler::FillMessageData(&data, handler->GetSession(), type, 0, "chan", handler->GetSession()->GetPlayer()->GetGUID(), msg, handler->GetSession()->GetPlayer()); ChatHandler::FillMessageData(&data, handler->GetSession(), type, 0, "chan", handler->GetSession()->GetPlayer()->GetGUID(), msg, handler->GetSession()->GetPlayer());
@@ -478,54 +480,64 @@ public:
return true; return true;
} }
static bool HandleDebugSendQuestPartyMsgCommand(ChatHandler* handler, const char* args) static bool HandleDebugSendQuestPartyMsgCommand(ChatHandler* handler, char const* args)
{ {
uint32 msg = atol((char*)args); uint32 msg = atol((char*)args);
handler->GetSession()->GetPlayer()->SendPushToPartyResponse(handler->GetSession()->GetPlayer(), msg); handler->GetSession()->GetPlayer()->SendPushToPartyResponse(handler->GetSession()->GetPlayer(), msg);
return true; return true;
} }
static bool HandleDebugGetLootRecipientCommand(ChatHandler* handler, const char* /*args*/) static bool HandleDebugGetLootRecipientCommand(ChatHandler* handler, char const* /*args*/)
{ {
Creature* target = handler->getSelectedCreature(); Creature* target = handler->getSelectedCreature();
if (!target) if (!target)
return false; return false;
handler->PSendSysMessage("Loot recipient for creature %s (GUID %u, DB GUID %u) is %s", target->GetName(), target->GetGUIDLow(), target->GetDBTableGUIDLow(), target->hasLootRecipient()?(target->GetLootRecipient()?target->GetLootRecipient()->GetName():"offline"):"no loot recipient"); handler->PSendSysMessage("Loot recipient for creature %s (GUID %u, DB GUID %u) is %s", target->GetName(), target->GetGUIDLow(), target->GetDBTableGUIDLow(), target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName() : "offline") : "no loot recipient");
return true; return true;
} }
static bool HandleDebugSendQuestInvalidMsgCommand(ChatHandler* handler, const char* args) static bool HandleDebugSendQuestInvalidMsgCommand(ChatHandler* handler, char const* args)
{ {
uint32 msg = atol((char*)args); uint32 msg = atol((char*)args);
handler->GetSession()->GetPlayer()->SendCanTakeQuestResponse(msg); handler->GetSession()->GetPlayer()->SendCanTakeQuestResponse(msg);
return true; return true;
} }
static bool HandleDebugGetItemStateCommand(ChatHandler* handler, const char* args) static bool HandleDebugGetItemStateCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
std::string state_str = args; std::string itemState = args;
ItemUpdateState state = ITEM_UNCHANGED; ItemUpdateState state = ITEM_UNCHANGED;
bool list_queue = false, check_all = false; bool listQueue = false;
if (state_str == "unchanged") state = ITEM_UNCHANGED; bool checkAll = false;
else if (state_str == "changed") state = ITEM_CHANGED;
else if (state_str == "new") state = ITEM_NEW; if (itemState == "unchanged")
else if (state_str == "removed") state = ITEM_REMOVED; state = ITEM_UNCHANGED;
else if (state_str == "queue") list_queue = true; else if (itemState == "changed")
else if (state_str == "check_all") check_all = true; state = ITEM_CHANGED;
else return false; else if (itemState == "new")
state = ITEM_NEW;
else if (itemState == "removed")
state = ITEM_REMOVED;
else if (itemState == "queue")
listQueue = true;
else if (itemState == "check_all")
checkAll = true;
else
return false;
Player* player = handler->getSelectedPlayer(); Player* player = handler->getSelectedPlayer();
if (!player) player = handler->GetSession()->GetPlayer(); if (!player)
player = handler->GetSession()->GetPlayer();
if (!list_queue && !check_all) if (!listQueue && !checkAll)
{ {
state_str = "The player has the following " + state_str + " items: "; itemState = "The player has the following " + itemState + " items: ";
handler->SendSysMessage(state_str.c_str()); handler->SendSysMessage(itemState.c_str());
for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i)
{ {
if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END)
@@ -546,60 +558,73 @@ public:
} }
} }
if (list_queue) if (listQueue)
{ {
std::vector<Item*> &updateQueue = player->GetItemUpdateQueue(); std::vector<Item*>& updateQueue = player->GetItemUpdateQueue();
for (size_t i = 0; i < updateQueue.size(); ++i) for (size_t i = 0; i < updateQueue.size(); ++i)
{ {
Item* item = updateQueue[i]; Item* item = updateQueue[i];
if (!item) continue; if (!item)
continue;
Bag* container = item->GetContainer(); Bag* container = item->GetContainer();
uint8 bag_slot = container ? container->GetSlot() : uint8(INVENTORY_SLOT_BAG_0); uint8 bagSlot = container ? container->GetSlot() : uint8(INVENTORY_SLOT_BAG_0);
std::string st; std::string st;
switch (item->GetState()) switch (item->GetState())
{ {
case ITEM_UNCHANGED: st = "unchanged"; break; case ITEM_UNCHANGED:
case ITEM_CHANGED: st = "changed"; break; st = "unchanged";
case ITEM_NEW: st = "new"; break; break;
case ITEM_REMOVED: st = "removed"; break; case ITEM_CHANGED:
st = "changed";
break;
case ITEM_NEW:
st = "new";
break;
case ITEM_REMOVED:
st = "removed";
break;
} }
handler->PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bag_slot, item->GetSlot(), item->GetGUIDLow(), st.c_str()); handler->PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bagSlot, item->GetSlot(), item->GetGUIDLow(), st.c_str());
} }
if (updateQueue.empty()) if (updateQueue.empty())
handler->PSendSysMessage("The player's updatequeue is empty"); handler->PSendSysMessage("The player's updatequeue is empty");
} }
if (check_all) if (checkAll)
{ {
bool error = false; bool error = false;
std::vector<Item*> &updateQueue = player->GetItemUpdateQueue(); std::vector<Item*>& updateQueue = player->GetItemUpdateQueue();
for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i)
{ {
if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END)
continue; continue;
Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if (!item) continue; if (!item)
continue;
if (item->GetSlot() != i) if (item->GetSlot() != i)
{ {
handler->PSendSysMessage("Item with slot %d and guid %d has an incorrect slot value: %d", i, item->GetGUIDLow(), item->GetSlot()); handler->PSendSysMessage("Item with slot %d and guid %d has an incorrect slot value: %d", i, item->GetGUIDLow(), item->GetSlot());
error = true; continue; error = true;
continue;
} }
if (item->GetOwnerGUID() != player->GetGUID()) if (item->GetOwnerGUID() != player->GetGUID())
{ {
handler->PSendSysMessage("The item with slot %d and itemguid %d does have non-matching owner guid (%d) and player guid (%d) !", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); handler->PSendSysMessage("The item with slot %d and itemguid %d does have non-matching owner guid (%d) and player guid (%d) !", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow());
error = true; continue; error = true;
continue;
} }
if (Bag* container = item->GetContainer()) if (Bag* container = item->GetContainer())
{ {
handler->PSendSysMessage("The item with slot %d and guid %d has a container (slot: %d, guid: %d) but shouldn't!", item->GetSlot(), item->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow()); handler->PSendSysMessage("The item with slot %d and guid %d has a container (slot: %d, guid: %d) but shouldn't!", item->GetSlot(), item->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow());
error = true; continue; error = true;
continue;
} }
if (item->IsInUpdateQueue()) if (item->IsInUpdateQueue())
@@ -608,25 +633,29 @@ public:
if (qp > updateQueue.size()) if (qp > updateQueue.size())
{ {
handler->PSendSysMessage("The item with slot %d and guid %d has its queuepos (%d) larger than the update queue size! ", item->GetSlot(), item->GetGUIDLow(), qp); handler->PSendSysMessage("The item with slot %d and guid %d has its queuepos (%d) larger than the update queue size! ", item->GetSlot(), item->GetGUIDLow(), qp);
error = true; continue; error = true;
continue;
} }
if (updateQueue[qp] == NULL) if (updateQueue[qp] == NULL)
{ {
handler->PSendSysMessage("The item with slot %d and guid %d has its queuepos (%d) pointing to NULL in the queue!", item->GetSlot(), item->GetGUIDLow(), qp); handler->PSendSysMessage("The item with slot %d and guid %d has its queuepos (%d) pointing to NULL in the queue!", item->GetSlot(), item->GetGUIDLow(), qp);
error = true; continue; error = true;
continue;
} }
if (updateQueue[qp] != item) if (updateQueue[qp] != item)
{ {
handler->PSendSysMessage("The item with slot %d and guid %d 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 with slot %d and guid %d 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; error = true;
continue;
} }
} }
else if (item->GetState() != ITEM_UNCHANGED) else if (item->GetState() != ITEM_UNCHANGED)
{ {
handler->PSendSysMessage("The item with slot %d and guid %d is not in queue but should be (state: %d)!", item->GetSlot(), item->GetGUIDLow(), item->GetState()); handler->PSendSysMessage("The item with slot %d and guid %d is not in queue but should be (state: %d)!", item->GetSlot(), item->GetGUIDLow(), item->GetState());
error = true; continue; error = true;
continue;
} }
if (Bag* bag = item->ToBag()) if (Bag* bag = item->ToBag())
@@ -634,31 +663,36 @@ public:
for (uint8 j = 0; j < bag->GetBagSize(); ++j) for (uint8 j = 0; j < bag->GetBagSize(); ++j)
{ {
Item* item2 = bag->GetItemByPos(j); Item* item2 = bag->GetItemByPos(j);
if (!item2) continue; if (!item2)
continue;
if (item2->GetSlot() != j) if (item2->GetSlot() != j)
{ {
handler->PSendSysMessage("The item in bag %d and slot %d (guid: %d) has an incorrect slot value: %d", bag->GetSlot(), j, item2->GetGUIDLow(), item2->GetSlot()); handler->PSendSysMessage("The item in bag %d and slot %d (guid: %d) has an incorrect slot value: %d", bag->GetSlot(), j, item2->GetGUIDLow(), item2->GetSlot());
error = true; continue; error = true;
continue;
} }
if (item2->GetOwnerGUID() != player->GetGUID()) if (item2->GetOwnerGUID() != player->GetGUID())
{ {
handler->PSendSysMessage("The item in bag %d at slot %d and with itemguid %d, the owner's guid (%d) and the player's guid (%d) don't match!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID()), player->GetGUIDLow()); handler->PSendSysMessage("The item in bag %d at slot %d and with itemguid %d, the owner's guid (%d) and the player's guid (%d) don't match!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID()), player->GetGUIDLow());
error = true; continue; error = true;
continue;
} }
Bag* container = item2->GetContainer(); Bag* container = item2->GetContainer();
if (!container) if (!container)
{ {
handler->PSendSysMessage("The item in bag %d at slot %d with guid %d has no container!", bag->GetSlot(), item2->GetSlot(), item2->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; error = true;
continue;
} }
if (container != bag) if (container != bag)
{ {
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("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; error = true;
continue;
} }
if (item2->IsInUpdateQueue()) if (item2->IsInUpdateQueue())
@@ -667,25 +701,29 @@ public:
if (qp > updateQueue.size()) if (qp > updateQueue.size())
{ {
handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp); handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp);
error = true; continue; error = true;
continue;
} }
if (updateQueue[qp] == NULL) if (updateQueue[qp] == NULL)
{ {
handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) that points to NULL in the queue!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp); handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) that points to NULL in the queue!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp);
error = true; continue; error = true;
continue;
} }
if (updateQueue[qp] != item2) if (updateQueue[qp] != item2)
{ {
handler->PSendSysMessage("The item in bag %d at slot %d having guid %d 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()); handler->PSendSysMessage("The item in bag %d at slot %d having guid %d 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; error = true;
continue;
} }
} }
else if (item2->GetState() != ITEM_UNCHANGED) else if (item2->GetState() != ITEM_UNCHANGED)
{ {
handler->PSendSysMessage("The item in bag %d at slot %d having guid %d is not in queue but should be (state: %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), item2->GetState()); handler->PSendSysMessage("The item in bag %d at slot %d having guid %d is not in queue but should be (state: %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), item2->GetState());
error = true; continue; error = true;
continue;
} }
} }
} }
@@ -694,33 +732,40 @@ public:
for (size_t i = 0; i < updateQueue.size(); ++i) for (size_t i = 0; i < updateQueue.size(); ++i)
{ {
Item* item = updateQueue[i]; Item* item = updateQueue[i];
if (!item) continue; if (!item)
continue;
if (item->GetOwnerGUID() != player->GetGUID()) if (item->GetOwnerGUID() != player->GetGUID())
{ {
handler->PSendSysMessage("queue(" SIZEFMTD "): For the item with guid %d, the owner's guid (%d) and the player's guid (%d) don't match!", i, item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); handler->PSendSysMessage("queue(" SIZEFMTD "): For the item with guid %d, the owner's guid (%d) and the player's guid (%d) don't match!", i, item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow());
error = true; continue; error = true;
continue;
} }
if (item->GetQueuePos() != i) if (item->GetQueuePos() != i)
{ {
handler->PSendSysMessage("queue(" SIZEFMTD "): For the item with guid %d, the queuepos doesn't match it's position in the queue!", i, item->GetGUIDLow()); handler->PSendSysMessage("queue(" SIZEFMTD "): For the item with guid %d, the queuepos doesn't match it's position in the queue!", i, item->GetGUIDLow());
error = true; continue; error = true;
continue;
} }
if (item->GetState() == ITEM_REMOVED) continue; if (item->GetState() == ITEM_REMOVED)
continue;
Item* test = player->GetItemByPos(item->GetBagSlot(), item->GetSlot()); Item* test = player->GetItemByPos(item->GetBagSlot(), item->GetSlot());
if (test == NULL) 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 any item at that position!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow()); handler->PSendSysMessage("queue(" SIZEFMTD "): The bag(%d) and slot(%d) values for the item with guid %d are incorrect, the player doesn't have any item at that position!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow());
error = true; continue; error = true;
continue;
} }
if (test != item) if (test != item)
{ {
handler->PSendSysMessage("queue(" SIZEFMTD "): The bag(%d) and slot(%d) values for the item with guid %d are incorrect, an item which guid is %d is there instead!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow()); handler->PSendSysMessage("queue(" SIZEFMTD "): The bag(%d) and slot(%d) values for the item with guid %d are incorrect, an item which guid is %d is there instead!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow());
error = true; continue; error = true;
continue;
} }
} }
if (!error) if (!error)
@@ -730,54 +775,54 @@ public:
return true; return true;
} }
static bool HandleDebugBattlegroundCommand(ChatHandler* /*handler*/, const char* /*args*/) static bool HandleDebugBattlegroundCommand(ChatHandler* /*handler*/, char const* /*args*/)
{ {
sBattlegroundMgr->ToggleTesting(); sBattlegroundMgr->ToggleTesting();
return true; return true;
} }
static bool HandleDebugArenaCommand(ChatHandler* /*handler*/, const char* /*args*/) static bool HandleDebugArenaCommand(ChatHandler* /*handler*/, char const* /*args*/)
{ {
sBattlegroundMgr->ToggleArenaTesting(); sBattlegroundMgr->ToggleArenaTesting();
return true; return true;
} }
static bool HandleDebugThreatListCommand(ChatHandler* handler, const char* /*args*/) static bool HandleDebugThreatListCommand(ChatHandler* handler, char const* /*args*/)
{ {
Creature* target = handler->getSelectedCreature(); Creature* target = handler->getSelectedCreature();
if (!target || target->isTotem() || target->isPet()) if (!target || target->isTotem() || target->isPet())
return false; return false;
std::list<HostileReference*>& tlist = target->getThreatManager().getThreatList(); std::list<HostileReference*>& threatList = target->getThreatManager().getThreatList();
std::list<HostileReference*>::iterator itr; std::list<HostileReference*>::iterator itr;
uint32 cnt = 0; uint32 count = 0;
handler->PSendSysMessage("Threat list of %s (guid %u)", target->GetName(), target->GetGUIDLow()); handler->PSendSysMessage("Threat list of %s (guid %u)", target->GetName(), target->GetGUIDLow());
for (itr = tlist.begin(); itr != tlist.end(); ++itr) for (itr = threatList.begin(); itr != threatList.end(); ++itr)
{ {
Unit* unit = (*itr)->getTarget(); Unit* unit = (*itr)->getTarget();
if (!unit) if (!unit)
continue; continue;
++cnt; ++count;
handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", cnt, unit->GetName(), unit->GetGUIDLow(), (*itr)->getThreat()); handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName(), unit->GetGUIDLow(), (*itr)->getThreat());
} }
handler->SendSysMessage("End of threat list."); handler->SendSysMessage("End of threat list.");
return true; return true;
} }
static bool HandleDebugHostileRefListCommand(ChatHandler* handler, const char* /*args*/) static bool HandleDebugHostileRefListCommand(ChatHandler* handler, char const* /*args*/)
{ {
Unit* target = handler->getSelectedUnit(); Unit* target = handler->getSelectedUnit();
if (!target) if (!target)
target = handler->GetSession()->GetPlayer(); target = handler->GetSession()->GetPlayer();
HostileReference* ref = target->getHostileRefManager().getFirst(); HostileReference* ref = target->getHostileRefManager().getFirst();
uint32 cnt = 0; uint32 count = 0;
handler->PSendSysMessage("Hostil reference list of %s (guid %u)", target->GetName(), target->GetGUIDLow()); handler->PSendSysMessage("Hostil reference list of %s (guid %u)", target->GetName(), target->GetGUIDLow());
while (ref) while (ref)
{ {
if (Unit* unit = ref->getSource()->getOwner()) if (Unit* unit = ref->getSource()->getOwner())
{ {
++cnt; ++count;
handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", cnt, unit->GetName(), unit->GetGUIDLow(), ref->getThreat()); handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", count, unit->GetName(), unit->GetGUIDLow(), ref->getThreat());
} }
ref = ref->next(); ref = ref->next();
} }
@@ -785,7 +830,7 @@ public:
return true; return true;
} }
static bool HandleDebugSetVehicleIdCommand(ChatHandler* handler, const char* args) static bool HandleDebugSetVehicleIdCommand(ChatHandler* handler, char const* args)
{ {
Unit* target = handler->getSelectedUnit(); Unit* target = handler->getSelectedUnit();
if (!target || target->IsVehicle()) if (!target || target->IsVehicle())
@@ -804,7 +849,7 @@ public:
return true; return true;
} }
static bool HandleDebugEnterVehicleCommand(ChatHandler* handler, const char* args) static bool HandleDebugEnterVehicleCommand(ChatHandler* handler, char const* args)
{ {
Unit* target = handler->getSelectedUnit(); Unit* target = handler->getSelectedUnit();
if (!target || !target->IsVehicle()) if (!target || !target->IsVehicle())
@@ -839,7 +884,7 @@ public:
return true; return true;
} }
static bool HandleDebugSpawnVehicleCommand(ChatHandler* handler, const char* args) static bool HandleDebugSpawnVehicleCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
@@ -885,7 +930,7 @@ public:
return true; return true;
} }
static bool HandleDebugSendLargePacketCommand(ChatHandler* handler, const char* /*args*/) static bool HandleDebugSendLargePacketCommand(ChatHandler* handler, char const* /*args*/)
{ {
const char* stuffingString = "This is a dummy string to push the packet's size beyond 128000 bytes. "; const char* stuffingString = "This is a dummy string to push the packet's size beyond 128000 bytes. ";
std::ostringstream ss; std::ostringstream ss;
@@ -895,7 +940,7 @@ public:
return true; return true;
} }
static bool HandleDebugSendSetPhaseShiftCommand(ChatHandler* handler, const char* args) static bool HandleDebugSendSetPhaseShiftCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
@@ -905,7 +950,7 @@ public:
return true; return true;
} }
static bool HandleDebugGetItemValueCommand(ChatHandler* handler, const char* args) static bool HandleDebugGetItemValueCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
@@ -934,7 +979,7 @@ public:
return true; return true;
} }
static bool HandleDebugSetItemValueCommand(ChatHandler* handler, const char* args) static bool HandleDebugSetItemValueCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
@@ -963,7 +1008,7 @@ public:
return true; return true;
} }
static bool HandleDebugItemExpireCommand(ChatHandler* handler, const char* args) static bool HandleDebugItemExpireCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
@@ -986,17 +1031,17 @@ public:
} }
//show animation //show animation
static bool HandleDebugAnimCommand(ChatHandler* handler, const char* args) static bool HandleDebugAnimCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
uint32 anim_id = atoi((char*)args); uint32 animId = atoi((char*)args);
handler->GetSession()->GetPlayer()->HandleEmoteCommand(anim_id); handler->GetSession()->GetPlayer()->HandleEmoteCommand(animId);
return true; return true;
} }
static bool HandleDebugSetAuraStateCommand(ChatHandler* handler, const char* args) static bool HandleDebugSetAuraStateCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
{ {
@@ -1026,16 +1071,16 @@ public:
return true; return true;
} }
static bool HandleDebugSetValueCommand(ChatHandler* handler, const char* args) static bool HandleDebugSetValueCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
char* px = strtok((char*)args, " "); char* x = strtok((char*)args, " ");
char* py = strtok(NULL, " "); char* y = strtok(NULL, " ");
char* pz = strtok(NULL, " "); char* z = strtok(NULL, " ");
if (!px || !py) if (!x || !y)
return false; return false;
WorldObject* target = handler->getSelectedObject(); WorldObject* target = handler->getSelectedObject();
@@ -1048,41 +1093,42 @@ public:
uint64 guid = target->GetGUID(); uint64 guid = target->GetGUID();
uint32 Opcode = (uint32)atoi(px); uint32 opcode = (uint32)atoi(x);
if (Opcode >= target->GetValuesCount()) if (opcode >= target->GetValuesCount())
{ {
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, GUID_LOPART(guid), target->GetValuesCount());
return false; return false;
} }
bool isint32 = true; bool isInt32 = true;
if (pz) if (z)
isint32 = (bool)atoi(pz); isInt32 = (bool)atoi(z);
if (isint32)
if (isInt32)
{ {
uint32 iValue = (uint32)atoi(py); uint32 value = (uint32)atoi(y);
target->SetUInt32Value(Opcode, iValue); target->SetUInt32Value(opcode , value);
handler->PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue); handler->PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), opcode, value);
} }
else else
{ {
float fValue = (float)atof(py); float value = (float)atof(y);
target->SetFloatValue(Opcode, fValue); target->SetFloatValue(opcode , value);
handler->PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue); handler->PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), opcode, value);
} }
return true; return true;
} }
static bool HandleDebugGetValueCommand(ChatHandler* handler, const char* args) static bool HandleDebugGetValueCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
char* px = strtok((char*)args, " "); char* x = strtok((char*)args, " ");
char* pz = strtok(NULL, " "); char* z = strtok(NULL, " ");
if (!px) if (!x)
return false; return false;
Unit* target = handler->getSelectedUnit(); Unit* target = handler->getSelectedUnit();
@@ -1095,62 +1141,62 @@ public:
uint64 guid = target->GetGUID(); uint64 guid = target->GetGUID();
uint32 Opcode = (uint32)atoi(px); uint32 opcode = (uint32)atoi(x);
if (Opcode >= target->GetValuesCount()) if (opcode >= target->GetValuesCount())
{ {
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, GUID_LOPART(guid), target->GetValuesCount());
return false; return false;
} }
bool isint32 = true; bool isInt32 = true;
if (pz) if (z)
isint32 = (bool)atoi(pz); isInt32 = (bool)atoi(z);
if (isint32) if (isInt32)
{ {
uint32 iValue = target->GetUInt32Value(Opcode); uint32 value = target->GetUInt32Value(opcode);
handler->PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue); handler->PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), opcode, value);
} }
else else
{ {
float fValue = target->GetFloatValue(Opcode); float value = target->GetFloatValue(opcode);
handler->PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue); handler->PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), opcode, value);
} }
return true; return true;
} }
static bool HandleDebugMod32ValueCommand(ChatHandler* handler, const char* args) static bool HandleDebugMod32ValueCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
char* px = strtok((char*)args, " "); char* x = strtok((char*)args, " ");
char* py = strtok(NULL, " "); char* y = strtok(NULL, " ");
if (!px || !py) if (!x || !y)
return false; return false;
uint32 Opcode = (uint32)atoi(px); uint32 opcode = (uint32)atoi(x);
int Value = atoi(py); int value = atoi(y);
if (Opcode >= handler->GetSession()->GetPlayer()->GetValuesCount()) if (opcode >= handler->GetSession()->GetPlayer()->GetValuesCount())
{ {
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, handler->GetSession()->GetPlayer()->GetGUIDLow(), handler->GetSession()->GetPlayer()->GetValuesCount()); handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, handler->GetSession()->GetPlayer()->GetGUIDLow(), handler->GetSession()->GetPlayer()->GetValuesCount());
return false; return false;
} }
int CurrentValue = (int)handler->GetSession()->GetPlayer()->GetUInt32Value(Opcode); int currentValue = (int)handler->GetSession()->GetPlayer()->GetUInt32Value(opcode);
CurrentValue += Value; currentValue += value;
handler->GetSession()->GetPlayer()->SetUInt32Value(Opcode, (uint32)CurrentValue); handler->GetSession()->GetPlayer()->SetUInt32Value(opcode , (uint32)currentValue);
handler->PSendSysMessage(LANG_CHANGE_32BIT_FIELD, Opcode, CurrentValue); handler->PSendSysMessage(LANG_CHANGE_32BIT_FIELD, opcode, currentValue);
return true; return true;
} }
static bool HandleDebugUpdateCommand(ChatHandler* handler, const char* args) static bool HandleDebugUpdateCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
@@ -1158,49 +1204,48 @@ public:
uint32 updateIndex; uint32 updateIndex;
uint32 value; uint32 value;
char* pUpdateIndex = strtok((char*)args, " "); char* index = strtok((char*)args, " ");
Unit* chr = handler->getSelectedUnit(); Unit* unit = handler->getSelectedUnit();
if (chr == NULL) if (!unit)
{ {
handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
if (!pUpdateIndex) if (!index)
{
return true; return true;
}
updateIndex = atoi(pUpdateIndex); updateIndex = atoi(index);
//check updateIndex //check updateIndex
if (chr->GetTypeId() == TYPEID_PLAYER) if (unit->GetTypeId() == TYPEID_PLAYER)
{ {
if (updateIndex >= PLAYER_END) return true; if (updateIndex >= PLAYER_END)
} return true;
else
{
if (updateIndex >= UNIT_END) return true;
} }
else if (updateIndex >= UNIT_END)
return true;
char* pvalue = strtok(NULL, " "); char* val = strtok(NULL, " ");
if (!pvalue) if (!val)
{ {
value=chr->GetUInt32Value(updateIndex); value = unit->GetUInt32Value(updateIndex);
handler->PSendSysMessage(LANG_UPDATE, chr->GetGUIDLow(), updateIndex, value); handler->PSendSysMessage(LANG_UPDATE, unit->GetGUIDLow(), updateIndex, value);
return true; return true;
} }
value=atoi(pvalue); value = atoi(val);
handler->PSendSysMessage(LANG_UPDATE_CHANGE, chr->GetGUIDLow(), updateIndex, value); handler->PSendSysMessage(LANG_UPDATE_CHANGE, unit->GetGUIDLow(), updateIndex, value);
chr->SetUInt32Value(updateIndex, value); unit->SetUInt32Value(updateIndex, value);
return true; return true;
} }
static bool HandleDebugSet32BitCommand(ChatHandler* handler, const char* args)
static bool HandleDebugSet32BitCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
@@ -1213,21 +1258,21 @@ public:
return false; return false;
} }
char* px = strtok((char*)args, " "); char* x = strtok((char*)args, " ");
char* py = strtok(NULL, " "); char* y = strtok(NULL, " ");
if (!px || !py) if (!x || !y)
return false; return false;
uint32 Opcode = (uint32)atoi(px); uint32 opcode = (uint32)atoi(x);
uint32 Value = (uint32)atoi(py); uint32 val = (uint32)atoi(y);
if (Value > 32) //uint32 = 32 bits if (val > 32) //uint32 = 32 bits
return false; return false;
uint32 iValue = Value ? 1 << (Value - 1) : 0; uint32 value = val ? 1 << (val - 1) : 0;
target->SetUInt32Value(Opcode, iValue); target->SetUInt32Value(opcode, value);
handler->PSendSysMessage(LANG_SET_32BIT_FIELD, Opcode, iValue); handler->PSendSysMessage(LANG_SET_32BIT_FIELD, opcode, value);
return true; return true;
} }
}; };
+34 -34
View File
@@ -49,7 +49,7 @@ public:
return commandTable; return commandTable;
} }
static bool HandleEventActiveListCommand(ChatHandler* handler, const char* /*args*/) static bool HandleEventActiveListCommand(ChatHandler* handler, char const* /*args*/)
{ {
uint32 counter = 0; uint32 counter = 0;
@@ -60,13 +60,13 @@ public:
for (GameEventMgr::ActiveEvents::const_iterator itr = activeEvents.begin(); itr != activeEvents.end(); ++itr) for (GameEventMgr::ActiveEvents::const_iterator itr = activeEvents.begin(); itr != activeEvents.end(); ++itr)
{ {
uint32 event_id = *itr; uint32 eventId = *itr;
GameEventData const& eventData = events[event_id]; GameEventData const& eventData = events[eventId];
if (handler->GetSession()) if (handler->GetSession())
handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, event_id, event_id, eventData.description.c_str(), active); handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, eventId, eventId, eventData.description.c_str(), active);
else else
handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, event_id, eventData.description.c_str(), active); handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, eventId, eventData.description.c_str(), active);
++counter; ++counter;
} }
@@ -78,28 +78,28 @@ public:
return true; return true;
} }
static bool HandleEventInfoCommand(ChatHandler* handler, const char* args) static bool HandleEventInfoCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
// id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*)args, "Hgameevent"); char* id = handler->extractKeyFromLink((char*)args, "Hgameevent");
if (!cId) if (!id)
return false; return false;
uint32 event_id = atoi(cId); uint32 eventId = atoi(id);
GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap(); GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
if (event_id >=events.size()) if (eventId >= events.size())
{ {
handler->SendSysMessage(LANG_EVENT_NOT_EXIST); handler->SendSysMessage(LANG_EVENT_NOT_EXIST);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
GameEventData const& eventData = events[event_id]; GameEventData const& eventData = events[eventId];
if (!eventData.isValid()) if (!eventData.isValid())
{ {
handler->SendSysMessage(LANG_EVENT_NOT_EXIST); handler->SendSysMessage(LANG_EVENT_NOT_EXIST);
@@ -108,47 +108,47 @@ public:
} }
GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList(); GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
bool active = activeEvents.find(event_id) != activeEvents.end(); bool active = activeEvents.find(eventId) != activeEvents.end();
char const* activeStr = active ? handler->GetTrinityString(LANG_ACTIVE) : ""; char const* activeStr = active ? handler->GetTrinityString(LANG_ACTIVE) : "";
std::string startTimeStr = TimeToTimestampStr(eventData.start); std::string startTimeStr = TimeToTimestampStr(eventData.start);
std::string endTimeStr = TimeToTimestampStr(eventData.end); std::string endTimeStr = TimeToTimestampStr(eventData.end);
uint32 delay = sGameEventMgr->NextCheck(event_id); uint32 delay = sGameEventMgr->NextCheck(eventId);
time_t nextTime = time(NULL)+delay; time_t nextTime = time(NULL) + delay;
std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(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 occurenceStr = secsToTimeString(eventData.occurence * MINUTE);
std::string lengthStr = secsToTimeString(eventData.length * MINUTE); std::string lengthStr = secsToTimeString(eventData.length * MINUTE);
handler->PSendSysMessage(LANG_EVENT_INFO, event_id, eventData.description.c_str(), activeStr, handler->PSendSysMessage(LANG_EVENT_INFO, eventId, eventData.description.c_str(), activeStr,
startTimeStr.c_str(), endTimeStr.c_str(), occurenceStr.c_str(), lengthStr.c_str(), startTimeStr.c_str(), endTimeStr.c_str(), occurenceStr.c_str(), lengthStr.c_str(),
nextStr.c_str()); nextStr.c_str());
return true; return true;
} }
static bool HandleEventStartCommand(ChatHandler* handler, const char* args) static bool HandleEventStartCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
// id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*)args, "Hgameevent"); char* id = handler->extractKeyFromLink((char*)args, "Hgameevent");
if (!cId) if (!id)
return false; return false;
int32 event_id = atoi(cId); int32 eventId = atoi(id);
GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap(); GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
if (event_id < 1 || uint32(event_id) >= events.size()) if (eventId < 1 || uint32(eventId) >= events.size())
{ {
handler->SendSysMessage(LANG_EVENT_NOT_EXIST); handler->SendSysMessage(LANG_EVENT_NOT_EXIST);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
GameEventData const& eventData = events[event_id]; GameEventData const& eventData = events[eventId];
if (!eventData.isValid()) if (!eventData.isValid())
{ {
handler->SendSysMessage(LANG_EVENT_NOT_EXIST); handler->SendSysMessage(LANG_EVENT_NOT_EXIST);
@@ -157,39 +157,39 @@ public:
} }
GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList(); GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
if (activeEvents.find(event_id) != activeEvents.end()) if (activeEvents.find(eventId) != activeEvents.end())
{ {
handler->PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE, event_id); handler->PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE, eventId);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
sGameEventMgr->StartEvent(event_id, true); sGameEventMgr->StartEvent(eventId, true);
return true; return true;
} }
static bool HandleEventStopCommand(ChatHandler* handler, const char* args) static bool HandleEventStopCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
// id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*)args, "Hgameevent"); char* id = handler->extractKeyFromLink((char*)args, "Hgameevent");
if (!cId) if (!id)
return false; return false;
int32 event_id = atoi(cId); int32 eventId = atoi(id);
GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap(); GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
if (event_id < 1 || uint32(event_id) >= events.size()) if (eventId < 1 || uint32(eventId) >= events.size())
{ {
handler->SendSysMessage(LANG_EVENT_NOT_EXIST); handler->SendSysMessage(LANG_EVENT_NOT_EXIST);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
GameEventData const& eventData = events[event_id]; GameEventData const& eventData = events[eventId];
if (!eventData.isValid()) if (!eventData.isValid())
{ {
handler->SendSysMessage(LANG_EVENT_NOT_EXIST); handler->SendSysMessage(LANG_EVENT_NOT_EXIST);
@@ -199,14 +199,14 @@ public:
GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList(); GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
if (activeEvents.find(event_id) == activeEvents.end()) if (activeEvents.find(eventId) == activeEvents.end())
{ {
handler->PSendSysMessage(LANG_EVENT_NOT_ACTIVE, event_id); handler->PSendSysMessage(LANG_EVENT_NOT_ACTIVE, eventId);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
sGameEventMgr->StopEvent(event_id, true); sGameEventMgr->StopEvent(eventId, true);
return true; return true;
} }
}; };
+27 -29
View File
@@ -53,7 +53,7 @@ public:
} }
// Enables or disables hiding of the staff badge // Enables or disables hiding of the staff badge
static bool HandleGMChatCommand(ChatHandler* handler, const char* args) static bool HandleGMChatCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
{ {
@@ -65,16 +65,16 @@ public:
return true; return true;
} }
std::string argstr = (char*)args; std::string param = (char*)args;
if (argstr == "on") if (param == "on")
{ {
handler->GetSession()->GetPlayer()->SetGMChat(true); handler->GetSession()->GetPlayer()->SetGMChat(true);
handler->GetSession()->SendNotification(LANG_GM_CHAT_ON); handler->GetSession()->SendNotification(LANG_GM_CHAT_ON);
return true; return true;
} }
if (argstr == "off") if (param == "off")
{ {
handler->GetSession()->GetPlayer()->SetGMChat(false); handler->GetSession()->GetPlayer()->SetGMChat(false);
handler->GetSession()->SendNotification(LANG_GM_CHAT_OFF); handler->GetSession()->SendNotification(LANG_GM_CHAT_OFF);
@@ -86,7 +86,7 @@ public:
return false; return false;
} }
static bool HandleGMFlyCommand(ChatHandler* handler, const char* args) static bool HandleGMFlyCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
@@ -112,17 +112,17 @@ public:
return true; return true;
} }
static bool HandleGMListIngameCommand(ChatHandler* handler, const char* /*args*/) static bool HandleGMListIngameCommand(ChatHandler* handler, char const* /*args*/)
{ {
bool first = true; bool first = true;
bool footer = false; bool footer = false;
ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, *HashMapHolder<Player>::GetLock(), true); ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, *HashMapHolder<Player>::GetLock(), true);
HashMapHolder<Player>::MapType &m = sObjectAccessor->GetPlayers(); HashMapHolder<Player>::MapType& m = sObjectAccessor->GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
AccountTypes itr_sec = itr->second->GetSession()->GetSecurity(); AccountTypes itrSec = itr->second->GetSession()->GetSecurity();
if ((itr->second->isGameMaster() || (!AccountMgr::IsPlayerAccount(itr_sec) && itr_sec <= AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_GM_LIST)))) && if ((itr->second->isGameMaster() || (!AccountMgr::IsPlayerAccount(itrSec) && itrSec <= AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_GM_LIST)))) &&
(!handler->GetSession() || itr->second->IsVisibleGloballyFor(handler->GetSession()->GetPlayer()))) (!handler->GetSession() || itr->second->IsVisibleGloballyFor(handler->GetSession()->GetPlayer())))
{ {
if (first) if (first)
@@ -132,12 +132,12 @@ public:
handler->SendSysMessage(LANG_GMS_ON_SRV); handler->SendSysMessage(LANG_GMS_ON_SRV);
handler->SendSysMessage("========================"); handler->SendSysMessage("========================");
} }
const char* name = itr->second->GetName(); char const* name = itr->second->GetName();
uint8 security = itr_sec; uint8 security = itrSec;
uint8 max = ((16 - strlen(name)) / 2); uint8 max = ((16 - strlen(name)) / 2);
uint8 max2 = max; uint8 max2 = max;
if (((max)+(max2)+(strlen(name))) == 16) if ((max + max2 + strlen(name)) == 16)
max2 = ((max)-1); max2 = max - 1;
if (handler->GetSession()) if (handler->GetSession())
handler->PSendSysMessage("| %s GMLevel %u", name, security); handler->PSendSysMessage("| %s GMLevel %u", name, security);
else else
@@ -152,7 +152,7 @@ public:
} }
/// Display the list of GMs /// Display the list of GMs
static bool HandleGMListFullCommand(ChatHandler* handler, const char* /*args*/) static bool HandleGMListFullCommand(ChatHandler* handler, char const* /*args*/)
{ {
///- Get the accounts with GM Level >0 ///- Get the accounts with GM Level >0
QueryResult result = LoginDatabase.PQuery("SELECT a.username, aa.gmlevel FROM account a, account_access aa WHERE a.id=aa.id AND aa.gmlevel >= %u", SEC_MODERATOR); QueryResult result = LoginDatabase.PQuery("SELECT a.username, aa.gmlevel FROM account a, account_access aa WHERE a.id=aa.id AND aa.gmlevel >= %u", SEC_MODERATOR);
@@ -164,19 +164,17 @@ public:
do do
{ {
Field* fields = result->Fetch(); Field* fields = result->Fetch();
const char* name = fields[0].GetCString(); char const* name = fields[0].GetCString();
uint8 security = fields[1].GetUInt8(); uint8 security = fields[1].GetUInt8();
uint8 max = ((16 - strlen(name)) / 2); uint8 max = (16 - strlen(name)) / 2;
uint8 max2 = max; uint8 max2 = max;
if (((max)+(max2)+(strlen(name))) == 16) if ((max + max2 + strlen(name)) == 16)
max2 = ((max)-1); max2 = max - 1;
if (handler->GetSession()) if (handler->GetSession())
handler->PSendSysMessage("| %s GMLevel %u", name, security); handler->PSendSysMessage("| %s GMLevel %u", name, security);
else else
handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security); handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security);
} } while (result->NextRow());
while (result->NextRow());
handler->SendSysMessage("========================"); handler->SendSysMessage("========================");
} }
else else
@@ -185,7 +183,7 @@ public:
} }
//Enable\Disable Invisible mode //Enable\Disable Invisible mode
static bool HandleGMVisibleCommand(ChatHandler* handler, const char* args) static bool HandleGMVisibleCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
{ {
@@ -193,16 +191,16 @@ public:
return true; return true;
} }
std::string argstr = (char*)args; std::string param = (char*)args;
if (argstr == "on") if (param == "on")
{ {
handler->GetSession()->GetPlayer()->SetGMVisible(true); handler->GetSession()->GetPlayer()->SetGMVisible(true);
handler->GetSession()->SendNotification(LANG_INVISIBLE_VISIBLE); handler->GetSession()->SendNotification(LANG_INVISIBLE_VISIBLE);
return true; return true;
} }
if (argstr == "off") if (param == "off")
{ {
handler->GetSession()->SendNotification(LANG_INVISIBLE_INVISIBLE); handler->GetSession()->SendNotification(LANG_INVISIBLE_INVISIBLE);
handler->GetSession()->GetPlayer()->SetGMVisible(false); handler->GetSession()->GetPlayer()->SetGMVisible(false);
@@ -215,7 +213,7 @@ public:
} }
//Enable\Disable GM Mode //Enable\Disable GM Mode
static bool HandleGMCommand(ChatHandler* handler, const char* args) static bool HandleGMCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
{ {
@@ -226,9 +224,9 @@ public:
return true; return true;
} }
std::string argstr = (char*)args; std::string param = (char*)args;
if (argstr == "on") if (param == "on")
{ {
handler->GetSession()->GetPlayer()->SetGameMaster(true); handler->GetSession()->GetPlayer()->SetGameMaster(true);
handler->GetSession()->SendNotification(LANG_GM_ON); handler->GetSession()->SendNotification(LANG_GM_ON);
@@ -240,7 +238,7 @@ public:
return true; return true;
} }
if (argstr == "off") if (param == "off")
{ {
handler->GetSession()->GetPlayer()->SetGameMaster(false); handler->GetSession()->GetPlayer()->SetGameMaster(false);
handler->GetSession()->SendNotification(LANG_GM_OFF); handler->GetSession()->SendNotification(LANG_GM_OFF);
+160 -172
View File
@@ -57,6 +57,7 @@ public:
}; };
return commandTable; return commandTable;
} }
/** \brief Teleport the GM to the specified creature /** \brief Teleport the GM to the specified creature
* *
* .gocreature <GUID> --> TP using creature.guid * .gocreature <GUID> --> TP using creature.guid
@@ -68,59 +69,52 @@ public:
* you will be teleported to the first one that is found. * you will be teleported to the first one that is found.
*/ */
//teleport to creature //teleport to creature
static bool HandleGoCreatureCommand(ChatHandler* handler, const char* args) static bool HandleGoCreatureCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
Player* _player = handler->GetSession()->GetPlayer();
Player* player = handler->GetSession()->GetPlayer();
// "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r // "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
char* pParam1 = handler->extractKeyFromLink((char*)args, "Hcreature"); char* param1 = handler->extractKeyFromLink((char*)args, "Hcreature");
if (!pParam1) if (!param1)
return false; return false;
std::ostringstream whereClause; std::ostringstream whereClause;
// User wants to teleport to the NPC's template entry // User wants to teleport to the NPC's template entry
if (strcmp(pParam1, "id") == 0) if (strcmp(param1, "id") == 0)
{ {
//sLog->outError("DEBUG: ID found");
// Get the "creature_template.entry" // Get the "creature_template.entry"
// number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
char* tail = strtok(NULL, ""); char* tail = strtok(NULL, "");
if (!tail) if (!tail)
return false; return false;
char* cId = handler->extractKeyFromLink(tail, "Hcreature_entry"); char* id = handler->extractKeyFromLink(tail, "Hcreature_entry");
if (!cId) if (!id)
return false; return false;
int32 tEntry = atoi(cId); int32 entry = atoi(id);
//sLog->outError("DEBUG: ID value: %d", tEntry); if (!entry)
if (!tEntry)
return false; return false;
whereClause << "WHERE id = '" << tEntry << '\''; whereClause << "WHERE id = '" << entry << '\'';
} }
else else
{ {
//sLog->outError("DEBUG: ID *not found*"); int32 guid = atoi(param1);
int32 guid = atoi(pParam1);
// Number is invalid - maybe the user specified the mob's name // Number is invalid - maybe the user specified the mob's name
if (!guid) if (!guid)
{ {
std::string name = pParam1; std::string name = param1;
WorldDatabase.EscapeString(name); WorldDatabase.EscapeString(name);
whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name "_LIKE_" '" << name << '\''; whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name "_LIKE_" '" << name << '\'';
} }
else else
{
whereClause << "WHERE guid = '" << guid << '\''; whereClause << "WHERE guid = '" << guid << '\'';
} }
}
//sLog->outError("DEBUG: %s", whereClause.c_str());
QueryResult result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z, orientation, map, guid, id FROM creature %s", whereClause.str().c_str()); QueryResult result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z, orientation, map, guid, id FROM creature %s", whereClause.str().c_str());
if (!result) if (!result)
@@ -137,12 +131,12 @@ public:
float y = fields[1].GetFloat(); float y = fields[1].GetFloat();
float z = fields[2].GetFloat(); float z = fields[2].GetFloat();
float ort = fields[3].GetFloat(); float ort = fields[3].GetFloat();
int mapid = fields[4].GetUInt16(); int mapId = fields[4].GetUInt16();
uint32 guid = fields[5].GetUInt32(); uint32 guid = fields[5].GetUInt32();
uint32 id = fields[6].GetUInt32(); uint32 id = fields[6].GetUInt32();
// if creature is in same map with caster go at its current location // if creature is in same map with caster go at its current location
if (Creature* creature = sObjectAccessor->GetCreature(*_player, MAKE_NEW_GUID(guid, id, HIGHGUID_UNIT))) if (Creature* creature = sObjectAccessor->GetCreature(*player, MAKE_NEW_GUID(guid, id, HIGHGUID_UNIT)))
{ {
x = creature->GetPositionX(); x = creature->GetPositionX();
y = creature->GetPositionY(); y = creature->GetPositionY();
@@ -150,46 +144,47 @@ public:
ort = creature->GetOrientation(); ort = creature->GetOrientation();
} }
if (!MapManager::IsValidMapCoord(mapid, x, y, z, ort)) if (!MapManager::IsValidMapCoord(mapId, x, y, z, ort))
{ {
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid); handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
// stop flight if need // stop flight if need
if (_player->isInFlight()) if (player->isInFlight())
{ {
_player->GetMotionMaster()->MovementExpired(); player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight(); player->CleanupAfterTaxiFlight();
} }
// save only in non-flight case // save only in non-flight case
else else
_player->SaveRecallPosition(); player->SaveRecallPosition();
_player->TeleportTo(mapid, x, y, z, ort); player->TeleportTo(mapId, x, y, z, ort);
return true; return true;
} }
static bool HandleGoGraveyardCommand(ChatHandler* handler, const char* args)
static bool HandleGoGraveyardCommand(ChatHandler* handler, char const* args)
{ {
Player* _player = handler->GetSession()->GetPlayer(); Player* player = handler->GetSession()->GetPlayer();
if (!*args) if (!*args)
return false; return false;
char *gyId = strtok((char*)args, " "); char* gyId = strtok((char*)args, " ");
if (!gyId) if (!gyId)
return false; return false;
int32 i_gyId = atoi(gyId); int32 graveyardId = atoi(gyId);
if (!i_gyId) if (!graveyardId)
return false; return false;
WorldSafeLocsEntry const* gy = sWorldSafeLocsStore.LookupEntry(i_gyId); WorldSafeLocsEntry const* gy = sWorldSafeLocsStore.LookupEntry(graveyardId);
if (!gy) if (!gy)
{ {
handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, i_gyId); handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, graveyardId);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
@@ -202,93 +197,92 @@ public:
} }
// stop flight if need // stop flight if need
if (_player->isInFlight()) if (player->isInFlight())
{ {
_player->GetMotionMaster()->MovementExpired(); player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight(); player->CleanupAfterTaxiFlight();
} }
// save only in non-flight case // save only in non-flight case
else else
_player->SaveRecallPosition(); player->SaveRecallPosition();
_player->TeleportTo(gy->map_id, gy->x, gy->y, gy->z, _player->GetOrientation()); player->TeleportTo(gy->map_id, gy->x, gy->y, gy->z, player->GetOrientation());
return true; return true;
} }
//teleport to grid //teleport to grid
static bool HandleGoGridCommand(ChatHandler* handler, const char* args) static bool HandleGoGridCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) return false; if (!*args)
Player* _player = handler->GetSession()->GetPlayer();
char* px = strtok((char*)args, " ");
char* py = strtok(NULL, " ");
char* pmapid = strtok(NULL, " ");
if (!px || !py)
return false; return false;
float grid_x = (float)atof(px); Player* player = handler->GetSession()->GetPlayer();
float grid_y = (float)atof(py);
uint32 mapid; char* gridX = strtok((char*)args, " ");
if (pmapid) char* gridY = strtok(NULL, " ");
mapid = (uint32)atoi(pmapid); char* id = strtok(NULL, " ");
else mapid = _player->GetMapId();
if (!gridX || !gridY)
return false;
uint32 mapId = id ? (uint32)atoi(id) : player->GetMapId();
// center of grid // center of grid
float x = (grid_x-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; float x = ((float)atof(gridX) - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
float y = (grid_y-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; float y = ((float)atof(gridY) - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
if (!MapManager::IsValidMapCoord(mapid, x, y)) if (!MapManager::IsValidMapCoord(mapId, x, y))
{ {
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid); handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
// stop flight if need // stop flight if need
if (_player->isInFlight()) if (player->isInFlight())
{ {
_player->GetMotionMaster()->MovementExpired(); player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight(); player->CleanupAfterTaxiFlight();
} }
// save only in non-flight case // save only in non-flight case
else else
_player->SaveRecallPosition(); player->SaveRecallPosition();
Map const* map = sMapMgr->CreateBaseMap(mapid); Map const* map = sMapMgr->CreateBaseMap(mapId);
float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
_player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
player->TeleportTo(mapId, x, y, z, player->GetOrientation());
return true; return true;
} }
//teleport to gameobject //teleport to gameobject
static bool HandleGoObjectCommand(ChatHandler* handler, const char* args) static bool HandleGoObjectCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
Player* _player = handler->GetSession()->GetPlayer(); Player* player = handler->GetSession()->GetPlayer();
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
if (!cId) if (!id)
return false; return false;
int32 guid = atoi(cId); int32 guid = atoi(id);
if (!guid) if (!guid)
return false; return false;
float x, y, z, ort; float x, y, z, ort;
int mapid; int mapId;
// by DB guid // by DB guid
if (GameObjectData const* go_data = sObjectMgr->GetGOData(guid)) if (GameObjectData const* goData = sObjectMgr->GetGOData(guid))
{ {
x = go_data->posX; x = goData->posX;
y = go_data->posY; y = goData->posY;
z = go_data->posZ; z = goData->posZ;
ort = go_data->orientation; ort = goData->orientation;
mapid = go_data->mapid; mapId = goData->mapid;
} }
else else
{ {
@@ -297,45 +291,46 @@ public:
return false; return false;
} }
if (!MapManager::IsValidMapCoord(mapid, x, y, z, ort)) if (!MapManager::IsValidMapCoord(mapId, x, y, z, ort))
{ {
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid); handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
// stop flight if need // stop flight if need
if (_player->isInFlight()) if (player->isInFlight())
{ {
_player->GetMotionMaster()->MovementExpired(); player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight(); player->CleanupAfterTaxiFlight();
} }
// save only in non-flight case // save only in non-flight case
else else
_player->SaveRecallPosition(); player->SaveRecallPosition();
_player->TeleportTo(mapid, x, y, z, ort); player->TeleportTo(mapId, x, y, z, ort);
return true; return true;
} }
static bool HandleGoTaxinodeCommand(ChatHandler* handler, const char* args)
static bool HandleGoTaxinodeCommand(ChatHandler* handler, char const* args)
{ {
Player* _player = handler->GetSession()->GetPlayer(); Player* player = handler->GetSession()->GetPlayer();
if (!*args) if (!*args)
return false; return false;
char* cNodeId = handler->extractKeyFromLink((char*)args, "Htaxinode"); char* id = handler->extractKeyFromLink((char*)args, "Htaxinode");
if (!cNodeId) if (!id)
return false; return false;
int32 i_nodeId = atoi(cNodeId); int32 nodeId = atoi(id);
if (!i_nodeId) if (!nodeId)
return false; return false;
TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i_nodeId); TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(nodeId);
if (!node) if (!node)
{ {
handler->PSendSysMessage(LANG_COMMAND_GOTAXINODENOTFOUND, i_nodeId); handler->PSendSysMessage(LANG_COMMAND_GOTAXINODENOTFOUND, nodeId);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
@@ -349,38 +344,39 @@ public:
} }
// stop flight if need // stop flight if need
if (_player->isInFlight()) if (player->isInFlight())
{ {
_player->GetMotionMaster()->MovementExpired(); player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight(); player->CleanupAfterTaxiFlight();
} }
// save only in non-flight case // save only in non-flight case
else else
_player->SaveRecallPosition(); player->SaveRecallPosition();
_player->TeleportTo(node->map_id, node->x, node->y, node->z, _player->GetOrientation()); player->TeleportTo(node->map_id, node->x, node->y, node->z, player->GetOrientation());
return true; return true;
} }
static bool HandleGoTriggerCommand(ChatHandler* handler, const char* args)
static bool HandleGoTriggerCommand(ChatHandler* handler, char const* args)
{ {
Player* _player = handler->GetSession()->GetPlayer(); Player* player = handler->GetSession()->GetPlayer();
if (!*args) if (!*args)
return false; return false;
char *atId = strtok((char*)args, " "); char* id = strtok((char*)args, " ");
if (!atId) if (!id)
return false; return false;
int32 i_atId = atoi(atId); int32 areaTriggerId = atoi(id);
if (!i_atId) if (!areaTriggerId)
return false; return false;
AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(i_atId); AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(areaTriggerId);
if (!at) if (!at)
{ {
handler->PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND, i_atId); handler->PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND, areaTriggerId);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
@@ -393,49 +389,50 @@ public:
} }
// stop flight if need // stop flight if need
if (_player->isInFlight()) if (player->isInFlight())
{ {
_player->GetMotionMaster()->MovementExpired(); player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight(); player->CleanupAfterTaxiFlight();
} }
// save only in non-flight case // save only in non-flight case
else else
_player->SaveRecallPosition(); player->SaveRecallPosition();
_player->TeleportTo(at->mapid, at->x, at->y, at->z, _player->GetOrientation()); player->TeleportTo(at->mapid, at->x, at->y, at->z, player->GetOrientation());
return true; return true;
} }
//teleport at coordinates //teleport at coordinates
static bool HandleGoZoneXYCommand(ChatHandler* handler, const char* args) static bool HandleGoZoneXYCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
Player* _player = handler->GetSession()->GetPlayer(); Player* player = handler->GetSession()->GetPlayer();
char* px = strtok((char*)args, " "); char* zoneX = strtok((char*)args, " ");
char* py = strtok(NULL, " "); char* zoneY = strtok(NULL, " ");
char* tail = strtok(NULL, ""); char* tail = strtok(NULL, "");
char* cAreaId = handler->extractKeyFromLink(tail, "Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r char* id = handler->extractKeyFromLink(tail, "Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r
if (!px || !py) if (!zoneX || !zoneY)
return false; return false;
float x = (float)atof(px); float x = (float)atof(zoneX);
float y = (float)atof(py); float y = (float)atof(zoneY);
// prevent accept wrong numeric args // prevent accept wrong numeric args
if ((x == 0.0f && *px != '0') || (y == 0.0f && *py != '0')) if ((x == 0.0f && *zoneX != '0') || (y == 0.0f && *zoneY != '0'))
return false; return false;
uint32 areaid = cAreaId ? (uint32)atoi(cAreaId) : _player->GetZoneId(); uint32 areaId = id ? (uint32)atoi(id) : player->GetZoneId();
AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaid); AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaId);
if (x < 0 || x > 100 || y < 0 || y > 100 || !areaEntry) if (x < 0 || x > 100 || y < 0 || y > 100 || !areaEntry)
{ {
handler->PSendSysMessage(LANG_INVALID_ZONE_COORD, x, y, areaid); handler->PSendSysMessage(LANG_INVALID_ZONE_COORD, x, y, areaId);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
@@ -462,99 +459,90 @@ public:
} }
// stop flight if need // stop flight if need
if (_player->isInFlight()) if (player->isInFlight())
{ {
_player->GetMotionMaster()->MovementExpired(); player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight(); player->CleanupAfterTaxiFlight();
} }
// save only in non-flight case // save only in non-flight case
else else
_player->SaveRecallPosition(); player->SaveRecallPosition();
float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
_player->TeleportTo(zoneEntry->mapid, x, y, z, _player->GetOrientation());
player->TeleportTo(zoneEntry->mapid, x, y, z, player->GetOrientation());
return true; return true;
} }
//teleport at coordinates, including Z and orientation //teleport at coordinates, including Z and orientation
static bool HandleGoXYZCommand(ChatHandler* handler, const char* args) static bool HandleGoXYZCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
Player* _player = handler->GetSession()->GetPlayer(); Player* player = handler->GetSession()->GetPlayer();
char* px = strtok((char*)args, " "); char* goX = strtok((char*)args, " ");
char* py = strtok(NULL, " "); char* goY = strtok(NULL, " ");
char* pz = strtok(NULL, " "); char* goZ = strtok(NULL, " ");
char* pmapid = strtok(NULL, " "); char* id = strtok(NULL, " ");
char* port = strtok(NULL, " "); char* port = strtok(NULL, " ");
if (!px || !py) if (!goX || !goY)
return false; return false;
float x = (float)atof(px); float x = (float)atof(goX);
float y = (float)atof(py); float y = (float)atof(goY);
float z; float z;
float ort; float ort = port ? (float)atof(port) : player->GetOrientation();
uint32 mapid; uint32 mapId = id ? (uint32)atoi(id) : player->GetMapId();
if (pmapid) if (goZ)
mapid = (uint32)atoi(pmapid);
else
mapid = _player->GetMapId();
if ( port )
ort = (float)atof(port);
else
ort = _player->GetOrientation();
if ( pz )
{ {
z = (float)atof(pz); z = (float)atof(goZ);
if (!MapManager::IsValidMapCoord(mapid, x, y, z)) if (!MapManager::IsValidMapCoord(mapId, x, y, z))
{ {
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid); handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
} }
else else
{ {
if (!MapManager::IsValidMapCoord(mapid, x, y)) if (!MapManager::IsValidMapCoord(mapId, x, y))
{ {
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid); handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
Map const* map = sMapMgr->CreateBaseMap(mapid); Map const* map = sMapMgr->CreateBaseMap(mapId);
z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
} }
// stop flight if need // stop flight if need
if (_player->isInFlight()) if (player->isInFlight())
{ {
_player->GetMotionMaster()->MovementExpired(); player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight(); player->CleanupAfterTaxiFlight();
} }
// save only in non-flight case // save only in non-flight case
else else
_player->SaveRecallPosition(); player->SaveRecallPosition();
_player->TeleportTo(mapid, x, y, z, ort);
player->TeleportTo(mapId, x, y, z, ort);
return true; return true;
} }
static bool HandleGoTicketCommand(ChatHandler* handler, const char* args)
static bool HandleGoTicketCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
char *sTicketId = strtok((char*)args, " "); char* id = strtok((char*)args, " ");
if (!sTicketId) if (!id)
return false; return false;
uint32 ticketId = atoi(sTicketId); uint32 ticketId = atoi(id);
if (!ticketId) if (!ticketId)
return false; return false;
@@ -565,16 +553,16 @@ public:
return true; return true;
} }
Player* _player = handler->GetSession()->GetPlayer(); Player* player = handler->GetSession()->GetPlayer();
if (_player->isInFlight()) if (player->isInFlight())
{ {
_player->GetMotionMaster()->MovementExpired(); player->GetMotionMaster()->MovementExpired();
_player->CleanupAfterTaxiFlight(); player->CleanupAfterTaxiFlight();
} }
else else
_player->SaveRecallPosition(); player->SaveRecallPosition();
ticket->TeleportTo(_player); ticket->TeleportTo(player);
return true; return true;
} }
}; };
+211 -214
View File
@@ -69,35 +69,35 @@ public:
return commandTable; return commandTable;
} }
static bool HandleGameObjectActivateCommand(ChatHandler* handler, const char* args) static bool HandleGameObjectActivateCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
if (!cId) if (!id)
return false; return false;
uint32 lowguid = atoi(cId); uint32 guidLow = atoi(id);
if (!lowguid) if (!guidLow)
return false; return false;
GameObject* obj = NULL; GameObject* object = NULL;
// by DB guid // by DB guid
if (GameObjectData const* go_data = sObjectMgr->GetGOData(lowguid)) if (GameObjectData const* goData = sObjectMgr->GetGOData(guidLow))
obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, go_data->id); object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, goData->id);
if (!obj) if (!object)
{ {
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
// Activate // Activate
obj->SetLootState(GO_READY); object->SetLootState(GO_READY);
obj->UseDoorOrButton(10000); object->UseDoorOrButton(10000);
handler->PSendSysMessage("Object activated!"); handler->PSendSysMessage("Object activated!");
@@ -105,92 +105,92 @@ public:
} }
//spawn go //spawn go
static bool HandleGameObjectAddCommand(ChatHandler* handler, const char* args) static bool HandleGameObjectAddCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
// number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject_entry"); char* id = handler->extractKeyFromLink((char*)args, "Hgameobject_entry");
if (!cId) if (!id)
return false; return false;
uint32 id = atol(cId); uint32 objectId = atol(id);
if (!id) if (!objectId)
return false; return false;
char* spawntimeSecs = strtok(NULL, " "); char* spawntimeSecs = strtok(NULL, " ");
const GameObjectTemplate* gInfo = sObjectMgr->GetGameObjectTemplate(id); const GameObjectTemplate* objectInfo = sObjectMgr->GetGameObjectTemplate(objectId);
if (!gInfo) if (!objectInfo)
{ {
handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, id); handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, objectId);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId)) if (objectInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(objectInfo->displayId))
{ {
// report to DB errors log as in loading case // 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); sLog->outErrorDb("Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.", objectId, objectInfo->type, objectInfo->displayId);
handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA, id); handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA, objectId);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
Player* chr = handler->GetSession()->GetPlayer(); Player* player = handler->GetSession()->GetPlayer();
float x = float(chr->GetPositionX()); float x = float(player->GetPositionX());
float y = float(chr->GetPositionY()); float y = float(player->GetPositionY());
float z = float(chr->GetPositionZ()); float z = float(player->GetPositionZ());
float o = float(chr->GetOrientation()); float o = float(player->GetOrientation());
Map* map = chr->GetMap(); Map* map = player->GetMap();
GameObject* pGameObj = new GameObject; GameObject* object = new GameObject;
uint32 db_lowGUID = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT); uint32 guidLow = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT);
if (!pGameObj->Create(db_lowGUID, gInfo->entry, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY)) if (!object->Create(guidLow, objectInfo->entry, map, player->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
{ {
delete pGameObj; delete object;
return false; return false;
} }
if (spawntimeSecs) if (spawntimeSecs)
{ {
uint32 value = atoi((char*)spawntimeSecs); uint32 value = atoi((char*)spawntimeSecs);
pGameObj->SetRespawnTime(value); object->SetRespawnTime(value);
//sLog->outDebug(LOG_FILTER_TSCR, "*** spawntimeSecs: %d", value);
} }
// fill the gameobject data and save to the db // fill the gameobject data and save to the db
pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), player->GetPhaseMaskForSpawn());
// this will generate a new guid if the object is in an instance // this will generate a new guid if the object is in an instance
if (!pGameObj->LoadFromDB(db_lowGUID, map)) if (!object->LoadFromDB(guidLow, map))
{ {
delete pGameObj; delete object;
return false; return false;
} }
map->Add(pGameObj); map->Add(object);
// TODO: is it really necessary to add both the real and DB table guid here ? // TODO: is it really necessary to add both the real and DB table guid here ?
sObjectMgr->AddGameobjectToGrid(db_lowGUID, sObjectMgr->GetGOData(db_lowGUID)); sObjectMgr->AddGameobjectToGrid(guidLow, sObjectMgr->GetGOData(guidLow));
handler->PSendSysMessage(LANG_GAMEOBJECT_ADD, id, gInfo->name.c_str(), db_lowGUID, x, y, z); handler->PSendSysMessage(LANG_GAMEOBJECT_ADD, objectId, objectInfo->name.c_str(), guidLow, x, y, z);
return true; return true;
} }
// add go, temp only // add go, temp only
static bool HandleGameObjectAddTempCommand(ChatHandler* handler, const char* args) static bool HandleGameObjectAddTempCommand(ChatHandler* handler, char const* args)
{ {
if (!*args) if (!*args)
return false; return false;
char* charID = strtok((char*)args, " ");
if (!charID) char* id = strtok((char*)args, " ");
if (!id)
return false; return false;
Player* chr = handler->GetSession()->GetPlayer(); Player* player = handler->GetSession()->GetPlayer();
char* spawntime = strtok(NULL, " "); char* spawntime = strtok(NULL, " ");
uint32 spawntm = 300; uint32 spawntm = 300;
@@ -198,46 +198,47 @@ public:
if (spawntime) if (spawntime)
spawntm = atoi((char*)spawntime); spawntm = atoi((char*)spawntime);
float x = chr->GetPositionX(); float x = player->GetPositionX();
float y = chr->GetPositionY(); float y = player->GetPositionY();
float z = chr->GetPositionZ(); float z = player->GetPositionZ();
float ang = chr->GetOrientation(); float ang = player->GetOrientation();
float rot2 = sin(ang/2); float rot2 = sin(ang/2);
float rot3 = cos(ang/2); float rot3 = cos(ang/2);
uint32 id = atoi(charID); uint32 objectId = atoi(id);
chr->SummonGameObject(id, x, y, z, ang, 0, 0, rot2, rot3, spawntm); player->SummonGameObject(objectId, x, y, z, ang, 0, 0, rot2, rot3, spawntm);
return true; return true;
} }
static bool HandleGameObjectTargetCommand(ChatHandler* handler, const char* args) static bool HandleGameObjectTargetCommand(ChatHandler* handler, char const* args)
{ {
Player* pl = handler->GetSession()->GetPlayer(); Player* player = handler->GetSession()->GetPlayer();
QueryResult result; QueryResult result;
GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr->GetActiveEventList(); GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr->GetActiveEventList();
if (*args) if (*args)
{ {
// number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject_entry"); char* id = handler->extractKeyFromLink((char*)args, "Hgameobject_entry");
if (!cId) if (!id)
return false; return false;
uint32 id = atol(cId); uint32 objectId = atol(id);
if (id) if (objectId)
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", 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); player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), objectId);
else else
{ {
std::string name = cId; std::string name = id;
WorldDatabase.EscapeString(name); WorldDatabase.EscapeString(name);
result = WorldDatabase.PQuery( 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_ " "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", "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()); player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), name.c_str());
} }
} }
else else
@@ -250,8 +251,8 @@ public:
{ {
if (initString) if (initString)
{ {
eventFilter << "OR eventEntry IN (" <<*itr; eventFilter << "OR eventEntry IN (" << *itr;
initString =false; initString = false;
} }
else else
eventFilter << ',' << *itr; eventFilter << ',' << *itr;
@@ -277,25 +278,25 @@ public:
bool found = false; bool found = false;
float x, y, z, o; float x, y, z, o;
uint32 lowguid, id; uint32 guidLow, id;
uint16 mapid, phase; uint16 mapId, phase;
uint32 pool_id; uint32 poolId;
do do
{ {
Field* fields = result->Fetch(); Field* fields = result->Fetch();
lowguid = fields[0].GetUInt32(); guidLow = fields[0].GetUInt32();
id = fields[1].GetUInt32(); id = fields[1].GetUInt32();
x = fields[2].GetFloat(); x = fields[2].GetFloat();
y = fields[3].GetFloat(); y = fields[3].GetFloat();
z = fields[4].GetFloat(); z = fields[4].GetFloat();
o = fields[5].GetFloat(); o = fields[5].GetFloat();
mapid = fields[6].GetUInt16(); mapId = fields[6].GetUInt16();
phase = fields[7].GetUInt16(); phase = fields[7].GetUInt16();
pool_id = sPoolMgr->IsPartOfAPool<GameObject>(lowguid); poolId = sPoolMgr->IsPartOfAPool<GameObject>(guidLow);
if (!pool_id || sPoolMgr->IsSpawnedObject<GameObject>(lowguid)) if (!poolId || sPoolMgr->IsSpawnedObject<GameObject>(guidLow))
found = true; found = true;
} while (result->NextRow() && (!found)); } while (result->NextRow() && !found);
if (!found) if (!found)
{ {
@@ -303,21 +304,21 @@ public:
return false; return false;
} }
GameObjectTemplate const* goI = sObjectMgr->GetGameObjectTemplate(id); GameObjectTemplate const* objectInfo = sObjectMgr->GetGameObjectTemplate(id);
if (!goI) if (!objectInfo)
{ {
handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, id); handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, id);
return false; 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(guidLow, id, HIGHGUID_GAMEOBJECT));
handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, lowguid, goI->name.c_str(), lowguid, id, x, y, z, mapid, o, phase); handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, guidLow, objectInfo->name.c_str(), guidLow, id, x, y, z, mapId, o, phase);
if (target) if (target)
{ {
int32 curRespawnDelay = int32(target->GetRespawnTimeEx()-time(NULL)); int32 curRespawnDelay = int32(target->GetRespawnTimeEx() - time(NULL));
if (curRespawnDelay < 0) if (curRespawnDelay < 0)
curRespawnDelay = 0; curRespawnDelay = 0;
@@ -330,219 +331,217 @@ public:
} }
//delete object by selection or guid //delete object by selection or guid
static bool HandleGameObjectDeleteCommand(ChatHandler* handler, const char* args) static bool HandleGameObjectDeleteCommand(ChatHandler* handler, char const* args)
{ {
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
if (!cId) if (!id)
return false; return false;
uint32 lowguid = atoi(cId); uint32 guidLow = atoi(id);
if (!lowguid) if (!guidLow)
return false; return false;
GameObject* obj = NULL; GameObject* object = NULL;
// by DB guid // by DB guid
if (GameObjectData const* go_data = sObjectMgr->GetGOData(lowguid)) if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, go_data->id); object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
if (!obj) if (!object)
{ {
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
uint64 owner_guid = obj->GetOwnerGUID(); uint64 ownerGuid = object->GetOwnerGUID();
if (owner_guid) if (ownerGuid)
{ {
Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(), owner_guid); Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(), ownerGuid);
if (!owner || !IS_PLAYER_GUID(owner_guid)) if (!owner || !IS_PLAYER_GUID(ownerGuid))
{ {
handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow()); handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(ownerGuid), object->GetGUIDLow());
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
owner->RemoveGameObject(obj, false); owner->RemoveGameObject(object, false);
} }
obj->SetRespawnTime(0); // not save respawn time object->SetRespawnTime(0); // not save respawn time
obj->Delete(); object->Delete();
obj->DeleteFromDB(); object->DeleteFromDB();
handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, obj->GetGUIDLow()); handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, object->GetGUIDLow());
return true; return true;
} }
//turn selected object //turn selected object
static bool HandleGameObjectTurnCommand(ChatHandler* handler, const char* args) static bool HandleGameObjectTurnCommand(ChatHandler* handler, char const* args)
{ {
// number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
if (!cId) if (!id)
return false; return false;
uint32 lowguid = atoi(cId); uint32 guidLow = atoi(id);
if (!lowguid) if (!guidLow)
return false; return false;
GameObject* obj = NULL; GameObject* object = NULL;
// by DB guid // by DB guid
if (GameObjectData const* go_data = sObjectMgr->GetGOData(lowguid)) if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, go_data->id); object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
if (!obj) if (!object)
{ {
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
char* po = strtok(NULL, " "); char* orientation = strtok(NULL, " ");
float o; float o;
if (po) if (orientation)
{ o = (float)atof(orientation);
o = (float)atof(po);
}
else else
{ {
Player* chr = handler->GetSession()->GetPlayer(); Player* player = handler->GetSession()->GetPlayer();
o = chr->GetOrientation(); o = player->GetOrientation();
} }
obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o); object->Relocate(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), o);
obj->UpdateRotationFields(); object->UpdateRotationFields();
obj->DestroyForNearbyPlayers(); object->DestroyForNearbyPlayers();
obj->UpdateObjectVisibility(); object->UpdateObjectVisibility();
obj->SaveToDB(); object->SaveToDB();
obj->Refresh(); object->Refresh();
handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name.c_str(), obj->GetGUIDLow(), o); handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, object->GetGUIDLow(), object->GetGOInfo()->name.c_str(), object->GetGUIDLow(), o);
return true; return true;
} }
//move selected object //move selected object
static bool HandleGameObjectMoveCommand(ChatHandler* handler, const char* args) static bool HandleGameObjectMoveCommand(ChatHandler* handler, char const* args)
{ {
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
if (!cId) if (!id)
return false; return false;
uint32 lowguid = atoi(cId); uint32 guidLow = atoi(id);
if (!lowguid) if (!guidLow)
return false; return false;
GameObject* obj = NULL; GameObject* object = NULL;
// by DB guid // by DB guid
if (GameObjectData const* go_data = sObjectMgr->GetGOData(lowguid)) if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, go_data->id); object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
if (!obj) if (!object)
{ {
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
char* px = strtok(NULL, " "); char* toX = strtok(NULL, " ");
char* py = strtok(NULL, " "); char* toY = strtok(NULL, " ");
char* pz = strtok(NULL, " "); char* toZ = strtok(NULL, " ");
if (!px) if (!toX)
{ {
Player* chr = handler->GetSession()->GetPlayer(); Player* player = handler->GetSession()->GetPlayer();
obj->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), obj->GetOrientation()); object->Relocate(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), object->GetOrientation());
obj->DestroyForNearbyPlayers(); object->DestroyForNearbyPlayers();
obj->UpdateObjectVisibility(); object->UpdateObjectVisibility();
} }
else else
{ {
if (!py || !pz) if (!toY || !toZ)
return false; return false;
float x = (float)atof(px); float x = (float)atof(toX);
float y = (float)atof(py); float y = (float)atof(toY);
float z = (float)atof(pz); float z = (float)atof(toZ);
if (!MapManager::IsValidMapCoord(obj->GetMapId(), x, y, z)) if (!MapManager::IsValidMapCoord(object->GetMapId(), x, y, z))
{ {
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, obj->GetMapId()); handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, object->GetMapId());
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
obj->Relocate(x, y, z, obj->GetOrientation()); object->Relocate(x, y, z, object->GetOrientation());
obj->DestroyForNearbyPlayers(); object->DestroyForNearbyPlayers();
obj->UpdateObjectVisibility(); object->UpdateObjectVisibility();
} }
obj->SaveToDB(); object->SaveToDB();
obj->Refresh(); object->Refresh();
handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name.c_str(), obj->GetGUIDLow()); handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, object->GetGUIDLow(), object->GetGOInfo()->name.c_str(), object->GetGUIDLow());
return true; return true;
} }
//set pahsemask for selected object //set phasemask for selected object
static bool HandleGameObjectSetPhaseCommand(ChatHandler* handler, const char* args) static bool HandleGameObjectSetPhaseCommand(ChatHandler* handler, char const* args)
{ {
// number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
if (!cId) if (!id)
return false; return false;
uint32 lowguid = atoi(cId); uint32 guidLow = atoi(id);
if (!lowguid) if (!guidLow)
return false; return false;
GameObject* obj = NULL; GameObject* object = NULL;
// by DB guid // by DB guid
if (GameObjectData const* go_data = sObjectMgr->GetGOData(lowguid)) if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, go_data->id); object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
if (!obj) if (!object)
{ {
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
char* phaseStr = strtok (NULL, " "); char* phase = strtok (NULL, " ");
uint32 phasemask = phaseStr? atoi(phaseStr) : 0; uint32 phaseMask = phase ? atoi(phase) : 0;
if (phasemask == 0) if (phaseMask == 0)
{ {
handler->SendSysMessage(LANG_BAD_VALUE); handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
obj->SetPhaseMask(phasemask, true); object->SetPhaseMask(phaseMask, true);
obj->SaveToDB(); object->SaveToDB();
return true; return true;
} }
static bool HandleGameObjectNearCommand(ChatHandler* handler, const char* args) static bool HandleGameObjectNearCommand(ChatHandler* handler, char const* args)
{ {
float distance = (!*args) ? 10.0f : (float)(atof(args)); float distance = (!*args) ? 10.0f : (float)(atof(args));
uint32 count = 0; uint32 count = 0;
Player* pl = handler->GetSession()->GetPlayer(); Player* player = handler->GetSession()->GetPlayer();
QueryResult result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, " 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_ " "(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_", "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(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(),
pl->GetMapId(), pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), distance*distance); player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), distance * distance);
if (result) if (result)
{ {
@@ -554,14 +553,14 @@ public:
float x = fields[2].GetFloat(); float x = fields[2].GetFloat();
float y = fields[3].GetFloat(); float y = fields[3].GetFloat();
float z = fields[4].GetFloat(); float z = fields[4].GetFloat();
uint16 mapid = fields[5].GetUInt16(); uint16 mapId = fields[5].GetUInt16();
GameObjectTemplate const* gInfo = sObjectMgr->GetGameObjectTemplate(entry); GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry);
if (!gInfo) if (!gameObjectInfo)
continue; continue;
handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name.c_str(), x, y, z, mapid); handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gameObjectInfo->name.c_str(), x, y, z, mapId);
++count; ++count;
} while (result->NextRow()); } while (result->NextRow());
@@ -572,99 +571,97 @@ public:
} }
//show info of gameobject //show info of gameobject
static bool HandleGameObjectInfoCommand(ChatHandler* handler, const char* args) static bool HandleGameObjectInfoCommand(ChatHandler* handler, char const* args)
{ {
uint32 entry = 0; uint32 entry = 0;
uint32 type = 0; uint32 type = 0;
uint32 displayid = 0; uint32 displayId = 0;
std::string name; std::string name;
uint32 lootId = 0; uint32 lootId = 0;
if (!*args) if (!*args)
{ {
if (WorldObject* obj = handler->getSelectedObject()) if (WorldObject* object = handler->getSelectedObject())
entry = obj->GetEntry(); entry = object->GetEntry();
else else
entry = atoi((char*)args); entry = atoi((char*)args);
} }
GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry); GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry);
if (!goinfo) if (!gameObjectInfo)
return false; return false;
type = goinfo->type; type = gameObjectInfo->type;
displayid = goinfo->displayId; displayId = gameObjectInfo->displayId;
name = goinfo->name; name = gameObjectInfo->name;
if (type == GAMEOBJECT_TYPE_CHEST) if (type == GAMEOBJECT_TYPE_CHEST)
lootId = goinfo->chest.lootId; lootId = gameObjectInfo->chest.lootId;
else if (type == GAMEOBJECT_TYPE_FISHINGHOLE) else if (type == GAMEOBJECT_TYPE_FISHINGHOLE)
lootId = goinfo->fishinghole.lootId; lootId = gameObjectInfo->fishinghole.lootId;
handler->PSendSysMessage(LANG_GOINFO_ENTRY, entry); handler->PSendSysMessage(LANG_GOINFO_ENTRY, entry);
handler->PSendSysMessage(LANG_GOINFO_TYPE, type); handler->PSendSysMessage(LANG_GOINFO_TYPE, type);
handler->PSendSysMessage(LANG_GOINFO_LOOTID, lootId); handler->PSendSysMessage(LANG_GOINFO_LOOTID, lootId);
handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayid); handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayId);
handler->PSendSysMessage(LANG_GOINFO_NAME, name.c_str()); handler->PSendSysMessage(LANG_GOINFO_NAME, name.c_str());
return true; return true;
} }
static bool HandleGameObjectSetStateCommand(ChatHandler* handler, const char* args) static bool HandleGameObjectSetStateCommand(ChatHandler* handler, char const* args)
{ {
// number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
if (!cId) if (!id)
return false; return false;
uint32 lowguid = atoi(cId); uint32 guidLow = atoi(id);
if (!lowguid) if (!guidLow)
return false; return false;
GameObject* gobj = NULL; GameObject* object = NULL;
if (GameObjectData const* goData = sObjectMgr->GetGOData(lowguid)) if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
gobj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, goData->id); object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
if (!gobj) if (!object)
{ {
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
return false; return false;
} }
char* ctype = strtok(NULL, " "); char* type = strtok(NULL, " ");
if (!ctype) if (!type)
return false; return false;
int32 type = atoi(ctype); int32 objectType = atoi(type);
if (type < 0) if (objectType < 0)
{
if (type == -1)
gobj->SendObjectDeSpawnAnim(gobj->GetGUID());
else if (type == -2)
{ {
if (objectType == -1)
object->SendObjectDeSpawnAnim(object->GetGUID());
else if (objectType == -2)
return false; return false;
}
return true; return true;
} }
char* cstate = strtok(NULL, " "); char* state = strtok(NULL, " ");
if (!cstate) if (!state)
return false; return false;
int32 state = atoi(cstate); int32 objectState = atoi(state);
if (type < 4) if (objectType < 4)
gobj->SetByteValue(GAMEOBJECT_BYTES_1, type, state); object->SetByteValue(GAMEOBJECT_BYTES_1, objectType, objectState);
else if (type == 4) else if (objectType == 4)
{ {
WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM, 8+4); WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM, 8+4);
data << gobj->GetGUID(); data << object->GetGUID();
data << (uint32)(state); data << (uint32)(objectState);
gobj->SendMessageToSet(&data, true); object->SendMessageToSet(&data, true);
} }
handler->PSendSysMessage("Set gobject type %d state %d", type, state); handler->PSendSysMessage("Set gobject type %d state %d", objectType, objectState);
return true; return true;
} }
}; };