From 1172114a3ee4c78b07e756bfe224295c21f3d456 Mon Sep 17 00:00:00 2001 From: megamage Date: Sat, 3 Jan 2009 21:02:04 -0600 Subject: *Trigger dimnishing return when player is killed rather than when player releases spirit. --HG-- branch : trunk --- src/game/Player.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/game') diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 4ae14a2e4a3..36d261827e3 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -3798,7 +3798,7 @@ void Player::BuildPlayerRepop() // BG - remove insignia related RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); - SendCorpseReclaimDelay(); +// SendCorpseReclaimDelay(); // to prevent cheating corpse->ResetGhostTime(); @@ -3906,6 +3906,7 @@ void Player::KillPlayer() m_deathTimer = 6*MINUTE*1000; UpdateCorpseReclaimDelay(); // dependent at use SetDeathPvP() call before kill + SendCorpseReclaimDelay(); // don't create corpse at this moment, player might be falling @@ -18820,17 +18821,21 @@ void Player::UpdateCorpseReclaimDelay() void Player::SendCorpseReclaimDelay(bool load) { Corpse* corpse = GetCorpse(); - if(!corpse) + if(load && !corpse) return; + bool pvp; + if(corpse) + pvp = (corpse->GetType() == CORPSE_RESURRECTABLE_PVP); + else + pvp = (m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH); + uint32 delay; if(load) { if(corpse->GetGhostTime() > m_deathExpireTime) return; - bool pvp = corpse->GetType()==CORPSE_RESURRECTABLE_PVP; - uint32 count; if( pvp && sWorld.getConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP) || !pvp && sWorld.getConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE) ) @@ -18851,7 +18856,7 @@ void Player::SendCorpseReclaimDelay(bool load) delay = expected_time-now; } else - delay = GetCorpseReclaimDelay(corpse->GetType()==CORPSE_RESURRECTABLE_PVP); + delay = GetCorpseReclaimDelay(pvp); //! corpse reclaim delay 30 * 1000ms or longer at often deaths WorldPacket data(SMSG_CORPSE_RECLAIM_DELAY, 4); -- cgit v1.2.3 From 5d4dcba0de0d764ae9bf81071171ef41e377b063 Mon Sep 17 00:00:00 2001 From: megamage Date: Sat, 3 Jan 2009 21:24:19 -0600 Subject: *Update pet's speed when pet is incombat rather than when owner is in combat. --HG-- branch : trunk --- src/game/PetAI.cpp | 3 +++ src/game/Unit.cpp | 33 +++++++++++++++++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) (limited to 'src/game') diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index 6a87d52cfca..82259cbba4d 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -73,6 +73,9 @@ void PetAI::AttackStart(Unit *u) if(i_pet.Attack(u,true)) { + i_pet.SetInCombatWith(u); + u->SetInCombatWith(&i_pet); + i_pet.clearUnitState(UNIT_STAT_FOLLOW); // TMGs call CreatureRelocation which via MoveInLineOfSight can call this function // thus with the following clear the original TMG gets invalidated and crash, doh diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index ee4ca89eaa5..8582d262e3a 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -9757,18 +9757,16 @@ void Unit::SetInCombatState(bool PvP) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - if(isCharmed() || GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->isPet()) - SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); - - if(GetTypeId() == TYPEID_PLAYER && GetPetGUID()) + if(GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->isPet()) { - if(Pet *pet = GetPet()) - { - pet->UpdateSpeed(MOVE_RUN, true); - pet->UpdateSpeed(MOVE_SWIM, true); - pet->UpdateSpeed(MOVE_FLIGHT, true); - } + UpdateSpeed(MOVE_RUN, true); + UpdateSpeed(MOVE_SWIM, true); + UpdateSpeed(MOVE_FLIGHT, true); } + else if(!isCharmed()) + return; + + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); } void Unit::ClearInCombat() @@ -9776,19 +9774,22 @@ void Unit::ClearInCombat() m_CombatTimer = 0; RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - if(isCharmed() || GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->isPet()) - RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); - // Player's state will be cleared in Player::UpdateContestedPvP if(GetTypeId()!=TYPEID_PLAYER) clearUnitState(UNIT_STAT_ATTACK_PLAYER); - if(GetTypeId() == TYPEID_PLAYER && GetPetGUID()) + if(GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->isPet()) { - if(Pet *pet = GetPet()) + if(Unit *owner = GetOwner()) + { for(int i = 0; i < MAX_MOVE_TYPE; ++i) - pet->SetSpeed(UnitMoveType(i), m_speed_rate[i], true); + SetSpeed(UnitMoveType(i), owner->GetSpeedRate(UnitMoveType(i)), true); + } } + else if(!isCharmed()) + return; + + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); } //TODO: remove this function -- cgit v1.2.3 From e19482bcb4a0867ca729779ab680fd10b849d797 Mon Sep 17 00:00:00 2001 From: megamage Date: Sat, 3 Jan 2009 22:14:32 -0600 Subject: *Fix a bug about corpse reclaim delay timer. --HG-- branch : trunk --- src/game/Player.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 36d261827e3..0db4a665d80 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -18792,7 +18792,8 @@ uint32 Player::GetCorpseReclaimDelay(bool pvp) const time_t now = time(NULL); // 0..2 full period - uint32 count = (now < m_deathExpireTime) ? (m_deathExpireTime - now)/DEATH_EXPIRE_STEP : 0; + // should be ceil(x)-1 but not floor(x) + uint32 count = (now < m_deathExpireTime - 1) ? (m_deathExpireTime - 1 - now)/DEATH_EXPIRE_STEP : 0; return copseReclaimDelay[count]; } -- cgit v1.2.3 From c9f0d4292afa4b468728c456f7ec0f56d8d15c62 Mon Sep 17 00:00:00 2001 From: Blaymoira Date: Sun, 4 Jan 2009 17:20:23 +0100 Subject: *Cleaned up database queries - by XTZGZoReX --HG-- branch : trunk --- src/game/AccountMgr.cpp | 50 +++++++++++++++++++-------------------- src/game/CharacterHandler.cpp | 10 ++++---- src/game/Level0.cpp | 4 ++-- src/game/Level2.cpp | 18 +++++++------- src/game/Level3.cpp | 38 ++++++++++++++--------------- src/game/MiscHandler.cpp | 2 +- src/game/Player.cpp | 2 +- src/game/World.cpp | 32 ++++++++++++------------- src/game/WorldSession.cpp | 2 +- src/game/WorldSocket.cpp | 12 +++++----- src/shared/Database/DatabaseEnv.h | 2 +- src/trinitycore/CliRunnable.cpp | 2 +- src/trinitycore/Main.cpp | 2 +- src/trinitycore/Master.cpp | 12 +++++----- src/trinitycore/RASocket.cpp | 10 ++++---- src/trinityrealm/AuthSocket.cpp | 36 ++++++++++++++-------------- src/trinityrealm/Main.cpp | 8 +++---- src/trinityrealm/RealmList.cpp | 4 ++-- 18 files changed, 123 insertions(+), 123 deletions(-) (limited to 'src/game') diff --git a/src/game/AccountMgr.cpp b/src/game/AccountMgr.cpp index dedc1150ba4..adf47f8acab 100644 --- a/src/game/AccountMgr.cpp +++ b/src/game/AccountMgr.cpp @@ -26,9 +26,9 @@ #include "Util.h" #ifdef DO_POSTGRESQL -extern DatabasePostgre loginDatabase; +extern DatabasePostgre LoginDatabase; #else -extern DatabaseMysql loginDatabase; +extern DatabaseMysql LoginDatabase; #endif INSTANTIATE_SINGLETON_1(AccountMgr); @@ -47,26 +47,26 @@ AccountOpResult AccountMgr::CreateAccount(std::string username, std::string pass normilizeString(username); normilizeString(password); - loginDatabase.escape_string(username); - loginDatabase.escape_string(password); + LoginDatabase.escape_string(username); + LoginDatabase.escape_string(password); - QueryResult *result = loginDatabase.PQuery("SELECT 1 FROM account WHERE username = '%s'", username.c_str()); + QueryResult *result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE username = '%s'", username.c_str()); if(result) { delete result; return AOR_NAME_ALREDY_EXIST; // username does already exist } - if(!loginDatabase.PExecute("INSERT INTO account(username,sha_pass_hash,joindate) VALUES('%s',SHA1(CONCAT('%s',':','%s')),NOW())", username.c_str(), username.c_str(), password.c_str())) + if(!LoginDatabase.PExecute("INSERT INTO account(username,sha_pass_hash,joindate) VALUES('%s',SHA1(CONCAT('%s',':','%s')),NOW())", username.c_str(), username.c_str(), password.c_str())) return AOR_DB_INTERNAL_ERROR; // unexpected error - loginDatabase.Execute("INSERT INTO realmcharacters (realmid, acctid, numchars) SELECT realmlist.id, account.id, 0 FROM realmlist,account LEFT JOIN realmcharacters ON acctid=account.id WHERE acctid IS NULL"); + LoginDatabase.Execute("INSERT INTO realmcharacters (realmid, acctid, numchars) SELECT realmlist.id, account.id, 0 FROM realmlist,account LEFT JOIN realmcharacters ON acctid=account.id WHERE acctid IS NULL"); return AOR_OK; // everything's fine } AccountOpResult AccountMgr::DeleteAccount(uint32 accid) { - QueryResult *result = loginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accid); + QueryResult *result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accid); if(!result) return AOR_NAME_NOT_EXIST; // account doesn't exist delete result; @@ -97,13 +97,13 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid) // table realm specific but common for all characters of account for realm CharacterDatabase.PExecute("DELETE FROM character_tutorial WHERE account = '%u'",accid); - loginDatabase.BeginTransaction(); + LoginDatabase.BeginTransaction(); bool res = - loginDatabase.PExecute("DELETE FROM account WHERE id='%d'", accid) && - loginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid='%d'", accid); + LoginDatabase.PExecute("DELETE FROM account WHERE id='%d'", accid) && + LoginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid='%d'", accid); - loginDatabase.CommitTransaction(); + LoginDatabase.CommitTransaction(); if(!res) return AOR_DB_INTERNAL_ERROR; // unexpected error; @@ -113,7 +113,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid) AccountOpResult AccountMgr::ChangeUsername(uint32 accid, std::string new_uname, std::string new_passwd) { - QueryResult *result = loginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accid); + QueryResult *result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accid); if(!result) return AOR_NAME_NOT_EXIST; // account doesn't exist delete result; @@ -127,9 +127,9 @@ AccountOpResult AccountMgr::ChangeUsername(uint32 accid, std::string new_uname, normilizeString(new_uname); normilizeString(new_passwd); - loginDatabase.escape_string(new_uname); - loginDatabase.escape_string(new_passwd); - if(!loginDatabase.PExecute("UPDATE account SET username='%s',sha_pass_hash=SHA1(CONCAT('%s',':','%s')) WHERE id='%d'", new_uname.c_str(), new_uname.c_str(), new_passwd.c_str(), accid)) + LoginDatabase.escape_string(new_uname); + LoginDatabase.escape_string(new_passwd); + if(!LoginDatabase.PExecute("UPDATE account SET username='%s',sha_pass_hash=SHA1(CONCAT('%s',':','%s')) WHERE id='%d'", new_uname.c_str(), new_uname.c_str(), new_passwd.c_str(), accid)) return AOR_DB_INTERNAL_ERROR; // unexpected error return AOR_OK; @@ -137,7 +137,7 @@ AccountOpResult AccountMgr::ChangeUsername(uint32 accid, std::string new_uname, AccountOpResult AccountMgr::ChangePassword(uint32 accid, std::string new_passwd) { - QueryResult *result = loginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accid); + QueryResult *result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accid); if(!result) return AOR_NAME_NOT_EXIST; // account doesn't exist delete result; @@ -147,8 +147,8 @@ AccountOpResult AccountMgr::ChangePassword(uint32 accid, std::string new_passwd) normilizeString(new_passwd); - loginDatabase.escape_string(new_passwd); - if(!loginDatabase.PExecute("UPDATE account SET sha_pass_hash=SHA1(CONCAT(username,':','%s')) WHERE id='%d'", new_passwd.c_str(), accid)) + LoginDatabase.escape_string(new_passwd); + if(!LoginDatabase.PExecute("UPDATE account SET sha_pass_hash=SHA1(CONCAT(username,':','%s')) WHERE id='%d'", new_passwd.c_str(), accid)) return AOR_DB_INTERNAL_ERROR; // unexpected error return AOR_OK; @@ -156,8 +156,8 @@ AccountOpResult AccountMgr::ChangePassword(uint32 accid, std::string new_passwd) uint32 AccountMgr::GetId(std::string username) { - loginDatabase.escape_string(username); - QueryResult *result = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", username.c_str()); + LoginDatabase.escape_string(username); + QueryResult *result = LoginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", username.c_str()); if(!result) return 0; else @@ -170,7 +170,7 @@ uint32 AccountMgr::GetId(std::string username) uint32 AccountMgr::GetSecurity(uint32 acc_id) { - QueryResult *result = loginDatabase.PQuery("SELECT gmlevel FROM account WHERE id = '%u'", acc_id); + QueryResult *result = LoginDatabase.PQuery("SELECT gmlevel FROM account WHERE id = '%u'", acc_id); if(result) { uint32 sec = (*result)[0].GetUInt32(); @@ -183,7 +183,7 @@ uint32 AccountMgr::GetSecurity(uint32 acc_id) bool AccountMgr::GetName(uint32 acc_id, std::string &name) { - QueryResult *result = loginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", acc_id); + QueryResult *result = LoginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", acc_id); if(result) { name = (*result)[0].GetCppString(); @@ -197,9 +197,9 @@ bool AccountMgr::GetName(uint32 acc_id, std::string &name) bool AccountMgr::CheckPassword(uint32 accid, std::string passwd) { normilizeString(passwd); - loginDatabase.escape_string(passwd); + LoginDatabase.escape_string(passwd); - QueryResult *result = loginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d' AND sha_pass_hash=SHA1(CONCAT(username,':','%s'))", accid, passwd.c_str()); + QueryResult *result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d' AND sha_pass_hash=SHA1(CONCAT(username,':','%s'))", accid, passwd.c_str()); if (result) { delete result; diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 1190a45d050..170f425022c 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -121,7 +121,7 @@ class CharacterHandler void WorldSession::HandleCharEnum(QueryResult * result) { // keys can be non cleared if player open realm list and close it by 'cancel' - loginDatabase.PExecute("UPDATE account SET v = '0', s = '0' WHERE id = '%u'", GetAccountId()); + LoginDatabase.PExecute("UPDATE account SET v = '0', s = '0' WHERE id = '%u'", GetAccountId()); WorldPacket data(SMSG_CHAR_ENUM, 100); // we guess size @@ -280,7 +280,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data ) return; } - QueryResult *resultacct = loginDatabase.PQuery("SELECT SUM(numchars) FROM realmcharacters WHERE acctid = '%d'", GetAccountId()); + QueryResult *resultacct = LoginDatabase.PQuery("SELECT SUM(numchars) FROM realmcharacters WHERE acctid = '%d'", GetAccountId()); if ( resultacct ) { Field *fields=resultacct->Fetch(); @@ -380,8 +380,8 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data ) pNewChar->SaveToDB(); charcount+=1; - loginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid= '%d' AND realmid = '%d'", GetAccountId(), realmID); - loginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)", charcount, GetAccountId(), realmID); + LoginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid= '%d' AND realmid = '%d'", GetAccountId(), realmID); + LoginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)", charcount, GetAccountId(), realmID); delete pNewChar; // created only to call SaveToDB() @@ -648,7 +648,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) pCurrChar->SendInitialPacketsAfterAddToMap(); CharacterDatabase.PExecute("UPDATE characters SET online = 1 WHERE guid = '%u'", pCurrChar->GetGUIDLow()); - loginDatabase.PExecute("UPDATE account SET online = 1 WHERE id = '%u'", GetAccountId()); + LoginDatabase.PExecute("UPDATE account SET online = 1 WHERE id = '%u'", GetAccountId()); pCurrChar->SetInGameTime( getMSTime() ); // announce group about member online (must be after add to player list to receive announce to self) diff --git a/src/game/Level0.cpp b/src/game/Level0.cpp index 75f7a257caf..126c889d854 100644 --- a/src/game/Level0.cpp +++ b/src/game/Level0.cpp @@ -243,14 +243,14 @@ bool ChatHandler::HandleLockAccountCommand(const char* args) std::string argstr = (char*)args; if (argstr == "on") { - loginDatabase.PExecute( "UPDATE account SET locked = '1' WHERE id = '%d'",m_session->GetAccountId()); + LoginDatabase.PExecute( "UPDATE account SET locked = '1' WHERE id = '%d'",m_session->GetAccountId()); PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED); return true; } if (argstr == "off") { - loginDatabase.PExecute( "UPDATE account SET locked = '0' WHERE id = '%d'",m_session->GetAccountId()); + LoginDatabase.PExecute( "UPDATE account SET locked = '0' WHERE id = '%d'",m_session->GetAccountId()); PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED); return true; } diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index a1db396dec9..6601e52d270 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -114,7 +114,7 @@ bool ChatHandler::HandleMuteCommand(const char* args) if (chr) chr->GetSession()->m_muteTime = mutetime; - loginDatabase.PExecute("UPDATE account SET mutetime = " I64FMTD " WHERE id = '%u'",uint64(mutetime), account_id ); + LoginDatabase.PExecute("UPDATE account SET mutetime = " I64FMTD " WHERE id = '%u'",uint64(mutetime), account_id ); if(chr) ChatHandler(chr).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime); @@ -187,7 +187,7 @@ bool ChatHandler::HandleUnmuteCommand(const char* args) chr->GetSession()->m_muteTime = 0; } - loginDatabase.PExecute("UPDATE account SET mutetime = '0' WHERE id = '%u'", account_id ); + LoginDatabase.PExecute("UPDATE account SET mutetime = '0' WHERE id = '%u'", account_id ); if(chr) ChatHandler(chr).PSendSysMessage(LANG_YOUR_CHAT_ENABLED); @@ -1869,7 +1869,7 @@ bool ChatHandler::HandlePInfoCommand(const char* args) uint32 security = 0; std::string last_login = GetTrinityString(LANG_ERROR); - QueryResult* result = loginDatabase.PQuery("SELECT username,gmlevel,last_ip,last_login FROM account WHERE id = '%u'",accId); + QueryResult* result = LoginDatabase.PQuery("SELECT username,gmlevel,last_ip,last_login FROM account WHERE id = '%u'",accId); if(result) { Field* fields = result->Fetch(); @@ -3583,9 +3583,9 @@ bool ChatHandler::HandleLookupPlayerIpCommand(const char* args) char* limit_str = strtok (NULL, " "); int32 limit = limit_str ? atoi (limit_str) : -1; - loginDatabase.escape_string (ip); + LoginDatabase.escape_string (ip); - QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE last_ip = '%s'", ip.c_str ()); + QueryResult* result = LoginDatabase.PQuery ("SELECT id,username FROM account WHERE last_ip = '%s'", ip.c_str ()); return LookupPlayerSearchCommand (result,limit); } @@ -3602,9 +3602,9 @@ bool ChatHandler::HandleLookupPlayerAccountCommand(const char* args) if (!AccountMgr::normilizeString (account)) return false; - loginDatabase.escape_string (account); + LoginDatabase.escape_string (account); - QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE username = '%s'", account.c_str ()); + QueryResult* result = LoginDatabase.PQuery ("SELECT id,username FROM account WHERE username = '%s'", account.c_str ()); return LookupPlayerSearchCommand (result,limit); } @@ -3619,9 +3619,9 @@ bool ChatHandler::HandleLookupPlayerEmailCommand(const char* args) char* limit_str = strtok (NULL, " "); int32 limit = limit_str ? atoi (limit_str) : -1; - loginDatabase.escape_string (email); + LoginDatabase.escape_string (email); - QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE email = '%s'", email.c_str ()); + QueryResult* result = LoginDatabase.PQuery ("SELECT id,username FROM account WHERE email = '%s'", email.c_str ()); return LookupPlayerSearchCommand (result,limit); } diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 123b1dceb09..6a05a81fbae 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -764,7 +764,7 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args) PSendSysMessage(LANG_YOURS_SECURITY_CHANGED, m_session->GetPlayer()->GetName(), gm); } - loginDatabase.PExecute("UPDATE account SET gmlevel = '%d' WHERE id = '%u'", gm, targetAccountId); + LoginDatabase.PExecute("UPDATE account SET gmlevel = '%d' WHERE id = '%u'", gm, targetAccountId); return true; }else { @@ -805,7 +805,7 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args) } PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); - loginDatabase.PExecute("UPDATE account SET gmlevel = '%d' WHERE id = '%u'", gm, targetAccountId); + LoginDatabase.PExecute("UPDATE account SET gmlevel = '%d' WHERE id = '%u'", gm, targetAccountId); return true; } } @@ -5239,7 +5239,7 @@ bool ChatHandler::HandleBanInfoCharacterCommand(const char* args) bool ChatHandler::HandleBanInfoHelper(uint32 accountid, char const* accountname) { - QueryResult *result = loginDatabase.PQuery("SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate,banreason,bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC",accountid); + QueryResult *result = LoginDatabase.PQuery("SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate,banreason,bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC",accountid); if(!result) { PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN, accountname); @@ -5279,8 +5279,8 @@ bool ChatHandler::HandleBanInfoIPCommand(const char* args) std::string IP = cIP; - loginDatabase.escape_string(IP); - QueryResult *result = loginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'",IP.c_str()); + LoginDatabase.escape_string(IP); + QueryResult *result = LoginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'",IP.c_str()); if(!result) { PSendSysMessage(LANG_BANINFO_NOIP); @@ -5298,14 +5298,14 @@ bool ChatHandler::HandleBanInfoIPCommand(const char* args) bool ChatHandler::HandleBanListCharacterCommand(const char* args) { - loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); + LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); char* cFilter = strtok ((char*)args, " "); if(!cFilter) return false; std::string filter = cFilter; - loginDatabase.escape_string(filter); + LoginDatabase.escape_string(filter); QueryResult* result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),filter.c_str()); if (!result) { @@ -5318,22 +5318,22 @@ bool ChatHandler::HandleBanListCharacterCommand(const char* args) bool ChatHandler::HandleBanListAccountCommand(const char* args) { - loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); + LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); char* cFilter = strtok((char*)args, " "); std::string filter = cFilter ? cFilter : ""; - loginDatabase.escape_string(filter); + LoginDatabase.escape_string(filter); QueryResult* result; if(filter.empty()) { - result = loginDatabase.Query("SELECT account.id, username FROM account, account_banned" + result = LoginDatabase.Query("SELECT account.id, username FROM account, account_banned" " WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id"); } else { - result = loginDatabase.PQuery("SELECT account.id, username FROM account, account_banned" + result = LoginDatabase.PQuery("SELECT account.id, username FROM account, account_banned" " WHERE account.id = account_banned.id AND active = 1 AND username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" GROUP BY account.id", filter.c_str()); } @@ -5359,7 +5359,7 @@ bool ChatHandler::HandleBanListHelper(QueryResult* result) Field* fields = result->Fetch(); uint32 accountid = fields[0].GetUInt32(); - QueryResult* banresult = loginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id",accountid); + QueryResult* banresult = LoginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id",accountid); if(banresult) { Field* fields2 = banresult->Fetch(); @@ -5390,7 +5390,7 @@ bool ChatHandler::HandleBanListHelper(QueryResult* result) accmgr.GetName (account_id,account_name); // No SQL injection. id is uint32. - QueryResult *banInfo = loginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id); + QueryResult *banInfo = LoginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id); if (banInfo) { Field *fields2 = banInfo->Fetch(); @@ -5427,23 +5427,23 @@ bool ChatHandler::HandleBanListHelper(QueryResult* result) bool ChatHandler::HandleBanListIPCommand(const char* args) { - loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); + LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); char* cFilter = strtok((char*)args, " "); std::string filter = cFilter ? cFilter : ""; - loginDatabase.escape_string(filter); + LoginDatabase.escape_string(filter); QueryResult* result; if(filter.empty()) { - result = loginDatabase.Query ("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" + result = LoginDatabase.Query ("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP())" " ORDER BY unbandate" ); } else { - result = loginDatabase.PQuery( "SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" + result = LoginDatabase.PQuery( "SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP()) AND ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'") " ORDER BY unbandate",filter.c_str() ); } @@ -6231,7 +6231,7 @@ bool ChatHandler::HandleInstanceSaveDataCommand(const char * /*args*/) bool ChatHandler::HandleGMListFullCommand(const char* /*args*/) { ///- Get the accounts with GM Level >0 - QueryResult *result = loginDatabase.Query( "SELECT username,gmlevel FROM account WHERE gmlevel > 0" ); + QueryResult *result = LoginDatabase.Query( "SELECT username,gmlevel FROM account WHERE gmlevel > 0" ); if(result) { SendSysMessage(LANG_GMLIST); @@ -6310,7 +6310,7 @@ bool ChatHandler::HandleAccountSetAddonCommand(const char* args) return false; // No SQL injection - loginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",lev,account_id); + LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",lev,account_id); PSendSysMessage(LANG_ACCOUNT_SETADDON,account_name.c_str(),account_id,lev); return true; } diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index f5ee5dbcf4c..73bfbf2ff31 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -1285,7 +1285,7 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) uint32 accid = plr->GetSession()->GetAccountId(); - QueryResult *result = loginDatabase.PQuery("SELECT username,email,last_ip FROM account WHERE id=%u", accid); + QueryResult *result = LoginDatabase.PQuery("SELECT username,email,last_ip FROM account WHERE id=%u", accid); if(!result) { SendNotification(LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND, charname.c_str()); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 0db4a665d80..7096118f02f 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -3735,7 +3735,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u'",guid); CharacterDatabase.CommitTransaction(); - //loginDatabase.PExecute("UPDATE realmcharacters SET numchars = numchars - 1 WHERE acctid = %d AND realmid = %d", accountId, realmID); + //LoginDatabase.PExecute("UPDATE realmcharacters SET numchars = numchars - 1 WHERE acctid = %d AND realmid = %d", accountId, realmID); if(updateRealmChars) sWorld.UpdateRealmCharCount(accountId); } diff --git a/src/game/World.cpp b/src/game/World.cpp index d525945bd20..c5ed1800132 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -267,7 +267,7 @@ World::AddSession_ (WorldSession* s) float popu = GetActiveSessionCount (); //updated number of users on the server popu /= pLimit; popu *= 2; - loginDatabase.PExecute ("UPDATE realmlist SET population = '%f' WHERE id = '%d'", popu, realmID); + LoginDatabase.PExecute ("UPDATE realmlist SET population = '%f' WHERE id = '%d'", popu, realmID); sLog.outDetail ("Server Population (%f).", popu); } } @@ -1052,7 +1052,7 @@ void World::SetInitialWorldSettings() // not send custom type REALM_FFA_PVP to realm list uint32 server_type = IsFFAPvPRealm() ? REALM_TYPE_PVP : getConfig(CONFIG_GAME_TYPE); uint32 realm_zone = getConfig(CONFIG_REALM_ZONE); - loginDatabase.PExecute("UPDATE realmlist SET icon = %u, timezone = %u WHERE id = '%d'", server_type, realm_zone, realmID); + LoginDatabase.PExecute("UPDATE realmlist SET icon = %u, timezone = %u WHERE id = '%d'", server_type, realm_zone, realmID); ///- Remove the bones after a restart CharacterDatabase.PExecute("DELETE FROM corpse WHERE corpse_type = '0'"); @@ -1362,7 +1362,7 @@ void World::SetInitialWorldSettings() objmgr.LoadTransportEvents(); sLog.outString("Deleting expired bans..." ); - loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); + LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); sLog.outString("Calculate next daily quest reset time..." ); InitDailyQuestResetTime(); @@ -2601,10 +2601,10 @@ bool World::KickPlayer(const std::string& playerName) /// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author) { - loginDatabase.escape_string(nameOrIP); - loginDatabase.escape_string(reason); + LoginDatabase.escape_string(nameOrIP); + LoginDatabase.escape_string(reason); std::string safe_author=author; - loginDatabase.escape_string(safe_author); + LoginDatabase.escape_string(safe_author); uint32 duration_secs = TimeStringToSecs(duration); QueryResult *resultAccounts = NULL; //used for kicking @@ -2614,12 +2614,12 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string dura { case BAN_IP: //No SQL injection as strings are escaped - resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE last_ip = '%s'",nameOrIP.c_str()); - loginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+%u,'%s','%s')",nameOrIP.c_str(),duration_secs,safe_author.c_str(),reason.c_str()); + resultAccounts = LoginDatabase.PQuery("SELECT id FROM account WHERE last_ip = '%s'",nameOrIP.c_str()); + LoginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+%u,'%s','%s')",nameOrIP.c_str(),duration_secs,safe_author.c_str(),reason.c_str()); break; case BAN_ACCOUNT: //No SQL injection as string is escaped - resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'",nameOrIP.c_str()); + resultAccounts = LoginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'",nameOrIP.c_str()); break; case BAN_CHARACTER: //No SQL injection as string is escaped @@ -2646,7 +2646,7 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string dura if(mode!=BAN_IP) { //No SQL injection as strings are escaped - loginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, '%s', '%s', '1')", + LoginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, '%s', '%s', '1')", account,duration_secs,safe_author.c_str(),reason.c_str()); } @@ -2665,8 +2665,8 @@ bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP) { if (mode == BAN_IP) { - loginDatabase.escape_string(nameOrIP); - loginDatabase.PExecute("DELETE FROM ip_banned WHERE ip = '%s'",nameOrIP.c_str()); + LoginDatabase.escape_string(nameOrIP); + LoginDatabase.PExecute("DELETE FROM ip_banned WHERE ip = '%s'",nameOrIP.c_str()); } else { @@ -2680,7 +2680,7 @@ bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP) return false; //NO SQL injection as account is uint32 - loginDatabase.PExecute("UPDATE account_banned SET active = '0' WHERE id = '%u'",account); + LoginDatabase.PExecute("UPDATE account_banned SET active = '0' WHERE id = '%u'",account); } return true; } @@ -2877,8 +2877,8 @@ void World::_UpdateRealmCharCount(QueryResult *resultCharCount, uint32 accountId Field *fields = resultCharCount->Fetch(); uint32 charCount = fields[0].GetUInt32(); delete resultCharCount; - loginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid= '%d' AND realmid = '%d'", accountId, realmID); - loginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)", charCount, accountId, realmID); + LoginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid= '%d' AND realmid = '%d'", accountId, realmID); + LoginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)", charCount, accountId, realmID); } } @@ -2941,7 +2941,7 @@ void World::SetPlayerLimit( int32 limit, bool needUpdate ) m_playerLimit = limit; if(db_update_need) - loginDatabase.PExecute("UPDATE realmlist SET allowedSecurityLevel = '%u' WHERE id = '%d'",uint8(GetPlayerSecurityLimit()),realmID); + LoginDatabase.PExecute("UPDATE realmlist SET allowedSecurityLevel = '%u' WHERE id = '%d'",uint8(GetPlayerSecurityLimit()),realmID); } void World::UpdateMaxSessionCounters() diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 47e1334198e..f2e08969a96 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -324,7 +324,7 @@ void WorldSession::LogoutPlayer(bool Save) ///- Reset the online field in the account table // no point resetting online in character table here as Player::SaveToDB() will set it to 1 since player has not been removed from world at this stage //No SQL injection as AccountID is uint32 - loginDatabase.PExecute("UPDATE account SET online = 0 WHERE id = '%u'", GetAccountId()); + LoginDatabase.PExecute("UPDATE account SET online = 0 WHERE id = '%u'", GetAccountId()); ///- If the player is in a guild, update the guild roster and broadcast a logout message to other guild members Guild *guild = objmgr.GetGuildById(_player->GetGuildId()); diff --git a/src/game/WorldSocket.cpp b/src/game/WorldSocket.cpp index 01d5a0e5490..847fd2e8384 100644 --- a/src/game/WorldSocket.cpp +++ b/src/game/WorldSocket.cpp @@ -679,11 +679,11 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) // Get the account information from the realmd database std::string safe_account = account; // Duplicate, else will screw the SHA hash verification below - loginDatabase.escape_string (safe_account); + LoginDatabase.escape_string (safe_account); // No SQL injection, username escaped. QueryResult *result = - loginDatabase.PQuery ("SELECT " + LoginDatabase.PQuery ("SELECT " "id, " //0 "gmlevel, " //1 "sessionkey, " //2 @@ -748,7 +748,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) vold, vStr); - loginDatabase.PExecute ("UPDATE account " + LoginDatabase.PExecute ("UPDATE account " "SET " "v = '0', " "s = '0' " @@ -800,7 +800,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) // Re-check account ban (same check as in realmd) QueryResult *banresult = - loginDatabase.PQuery ("SELECT " + LoginDatabase.PQuery ("SELECT " "bandate, " "unbandate " "FROM account_banned " @@ -866,9 +866,9 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) // Update the last_ip in the database // No SQL injection, username escaped. - loginDatabase.escape_string (address); + LoginDatabase.escape_string (address); - loginDatabase.PExecute ("UPDATE account " + LoginDatabase.PExecute ("UPDATE account " "SET last_ip = '%s' " "WHERE username = '%s'", address.c_str (), diff --git a/src/shared/Database/DatabaseEnv.h b/src/shared/Database/DatabaseEnv.h index cc09b7611db..d984a838c90 100644 --- a/src/shared/Database/DatabaseEnv.h +++ b/src/shared/Database/DatabaseEnv.h @@ -53,6 +53,6 @@ typedef DatabaseMysql DatabaseType; extern DatabaseType WorldDatabase; extern DatabaseType CharacterDatabase; -extern DatabaseType loginDatabase; +extern DatabaseType LoginDatabase; #endif diff --git a/src/trinitycore/CliRunnable.cpp b/src/trinitycore/CliRunnable.cpp index 78c6e0dbb85..267a8d41a27 100644 --- a/src/trinitycore/CliRunnable.cpp +++ b/src/trinitycore/CliRunnable.cpp @@ -194,7 +194,7 @@ bool ChatHandler::HandleAccountOnlineListCommand(const char* args) ///- Get the username, last IP and GM level of each account // No SQL injection. account is uint32. // 0 1 2 3 - QueryResult *resultLogin = loginDatabase.PQuery("SELECT username, last_ip, gmlevel, expansion FROM account WHERE id = '%u'",account); + QueryResult *resultLogin = LoginDatabase.PQuery("SELECT username, last_ip, gmlevel, expansion FROM account WHERE id = '%u'",account); if(resultLogin) { diff --git a/src/trinitycore/Main.cpp b/src/trinitycore/Main.cpp index 3767e73b844..a4bcf717d62 100644 --- a/src/trinitycore/Main.cpp +++ b/src/trinitycore/Main.cpp @@ -54,7 +54,7 @@ int m_ServiceStatus = -1; DatabaseType WorldDatabase; ///< Accessor to the world database DatabaseType CharacterDatabase; ///< Accessor to the character database -DatabaseType loginDatabase; ///< Accessor to the realm/login database +DatabaseType LoginDatabase; ///< Accessor to the realm/login database uint32 realmID; ///< Id of the realm diff --git a/src/trinitycore/Master.cpp b/src/trinitycore/Master.cpp index eea1606256c..c1484fede8e 100644 --- a/src/trinitycore/Master.cpp +++ b/src/trinitycore/Master.cpp @@ -136,7 +136,7 @@ public: loopCounter = 0; sLog.outDetail ("Ping MySQL to keep connection alive"); delete WorldDatabase.Query ("SELECT 1 FROM command LIMIT 1"); - delete loginDatabase.Query ("SELECT 1 FROM realmlist LIMIT 1"); + delete LoginDatabase.Query ("SELECT 1 FROM realmlist LIMIT 1"); delete CharacterDatabase.Query ("SELECT 1 FROM bugreport LIMIT 1"); } } @@ -239,7 +239,7 @@ int Master::Run() t.setPriority ((ZThread::Priority )2); // set server online - loginDatabase.PExecute("UPDATE realmlist SET color = 0, population = 0 WHERE id = '%d'",realmID); + LoginDatabase.PExecute("UPDATE realmlist SET color = 0, population = 0 WHERE id = '%d'",realmID); #ifdef WIN32 if (sConfig.GetBoolDefault("Console.Enable", true) && (m_ServiceStatus == -1)/* need disable console in service mode*/) @@ -330,7 +330,7 @@ int Master::Run() sWorldSocketMgr->Wait (); // set server offline - loginDatabase.PExecute("UPDATE realmlist SET color = 2 WHERE id = '%d'",realmID); + LoginDatabase.PExecute("UPDATE realmlist SET color = 2 WHERE id = '%d'",realmID); ///- Remove signal handling before leaving _UnhookSignals(); @@ -346,7 +346,7 @@ int Master::Run() ///- Wait for delay threads to end CharacterDatabase.HaltDelayThread(); WorldDatabase.HaltDelayThread(); - loginDatabase.HaltDelayThread(); + LoginDatabase.HaltDelayThread(); sLog.outString( "Halting process..." ); @@ -440,7 +440,7 @@ bool Master::_StartDB() ///- Initialise the login database sLog.outString("Login Database: %s", dbstring.c_str() ); - if(!loginDatabase.Initialize(dbstring.c_str())) + if(!LoginDatabase.Initialize(dbstring.c_str())) { sLog.outError("Cannot connect to login database %s",dbstring.c_str()); return false; @@ -469,7 +469,7 @@ void Master::clearOnlineAccounts() { // Cleanup online status for characters hosted at current realm /// \todo Only accounts with characters logged on *this* realm should have online status reset. Move the online column from 'account' to 'realmcharacters'? - loginDatabase.PExecute( + LoginDatabase.PExecute( "UPDATE account SET online = 0 WHERE online > 0 " "AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = '%d')",realmID); diff --git a/src/trinitycore/RASocket.cpp b/src/trinitycore/RASocket.cpp index f953dc3f592..cfc50d95f89 100644 --- a/src/trinitycore/RASocket.cpp +++ b/src/trinitycore/RASocket.cpp @@ -152,9 +152,9 @@ void RASocket::OnRead() AccountMgr::normilizeString(login); ///- Escape the Login to allow quotes in names - loginDatabase.escape_string(login); + LoginDatabase.escape_string(login); - QueryResult* result = loginDatabase.PQuery("SELECT gmlevel FROM account WHERE username = '%s'",login.c_str()); + QueryResult* result = LoginDatabase.PQuery("SELECT gmlevel FROM account WHERE username = '%s'",login.c_str()); ///- If the user is not found, deny access if(!result) @@ -193,10 +193,10 @@ void RASocket::OnRead() AccountMgr::normilizeString(login); AccountMgr::normilizeString(pw); - loginDatabase.escape_string(login); - loginDatabase.escape_string(pw); + LoginDatabase.escape_string(login); + LoginDatabase.escape_string(pw); - QueryResult *check = loginDatabase.PQuery( + QueryResult *check = LoginDatabase.PQuery( "SELECT 1 FROM account WHERE username = '%s' AND sha_pass_hash=SHA1(CONCAT(username,':','%s'))", login.c_str(), pw.c_str()); diff --git a/src/trinityrealm/AuthSocket.cpp b/src/trinityrealm/AuthSocket.cpp index 7168bcf700b..6f8363a9724 100644 --- a/src/trinityrealm/AuthSocket.cpp +++ b/src/trinityrealm/AuthSocket.cpp @@ -36,7 +36,7 @@ extern RealmList m_realmList; -extern DatabaseType dbRealmServer; +extern DatabaseType LoginDatabase; #define ChunkSize 2048 @@ -324,7 +324,7 @@ void AuthSocket::_SetVSFields(const std::string& rI) const char *v_hex, *s_hex; v_hex = v.AsHexStr(); s_hex = s.AsHexStr(); - dbRealmServer.PExecute("UPDATE account SET v = '%s', s = '%s' WHERE username = '%s'",v_hex,s_hex, _safelogin.c_str() ); + LoginDatabase.PExecute("UPDATE account SET v = '%s', s = '%s' WHERE username = '%s'",v_hex,s_hex, _safelogin.c_str() ); OPENSSL_free((void*)v_hex); OPENSSL_free((void*)s_hex); } @@ -380,18 +380,18 @@ bool AuthSocket::_HandleLogonChallenge() //Escape the user login to avoid further SQL injection //Memory will be freed on AuthSocket object destruction _safelogin=_login; - dbRealmServer.escape_string(_safelogin); + LoginDatabase.escape_string(_safelogin); pkt << (uint8) AUTH_LOGON_CHALLENGE; pkt << (uint8) 0x00; ///- Verify that this IP is not in the ip_banned table // No SQL injection possible (paste the IP address as passed by the socket) - dbRealmServer.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); + LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); std::string address = GetRemoteAddress(); - dbRealmServer.escape_string(address); - QueryResult *result = dbRealmServer.PQuery( "SELECT * FROM ip_banned WHERE ip = '%s'",address.c_str()); + LoginDatabase.escape_string(address); + QueryResult *result = LoginDatabase.PQuery( "SELECT * FROM ip_banned WHERE ip = '%s'",address.c_str()); if(result) { pkt << (uint8)REALM_AUTH_ACCOUNT_BANNED; @@ -403,7 +403,7 @@ bool AuthSocket::_HandleLogonChallenge() ///- Get the account details from the account table // No SQL injection (escaped user name) - result = dbRealmServer.PQuery("SELECT sha_pass_hash,id,locked,last_ip,gmlevel FROM account WHERE username = '%s'",_safelogin.c_str ()); + result = LoginDatabase.PQuery("SELECT sha_pass_hash,id,locked,last_ip,gmlevel FROM account WHERE username = '%s'",_safelogin.c_str ()); if( result ) { ///- If the IP is 'locked', check that the player comes indeed from the correct IP address @@ -431,9 +431,9 @@ bool AuthSocket::_HandleLogonChallenge() if (!locked) { //set expired bans to inactive - dbRealmServer.Execute("UPDATE account_banned SET active = 0 WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); + LoginDatabase.Execute("UPDATE account_banned SET active = 0 WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); ///- If the account is banned, reject the logon attempt - QueryResult *banresult = dbRealmServer.PQuery("SELECT bandate,unbandate FROM account_banned WHERE id = %u AND active = 1", (*result)[1].GetUInt32()); + QueryResult *banresult = LoginDatabase.PQuery("SELECT bandate,unbandate FROM account_banned WHERE id = %u AND active = 1", (*result)[1].GetUInt32()); if(banresult) { if((*banresult)[0].GetUInt64() == (*banresult)[1].GetUInt64()) @@ -652,7 +652,7 @@ bool AuthSocket::_HandleLogonProof() ///- Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account // No SQL injection (escaped user name) and IP address as received by socket const char* K_hex = K.AsHexStr(); - dbRealmServer.PExecute("UPDATE account SET sessionkey = '%s', last_ip = '%s', last_login = NOW(), locale = '%u', failed_logins = 0 WHERE username = '%s'", K_hex, GetRemoteAddress().c_str(), GetLocaleByName(_localizationName), _safelogin.c_str() ); + LoginDatabase.PExecute("UPDATE account SET sessionkey = '%s', last_ip = '%s', last_login = NOW(), locale = '%u', failed_logins = 0 WHERE username = '%s'", K_hex, GetRemoteAddress().c_str(), GetLocaleByName(_localizationName), _safelogin.c_str() ); OPENSSL_free((void*)K_hex); ///- Finish SRP6 and send the final result to the client @@ -683,9 +683,9 @@ bool AuthSocket::_HandleLogonProof() if(MaxWrongPassCount > 0) { //Increment number of failed logins by one and if it reaches the limit temporarily ban that account or IP - dbRealmServer.PExecute("UPDATE account SET failed_logins = failed_logins + 1 WHERE username = '%s'",_safelogin.c_str()); + LoginDatabase.PExecute("UPDATE account SET failed_logins = failed_logins + 1 WHERE username = '%s'",_safelogin.c_str()); - if(QueryResult *loginfail = dbRealmServer.PQuery("SELECT id, failed_logins FROM account WHERE username = '%s'", _safelogin.c_str())) + if(QueryResult *loginfail = LoginDatabase.PQuery("SELECT id, failed_logins FROM account WHERE username = '%s'", _safelogin.c_str())) { Field* fields = loginfail->Fetch(); uint32 failed_logins = fields[1].GetUInt32(); @@ -698,7 +698,7 @@ bool AuthSocket::_HandleLogonProof() if(WrongPassBanType) { uint32 acc_id = fields[0].GetUInt32(); - dbRealmServer.PExecute("INSERT INTO account_banned VALUES ('%u',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','Trinity realmd','Failed login autoban',1)", + LoginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','Trinity realmd','Failed login autoban',1)", acc_id, WrongPassBanTime); sLog.outBasic("[AuthChallenge] account %s got banned for '%u' seconds because it failed to authenticate '%u' times", _login.c_str(), WrongPassBanTime, failed_logins); @@ -706,8 +706,8 @@ bool AuthSocket::_HandleLogonProof() else { std::string current_ip = GetRemoteAddress(); - dbRealmServer.escape_string(current_ip); - dbRealmServer.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','Trinity realmd','Failed login autoban')", + LoginDatabase.escape_string(current_ip); + LoginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','Trinity realmd','Failed login autoban')", current_ip.c_str(), WrongPassBanTime); sLog.outBasic("[AuthChallenge] IP %s got banned for '%u' seconds because account %s failed to authenticate '%u' times", current_ip.c_str(), WrongPassBanTime, _login.c_str(), failed_logins); @@ -753,7 +753,7 @@ bool AuthSocket::_HandleReconnectChallenge() _login = (const char*)ch->I; _safelogin = _login; - QueryResult *result = dbRealmServer.PQuery ("SELECT sessionkey FROM account WHERE username = '%s'", _safelogin.c_str ()); + QueryResult *result = LoginDatabase.PQuery ("SELECT sessionkey FROM account WHERE username = '%s'", _safelogin.c_str ()); // Stop if the account is not found if (!result) @@ -833,7 +833,7 @@ bool AuthSocket::_HandleRealmList() ///- Get the user id (else close the connection) // No SQL injection (escaped user name) - QueryResult *result = dbRealmServer.PQuery("SELECT id,sha_pass_hash FROM account WHERE username = '%s'",_safelogin.c_str()); + QueryResult *result = LoginDatabase.PQuery("SELECT id,sha_pass_hash FROM account WHERE username = '%s'",_safelogin.c_str()); if(!result) { sLog.outError("[ERROR] user %s tried to login and we cannot find him in the database.",_login.c_str()); @@ -858,7 +858,7 @@ bool AuthSocket::_HandleRealmList() uint8 AmountOfCharacters; // No SQL injection. id of realm is controlled by the database. - result = dbRealmServer.PQuery( "SELECT numchars FROM realmcharacters WHERE realmid = '%d' AND acctid='%u'",i->second.m_ID,id); + result = LoginDatabase.PQuery( "SELECT numchars FROM realmcharacters WHERE realmid = '%d' AND acctid='%u'",i->second.m_ID,id); if( result ) { Field *fields = result->Fetch(); diff --git a/src/trinityrealm/Main.cpp b/src/trinityrealm/Main.cpp index 0e2f68f76c6..e74cd5144d3 100644 --- a/src/trinityrealm/Main.cpp +++ b/src/trinityrealm/Main.cpp @@ -64,7 +64,7 @@ void HookSignals(); bool stopEvent = false; ///< Setting it to true stops the server RealmList m_realmList; ///< Holds the list of realms for this server -DatabaseType dbRealmServer; ///< Accessor to the realm server database +DatabaseType LoginDatabase; ///< Accessor to the realm server database /// Print out the usage string for this program on the console. void usage(const char *prog) @@ -265,7 +265,7 @@ extern int main(int argc, char **argv) { loopCounter = 0; sLog.outDetail("Ping MySQL to keep connection alive"); - delete dbRealmServer.Query("SELECT 1 FROM realmlist LIMIT 1"); + delete LoginDatabase.Query("SELECT 1 FROM realmlist LIMIT 1"); } #ifdef WIN32 if (m_ServiceStatus == 0) stopEvent = true; @@ -274,7 +274,7 @@ extern int main(int argc, char **argv) } ///- Wait for the delay thread to exit - dbRealmServer.HaltDelayThread(); + LoginDatabase.HaltDelayThread(); ///- Remove signal handling before leaving UnhookSignals(); @@ -313,7 +313,7 @@ bool StartDB(std::string &dbstring) } sLog.outString("Database: %s", dbstring.c_str() ); - if(!dbRealmServer.Initialize(dbstring.c_str())) + if(!LoginDatabase.Initialize(dbstring.c_str())) { sLog.outError("Cannot connect to database"); return false; diff --git a/src/trinityrealm/RealmList.cpp b/src/trinityrealm/RealmList.cpp index 97fdfbdd91f..32c0cbc12c1 100644 --- a/src/trinityrealm/RealmList.cpp +++ b/src/trinityrealm/RealmList.cpp @@ -29,7 +29,7 @@ INSTANTIATE_SINGLETON_1( RealmList ); -extern DatabaseType dbRealmServer; +extern DatabaseType LoginDatabase; RealmList::RealmList( ) : m_UpdateInterval(0), m_NextUpdateTime(time(NULL)) { @@ -82,7 +82,7 @@ void RealmList::UpdateRealms(bool init) { sLog.outDetail("Updating Realm List..."); - QueryResult *result = dbRealmServer.Query( "SELECT id, name, address, port, icon, color, timezone, allowedSecurityLevel, population FROM realmlist WHERE color <> 3 ORDER BY name" ); + QueryResult *result = LoginDatabase.Query( "SELECT id, name, address, port, icon, color, timezone, allowedSecurityLevel, population FROM realmlist WHERE color <> 3 ORDER BY name" ); ///- Circle through results and add them to the realm map if(result) -- cgit v1.2.3 From 73e4623119784e48f87898c725d0876163eab0f0 Mon Sep 17 00:00:00 2001 From: megamage Date: Sun, 4 Jan 2009 10:42:53 -0600 Subject: *Calculate spell damage bonus when spell is casted rather than when spell hits target. --HG-- branch : trunk --- src/game/Spell.cpp | 26 ++++++++++++++++---------- src/game/SpellAuras.cpp | 3 ++- src/game/Unit.cpp | 23 ++++++++++++++++------- src/game/Unit.h | 2 +- 4 files changed, 35 insertions(+), 19 deletions(-) (limited to 'src/game') diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 96ce55d5540..49ee1d2849f 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1012,7 +1012,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) SpellNonMeleeDamage damageInfo(caster, unitTarget, m_spellInfo->Id, m_spellSchoolMask); // Add bonuses and fill damageInfo struct - caster->CalculateSpellDamage(&damageInfo, m_damage, m_spellInfo); + caster->CalculateSpellDamageTaken(&damageInfo, m_damage, m_spellInfo); // Send log damage message to client caster->SendSpellNonMeleeDamageLog(&damageInfo); @@ -5367,19 +5367,14 @@ void Spell::CalculateDamageDoneForAllTargets() int32 Spell::CalculateDamageDone(Unit *unit, const uint32 effectMask, float *multiplier) { - m_damage = 0; + int32 damageDone = 0; unitTarget = unit; for(uint32 i = 0; i < 3; ++i) { if (effectMask & (1<Effect[i]) { @@ -5396,7 +5391,18 @@ int32 Spell::CalculateDamageDone(Unit *unit, const uint32 effectMask, float *mul SpellDamageHeal(i); break; } + + if(m_damage > 0 && m_originalCaster) + m_originalCaster->SpellDamageBonus(unit, m_spellInfo, m_damage, SPELL_DIRECT_DAMAGE); + if(m_applyMultiplierMask & (1 << i)) + { + m_damage *= m_damageMultipliers[i]; + m_damageMultipliers[i] *= multiplier[i]; + } + + damageDone += m_damage; } } - return m_damage; + + return damageDone; } \ No newline at end of file diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 06fff3309c0..3469f65d7ff 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -5875,7 +5875,8 @@ void Aura::PeriodicTick() SpellEntry const* spellProto = GetSpellProto(); //maybe has to be sent different to client, but not by SMSG_PERIODICAURALOG SpellNonMeleeDamage damageInfo(pCaster, m_target, spellProto->Id, spellProto->SchoolMask); - pCaster->CalculateSpellDamage(&damageInfo, gain, spellProto); + //no SpellDamageBonus for burn mana + pCaster->CalculateSpellDamageTaken(&damageInfo, gain, spellProto); pCaster->SendSpellNonMeleeDamageLog(&damageInfo); // Set trigger flag diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 8582d262e3a..cb52b70a271 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -1478,13 +1478,14 @@ uint32 Unit::SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellID); SpellNonMeleeDamage damageInfo(this, pVictim, spellInfo->Id, spellInfo->SchoolMask); - CalculateSpellDamage(&damageInfo, damage, spellInfo); + damage = SpellDamageBonus(pVictim, spellInfo, damage, SPELL_DIRECT_DAMAGE); + CalculateSpellDamageTaken(&damageInfo, damage, spellInfo); SendSpellNonMeleeDamageLog(&damageInfo); DealSpellDamage(&damageInfo, true); return damageInfo.damage; } -void Unit::CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType) +void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType) { SpellSchoolMask damageSchoolMask = SpellSchoolMask(damageInfo->schoolMask); Unit *pVictim = damageInfo->target; @@ -1512,16 +1513,16 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, S if ( damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL ) { //Calculate armor mitigation - damage = CalcArmorReducedDamage(pVictim, damage); + //damage = CalcArmorReducedDamage(pVictim, damage); // Get blocked status blocked = isSpellBlocked(pVictim, spellInfo, attackType); } // Magical Damage - else + /*else { // Calculate damage bonus damage = SpellDamageBonus(pVictim, spellInfo, damage, SPELL_DIRECT_DAMAGE); - } + }*/ if (crit) { damageInfo->HitInfo|= SPELL_HIT_TYPE_CRIT; @@ -1567,7 +1568,7 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, S case SPELL_DAMAGE_CLASS_MAGIC: { // Calculate damage bonus - damage = SpellDamageBonus(pVictim, spellInfo, damage, SPELL_DIRECT_DAMAGE); + //damage = SpellDamageBonus(pVictim, spellInfo, damage, SPELL_DIRECT_DAMAGE); // If crit add critical bonus if (crit) { @@ -1581,6 +1582,9 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, S break; } + if( damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL ) + damage = CalcArmorReducedDamage(pVictim, damage); + // Calculate absorb resist if(damage > 0) { @@ -8489,6 +8493,10 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 if(!spellProto || !pVictim || damagetype==DIRECT_DAMAGE ) return pdamage; + if(spellProto->SchoolMask == SPELL_SCHOOL_MASK_NORMAL) + return pdamage; + //damage = CalcArmorReducedDamage(pVictim, damage); + int32 BonusDamage = 0; if( GetTypeId()==TYPEID_UNIT ) { @@ -11711,7 +11719,8 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag { sLog.outDebug("ProcDamageAndSpell: doing %u damage from spell id %u (triggered by %s aura of spell %u)", auraModifier->m_amount, spellInfo->Id, (isVictim?"a victim's":"an attacker's"), triggeredByAura->GetId()); SpellNonMeleeDamage damageInfo(this, pTarget, spellInfo->Id, spellInfo->SchoolMask); - CalculateSpellDamage(&damageInfo, auraModifier->m_amount, spellInfo); + uint32 damage = SpellDamageBonus(pTarget, spellInfo, auraModifier->m_amount, SPELL_DIRECT_DAMAGE); + CalculateSpellDamageTaken(&damageInfo, damage, spellInfo); SendSpellNonMeleeDamageLog(&damageInfo); DealSpellDamage(&damageInfo, true); break; diff --git a/src/game/Unit.h b/src/game/Unit.h index c3f5be3adb1..3cba888eb01 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -919,7 +919,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType = BASE_ATTACK); void DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss); - void CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType = BASE_ATTACK); + void CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType = BASE_ATTACK); void DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss); float MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const; -- cgit v1.2.3 From a7cc53d2620512548feb23446f469326110fb859 Mon Sep 17 00:00:00 2001 From: megamage Date: Sun, 4 Jan 2009 10:51:41 -0600 Subject: *Fix the bug that creature do not return to home position. --HG-- branch : trunk --- src/game/Unit.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index cb52b70a271..210060982a4 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8172,7 +8172,6 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) ((WorldObject*)this)->SendMessageToSet(&data, true); ((Creature*)this)->CallAssistance(); - ((Creature*)this)->SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); } // delay offhand weapon attack to next attack time @@ -9765,6 +9764,9 @@ void Unit::SetInCombatState(bool PvP) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); + if(GetTypeId() != TYPEID_PLAYER) + ((Creature*)this)->SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + if(GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->isPet()) { UpdateSpeed(MOVE_RUN, true); -- cgit v1.2.3 From b9f1a0fda1fee76b57ba1fcdaec82be18610bcc0 Mon Sep 17 00:00:00 2001 From: Blaymoira Date: Sun, 4 Jan 2009 18:56:54 +0100 Subject: *Changes in Grandmaster Vorpil - by Iskander *Target limitation for spell 39835 --HG-- branch : trunk --- .../shadow_labyrinth/boss_grandmaster_vorpil.cpp | 350 +++++++++------------ src/game/SpellMgr.cpp | 1 + 2 files changed, 153 insertions(+), 198 deletions(-) (limited to 'src/game') diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp index 06947376619..35f1cffa8e8 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 +/* Copyright (C) 2006 - 2009 ScriptDev2 * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -36,22 +36,20 @@ EndScriptData */ #define SPELL_RAIN_OF_FIRE 33617 #define H_SPELL_RAIN_OF_FIRE 39363 -#define SPELL_DRAWN_SHADOWS 33563 +#define SPELL_DRAW_SHADOWS 33563 #define SPELL_SHADOWBOLT_VOLLEY 33841 +#define SPELL_BANISH 38791 #define MOB_VOID_TRAVELER 19226 #define SPELL_SACRIFICE 33587 #define SPELL_SHADOW_NOVA 33846 -#define SPELL_HEALVORPIL 33783 -#define H_SPELL_HEALVORPIL 39364 +#define SPELL_EMPOWERING_SHADOWS 33783 +#define H_SPELL_EMPOWERING_SHADOWS 39364 #define MOB_VOID_PORTAL 19224 #define SPELL_VOID_PORTAL_VISUAL 33569 -float VorpilPosition[1][3] = -{ - {-252.8820,-264.3030,17.1} -}; +float VorpilPosition[3] = {-252.8820,-264.3030,17.1}; float VoidPortalCoords[5][3] = { @@ -62,76 +60,154 @@ float VoidPortalCoords[5][3] = {-261.4533, -297.3298, 17.1} }; +class EmpoweringShadowsAura: public Aura +{ + public: + EmpoweringShadowsAura(SpellEntry *spell, uint32 eff, int32 *bp, Unit *target, Unit *caster) : Aura(spell, eff, bp, target, caster, NULL) {} +}; + +struct TRINITY_DLL_DECL mob_voidtravelerAI : public ScriptedAI +{ + mob_voidtravelerAI(Creature *c) : ScriptedAI(c) + { + HeroicMode = m_creature->GetMap()->IsHeroic(); + Reset(); + } + + bool HeroicMode; + Unit *Vorpil; + uint32 move; + bool sacrificed; + + void Reset() + { + Vorpil = NULL; + move = 0; + sacrificed = false; + } + + void Aggro(Unit *who){} + + void UpdateAI(const uint32 diff) + { + if(!Vorpil) + { + m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + return; + } + if(move < diff) + { + if(sacrificed) + { + SpellEntry *spell = (SpellEntry *)GetSpellStore()->LookupEntry(HeroicMode?H_SPELL_EMPOWERING_SHADOWS:SPELL_EMPOWERING_SHADOWS); + if( spell ) + Vorpil->AddAura(new EmpoweringShadowsAura(spell, 0, NULL, Vorpil, m_creature)); + Vorpil->SetHealth(Vorpil->GetHealth()+Vorpil->GetMaxHealth()/25); + DoCast(m_creature, SPELL_SHADOW_NOVA, true); + m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + return; + } + m_creature->GetMotionMaster()->MoveFollow(Vorpil,0,0); + if(m_creature->GetDistance(Vorpil) < 3) + { + DoCast(m_creature, SPELL_SACRIFICE, false); + sacrificed = true; + move = 500; + return; + } + if(!Vorpil->isInCombat() || Vorpil->isDead()) + { + m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + return; + } + move = 1000; + }else move -= diff; + } +}; +CreatureAI* GetAI_mob_voidtraveler(Creature *_Creature) +{ + return new mob_voidtravelerAI (_Creature); +} + struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI { boss_grandmaster_vorpilAI(Creature *c) : ScriptedAI(c) { pInstance = ((ScriptedInstance*)c->GetInstanceData()); + HeroicMode = m_creature->GetMap()->IsHeroic(); Intro = false; Reset(); } ScriptedInstance *pInstance; - bool Intro; + bool Intro, HelpYell; bool sumportals; bool HeroicMode; uint32 ShadowBoltVolley_Timer; - uint32 DrawnShadows_Timer; - uint32 sumportals_Timer; + uint32 DrawShadows_Timer; uint32 summonTraveler_Timer; - uint64 PortalsGuid[5]; + uint32 banish_Timer; + uint64 PortalsGuid[5]; + + void Reset() + { + ShadowBoltVolley_Timer = 15000; + DrawShadows_Timer = 45000; + summonTraveler_Timer = 90000; + banish_Timer = 17000; + HelpYell = false; + destroyPortals(); + if(pInstance) + pInstance->SetData(DATA_GRANDMASTERVORPILEVENT, NOT_STARTED); + } void summonPortals() { - for (int i = 0;i<5;i++) + if(!sumportals) { - Creature *Portal = NULL; - Portal = m_creature->SummonCreature(MOB_VOID_PORTAL,VoidPortalCoords[i][0],VoidPortalCoords[i][1],VoidPortalCoords[i][2],0,TEMPSUMMON_CORPSE_DESPAWN,3000000); - PortalsGuid[i] = Portal->GetGUID(); - Portal->CastSpell(Portal,SPELL_VOID_PORTAL_VISUAL,false); + for (int i = 0;i<5;i++) + { + Creature *Portal = NULL; + Portal = m_creature->SummonCreature(MOB_VOID_PORTAL,VoidPortalCoords[i][0],VoidPortalCoords[i][1],VoidPortalCoords[i][2],0,TEMPSUMMON_CORPSE_DESPAWN,3000000); + PortalsGuid[i] = Portal->GetGUID(); + Portal->CastSpell(Portal,SPELL_VOID_PORTAL_VISUAL,false); + } + sumportals = true; + summonTraveler_Timer = 5000; } - sumportals = true; - summonTraveler_Timer = 5000; } void destroyPortals() { - for (int i = 0;i < 5; i ++) + if(sumportals) { - Unit *Portal = Unit::GetUnit((*m_creature), PortalsGuid[i]); - if (Portal) - if (Portal->isAlive()) + for (int i = 0;i < 5; i ++) + { + Unit *Portal = Unit::GetUnit((*m_creature), PortalsGuid[i]); + if (Portal && Portal->isAlive()) Portal->DealDamage(Portal, Portal->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - PortalsGuid[i] = 0; - } + PortalsGuid[i] = 0; + } + sumportals = false; + } } void spawnVoidTraveler() { - srand( (unsigned) time(NULL) ) ; int pos = rand()%5; - Creature *traveler; - traveler = m_creature->SummonCreature(MOB_VOID_TRAVELER,VoidPortalCoords[pos][0],VoidPortalCoords[pos][1],VoidPortalCoords[pos][2],0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,10000); + m_creature->SummonCreature(MOB_VOID_TRAVELER,VoidPortalCoords[pos][0],VoidPortalCoords[pos][1],VoidPortalCoords[pos][2],0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,5000); + if(!HelpYell) + { + DoScriptText(SAY_HELP, m_creature); + HelpYell = true; + } } - void Reset() + void JustSummoned(Creature *summoned) { - HeroicMode = m_creature->GetMap()->IsHeroic(); - if( HeroicMode ) - debug_log("SD2: creature %u is in heroic mode",m_creature->GetEntry()); - - ShadowBoltVolley_Timer = 15000; - DrawnShadows_Timer = 45000; - sumportals_Timer = 10000; - summonTraveler_Timer = 90000; - - InCombat = false; - sumportals = false; - destroyPortals(); - - if(pInstance) - pInstance->SetData(DATA_GRANDMASTERVORPILEVENT, NOT_STARTED); + if (summoned && summoned->GetEntry() == MOB_VOID_TRAVELER) + ((mob_voidtravelerAI*)summoned->AI())->Vorpil = m_creature; } void KilledUnit(Unit *victim) @@ -151,7 +227,7 @@ struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI pInstance->SetData(DATA_GRANDMASTERVORPILEVENT, DONE); } - void StartEvent() + void Aggro(Unit *who) { switch(rand()%3) { @@ -159,55 +235,27 @@ struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI case 1: DoScriptText(SAY_AGGRO2, m_creature); break; case 2: DoScriptText(SAY_AGGRO3, m_creature); break; } - + summonPortals(); if(pInstance) pInstance->SetData(DATA_GRANDMASTERVORPILEVENT, IN_PROGRESS); } - void Aggro(Unit *who) - { - if(!InCombat) - { - InCombat = true; - StartEvent(); - } - } - void MoveInLineOfSight(Unit *who) { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessiblePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - AttackStart(who); - } - } - else if (!Intro && m_creature->IsWithinLOSInMap(who)&& m_creature->IsWithinDistInMap(who, 100) ) //not sure about right radius + if(who && !m_creature->getVictim() && m_creature->canStartAttack(who)) + AttackStart(who); + if (!Intro && who && m_creature->IsWithinLOSInMap(who)&& m_creature->IsWithinDistInMap(who, 100) && m_creature->IsHostileTo(who)) { DoScriptText(SAY_INTRO, m_creature); Intro = true; } - } - + void UpdateAI(const uint32 diff) { if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) return; - - if (!sumportals) - if (sumportals_Timer < diff) - { - DoScriptText(SAY_HELP, m_creature); - summonPortals(); - sumportals_Timer = 1000000; - - }else sumportals_Timer -= diff; if (ShadowBoltVolley_Timer < diff) { @@ -215,23 +263,41 @@ struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI ShadowBoltVolley_Timer = 15000; }else ShadowBoltVolley_Timer -= diff; - if ( DrawnShadows_Timer < diff) + if (HeroicMode && banish_Timer < diff) + { + Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0,30,false); + if (target) + { + DoCast(target,SPELL_BANISH); + banish_Timer = 16000; + } + }else banish_Timer -= diff; + + if ( DrawShadows_Timer < diff) { - DoTeleportAll(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0); - m_creature->Relocate(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0); - DoCast(m_creature,SPELL_DRAWN_SHADOWS,true); + Map *map = m_creature->GetMap(); + Map::PlayerList const &PlayerList = map->GetPlayers(); + for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + if (Player* i_pl = i->getSource()) + if (i_pl->isAlive() && !i_pl->HasAura(SPELL_BANISH,0)) + i_pl->TeleportTo(m_creature->GetMapId(), VorpilPosition[0],VorpilPosition[1],VorpilPosition[2], 0, TELE_TO_NOT_LEAVE_COMBAT); - if(!HeroicMode) DoCast(m_creature,SPELL_RAIN_OF_FIRE); - else DoCast(m_creature,H_SPELL_RAIN_OF_FIRE); + m_creature->Relocate(VorpilPosition[0],VorpilPosition[1],VorpilPosition[2]); + DoCast(m_creature,SPELL_DRAW_SHADOWS,true); + + DoCast(m_creature,HeroicMode?H_SPELL_RAIN_OF_FIRE:SPELL_RAIN_OF_FIRE); ShadowBoltVolley_Timer = 6000; - DrawnShadows_Timer = 45000; - }else DrawnShadows_Timer -= diff; + DrawShadows_Timer = 30000; + }else DrawShadows_Timer -= diff; if ( summonTraveler_Timer < diff) { spawnVoidTraveler(); summonTraveler_Timer = 10000; + //enrage at 20% + if((m_creature->GetHealth()*5) < m_creature->GetMaxHealth()) + summonTraveler_Timer = 5000; }else summonTraveler_Timer -=diff; DoMeleeAttackIfReady(); @@ -242,118 +308,6 @@ CreatureAI* GetAI_boss_grandmaster_vorpil(Creature *_Creature) return new boss_grandmaster_vorpilAI (_Creature); } -struct TRINITY_DLL_DECL mob_voidtravelerAI : public ScriptedAI -{ - mob_voidtravelerAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - uint32 VorpilCheck_Timer; - uint32 eventCheck_Timer; - bool sacrifice; - bool sacrificed; - bool oneTarget; - bool HeroicMode; - - uint32 target_timer; - - void Reset() - { - HeroicMode = m_creature->GetMap()->IsHeroic(); - if( HeroicMode ) - debug_log("SD2: creature %u is in heroic mode",m_creature->GetEntry()); - - VorpilCheck_Timer = 5000; - eventCheck_Timer = 1000; - target_timer = 2000; - oneTarget = false; - sacrificed = false; - sacrifice = false; - } - void EnterEvadeMode(){} - void Aggro(Unit *who) {} - void AttackStart(Unit *who){} - void MoveInLineOfSight(Unit *who){} - - void UpdateAI(const uint32 diff) - { - if (eventCheck_Timer < diff) - { - if(pInstance) - { - Unit *Vorpil = Unit::GetUnit((*m_creature),pInstance->GetData64(DATA_GRANDMASTERVORPIL)); - if (Vorpil) - { - if (Vorpil->isDead()) - { - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - - if (Vorpil->getVictim()) - { - if((*m_creature).GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE) - (*m_creature).GetMotionMaster()->MoveFollow(Vorpil,1,0); - } - } - if(pInstance->GetData(DATA_GRANDMASTERVORPILEVENT) != IN_PROGRESS) - { - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - } - eventCheck_Timer = 5000; - }else eventCheck_Timer -=diff; - - if (VorpilCheck_Timer < diff) - { - if (pInstance) - { - if (!sacrificed) - { - if (!sacrifice) - { - Unit *Vorpil = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_GRANDMASTERVORPIL)); - if (Vorpil) - if (Vorpil->isAlive()) - { - if (m_creature->IsWithinDistInMap(Vorpil, 2)) - { - sacrifice = true; - DoCast(m_creature,SPELL_SACRIFICE); - VorpilCheck_Timer = 2000; - } - } - - if (!sacrifice) - VorpilCheck_Timer = 3000; - } - else - { - Unit *Vorpil = Unit::GetUnit((*m_creature),pInstance->GetData64(DATA_GRANDMASTERVORPIL)); - if (Vorpil) - if (Vorpil->isAlive()) - { - if(!HeroicMode) Vorpil->CastSpell(Vorpil,SPELL_HEALVORPIL,true); - else Vorpil->CastSpell(Vorpil,H_SPELL_HEALVORPIL,true); - }; - DoCast(m_creature,SPELL_SHADOW_NOVA); - sacrificed = true; - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - VorpilCheck_Timer = 100000; - } - } - } - }else VorpilCheck_Timer -= diff; - } -}; - -CreatureAI* GetAI_mob_voidtraveler(Creature *_Creature) -{ - return new mob_voidtravelerAI (_Creature); -} - void AddSC_boss_grandmaster_vorpil() { Script *newscript; diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 494921eb2a5..202682e138a 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -2159,6 +2159,7 @@ void SpellMgr::LoadSpellCustomAttr() case 37790: //Spread Shot case 46771: //Flame Sear case 45248: //Shadow Blades + case 39835: //Needle Spine spellInfo->MaxAffectedTargets = 3; break; case 38310: //Multi-Shot -- cgit v1.2.3 From 0389ed45281b65c39b034bf4cc899dbdaf5d04ce Mon Sep 17 00:00:00 2001 From: Blaymoira Date: Sun, 4 Jan 2009 19:34:15 +0100 Subject: * Fix reload tickets from database * Fix crash /exploit issue with improper pasing when '%' is in ticket message * Remove obsolete recv_data from tickets * Allow closing of a ticket inserting the guid of the GM or player that closed it into the database. * Allow assigning tickets to offline GMs. * Tighten up SQL escape strings, increased security against SQL injections * Fix issue where multiple tickets could have the same entry * --- by Machiavelli --- --HG-- branch : trunk --- sql/updates/780_characters.sql | 2 ++ src/game/Chat.cpp | 2 +- src/game/Level1.cpp | 82 ++++++++++++++++++++++-------------------- src/game/TicketHandler.cpp | 12 ++----- src/game/TicketMgr.cpp | 40 ++++++++++----------- src/game/TicketMgr.h | 20 ++--------- 6 files changed, 71 insertions(+), 87 deletions(-) create mode 100644 sql/updates/780_characters.sql (limited to 'src/game') diff --git a/sql/updates/780_characters.sql b/sql/updates/780_characters.sql new file mode 100644 index 00000000000..cbcb193c276 --- /dev/null +++ b/sql/updates/780_characters.sql @@ -0,0 +1,2 @@ +ALTER TABLE `gm_tickets` CHANGE `guid` `guid` int(10) NOT NULL AUTO_INCREMENT; +ALTER TABLE `gm_tickets` CHANGE `closed` `closed` int(10) NOT NULL; \ No newline at end of file diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 3ec5d92bd6a..c16d4f69652 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -300,7 +300,7 @@ ChatCommand * ChatHandler::getCommandTable() { "locales_page_text", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesPageTextCommand, "", NULL }, { "locales_quest", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesQuestCommand, "", NULL }, { "waypoint_scripts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadWpScriptsCommand, "", NULL }, - { "tickets", SEC_ADMINISTRATOR, true, &ChatHandler::HandleGMTicketReloadCommand, "", NULL }, + { "gm_tickets", SEC_ADMINISTRATOR, true, &ChatHandler::HandleGMTicketReloadCommand, "", NULL }, { "", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index 1566d16c66c..d1f02ad507f 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -272,19 +272,20 @@ bool ChatHandler::HandleGMTicketListCommand(const char* args) SendSysMessage(LANG_COMMAND_TICKETSHOWLIST); for(GmTicketList::iterator itr = ticketmgr.GM_TicketList.begin(); itr != ticketmgr.GM_TicketList.end(); ++itr) { - if((*itr)->closed == 1) + if((*itr)->closed != 0) continue; std::stringstream message; message << "|cff00ff00Ticket|r: |cff00ccff" << (*itr)->guid; message << ".|r |cff00ff00created by:|r |cff00ccff" << (*itr)->name; message << ".|r |cff00ff00Last change:|r |cff00ccff " << secsToTimeString(time(NULL) - (*itr)->timestamp, true, false) << " ago."; - if((*itr)->assignedToGM != 0 && objmgr.GetPlayer((*itr)->assignedToGM)) + if((*itr)->assignedToGM != 0) { - std::string gmname = objmgr.GetPlayer((*itr)->assignedToGM)->GetName(); + std::string gmname; + objmgr.GetPlayerNameByGUID((*itr)->assignedToGM, gmname); message << "|r |cff00ff00Assigned to:|r |cff00ccff " << gmname; } - SendGlobalGMSysMessage(message.str().c_str()); + SendSysMessage(message.str().c_str()); } return true; } @@ -295,7 +296,7 @@ bool ChatHandler::HandleGMTicketListOnlineCommand(const char* args) SendSysMessage(LANG_COMMAND_TICKETSHOWONLINELIST); for(GmTicketList::iterator itr = ticketmgr.GM_TicketList.begin(); itr != ticketmgr.GM_TicketList.end(); ++itr) { - if((*itr)->closed == 1 || !objmgr.GetPlayer((*itr)->playerGuid)) + if((*itr)->closed != 0 || !objmgr.GetPlayer((*itr)->playerGuid)) continue; std::stringstream message; @@ -304,10 +305,11 @@ bool ChatHandler::HandleGMTicketListOnlineCommand(const char* args) message << ".|r |cff00ff00Last change:|r |cff00ccff " << secsToTimeString((time(NULL) - (*itr)->timestamp), true, false) << " ago."; if((*itr)->assignedToGM != 0 && objmgr.GetPlayer((*itr)->assignedToGM)) { - std::string gmname = objmgr.GetPlayer((*itr)->assignedToGM)->GetName(); + std::string gmname; + objmgr.GetPlayerNameByGUID((*itr)->assignedToGM, gmname); message << "|r |cff00ff00Assigned to:|r |cff00ccff " << gmname; } - SendGlobalGMSysMessage(message.str().c_str()); + SendSysMessage(message.str().c_str()); } return true; } @@ -331,7 +333,8 @@ bool ChatHandler::HandleGMTicketGetByIdCommand(const char* args) message << ".|r |cff00ff00Last change:|r |cff00ccff " << secsToTimeString((time(NULL)-ticket->timestamp), true, false) << " ago."; if(ticket->assignedToGM != 0 && objmgr.GetPlayer(ticket->assignedToGM)) { - std::string gmname = objmgr.GetPlayer(ticket->assignedToGM)->GetName(); + std::string gmname; + objmgr.GetPlayerNameByGUID(ticket->assignedToGM, gmname); message << "|r |cff00ff00Assigned to:|r |cff00ccff " << gmname; } message << "|r\n|cff00ff00Message:|r " << ticket->message; @@ -339,7 +342,7 @@ bool ChatHandler::HandleGMTicketGetByIdCommand(const char* args) { message << "|r |cff00ff00Comment:|r |cff00ccff " << ticket->comment; } - PSendSysMessage(message.str().c_str()); + SendSysMessage(message.str().c_str()); return true; } @@ -361,7 +364,8 @@ bool ChatHandler::HandleGMTicketGetByNameCommand(const char* args) message << ".|r |cff00ff00Last change:|r |cff00ccff " << secsToTimeString((time(NULL)-ticket->timestamp), true, false) << " ago."; if(ticket->assignedToGM != 0 && objmgr.GetPlayer(ticket->assignedToGM)) { - std::string gmname = objmgr.GetPlayer(ticket->assignedToGM)->GetName(); + std::string gmname; + objmgr.GetPlayerNameByGUID(ticket->assignedToGM, gmname); message << "|r |cff00ff00Assigned to:|r |cff00ccff " << gmname; } message << "|r\n|cff00ff00Message:|r " << ticket->message; @@ -369,7 +373,7 @@ bool ChatHandler::HandleGMTicketGetByNameCommand(const char* args) { message << "|r |cff00ff00Comment:|r |cff00ccff " << ticket->comment; } - PSendSysMessage(message.str().c_str()); + SendSysMessage(message.str().c_str()); return true; } @@ -380,22 +384,22 @@ bool ChatHandler::HandleGMTicketCloseByIdCommand(const char* args) uint64 tguid = atoi(args); GM_Ticket *ticket = ticketmgr.GetGMTicket(tguid); - if(!ticket || ticket->closed == 1) + if(!ticket || ticket->closed != 0) { SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); - return false; + return true; } if(ticket && ticket->assignedToGM != 0 && ticket->assignedToGM != m_session->GetPlayer()->GetGUID()) { PSendSysMessage(LANG_COMMAND_TICKETCANNOTCLOSE, ticket->guid); - return false; + return true; } - sWorld.SendGMText(LANG_COMMAND_TICKETCLOSED, ticket->name.c_str(), ticket->guid); - ticketmgr.RemoveGMTicket(ticket->guid); + sWorld.SendGMText(LANG_COMMAND_TICKETCLOSED, m_session->GetPlayer()->GetName(), ticket->guid); + ticketmgr.RemoveGMTicket(ticket->guid, m_session->GetPlayer()->GetGUID()); Player *plr = objmgr.GetPlayer(ticket->playerGuid); if(!plr || !plr->IsInWorld()) - return false; + return true; // send abandon ticket WorldPacket data(SMSG_GMTICKET_DELETETICKET, 4); @@ -425,40 +429,38 @@ bool ChatHandler::HandleGMTicketAssignToCommand(const char* args) std::string gmname; GM_Ticket *ticket = ticketmgr.GetGMTicket(ticketGuid); - if(!ticket || ticket->closed == 1) + if(!ticket || ticket->closed != 0) { SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } - Player *plr = objmgr.GetPlayer(targm.c_str()); - if(!plr || !plr->IsInWorld() || plr->GetSession()->GetSecurity() < SEC_MODERATOR) + uint64 tarGUID = objmgr.GetPlayerGUIDByName(targm.c_str()); + uint64 accid = objmgr.GetPlayerAccountIdByGUID(tarGUID); + QueryResult *result = LoginDatabase.PQuery("SELECT `gmlevel` FROM `account` WHERE `id` = '%u'", accid); + if(!tarGUID|| !result || result->Fetch()->GetUInt32() < SEC_MODERATOR) { SendSysMessage(LANG_COMMAND_TICKETASSIGNERROR_A); return true; } - if(ticket->assignedToGM == plr->GetGUID()) + if(ticket->assignedToGM == tarGUID) { PSendSysMessage(LANG_COMMAND_TICKETASSIGNERROR_B, ticket->guid); return true; } + objmgr.GetPlayerNameByGUID(tarGUID, gmname); if(ticket->assignedToGM != 0 && ticket->assignedToGM != cplr->GetGUID()) { - Player *aplr = objmgr.GetPlayer(ticket->assignedToGM); - if(aplr && aplr->IsInWorld()) - { - gmname = aplr->GetName(); - PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->guid, gmname.c_str()); - return true; - } + PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->guid, gmname.c_str()); + return true; } - ticket->assignedToGM = plr->GetGUID(); + ticket->assignedToGM = tarGUID; ticketmgr.UpdateGMTicket(ticket); std::stringstream ss; ss << "|cff00ff00Ticket:|r "; ss << "|cffff00ff" << ticket->guid << ". " << cplr->GetName() << "|r"; ss << "|cff00ff00 assigned to:|r "; - ss << "|cffff00ff\"" << targetgm << "\"."; + ss << "|cffff00ff\"" << gmname << "\"."; SendGlobalGMSysMessage(ss.str().c_str()); return true; } @@ -472,19 +474,20 @@ bool ChatHandler::HandleGMTicketUnAssignCommand(const char* args) Player *cplr = m_session->GetPlayer(); GM_Ticket *ticket = ticketmgr.GetGMTicket(ticketGuid); - if(!ticket|| ticket->closed) + if(!ticket|| ticket->closed != 0) { SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } - if(ticket->assignedToGM = 0) + if(ticket->assignedToGM == 0) { SendSysMessage(LANG_COMMAND_TICKETNOTASSIGNED); return true; } - Player *plr = objmgr.GetPlayer(ticket->assignedToGM); - + std::string gmname; + objmgr.GetPlayerNameByGUID(ticket->assignedToGM, gmname); + Player *plr = objmgr.GetPlayer(ticket->assignedToGM); if(plr && plr->IsInWorld() && plr->GetSession()->GetSecurity() > cplr->GetSession()->GetSecurity()) { SendSysMessage(LANG_COMMAND_TICKETUNASSIGNSECURITY); @@ -516,7 +519,7 @@ bool ChatHandler::HandleGMTicketCommentCommand(const char* args) Player *cplr = m_session->GetPlayer(); GM_Ticket *ticket = ticketmgr.GetGMTicket(ticketGuid); - if(!ticket || ticket->closed == 1) + if(!ticket || ticket->closed != 0) { PSendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; @@ -550,14 +553,17 @@ bool ChatHandler::HandleGMTicketDeleteByIdCommand(const char* args) SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); return true; } - if(!ticket->closed == 1) + if(ticket->closed == 0) { SendSysMessage(LANG_COMMAND_TICKETCLOSEFIRST); return true; } - std::string gmname = m_session->GetPlayer()->GetName(); - sWorld.SendGMText(LANG_COMMAND_TICKETDELETED, ticket->guid, gmname.c_str()); + std::stringstream ss; + ss << "|cff00ff00Ticket:|r "; + ss << "|cffff00ff" << m_session->GetPlayer()->GetName() << "|r"; + ss << "|cff00ff00 deleted.|r"; + SendGlobalGMSysMessage(ss.str().c_str()); Player *plr = objmgr.GetPlayer(ticket->playerGuid); ticketmgr.DeleteGMTicketPermanently(ticket->guid); if(plr && plr->IsInWorld()) diff --git a/src/game/TicketHandler.cpp b/src/game/TicketHandler.cpp index f3374332f79..1e1d97fd4ce 100644 --- a/src/game/TicketHandler.cpp +++ b/src/game/TicketHandler.cpp @@ -36,8 +36,6 @@ void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data ) // always do a packet check CHECK_PACKET_SIZE(recv_data, 4*4+1+2*4); - uint32 map; - float x, y, z; std::string ticketText = ""; std::string ticketText2 = ""; GM_Ticket *ticket = new GM_Ticket; @@ -45,13 +43,9 @@ void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data ) WorldPacket data(SMSG_GMTICKET_CREATE, 4); // recv Data - recv_data >> map; - recv_data >> x; - recv_data >> y; - recv_data >> z; recv_data >> ticketText; - // get additional data + // get additional data, rarely used recv_data >> ticketText2; // assign values @@ -65,7 +59,7 @@ void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data ) ticket->comment = ""; // remove ticket by player, shouldn't happen - ticketmgr.RemoveGMTicketByPlayer(GetPlayer()->GetGUID()); + ticketmgr.RemoveGMTicketByPlayer(GetPlayer()->GetGUID(), GetPlayer()->GetGUID()); // add ticket ticketmgr.AddGMTicket(ticket, false); @@ -140,7 +134,7 @@ void WorldSession::HandleGMTicketDeleteOpcode( WorldPacket & /*recv_data*/) SendPacket(&data); sWorld.SendGMText(LANG_COMMAND_TICKETPLAYERABANDON, GetPlayer()->GetName(), ticket->guid ); - ticketmgr.RemoveGMTicketByPlayer(GetPlayer()->GetGUID()); + ticketmgr.RemoveGMTicketByPlayer(GetPlayer()->GetGUID(), GetPlayer()->GetGUID()); } } diff --git a/src/game/TicketMgr.cpp b/src/game/TicketMgr.cpp index 0f1f7501e67..ffa8c522672 100644 --- a/src/game/TicketMgr.cpp +++ b/src/game/TicketMgr.cpp @@ -24,13 +24,9 @@ #include "ObjectMgr.h" #include "Language.h" #include "Player.h" -INSTANTIATE_SINGLETON_1( TicketMgr ); - #include "Common.h" -//#include "Log.h" #include "ObjectAccessor.h" - - +INSTANTIATE_SINGLETON_1( TicketMgr ); GM_Ticket* TicketMgr::GetGMTicket(uint64 ticketGuid) { @@ -106,7 +102,7 @@ void TicketMgr::DeleteGMTicketPermanently(uint64 ticketGuid) } // delete database record - CharacterDatabase.PExecute("DELETE FROM gm_tickets WHERE guid=%u", ticketGuid); + CharacterDatabase.PExecute("DELETE FROM `gm_tickets` WHERE guid= '%u'", ticketGuid); } @@ -114,13 +110,13 @@ void TicketMgr::LoadGMTickets() { // Delete all out of object holder GM_TicketList.clear(); - QueryResult *result = CharacterDatabase.Query( "SELECT `guid`, `playerGuid`, `name`, `message`, `timestamp`, `closed`, `assignedto`, `comment` FROM gm_tickets WHERE closed = '0'" ); + QueryResult *result = CharacterDatabase.Query( "SELECT `guid`, `playerGuid`, `name`, `message`, `timestamp`, `closed`, `assignedto`, `comment` FROM `gm_tickets` WHERE `closed` = '0'" ); GM_Ticket *ticket; - //ticket = NULL; if(!result) return; + // Assign values from SQL to the object holder do { Field *fields = result->Fetch(); @@ -143,13 +139,13 @@ void TicketMgr::LoadGMTickets() delete result; } -void TicketMgr::RemoveGMTicket(uint64 ticketGuid) +void TicketMgr::RemoveGMTicket(uint64 ticketGuid, uint64 GMguid) { for(GmTicketList::iterator i = GM_TicketList.begin(); i != GM_TicketList.end();) { if((*i)->guid == ticketGuid && (*i)->closed == 0) { - (*i)->closed = 1; + (*i)->closed = GMguid; SaveGMTicket((*i)); } ++i; @@ -157,13 +153,13 @@ void TicketMgr::RemoveGMTicket(uint64 ticketGuid) } -void TicketMgr::RemoveGMTicketByPlayer(uint64 playerGuid) +void TicketMgr::RemoveGMTicketByPlayer(uint64 playerGuid, uint64 GMguid) { for(GmTicketList::iterator i = GM_TicketList.begin(); i != GM_TicketList.end();) { if((*i)->playerGuid == playerGuid && (*i)->closed == 0) { - (*i)->closed = true; + (*i)->closed = GMguid; SaveGMTicket((*i)); } ++i; @@ -173,15 +169,15 @@ void TicketMgr::RemoveGMTicketByPlayer(uint64 playerGuid) void TicketMgr::SaveGMTicket(GM_Ticket* ticket) { std::stringstream ss; - ss << "REPLACE INTO gm_tickets (`guid`, `playerGuid`, `name`, `message`, `timestamp`, `closed`, `assignedto`, `comment`) VALUES("; - ss << ticket->guid << ", "; - ss << ticket->playerGuid << ", '"; - ss << ticket->name << "', '"; - ss << ticket->message << "', " ; - ss << ticket->timestamp << ", "; - ss << ticket->closed << ", '"; - ss << ticket->assignedToGM << "', '"; - ss << ticket->comment << "');"; + ss << "REPLACE INTO `gm_tickets` (`guid`, `playerGuid`, `name`, `message`, `timestamp`, `closed`, `assignedto`, `comment`) VALUES(\""; + ss << ticket->guid << "\", \""; + ss << ticket->playerGuid << "\", \""; + ss << ticket->name << "\", \""; + ss << ticket->message << "\", \"" ; + ss << ticket->timestamp << "\", \""; + ss << ticket->closed << "\", \""; + ss << ticket->assignedToGM << "\", \""; + ss << ticket->comment << "\");"; CharacterDatabase.BeginTransaction(); CharacterDatabase.Execute(ss.str().c_str()); @@ -203,5 +199,5 @@ uint64 TicketMgr::GenerateTicketID() delete result; } - return m_ticketid; + return ++m_ticketid; } \ No newline at end of file diff --git a/src/game/TicketMgr.h b/src/game/TicketMgr.h index e41be9db5c3..33a9598e7cf 100644 --- a/src/game/TicketMgr.h +++ b/src/game/TicketMgr.h @@ -39,27 +39,13 @@ struct GM_Ticket std::string comment; }; -enum GMticketType -{ - GM_TICKET_TYPE_STUCK = 1, - GM_TICKET_TYPE_BEHAVIOR_HARASSMENT = 2, - GM_TICKET_TYPE_GUILD = 3, - GM_TICKET_TYPE_ITEM = 4, - GM_TICKET_TYPE_ENVIRONMENTAL = 5, - GM_TICKET_TYPE_NON_QUEST_CREEP = 6, - GM_TICKET_TYPE_QUEST_QUEST_NPC = 7, - GM_TICKET_TYPE_TECHNICAL = 8, - GM_TICKET_TYPE_ACCOUNT_BILLING = 9, - GM_TICKET_TYPE_CHARACTER = 10 -}; - // Map Typedef typedef std::list GmTicketList; class TicketMgr { public: - TicketMgr(){} //constructor + TicketMgr(){m_ticketid = 1;} //constructor ~TicketMgr(){} //destructor // Object Holder @@ -69,8 +55,8 @@ class TicketMgr void DeleteAllRemovedGMTickets(); void DeleteGMTicketPermanently(uint64 ticketGuid); void LoadGMTickets(); - void RemoveGMTicketByPlayer(uint64 playerGuid); - void RemoveGMTicket(uint64 ticketGuid); + void RemoveGMTicketByPlayer(uint64 playerGuid, uint64 GMguid); + void RemoveGMTicket(uint64 ticketGuid, uint64 GMguid); void UpdateGMTicket(GM_Ticket *ticket); void SaveGMTicket(GM_Ticket* ticket); -- cgit v1.2.3 From d608a48839e48860345062b69a7e59f81e8e9904 Mon Sep 17 00:00:00 2001 From: Blaymoira Date: Sun, 4 Jan 2009 19:48:14 +0100 Subject: *Fix a typo in password command - by Machiavelli --HG-- branch : trunk --- src/game/Level0.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/Level0.cpp b/src/game/Level0.cpp index 126c889d854..63a015f9802 100644 --- a/src/game/Level0.cpp +++ b/src/game/Level0.cpp @@ -197,7 +197,7 @@ bool ChatHandler::HandlePasswordCommand(const char* args) std::string password_new = new_pass; std::string password_new_c = new_pass_c; - if (password_new != password_new_c) + if (strcmp(new_pass, new_pass_c) != 0) { SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH); SetSentErrorMessage (true); -- cgit v1.2.3 From 2641173fbeedc2a3f3900122443587b97626b5e1 Mon Sep 17 00:00:00 2001 From: megamage Date: Sun, 4 Jan 2009 15:27:11 -0600 Subject: *Fix a bug in ScriptedAI::SelectUnitList. --HG-- branch : trunk --- src/bindings/scripts/include/sc_creature.cpp | 3 ++- src/game/SpellMgr.cpp | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/game') diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp index b54f91a113d..bb7f98c9f7b 100644 --- a/src/bindings/scripts/include/sc_creature.cpp +++ b/src/bindings/scripts/include/sc_creature.cpp @@ -432,7 +432,7 @@ void ScriptedAI::SelectUnitList(std::list &targetList, uint32 num, Select std::list m_threatlist = m_creature->getThreatManager().getThreatList(); std::list::iterator i; Unit *target; - while(m_threatlist.size()) + while(m_threatlist.size() && num) { if(targetType == SELECT_TARGET_BOTTOMAGGRO) { @@ -455,6 +455,7 @@ void ScriptedAI::SelectUnitList(std::list &targetList, uint32 num, Select continue; } targetList.push_back(target); + --num; } } } diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 202682e138a..494921eb2a5 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -2159,7 +2159,6 @@ void SpellMgr::LoadSpellCustomAttr() case 37790: //Spread Shot case 46771: //Flame Sear case 45248: //Shadow Blades - case 39835: //Needle Spine spellInfo->MaxAffectedTargets = 3; break; case 38310: //Multi-Shot -- cgit v1.2.3 From 15d25f45ae920a4418f3fcb1e6828c923a3aedc1 Mon Sep 17 00:00:00 2001 From: megamage Date: Sun, 4 Jan 2009 15:30:38 -0600 Subject: *Fix the bug that spell damage bonus is not applied. --HG-- branch : trunk --- src/game/Spell.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 49ee1d2849f..62082ba2fca 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -5393,7 +5393,7 @@ int32 Spell::CalculateDamageDone(Unit *unit, const uint32 effectMask, float *mul } if(m_damage > 0 && m_originalCaster) - m_originalCaster->SpellDamageBonus(unit, m_spellInfo, m_damage, SPELL_DIRECT_DAMAGE); + m_damage = m_originalCaster->SpellDamageBonus(unit, m_spellInfo, m_damage, SPELL_DIRECT_DAMAGE); if(m_applyMultiplierMask & (1 << i)) { m_damage *= m_damageMultipliers[i]; -- cgit v1.2.3