From 8536b360a06fac25cef240bb080edd581c275d94 Mon Sep 17 00:00:00 2001 From: Subv Date: Tue, 16 Oct 2012 09:24:53 -0500 Subject: [PATCH 1/7] Core/Spells: Fix a possible crash in Light's Beacon when a player logged in with the aura. --- src/server/game/Entities/Unit/Unit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index c1f7a5a1fe5..47449c2bf88 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -6637,7 +6637,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere if (GetTypeId() != TYPEID_PLAYER) { beaconTarget = triggeredByAura->GetBase()->GetCaster(); - if (beaconTarget == this || !(beaconTarget->GetAura(53563, victim->GetGUID()))) + if (!beaconTarget || beaconTarget == this || !(beaconTarget->GetAura(53563, victim->GetGUID()))) return false; basepoints0 = int32(damage); triggered_spell_id = procSpell->IsRankOf(sSpellMgr->GetSpellInfo(635)) ? 53652 : 53654; From fba9c0a82eb61980ffd3c7a912be9479ccad011c Mon Sep 17 00:00:00 2001 From: Subv Date: Tue, 16 Oct 2012 09:39:56 -0500 Subject: [PATCH 2/7] Scripts/Halion: Fixed some warnings --- .../Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp index 64210e97122..6ba13014585 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp @@ -696,7 +696,7 @@ class npc_halion_controller : public CreatureScript halion->AI()->Talk(SAY_INTRO); break; case EVENT_TWILIGHT_MENDING: - if (Creature* halion = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_HALION))) + if (ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_HALION))) // Just check if physical Halion is spawned if (Creature* twilightHalion = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_TWILIGHT_HALION))) twilightHalion->CastSpell((Unit*)NULL, SPELL_TWILIGHT_MENDING, true); break; @@ -1115,7 +1115,7 @@ class npc_combustion_consumption : public CreatureScript struct npc_combustion_consumptionAI : public Scripted_NoMovementAI { npc_combustion_consumptionAI(Creature* creature) : Scripted_NoMovementAI(creature), - _summonerGuid(0), _instance(creature->GetInstanceScript()) + _instance(creature->GetInstanceScript()), _summonerGuid(0) { switch (me->GetEntry()) { From 88ddc9662ee811ab39fe22ec2c536f5af0f71e11 Mon Sep 17 00:00:00 2001 From: kaelima Date: Wed, 17 Oct 2012 00:43:57 +0200 Subject: [PATCH 3/7] Core/Battleground: Allow players to start capping flags stealthed or invisible - gameobject should remove the stealth/invis aura on use. --- src/server/game/Entities/Player/Player.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 0d31c40f3a1..0f01e6c129e 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -23590,21 +23590,15 @@ bool Player::CanUseBattlegroundObject() // TODO : some spells gives player ForceReaction to one faction (ReputationMgr::ApplyForceReaction) // maybe gameobject code should handle that ForceReaction usage // BUG: sometimes when player clicks on flag in AB - client won't send gameobject_use, only gameobject_report_use packet - return (//InBattleground() && // in battleground - not need, check in other cases - //!IsMounted() && - not correct, player is dismounted when he clicks on flag - //player cannot use object when he is invulnerable (immune) - !isTotalImmune() && // not totally immune - //i'm not sure if these two are correct, because invisible players should get visible when they click on flag - !HasStealthAura() && // not stealthed - !HasInvisibilityAura() && // not invisible - !HasAura(SPELL_RECENTLY_DROPPED_FLAG) && // can't pickup - isAlive() // live player -); + // Note: Mount, stealth and invisibility will be removed when used + return (!isTotalImmune() && // Damage immune + !HasAura(SPELL_RECENTLY_DROPPED_FLAG) && // Still has recently held flag debuff + isAlive()); // Alive } bool Player::CanCaptureTowerPoint() { - return (!HasStealthAura() && // not stealthed + return (!HasStealthAura() && // not stealthed !HasInvisibilityAura() && // not invisible isAlive() // live player ); From 4ec23cdba5681808a3bc456b997a860d76b1ab16 Mon Sep 17 00:00:00 2001 From: kaelima Date: Wed, 17 Oct 2012 00:46:11 +0200 Subject: [PATCH 4/7] Core/PacketIO: Automatically set field count in SMSG_INIT_WORLD_STATES instead of manual switch. --- src/server/game/Entities/Player/Player.cpp | 93 ++-------------------- 1 file changed, 6 insertions(+), 87 deletions(-) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 0f01e6c129e..d22aba92f9e 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -9053,7 +9053,6 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid) { // data depends on zoneid/mapid... Battleground* bg = GetBattleground(); - uint16 NumberOfFields = 0; uint32 mapid = GetMapId(); OutdoorPvP* pvp = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(zoneid); InstanceScript* instance = GetInstanceScript(); @@ -9061,94 +9060,12 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid) sLog->outDebug(LOG_FILTER_NETWORKIO, "Sending SMSG_INIT_WORLD_STATES to Map: %u, Zone: %u", mapid, zoneid); - // may be exist better way to do this... - switch (zoneid) - { - case 0: - case 1: - case 4: - case 8: - case 10: - case 11: - case 12: - case 36: - case 38: - case 40: - case 41: - case 51: - case 267: - case 1519: - case 1537: - case 2257: - case 2918: - NumberOfFields = 8; - break; - case 139: - NumberOfFields = 41; - break; - case 1377: - NumberOfFields = 15; - break; - case 2597: - NumberOfFields = 83; - break; - case 3277: - NumberOfFields = 18; - break; - case 3358: - case 3820: - NumberOfFields = 40; - break; - case 3483: - NumberOfFields = 27; - break; - case 3518: - NumberOfFields = 39; - break; - case 3519: - NumberOfFields = 38; - break; - case 3521: - NumberOfFields = 37; - break; - case 3698: - case 3702: - case 3968: - case 4378: - case 3703: - NumberOfFields = 11; - break; - case 4384: - NumberOfFields = 30; - break; - case 4710: - NumberOfFields = 28; - break; - case 4812: // Icecrown Citadel - case 4100: // The Culling of Stratholme - NumberOfFields = 13; - break; - case 4987: // The Ruby Sanctum - NumberOfFields = 3; - break; - case 4273: // Ulduar - NumberOfFields = 10; - break; - case 4197: // Wintergrasp - /// Use the max here, and fill with zeros if missing. - NumberOfFields = 10 + WG_MAX_OBJ + WG_MAX_WORKSHOP; - break; - default: - NumberOfFields = 12; - break; - } - - WorldPacket data(SMSG_INIT_WORLD_STATES, (4+4+4+2+(NumberOfFields*8))); + WorldPacket data(SMSG_INIT_WORLD_STATES, (4+4+4+2+(12*8))); data << uint32(mapid); // mapid data << uint32(zoneid); // zone id data << uint32(areaid); // area id, new 2.1.0 size_t countPos = data.wpos(); - data << uint16(NumberOfFields); // count of uint64 blocks + data << uint16(0); // count of uint64 blocks data << uint32(0x8d8) << uint32(0x0); // 1 data << uint32(0x8d7) << uint32(0x0); // 2 data << uint32(0x8d6) << uint32(0x0); // 3 @@ -9711,8 +9628,6 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid) bf->FillInitialWorldStates(data); break; } - else - data.put(countPos, 12); // No break here, intended. default: data << uint32(0x914) << uint32(0x0); // 7 @@ -9721,6 +9636,10 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid) data << uint32(0x915) << uint32(0x0); // 10 break; } + + uint16 length = (data.wpos() - countPos) / 8; + data.put(countPos, length); + GetSession()->SendPacket(&data); SendBGWeekendWorldStates(); SendBattlefieldWorldStates(); From 98588aa19202c2d259fba0717f9c4a4feac32a0a Mon Sep 17 00:00:00 2001 From: kaelima Date: Wed, 17 Oct 2012 00:53:55 +0200 Subject: [PATCH 5/7] Core/Ticket: - Fully parse CMSG_GMTICKET_CREATE, use GmTicket::GetChatLog() to access the reporters chat log from this session (unused atm, possible useful to detect chat harassment) - Simplify SMSG_GMTICKET_GETTICKET and fix "category" field (renamed it same as in blizz LUA files) - Store response in DB --- .../2012_10_17_00_character_gm_tickets.sql | 3 + src/server/game/Handlers/TicketHandler.cpp | 44 ++++++++++- src/server/game/Tickets/TicketMgr.cpp | 79 +++++++++---------- src/server/game/Tickets/TicketMgr.h | 7 +- .../Implementation/CharacterDatabase.cpp | 4 +- 5 files changed, 90 insertions(+), 47 deletions(-) create mode 100644 sql/updates/characters/2012_10_17_00_character_gm_tickets.sql diff --git a/sql/updates/characters/2012_10_17_00_character_gm_tickets.sql b/sql/updates/characters/2012_10_17_00_character_gm_tickets.sql new file mode 100644 index 00000000000..c41df0c115d --- /dev/null +++ b/sql/updates/characters/2012_10_17_00_character_gm_tickets.sql @@ -0,0 +1,3 @@ +ALTER TABLE `gm_tickets` + ADD COLUMN `response` TEXT NOT NULL AFTER `comment`, + ADD COLUMN `haveTicket` TINYINT(3) UNSIGNED NOT NULL AFTER `viewed`; diff --git a/src/server/game/Handlers/TicketHandler.cpp b/src/server/game/Handlers/TicketHandler.cpp index d6675188f6e..7fcfbbbc23e 100755 --- a/src/server/game/Handlers/TicketHandler.cpp +++ b/src/server/game/Handlers/TicketHandler.cpp @@ -16,6 +16,7 @@ * with this program. If not, see . */ +#include "zlib.h" #include "Language.h" #include "WorldPacket.h" #include "Common.h" @@ -26,7 +27,7 @@ #include "WorldSession.h" #include "Util.h" -void WorldSession::HandleGMTicketCreateOpcode(WorldPacket & recv_data) +void WorldSession::HandleGMTicketCreateOpcode(WorldPacket& recvData) { // Don't accept tickets if the ticket queue is disabled. (Ticket UI is greyed out but not fully dependable) if (sTicketMgr->GetStatus() == GMTICKET_QUEUE_STATUS_DISABLED) @@ -42,7 +43,46 @@ void WorldSession::HandleGMTicketCreateOpcode(WorldPacket & recv_data) // Player must not have ticket if (!sTicketMgr->GetTicketByPlayer(GetPlayer()->GetGUID())) { - GmTicket* ticket = new GmTicket(GetPlayer(), recv_data); + GmTicket* ticket = new GmTicket(GetPlayer(), recvData); + + uint32 count; + std::list times; + uint32 decompressedSize; + std::string chatLog; + + recvData >> count; + + for (uint32 i = 0; i < count; i++) + { + uint32 time; + recvData >> time; + times.push_back(time); + } + + recvData >> decompressedSize; + + if (count && decompressedSize && decompressedSize < 0xFFFF) + { + uint32 pos = recvData.rpos(); + ByteBuffer dest; + dest.resize(decompressedSize); + + uLongf realSize = decompressedSize; + if (uncompress(const_cast(dest.contents()), &realSize, const_cast(recvData.contents() + pos), recvData.size() - pos) == Z_OK) + { + dest >> chatLog; + ticket->SetChatLog(times, chatLog); + } + else + { + sLog->outError(LOG_FILTER_NETWORKIO, "CMSG_GMTICKET_CREATE possibly corrupt. Uncompression failed."); + recvData.rfinish(); + return; + } + + recvData.rfinish(); // Will still have compressed data in buffer. + } + sTicketMgr->AddTicket(ticket); sTicketMgr->UpdateLastChange(); diff --git a/src/server/game/Tickets/TicketMgr.cpp b/src/server/game/Tickets/TicketMgr.cpp index 0a4682db759..51e17cb9076 100755 --- a/src/server/game/Tickets/TicketMgr.cpp +++ b/src/server/game/Tickets/TicketMgr.cpp @@ -31,45 +31,32 @@ inline float GetAge(uint64 t) { return float(time(NULL) - t) / DAY; } // GM ticket GmTicket::GmTicket() { } -GmTicket::GmTicket(Player* player, WorldPacket& recv_data) : _createTime(time(NULL)), _lastModifiedTime(time(NULL)), _closedBy(0), _assignedTo(0), _completed(false), _escalatedStatus(TICKET_UNASSIGNED) +GmTicket::GmTicket(Player* player, WorldPacket& recvData) : _createTime(time(NULL)), _lastModifiedTime(time(NULL)), _closedBy(0), _assignedTo(0), _completed(false), _escalatedStatus(TICKET_UNASSIGNED), _haveTicket(false) { _id = sTicketMgr->GenerateTicketId(); _playerName = player->GetName(); _playerGuid = player->GetGUID(); uint32 mapId; - recv_data >> mapId; // Map is sent as UInt32! + recvData >> mapId; // Map is sent as UInt32! _mapId = mapId; - recv_data >> _posX; - recv_data >> _posY; - recv_data >> _posZ; - recv_data >> _message; + recvData >> _posX; + recvData >> _posY; + recvData >> _posZ; + recvData >> _message; uint32 needResponse; - recv_data >> needResponse; - _needResponse = (needResponse == 17); // Requires GM response. 17 = true, 1 = false (17 is default) - uint8 unk1; - recv_data >> unk1; // Requests further GM interaction on a ticket to which a GM has already responded - - recv_data.rfinish(); - /* - recv_data >> uint32(count); // text lines - for (int i = 0; i < count; i++) - recv_data >> uint32(); - - if (something) - recv_data >> uint32(); - else - compressed uint32 + string; - */ + recvData >> needResponse; + _needResponse = (needResponse == 17); // Requires GM response. 17 = true, 1 = false (17 is default) + recvData >> _haveTicket; // Requests further GM interaction on a ticket to which a GM has already responded. Basically means "has a new ticket" } GmTicket::~GmTicket() { } bool GmTicket::LoadFromDB(Field* fields) { - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - // ticketId, guid, name, message, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, completed, escalated, viewed + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 + // ticketId, guid, name, message, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, haveTicket uint8 index = 0; _id = fields[ index].GetUInt32(); _playerGuid = MAKE_NEW_GUID(fields[++index].GetUInt32(), 0, HIGHGUID_PLAYER); @@ -84,9 +71,11 @@ bool GmTicket::LoadFromDB(Field* fields) _closedBy = fields[++index].GetInt32(); _assignedTo = MAKE_NEW_GUID(fields[++index].GetUInt32(), 0, HIGHGUID_PLAYER); _comment = fields[++index].GetString(); + _response = fields[++index].GetString(); _completed = fields[++index].GetBool(); _escalatedStatus = GMTicketEscalationStatus(fields[++index].GetUInt8()); _viewed = fields[++index].GetBool(); + _haveTicket = fields[++index].GetBool(); return true; } @@ -109,9 +98,11 @@ void GmTicket::SaveToDB(SQLTransaction& trans) const stmt->setInt32 (++index, GUID_LOPART(_closedBy)); stmt->setUInt32(++index, GUID_LOPART(_assignedTo)); stmt->setString(++index, _comment); + stmt->setString(++index, _response); stmt->setBool (++index, _completed); stmt->setUInt8 (++index, uint8(_escalatedStatus)); stmt->setBool (++index, _viewed); + stmt->setBool (++index, _haveTicket); CharacterDatabase.ExecuteOrAppend(trans, stmt); } @@ -125,6 +116,10 @@ void GmTicket::DeleteFromDB() void GmTicket::WritePacket(WorldPacket& data) const { + data << uint32(GMTICKET_STATUS_HASTEXT); + data << uint32(_id); + data << _message; + data << uint8(_haveTicket); data << GetAge(_lastModifiedTime); if (GmTicket* ticket = sTicketMgr->GetOldestOpenTicket()) data << GetAge(ticket->GetLastModifiedTime()); @@ -223,6 +218,20 @@ void GmTicket::TeleportTo(Player* player) const player->TeleportTo(_mapId, _posX, _posY, _posZ, 0.0f, 0); } +void GmTicket::SetChatLog(std::list time, std::string const& log) +{ + std::stringstream ss(log); + std::stringstream newss; + std::string line; + while (std::getline(ss, line)) + { + newss << secsToTimeString(time.front()) << ": " << line << "\n"; + time.pop_front(); + } + + _chatLog = newss.str(); +} + /////////////////////////////////////////////////////////////////////////////////////////////////// // Ticket manager TicketMgr::TicketMgr() : _status(true), _lastTicketId(0), _lastSurveyId(0), _openTicketCount(0), _lastChange(time(NULL)) { } @@ -365,26 +374,12 @@ void TicketMgr::ShowEscalatedList(ChatHandler& handler) const void TicketMgr::SendTicket(WorldSession* session, GmTicket* ticket) const { - uint32 status = GMTICKET_STATUS_DEFAULT; - std::string message; - if (ticket) - { - message = ticket->GetMessage(); - status = GMTICKET_STATUS_HASTEXT; - } - - WorldPacket data(SMSG_GMTICKET_GETTICKET, (4 + 4 + (ticket ? message.length() + 1 + 4 + 4 + 4 + 1 + 1 : 0))); - data << uint32(status); // standard 0x0A, 0x06 if text present - data << uint32(ticket ? ticket->GetId() : 0); // ticketID + WorldPacket data(SMSG_GMTICKET_GETTICKET, (ticket ? (4 + 4 + 1 + 4 + 4 + 4 + 1 + 1) : 4)); if (ticket) - { - data << message.c_str(); // ticket text - data << uint8(0x7); // ticket category; why is this hardcoded? does it make a diff re: client? - - // we've got the easy stuff done by now. - // Now we need to go through the client logic for displaying various levels of ticket load ticket->WritePacket(data); - } + else + data << uint32(GMTICKET_STATUS_DEFAULT); + session->SendPacket(&data); } diff --git a/src/server/game/Tickets/TicketMgr.h b/src/server/game/Tickets/TicketMgr.h index ecf315c059c..63837e39452 100755 --- a/src/server/game/Tickets/TicketMgr.h +++ b/src/server/game/Tickets/TicketMgr.h @@ -82,7 +82,7 @@ class GmTicket { public: GmTicket(); - explicit GmTicket(Player* player, WorldPacket& recv_data); + explicit GmTicket(Player* player, WorldPacket& recvData); ~GmTicket(); bool IsClosed() const { return _closedBy; } @@ -142,6 +142,9 @@ public: std::string FormatMessageString(ChatHandler& handler, bool detailed = false) const; std::string FormatMessageString(ChatHandler& handler, const char* szClosedName, const char* szAssignedToName, const char* szUnassignedName, const char* szDeletedName) const; + void SetChatLog(std::list time, std::string const& log); + std::string GetChatLog() const { return _chatLog; } + private: uint32 _id; uint64 _playerGuid; @@ -160,7 +163,9 @@ private: GMTicketEscalationStatus _escalatedStatus; bool _viewed; bool _needResponse; // TODO: find out the use of this, and then store it in DB + bool _haveTicket; std::string _response; + std::string _chatLog; // No need to store in db, will be refreshed every session client side }; typedef std::map GmTicketList; diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp index c29d8313c20..d9b517c098f 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/shared/Database/Implementation/CharacterDatabase.cpp @@ -327,8 +327,8 @@ void CharacterDatabaseConnection::DoPrepareStatements() PREPARE_STATEMENT(CHAR_DEL_GO_RESPAWN_BY_INSTANCE, "DELETE FROM gameobject_respawn WHERE mapId = ? AND instanceId = ?", CONNECTION_ASYNC) // GM Tickets - PREPARE_STATEMENT(CHAR_SEL_GM_TICKETS, "SELECT ticketId, guid, name, message, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, completed, escalated, viewed FROM gm_tickets", CONNECTION_SYNCH) - PREPARE_STATEMENT(CHAR_REP_GM_TICKET, "REPLACE INTO gm_tickets (ticketId, guid, name, message, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, completed, escalated, viewed) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC) + PREPARE_STATEMENT(CHAR_SEL_GM_TICKETS, "SELECT ticketId, guid, name, message, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, haveTicket FROM gm_tickets", CONNECTION_SYNCH) + PREPARE_STATEMENT(CHAR_REP_GM_TICKET, "REPLACE INTO gm_tickets (ticketId, guid, name, message, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, haveTicket) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC) PREPARE_STATEMENT(CHAR_DEL_GM_TICKET, "DELETE FROM gm_tickets WHERE ticketId = ?", CONNECTION_ASYNC) PREPARE_STATEMENT(CHAR_DEL_PLAYER_GM_TICKETS, "DELETE FROM gm_tickets WHERE guid = ?", CONNECTION_ASYNC) From 6abc6253a63b366b3d0259278889a83a756e9745 Mon Sep 17 00:00:00 2001 From: kaelima Date: Wed, 17 Oct 2012 02:56:07 +0200 Subject: [PATCH 6/7] DB: Add gm_tickets changes to base character db --- sql/base/characters_database.sql | 2 ++ sql/updates/characters/2012_10_17_00_character_gm_tickets.sql | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/base/characters_database.sql b/sql/base/characters_database.sql index b1c57a2f5fb..4a2d2951da3 100644 --- a/sql/base/characters_database.sql +++ b/sql/base/characters_database.sql @@ -1429,9 +1429,11 @@ CREATE TABLE `gm_tickets` ( `closedBy` int(10) NOT NULL DEFAULT '0', `assignedTo` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'GUID of admin to whom ticket is assigned', `comment` text NOT NULL, + `response` text NOT NULL, `completed` tinyint(3) unsigned NOT NULL DEFAULT '0', `escalated` tinyint(3) unsigned NOT NULL DEFAULT '0', `viewed` tinyint(3) unsigned NOT NULL DEFAULT '0', + `haveTicket` tinyint(3) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`ticketId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Player System'; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/sql/updates/characters/2012_10_17_00_character_gm_tickets.sql b/sql/updates/characters/2012_10_17_00_character_gm_tickets.sql index c41df0c115d..affb23f836c 100644 --- a/sql/updates/characters/2012_10_17_00_character_gm_tickets.sql +++ b/sql/updates/characters/2012_10_17_00_character_gm_tickets.sql @@ -1,3 +1,3 @@ ALTER TABLE `gm_tickets` - ADD COLUMN `response` TEXT NOT NULL AFTER `comment`, - ADD COLUMN `haveTicket` TINYINT(3) UNSIGNED NOT NULL AFTER `viewed`; + ADD COLUMN `response` text NOT NULL AFTER `comment`, + ADD COLUMN `haveTicket` tinyint(3) unsigned NOT NULL DEFAULT '0' AFTER `viewed`; From 27f091806a6f52f406837d188dd4171019bfa59b Mon Sep 17 00:00:00 2001 From: Subv Date: Tue, 16 Oct 2012 21:43:23 -0500 Subject: [PATCH 7/7] Core/SpellAreas: Changed the way quest_start and quest_end works. They now follow this rule: The player's quest status of quest_start must have the mask defined in quest_start_status in order for the spell to be applied/kept. The player's quest status of quest_end must _NOT_ have the mask defined in quest_end_status in order for the spell to be removed To generate the mask: Take the QuestStatus enum in QuestDef.h, use (1 << theValueYouWant) to obtain a mask and you can use | to combine masks. This expands the usage of the spell_area table, making possible to give a player an aura while he has a quest, but remove it as soon as the quest is completed (not rewarded). Feature request by @Svannon --- .../world/2012_10_16_00_world_spell_area.sql | 4 ++ src/server/game/Entities/Player/Player.cpp | 64 +++++++------------ src/server/game/Spells/SpellMgr.cpp | 44 +++++-------- src/server/game/Spells/SpellMgr.h | 6 +- 4 files changed, 46 insertions(+), 72 deletions(-) create mode 100644 sql/updates/world/2012_10_16_00_world_spell_area.sql diff --git a/sql/updates/world/2012_10_16_00_world_spell_area.sql b/sql/updates/world/2012_10_16_00_world_spell_area.sql new file mode 100644 index 00000000000..3dbc29d077f --- /dev/null +++ b/sql/updates/world/2012_10_16_00_world_spell_area.sql @@ -0,0 +1,4 @@ +ALTER TABLE `spell_area` ADD COLUMN `quest_start_status` INT(11) NOT NULL DEFAULT 64; -- default is QUEST_STATUS_REWARDED +ALTER TABLE `spell_area` ADD COLUMN `quest_end_status` INT(11) NOT NULL DEFAULT 11; -- default is QUEST_STATUS_COMPLETE | QUEST_STATUS_NONE | QUEST_STATUS_INCOMPLETE +UPDATE spell_area SET `quest_start_status` = (1 << 6) | (1 << 3) | (1 << 1) WHERE `quest_start_active` = 1; +ALTER TABLE spell_area DROP COLUMN `quest_start_active`; \ No newline at end of file diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index d22aba92f9e..501379228e2 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -14980,19 +14980,6 @@ void Player::AddQuest(Quest const* quest, Object* questGiver) if (questGiver && quest->GetQuestStartScript() != 0) GetMap()->ScriptsStart(sQuestStartScripts, quest->GetQuestStartScript(), questGiver, this); - // Some spells applied at quest activation - SpellAreaForQuestMapBounds saBounds = sSpellMgr->GetSpellAreaForQuestMapBounds(quest_id, true); - if (saBounds.first != saBounds.second) - { - uint32 zone, area; - GetZoneAndAreaId(zone, area); - - for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) - if (itr->second->autocast && itr->second->IsFitToRequirements(this, zone, area)) - if (!HasAura(itr->second->spellId)) - CastSpell(this, itr->second->spellId, true); - } - UpdateForQuestWorldObjects(); } @@ -15181,33 +15168,6 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT); UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST, quest->GetQuestId()); - uint32 zone = 0; - uint32 area = 0; - - // remove auras from spells with quest reward state limitations - SpellAreaForQuestMapBounds saEndBounds = sSpellMgr->GetSpellAreaForQuestEndMapBounds(quest_id); - if (saEndBounds.first != saEndBounds.second) - { - GetZoneAndAreaId(zone, area); - - for (SpellAreaForAreaMap::const_iterator itr = saEndBounds.first; itr != saEndBounds.second; ++itr) - if (!itr->second->IsFitToRequirements(this, zone, area)) - RemoveAurasDueToSpell(itr->second->spellId); - } - - // Some spells applied at quest reward - SpellAreaForQuestMapBounds saBounds = sSpellMgr->GetSpellAreaForQuestMapBounds(quest_id, false); - if (saBounds.first != saBounds.second) - { - if (!zone || !area) - GetZoneAndAreaId(zone, area); - - for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) - if (itr->second->autocast && itr->second->IsFitToRequirements(this, zone, area)) - if (!HasAura(itr->second->spellId)) - CastSpell(this, itr->second->spellId, true); - } - //lets remove flag for delayed teleports SetCanDelayTeleport(false); } @@ -15750,6 +15710,30 @@ void Player::SetQuestStatus(uint32 quest_id, QuestStatus status) m_QuestStatusSave[quest_id] = true; } + uint32 zone = 0, area = 0; + + SpellAreaForQuestMapBounds saBounds = sSpellMgr->GetSpellAreaForQuestMapBounds(quest_id); + if (saBounds.first != saBounds.second) + { + GetZoneAndAreaId(zone, area); + + for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) + if (itr->second->autocast && itr->second->IsFitToRequirements(this, zone, area)) + if (!HasAura(itr->second->spellId)) + CastSpell(this, itr->second->spellId, true); + } + + saBounds = sSpellMgr->GetSpellAreaForQuestEndMapBounds(quest_id); + if (saBounds.first != saBounds.second) + { + if (!zone || !area) + GetZoneAndAreaId(zone, area); + + for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) + if (!itr->second->IsFitToRequirements(this, zone, area)) + RemoveAurasDueToSpell(itr->second->spellId); + } + UpdateForQuestWorldObjects(); } diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 7c2ea8fbe9f..06f1187a833 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -1061,12 +1061,9 @@ SpellAreaMapBounds SpellMgr::GetSpellAreaMapBounds(uint32 spell_id) const return SpellAreaMapBounds(mSpellAreaMap.lower_bound(spell_id), mSpellAreaMap.upper_bound(spell_id)); } -SpellAreaForQuestMapBounds SpellMgr::GetSpellAreaForQuestMapBounds(uint32 quest_id, bool active) const +SpellAreaForQuestMapBounds SpellMgr::GetSpellAreaForQuestMapBounds(uint32 quest_id) const { - if (active) - return SpellAreaForQuestMapBounds(mSpellAreaForActiveQuestMap.lower_bound(quest_id), mSpellAreaForActiveQuestMap.upper_bound(quest_id)); - else - return SpellAreaForQuestMapBounds(mSpellAreaForQuestMap.lower_bound(quest_id), mSpellAreaForQuestMap.upper_bound(quest_id)); + return SpellAreaForQuestMapBounds(mSpellAreaForQuestMap.lower_bound(quest_id), mSpellAreaForQuestMap.upper_bound(quest_id)); } SpellAreaForQuestMapBounds SpellMgr::GetSpellAreaForQuestEndMapBounds(uint32 quest_id) const @@ -1099,11 +1096,11 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32 return false; if (questStart) // not in expected required quest state - if (!player || ((!questStartCanActive || !player->IsActiveQuest(questStart)) && !player->GetQuestRewardStatus(questStart))) + if (!player || (((1 << player->GetQuestStatus(questStart)) & questStartStatus) == 0)) return false; if (questEnd) // not in expected forbidden quest state - if (!player || player->GetQuestRewardStatus(questEnd)) + if (!player || (((1 << player->GetQuestStatus(questEnd)) & questEndStatus) == 0)) return false; if (auraSpell) // not have expected aura @@ -2433,12 +2430,11 @@ void SpellMgr::LoadSpellAreas() mSpellAreaMap.clear(); // need for reload case mSpellAreaForQuestMap.clear(); - mSpellAreaForActiveQuestMap.clear(); mSpellAreaForQuestEndMap.clear(); mSpellAreaForAuraMap.clear(); - // 0 1 2 3 4 5 6 7 8 - QueryResult result = WorldDatabase.Query("SELECT spell, area, quest_start, quest_start_active, quest_end, aura_spell, racemask, gender, autocast FROM spell_area"); + // 0 1 2 3 4 5 6 7 8 9 + QueryResult result = WorldDatabase.Query("SELECT spell, area, quest_start, quest_start_status, quest_end_status, quest_end, aura_spell, racemask, gender, autocast FROM spell_area"); if (!result) { @@ -2457,12 +2453,13 @@ void SpellMgr::LoadSpellAreas() spellArea.spellId = spell; spellArea.areaId = fields[1].GetUInt32(); spellArea.questStart = fields[2].GetUInt32(); - spellArea.questStartCanActive = fields[3].GetBool(); - spellArea.questEnd = fields[4].GetUInt32(); - spellArea.auraSpell = fields[5].GetInt32(); - spellArea.raceMask = fields[6].GetUInt32(); - spellArea.gender = Gender(fields[7].GetUInt8()); - spellArea.autocast = fields[8].GetBool(); + spellArea.questStartStatus = fields[3].GetUInt32(); + spellArea.questEndStatus = fields[4].GetUInt32(); + spellArea.questEnd = fields[5].GetUInt32(); + spellArea.auraSpell = fields[6].GetInt32(); + spellArea.raceMask = fields[7].GetUInt32(); + spellArea.gender = Gender(fields[8].GetUInt8()); + spellArea.autocast = fields[9].GetBool(); if (SpellInfo const* spellInfo = GetSpellInfo(spell)) { @@ -2494,7 +2491,7 @@ void SpellMgr::LoadSpellAreas() continue; // duplicate by requirements - ok =false; + ok = false; break; } @@ -2524,12 +2521,6 @@ void SpellMgr::LoadSpellAreas() sLog->outError(LOG_FILTER_SQL, "Spell %u listed in `spell_area` have wrong end quest (%u) requirement", spell, spellArea.questEnd); continue; } - - if (spellArea.questEnd == spellArea.questStart && !spellArea.questStartCanActive) - { - sLog->outError(LOG_FILTER_SQL, "Spell %u listed in `spell_area` have quest (%u) requirement for start and end in same time", spell, spellArea.questEnd); - continue; - } } if (spellArea.auraSpell) @@ -2605,12 +2596,7 @@ void SpellMgr::LoadSpellAreas() // for search at quest start/reward if (spellArea.questStart) - { - if (spellArea.questStartCanActive) - mSpellAreaForActiveQuestMap.insert(SpellAreaForQuestMap::value_type(spellArea.questStart, sa)); - else - mSpellAreaForQuestMap.insert(SpellAreaForQuestMap::value_type(spellArea.questStart, sa)); - } + mSpellAreaForQuestMap.insert(SpellAreaForQuestMap::value_type(spellArea.questStart, sa)); // for search at quest start/reward if (spellArea.questEnd) diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index 9646bc9dabf..cec9d4650f5 100755 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -495,7 +495,8 @@ struct SpellArea int32 auraSpell; // spell aura must be applied for spell apply)if possitive) and it must not be applied in other case uint32 raceMask; // can be applied only to races Gender gender; // can be applied only to gender - bool questStartCanActive; // if true then quest start can be active (not only rewarded) + uint32 questStartStatus; // QuestStatus that quest_start must have in order to keep the spell + uint32 questEndStatus; // QuestStatus that the quest_end must have in order to keep the spell (if the quest_end's status is different than this, the spell will be dropped) bool autocast; // if true then auto applied at area enter, in other case just allowed to cast // helpers @@ -681,7 +682,7 @@ class SpellMgr // Spell area SpellAreaMapBounds GetSpellAreaMapBounds(uint32 spell_id) const; - SpellAreaForQuestMapBounds GetSpellAreaForQuestMapBounds(uint32 quest_id, bool active) const; + SpellAreaForQuestMapBounds GetSpellAreaForQuestMapBounds(uint32 quest_id) const; SpellAreaForQuestMapBounds GetSpellAreaForQuestEndMapBounds(uint32 quest_id) const; SpellAreaForAuraMapBounds GetSpellAreaForAuraMapBounds(uint32 spell_id) const; SpellAreaForAreaMapBounds GetSpellAreaForAreaMapBounds(uint32 area_id) const; @@ -740,7 +741,6 @@ class SpellMgr EnchantCustomAttribute mEnchantCustomAttr; SpellAreaMap mSpellAreaMap; SpellAreaForQuestMap mSpellAreaForQuestMap; - SpellAreaForQuestMap mSpellAreaForActiveQuestMap; SpellAreaForQuestMap mSpellAreaForQuestEndMap; SpellAreaForAuraMap mSpellAreaForAuraMap; SpellAreaForAreaMap mSpellAreaForAreaMap;