diff options
| author | megamage <none@none> | 2009-01-04 16:17:46 -0600 |
|---|---|---|
| committer | megamage <none@none> | 2009-01-04 16:17:46 -0600 |
| commit | eb5a7b02eef6fe13684dfe14faf048bbce1d0f83 (patch) | |
| tree | 395bd3da004c0628956d64335ee0e2c404d4f772 /src/game | |
| parent | 820e0214faf4645ef1bc411aa5cc581392db62db (diff) | |
| parent | 15d25f45ae920a4418f3fcb1e6828c923a3aedc1 (diff) | |
*Merge with Trinity 783.
--HG--
branch : trunk
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/AccountMgr.cpp | 50 | ||||
| -rw-r--r-- | src/game/CharacterHandler.cpp | 10 | ||||
| -rw-r--r-- | src/game/Chat.cpp | 2 | ||||
| -rw-r--r-- | src/game/Level0.cpp | 6 | ||||
| -rw-r--r-- | src/game/Level1.cpp | 82 | ||||
| -rw-r--r-- | src/game/Level2.cpp | 18 | ||||
| -rw-r--r-- | src/game/Level3.cpp | 38 | ||||
| -rw-r--r-- | src/game/MiscHandler.cpp | 2 | ||||
| -rw-r--r-- | src/game/PetAI.cpp | 3 | ||||
| -rw-r--r-- | src/game/Player.cpp | 20 | ||||
| -rw-r--r-- | src/game/Spell.cpp | 26 | ||||
| -rw-r--r-- | src/game/SpellAuras.cpp | 3 | ||||
| -rw-r--r-- | src/game/TicketHandler.cpp | 12 | ||||
| -rw-r--r-- | src/game/TicketMgr.cpp | 40 | ||||
| -rw-r--r-- | src/game/TicketMgr.h | 20 | ||||
| -rw-r--r-- | src/game/Unit.cpp | 58 | ||||
| -rw-r--r-- | src/game/Unit.h | 2 | ||||
| -rw-r--r-- | src/game/World.cpp | 32 | ||||
| -rw-r--r-- | src/game/WorldSession.cpp | 2 | ||||
| -rw-r--r-- | src/game/WorldSocket.cpp | 12 |
20 files changed, 224 insertions, 214 deletions
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 5d091d55b1c..b51f24800ad 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -123,7 +123,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 @@ -281,7 +281,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(); @@ -464,8 +464,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() @@ -742,7 +742,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/Chat.cpp b/src/game/Chat.cpp index 1d45afef5ea..d5a59360035 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -304,7 +304,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 }, { NULL, 0, false, NULL, "", NULL } }; diff --git a/src/game/Level0.cpp b/src/game/Level0.cpp index 75f7a257caf..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); @@ -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/Level1.cpp b/src/game/Level1.cpp index 4489cbf1579..ba68df16f7f 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -275,19 +275,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; } @@ -298,7 +299,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; @@ -307,10 +308,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; } @@ -334,7 +336,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; @@ -342,7 +345,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; } @@ -364,7 +367,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; @@ -372,7 +376,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; } @@ -383,22 +387,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); @@ -428,40 +432,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; } @@ -475,19 +477,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); @@ -519,7 +522,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; @@ -553,14 +556,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/Level2.cpp b/src/game/Level2.cpp index afe22846cdd..c5db2cc2869 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -115,7 +115,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); @@ -188,7 +188,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); @@ -1896,7 +1896,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(); @@ -3870,9 +3870,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); } @@ -3889,9 +3889,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); } @@ -3906,9 +3906,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 a17d9d621b1..9c8c234c91c 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; } } @@ -5213,7 +5213,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); @@ -5253,8 +5253,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); @@ -5272,14 +5272,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) { @@ -5292,22 +5292,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()); } @@ -5333,7 +5333,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(); @@ -5364,7 +5364,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(); @@ -5401,23 +5401,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() ); } @@ -6205,7 +6205,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); @@ -6284,7 +6284,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 2107d792c7d..2d8a898132e 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -1367,7 +1367,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/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/Player.cpp b/src/game/Player.cpp index 1fca0b32067..cbf5c8dbfc5 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -3748,7 +3748,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC CharacterDatabase.PExecute("DELETE FROM character_achievement_progress WHERE guid = '%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); } @@ -3815,7 +3815,7 @@ void Player::BuildPlayerRepop() // BG - remove insignia related RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); - SendCorpseReclaimDelay(); +// SendCorpseReclaimDelay(); // to prevent cheating corpse->ResetGhostTime(); @@ -3923,6 +3923,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 @@ -19283,7 +19284,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]; } @@ -19312,17 +19314,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) ) @@ -19343,7 +19349,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); diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index d48294a77a1..20e10384a49 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -938,7 +938,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); @@ -5536,19 +5536,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<<i)) { - if(m_applyMultiplierMask & (1 << i)) - { - damage = CalculateDamage(i, NULL) * m_damageMultipliers[i]; - m_damageMultipliers[i] *= multiplier[i]; - } - else - damage = CalculateDamage(i, NULL); + m_damage = 0; + damage = CalculateDamage(i, NULL); switch(m_spellInfo->Effect[i]) { @@ -5565,7 +5560,18 @@ int32 Spell::CalculateDamageDone(Unit *unit, const uint32 effectMask, float *mul SpellDamageHeal(i); break; } + + if(m_damage > 0 && m_originalCaster) + m_damage = 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; } diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 66a91fbc19b..8ae85c89ff0 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -6033,7 +6033,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/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<GM_Ticket*> 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); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 766115742da..65689a71e84 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -1150,13 +1150,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; @@ -1184,16 +1185,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; @@ -1239,7 +1240,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) { @@ -1253,6 +1254,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) { @@ -6713,7 +6717,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 @@ -7038,6 +7041,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 ) { @@ -8299,18 +8306,19 @@ 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) + ((Creature*)this)->SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); - 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() @@ -8318,19 +8326,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 @@ -10086,7 +10097,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 98a49e519ac..238490d9428 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -951,7 +951,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; diff --git a/src/game/World.cpp b/src/game/World.cpp index 9bb936be6af..83543aa4f74 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); } } @@ -1085,7 +1085,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'"); @@ -1404,7 +1404,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(); @@ -2649,10 +2649,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 @@ -2662,12 +2662,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 @@ -2694,7 +2694,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()); } @@ -2713,8 +2713,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 { @@ -2728,7 +2728,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; } @@ -2925,8 +2925,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); } } @@ -2989,7 +2989,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 581b44b9e95..231d7783d9e 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -328,7 +328,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 2ae97819116..1f77e1111e5 100644 --- a/src/game/WorldSocket.cpp +++ b/src/game/WorldSocket.cpp @@ -720,11 +720,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 @@ -789,7 +789,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) vold, vStr); - loginDatabase.PExecute ("UPDATE account " + LoginDatabase.PExecute ("UPDATE account " "SET " "v = '0', " "s = '0' " @@ -841,7 +841,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 " @@ -907,9 +907,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 (), |
