Core/AdventureJournal: Handle CMSG_ADVENTURE_JOURNAL_OPEN_QUEST and CMSG_ADVENTURE_JOURNAL_UPDATE_SUGGESTIONS
Port From (https://github.com/TrinityCore/TrinityCore/commit/3addbe7dd418259149c39fc3b9423f7809de696a)
This commit is contained in:
@@ -28,9 +28,8 @@ namespace Framework.Database
|
||||
|
||||
// AdventureJournal.db2
|
||||
PrepareStatement(HotfixStatements.SEL_ADVENTURE_JOURNAL, "SELECT ID, Name, Description, ButtonText, RewardDescription, ContinueDescription, Type, " +
|
||||
"PlayerConditionId, Flags, ButtonActionType, TextureFileDataId, LfgDungeonId, QuestId, BattleMasterListId, PriorityMin, PriorityMax, ItemId, " +
|
||||
"ItemQuantity, CurrencyType, CurrencyQuantity, UiMapId, BonusPlayerConditionId1, BonusPlayerConditionId2, BonusValue1, BonusValue2" +
|
||||
" FROM adventure_journal");
|
||||
"PlayerConditionID, Flags, ButtonActionType, TextureFileDataID, LfgDungeonID, QuestID, BattleMasterListID, PriorityMin, PriorityMax, ItemID, " +
|
||||
"ItemQuantity, CurrencyType, CurrencyQuantity, UiMapID, BonusPlayerConditionID1, BonusPlayerConditionID2, BonusValue1, BonusValue2 FROM adventure_journal");
|
||||
PrepareStatement(HotfixStatements.SEL_ADVENTURE_JOURNAL_LOCALE, "SELECT ID, Name_lang, Description_lang, ButtonText_lang, RewardDescription_lang, " +
|
||||
"ContinueDescription_lang FROM adventure_journal_locale WHERE locale = ?");
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Game.DataStorage
|
||||
public ushort CurrencyType;
|
||||
public uint CurrencyQuantity;
|
||||
public ushort UiMapID;
|
||||
public int[] BonusPlayerConditionID = new int[2];
|
||||
public uint[] BonusPlayerConditionID = new uint[2];
|
||||
public byte[] BonusValue = new byte[2];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Framework.Constants;
|
||||
using Framework.IO;
|
||||
using Game.BattleGrounds;
|
||||
using Game.DataStorage;
|
||||
using Game.Entities;
|
||||
using Game.Groups;
|
||||
using Game.Guilds;
|
||||
using Game.Maps;
|
||||
using Game.Misc;
|
||||
using Game.Networking;
|
||||
using Game.Networking.Packets;
|
||||
using Game.PvP;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Game
|
||||
{
|
||||
public partial class WorldSession
|
||||
{
|
||||
[WorldPacketHandler(ClientOpcodes.AdventureJournalOpenQuest)]
|
||||
void HandleAdventureJournalOpenQuest(AdventureJournalOpenQuest openQuest)
|
||||
{
|
||||
var adventureJournal = CliDB.AdventureJournalStorage.LookupByKey(openQuest.AdventureJournalID);
|
||||
if (adventureJournal == null)
|
||||
return;
|
||||
|
||||
if (!_player.MeetPlayerCondition(adventureJournal.PlayerConditionID))
|
||||
return;
|
||||
|
||||
Quest quest = Global.ObjectMgr.GetQuestTemplate(adventureJournal.QuestID);
|
||||
if (quest == null)
|
||||
return;
|
||||
|
||||
if (_player.CanTakeQuest(quest, true))
|
||||
_player.PlayerTalkClass.SendQuestGiverQuestDetails(quest, _player.GetGUID(), true, false);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.AdventureJournalStartQuest)]
|
||||
void HandleAdventureJournalStartQuest(AdventureJournalStartQuest startQuest)
|
||||
{
|
||||
Quest quest = Global.ObjectMgr.GetQuestTemplate(startQuest.QuestID);
|
||||
if (quest == null)
|
||||
return;
|
||||
|
||||
AdventureJournalRecord adventureJournalEntry = null;
|
||||
foreach (var adventureJournal in CliDB.AdventureJournalStorage.Values)
|
||||
{
|
||||
if (quest.Id == adventureJournal.QuestID)
|
||||
{
|
||||
adventureJournalEntry = adventureJournal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (adventureJournalEntry == null)
|
||||
return;
|
||||
|
||||
if (_player.MeetPlayerCondition(adventureJournalEntry.PlayerConditionID) && _player.CanTakeQuest(quest, true))
|
||||
_player.AddQuestAndCheckCompletion(quest, null);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.AdventureJournalUpdateSuggestions)]
|
||||
void HandleAdventureJournalUpdateSuggestions(AdventureJournalUpdateSuggestions updateSuggestions)
|
||||
{
|
||||
AdventureJournalDataResponse response = new AdventureJournalDataResponse();
|
||||
response.OnLevelUp = updateSuggestions.OnLevelUp;
|
||||
|
||||
foreach (var adventureJournal in CliDB.AdventureJournalStorage.Values)
|
||||
{
|
||||
if (_player.MeetPlayerCondition(adventureJournal.PlayerConditionID))
|
||||
{
|
||||
AdventureJournalEntry adventureJournalData;
|
||||
adventureJournalData.AdventureJournalID = (int)adventureJournal.Id;
|
||||
adventureJournalData.Priority = adventureJournal.PriorityMax;
|
||||
response.AdventureJournalDatas.Add(adventureJournalData);
|
||||
}
|
||||
}
|
||||
|
||||
SendPacket(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -770,70 +770,5 @@ namespace Game
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.AdventureJournalOpenQuest)]
|
||||
void HandleAdventureJournalOpenQuest(AdventureJournalOpenQuest adventureJournalOpenQuest)
|
||||
{
|
||||
var adventureJournalEntry = CliDB.AdventureJournalStorage.LookupByKey(adventureJournalOpenQuest.AdventureJournalID);
|
||||
if (adventureJournalEntry == null)
|
||||
return;
|
||||
|
||||
Quest quest = Global.ObjectMgr.GetQuestTemplate(adventureJournalEntry.QuestID);
|
||||
if (quest == null)
|
||||
return;
|
||||
|
||||
if (_player.CanTakeQuest(quest, true))
|
||||
{
|
||||
PlayerMenu menu = new PlayerMenu(_player.GetSession());
|
||||
menu.SendQuestGiverQuestDetails(quest, _player.GetGUID(), true, false);
|
||||
}
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.AdventureJournalStartQuest)]
|
||||
void HandleAdventureJournalStartQuest(AdventureJournalStartQuest adventureJournalStartQuest)
|
||||
{
|
||||
Quest quest = Global.ObjectMgr.GetQuestTemplate(adventureJournalStartQuest.QuestID);
|
||||
if (quest == null)
|
||||
return;
|
||||
|
||||
AdventureJournalRecord adventureJournalEntry = null;
|
||||
foreach (var adventureJournal in CliDB.AdventureJournalStorage.Values)
|
||||
{
|
||||
if (quest.Id == adventureJournal.QuestID)
|
||||
{
|
||||
adventureJournalEntry = adventureJournal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (adventureJournalEntry == null)
|
||||
return;
|
||||
|
||||
if (_player.MeetPlayerCondition(adventureJournalEntry.PlayerConditionID) && _player.CanTakeQuest(quest, true))
|
||||
_player.AddQuestAndCheckCompletion(quest, null);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.AdventureJournalUpdateSuggestions)]
|
||||
void HandleAdventureJournalUpdateSuggestions(AdventureJournalUpdateSuggestions adventureJournalUpdateSuggestions)
|
||||
{
|
||||
if (adventureJournalUpdateSuggestions.OnLevelUp && _player.GetLevel() < 10)
|
||||
return;
|
||||
|
||||
AdventureJournalDataResponse response = new AdventureJournalDataResponse();
|
||||
response.OnLevelUp = adventureJournalUpdateSuggestions.OnLevelUp;
|
||||
|
||||
foreach (var adventureJournal in CliDB.AdventureJournalStorage.Values)
|
||||
{
|
||||
if (_player.MeetPlayerCondition(adventureJournal.PlayerConditionID))
|
||||
{
|
||||
AdventureJournalData adventureJournalData;
|
||||
adventureJournalData.AdventureJournalID = (int)adventureJournal.Id;
|
||||
adventureJournalData.Priority = adventureJournal.PriorityMax;
|
||||
response.AdventureJournalDatas.Add(adventureJournalData);
|
||||
}
|
||||
}
|
||||
|
||||
SendPacket(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Framework.Constants;
|
||||
using Framework.Dynamic;
|
||||
using Framework.GameMath;
|
||||
using Game.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Game.Networking.Packets
|
||||
{
|
||||
class AdventureJournalOpenQuest : ClientPacket
|
||||
{
|
||||
public AdventureJournalOpenQuest(WorldPacket packet) : base(packet) { }
|
||||
|
||||
public override void Read()
|
||||
{
|
||||
AdventureJournalID = _worldPacket.ReadUInt32();
|
||||
}
|
||||
|
||||
public uint AdventureJournalID;
|
||||
}
|
||||
|
||||
class AdventureJournalStartQuest : ClientPacket
|
||||
{
|
||||
public AdventureJournalStartQuest(WorldPacket packet) : base(packet) { }
|
||||
|
||||
public override void Read()
|
||||
{
|
||||
QuestID = _worldPacket.ReadUInt32();
|
||||
}
|
||||
|
||||
public uint QuestID;
|
||||
}
|
||||
|
||||
class AdventureJournalUpdateSuggestions : ClientPacket
|
||||
{
|
||||
public AdventureJournalUpdateSuggestions(WorldPacket packet) : base(packet) { }
|
||||
|
||||
public override void Read()
|
||||
{
|
||||
OnLevelUp = _worldPacket.HasBit();
|
||||
}
|
||||
|
||||
public bool OnLevelUp;
|
||||
}
|
||||
|
||||
class AdventureJournalDataResponse : ServerPacket
|
||||
{
|
||||
public AdventureJournalDataResponse() : base(ServerOpcodes.AdventureJournalDataResponse) { }
|
||||
|
||||
public override void Write()
|
||||
{
|
||||
_worldPacket.WriteBit(OnLevelUp);
|
||||
_worldPacket.FlushBits();
|
||||
_worldPacket.WriteInt32(AdventureJournalDatas.Count);
|
||||
foreach (var adventureJournal in AdventureJournalDatas)
|
||||
{
|
||||
_worldPacket.WriteInt32(adventureJournal.AdventureJournalID);
|
||||
_worldPacket.WriteInt32(adventureJournal.Priority);
|
||||
}
|
||||
}
|
||||
|
||||
public bool OnLevelUp;
|
||||
public List<AdventureJournalEntry> AdventureJournalDatas = new List<AdventureJournalEntry>();
|
||||
}
|
||||
|
||||
struct AdventureJournalEntry
|
||||
{
|
||||
public int AdventureJournalID;
|
||||
public int Priority;
|
||||
}
|
||||
}
|
||||
@@ -1320,62 +1320,6 @@ namespace Game.Networking.Packets
|
||||
|
||||
public ObjectGuid SourceGuid;
|
||||
}
|
||||
|
||||
class AdventureJournalOpenQuest : ClientPacket
|
||||
{
|
||||
public AdventureJournalOpenQuest(WorldPacket packet) : base(packet) { }
|
||||
|
||||
public override void Read()
|
||||
{
|
||||
AdventureJournalID = _worldPacket.ReadUInt32();
|
||||
}
|
||||
|
||||
public uint AdventureJournalID;
|
||||
}
|
||||
|
||||
class AdventureJournalStartQuest : ClientPacket
|
||||
{
|
||||
public AdventureJournalStartQuest(WorldPacket packet) : base(packet) { }
|
||||
|
||||
public override void Read()
|
||||
{
|
||||
QuestID = _worldPacket.ReadUInt32();
|
||||
}
|
||||
|
||||
public uint QuestID;
|
||||
}
|
||||
|
||||
class AdventureJournalUpdateSuggestions : ClientPacket
|
||||
{
|
||||
public AdventureJournalUpdateSuggestions(WorldPacket packet) : base(packet) { }
|
||||
|
||||
public override void Read()
|
||||
{
|
||||
OnLevelUp = _worldPacket.HasBit();
|
||||
}
|
||||
|
||||
public bool OnLevelUp;
|
||||
}
|
||||
|
||||
class AdventureJournalDataResponse : ServerPacket
|
||||
{
|
||||
public AdventureJournalDataResponse() : base(ServerOpcodes.AdventureJournalDataResponse) { }
|
||||
|
||||
public override void Write()
|
||||
{
|
||||
_worldPacket.WriteBit(OnLevelUp);
|
||||
_worldPacket.FlushBits();
|
||||
_worldPacket.WriteInt32(AdventureJournalDatas.Count);
|
||||
foreach (var adventureJournal in AdventureJournalDatas)
|
||||
{
|
||||
_worldPacket.WriteInt32(adventureJournal.AdventureJournalID);
|
||||
_worldPacket.WriteInt32(adventureJournal.Priority);
|
||||
}
|
||||
}
|
||||
|
||||
public bool OnLevelUp;
|
||||
public List<AdventureJournalData> AdventureJournalDatas = new List<AdventureJournalData>();
|
||||
}
|
||||
|
||||
//Structs
|
||||
struct PhaseShiftDataPhase
|
||||
@@ -1411,10 +1355,4 @@ namespace Game.Networking.Packets
|
||||
public List<PhaseShiftDataPhase> Phases = new List<PhaseShiftDataPhase>();
|
||||
public ObjectGuid PersonalGUID;
|
||||
}
|
||||
|
||||
struct AdventureJournalData
|
||||
{
|
||||
public int AdventureJournalID;
|
||||
public int Priority;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
--
|
||||
-- Table structure for table `adventure_journal`
|
||||
--
|
||||
DROP TABLE IF EXISTS `adventure_journal`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `adventure_journal` (
|
||||
`ID` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`Name` text,
|
||||
`Description` text,
|
||||
`ButtonText` text,
|
||||
`RewardDescription` text,
|
||||
`ContinueDescription` text,
|
||||
`Type` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||
`PlayerConditionID` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`Flags` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||
`ButtonActionType` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||
`TextureFileDataID` int(11) NOT NULL DEFAULT '0',
|
||||
`LfgDungeonID` smallint(5) unsigned NOT NULL DEFAULT '0',
|
||||
`QuestID` int(11) NOT NULL DEFAULT '0',
|
||||
`BattleMasterListID` smallint(5) unsigned NOT NULL DEFAULT '0',
|
||||
`PriorityMin` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||
`PriorityMax` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||
`ItemID` int(11) NOT NULL DEFAULT '0',
|
||||
`ItemQuantity` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`CurrencyType` smallint(5) unsigned NOT NULL DEFAULT '0',
|
||||
`CurrencyQuantity` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`UiMapID` smallint(5) unsigned NOT NULL DEFAULT '0',
|
||||
`BonusPlayerConditionID1` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`BonusPlayerConditionID2` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`BonusValue1` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||
`BonusValue2` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||
`VerifiedBuild` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`ID`,`VerifiedBuild`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `adventure_journal_locale`
|
||||
--
|
||||
DROP TABLE IF EXISTS `adventure_journal_locale`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `adventure_journal_locale` (
|
||||
`ID` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`locale` varchar(4) NOT NULL,
|
||||
`Name_lang` text,
|
||||
`Description_lang` text,
|
||||
`ButtonText_lang` text,
|
||||
`RewardDescription_lang` text,
|
||||
`ContinueDescription_lang` text,
|
||||
`VerifiedBuild` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`ID`,`locale`,`VerifiedBuild`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
/*!50500 PARTITION BY LIST COLUMNS(locale)
|
||||
(PARTITION deDE VALUES IN ('deDE') ENGINE = InnoDB,
|
||||
PARTITION esES VALUES IN ('esES') ENGINE = InnoDB,
|
||||
PARTITION esMX VALUES IN ('esMX') ENGINE = InnoDB,
|
||||
PARTITION frFR VALUES IN ('frFR') ENGINE = InnoDB,
|
||||
PARTITION itIT VALUES IN ('itIT') ENGINE = InnoDB,
|
||||
PARTITION koKR VALUES IN ('koKR') ENGINE = InnoDB,
|
||||
PARTITION ptBR VALUES IN ('ptBR') ENGINE = InnoDB,
|
||||
PARTITION ruRU VALUES IN ('ruRU') ENGINE = InnoDB,
|
||||
PARTITION zhCN VALUES IN ('zhCN') ENGINE = InnoDB,
|
||||
PARTITION zhTW VALUES IN ('zhTW') ENGINE = InnoDB) */;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
Reference in New Issue
Block a user