From f6203e98ee15c9289af0512eb97798b5024d4f08 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 15 Dec 2020 13:20:10 -0500 Subject: [PATCH] Fix build and loading crashes Port From (https://github.com/TrinityCore/TrinityCore/commit/) --- README.md | 4 ++-- Source/Game/Collision/Maps/MapTree.cs | 2 +- Source/Game/DataStorage/CliDB.cs | 2 +- Source/Game/DataStorage/DB2Manager.cs | 10 ++++++---- Source/Game/Entities/Object/Update/UpdateFields.cs | 7 ++++++- Source/Game/Entities/Player/Player.DB.cs | 2 +- Source/Game/Globals/ObjectManager.cs | 4 ++-- Source/Game/Handlers/CharacterHandler.cs | 8 +++----- Source/Game/Networking/Packets/SpellPackets.cs | 2 +- Source/Game/Networking/WorldSocket.cs | 4 ++-- Source/Game/Scenarios/ScenarioManager.cs | 2 +- 11 files changed, 26 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 2a80363dc..0e175d715 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ CypherCore is an open source server project for World of Warcraft written in C#. -The current support game version is: 8.3.7.35662 +The current support game version is: 9.0.2.36839 ### Prerequisites * Visual Studio 2019 with netcore 3.1 [Download](https://www.visualstudio.com/downloads/) @@ -19,7 +19,7 @@ The current support game version is: 8.3.7.35662 * Extract the sql files into the core sql folder (ex: C:\CypherCore\sql) ### Playing -* Must use Arctium WoW Client Launcher [Download](https://arctium.io) (World of Warcraft -> Client Launchers) +* Must use Arctium WoW Client Launcher [Download](https://arctium.io) (Downloads -> World of Warcraft -> Client Launcher -> Custom Server) ### Support / General Info * Check out our channel on Arctium Discord [Here](https://discord.gg/Hac3qn6) diff --git a/Source/Game/Collision/Maps/MapTree.cs b/Source/Game/Collision/Maps/MapTree.cs index af228b937..746ecbb0e 100644 --- a/Source/Game/Collision/Maps/MapTree.cs +++ b/Source/Game/Collision/Maps/MapTree.cs @@ -261,7 +261,7 @@ namespace Game.Collision parentMapId = vm.GetParentMapId((uint)parentMapId); } - return null; + return result; } public static LoadResult CanLoadMap(string vmapPath, uint mapID, uint tileX, uint tileY, VMapManager vm) diff --git a/Source/Game/DataStorage/CliDB.cs b/Source/Game/DataStorage/CliDB.cs index 28cfa29f3..4ca0a1eca 100644 --- a/Source/Game/DataStorage/CliDB.cs +++ b/Source/Game/DataStorage/CliDB.cs @@ -51,7 +51,7 @@ namespace Game.DataStorage } AchievementStorage = ReadDB2("Achievement.db2", HotfixStatements.SEL_ACHIEVEMENT, HotfixStatements.SEL_ACHIEVEMENT_LOCALE); - //AnimationDataStorage = ReadDB2("AnimationData.db2", HotfixStatements.SEL_ANIMATION_DATA); + AnimationDataStorage = ReadDB2("AnimationData.db2", HotfixStatements.SEL_ANIMATION_DATA); AnimKitStorage = ReadDB2("AnimKit.db2", HotfixStatements.SEL_ANIM_KIT); AreaGroupMemberStorage = ReadDB2("AreaGroupMember.db2", HotfixStatements.SEL_AREA_GROUP_MEMBER); AreaTableStorage = ReadDB2("AreaTable.db2", HotfixStatements.SEL_AREA_TABLE, HotfixStatements.SEL_AREA_TABLE_LOCALE); diff --git a/Source/Game/DataStorage/DB2Manager.cs b/Source/Game/DataStorage/DB2Manager.cs index 40a1dcdf2..a4cfbb587 100644 --- a/Source/Game/DataStorage/DB2Manager.cs +++ b/Source/Game/DataStorage/DB2Manager.cs @@ -194,14 +194,16 @@ namespace Game.DataStorage // link shapeshift displays to race/gender/form foreach (var shapeshiftOptionsForModel in shapeshiftFormByModel.LookupByKey(model.Id)) { - ShapeshiftFormModelData data = _chrCustomizationChoicesForShapeshifts[Tuple.Create((byte)raceModel.ChrRacesID, (byte)model.Sex, shapeshiftOptionsForModel.Item2)]; + ShapeshiftFormModelData data = new ShapeshiftFormModelData(); data.OptionID = shapeshiftOptionsForModel.Item2; data.Choices = _chrCustomizationChoicesByOption.LookupByKey(shapeshiftOptionsForModel.Item2); if (!data.Choices.Empty()) { for (int i = 0; i < data.Choices.Count; ++i) - data.Displays[i] = displayInfoByCustomizationChoice.LookupByKey(data.Choices[i].Id); + data.Displays.Add(displayInfoByCustomizationChoice.LookupByKey(data.Choices[i].Id)); } + + _chrCustomizationChoicesForShapeshifts[Tuple.Create((byte)raceModel.ChrRacesID, (byte)model.Sex, shapeshiftOptionsForModel.Item2)] = data; } } } @@ -905,7 +907,7 @@ namespace Game.DataStorage public List GetCustomiztionOptions(Race race, Gender gender) { - return _chrCustomizationOptionsByRaceAndGender.LookupByKey(Tuple.Create(race, gender)); + return _chrCustomizationOptionsByRaceAndGender.LookupByKey(Tuple.Create((byte)race, (byte)gender)); } public MultiMap GetRequiredCustomizationChoices(uint chrCustomizationReqId) @@ -915,7 +917,7 @@ namespace Game.DataStorage public ChrModelRecord GetChrModel(Race race, Gender gender) { - return _chrModelsByRaceAndGender.LookupByKey(Tuple.Create(race, gender)); + return _chrModelsByRaceAndGender.LookupByKey(Tuple.Create((byte)race, (byte)gender)); } public string GetChrRaceName(Race race, Locale locale = Locale.enUS) diff --git a/Source/Game/Entities/Object/Update/UpdateFields.cs b/Source/Game/Entities/Object/Update/UpdateFields.cs index b7e0cda0c..398c1b167 100644 --- a/Source/Game/Entities/Object/Update/UpdateFields.cs +++ b/Source/Game/Entities/Object/Update/UpdateFields.cs @@ -2276,7 +2276,7 @@ namespace Game.Entities } } - public struct ChrCustomizationChoice + public struct ChrCustomizationChoice : IComparable { public uint ChrCustomizationOptionID; public uint ChrCustomizationChoiceID; @@ -2298,6 +2298,11 @@ namespace Game.Entities data.WriteUInt32(ChrCustomizationOptionID); data.WriteUInt32(ChrCustomizationChoiceID); } + + public int CompareTo(ChrCustomizationChoice other) + { + return ChrCustomizationOptionID.CompareTo(other.ChrCustomizationOptionID); + } } public class QuestLog : BaseUpdateData diff --git a/Source/Game/Entities/Player/Player.DB.cs b/Source/Game/Entities/Player/Player.DB.cs index b04df9f6e..77f5d0c91 100644 --- a/Source/Game/Entities/Player/Player.DB.cs +++ b/Source/Game/Entities/Player/Player.DB.cs @@ -2506,7 +2506,7 @@ namespace Game.Entities uint health = result.Read(fieldIndex++); uint[] powers = new uint[(int)PowerType.MaxPerClass]; - for (var i = 0; fieldIndex < powers.Length; ++i) + for (var i = 0; i < powers.Length; ++i) powers[i] = result.Read(fieldIndex++); uint instance_id = result.Read(fieldIndex++); diff --git a/Source/Game/Globals/ObjectManager.cs b/Source/Game/Globals/ObjectManager.cs index 553df65c6..efb21d636 100644 --- a/Source/Game/Globals/ObjectManager.cs +++ b/Source/Game/Globals/ObjectManager.cs @@ -5491,13 +5491,13 @@ namespace Game float positionZ = result.Read(6); float orientation = result.Read(7); - if (CliDB.ChrRacesStorage.ContainsKey(currentrace)) + if (!CliDB.ChrRacesStorage.ContainsKey(currentrace)) { Log.outError(LogFilter.Sql, $"Wrong race {currentrace} in `playercreateinfo` table, ignoring."); continue; } - if (CliDB.ChrClassesStorage.ContainsKey(currentclass)) + if (!CliDB.ChrClassesStorage.ContainsKey(currentclass)) { Log.outError(LogFilter.Sql, $"Wrong class {currentclass} in `playercreateinfo` table, ignoring."); continue; diff --git a/Source/Game/Handlers/CharacterHandler.cs b/Source/Game/Handlers/CharacterHandler.cs index 0642cf62d..f88d092e5 100644 --- a/Source/Game/Handlers/CharacterHandler.cs +++ b/Source/Game/Handlers/CharacterHandler.cs @@ -68,12 +68,10 @@ namespace Game { do { - var customizationsForCharacter = customizations[customizationsResult.Read(0)]; - ChrCustomizationChoice choice = new ChrCustomizationChoice(); choice.ChrCustomizationOptionID = customizationsResult.Read(1); choice.ChrCustomizationChoiceID = customizationsResult.Read(2); - customizationsForCharacter.Add(choice); + customizations.Add(customizationsResult.Read(0), choice); } while (customizationsResult.NextRow()); } @@ -87,7 +85,7 @@ namespace Game var customizationsForChar = customizations.LookupByKey(charInfo.Guid.GetCounter()); if (!customizationsForChar.Empty()) - charInfo.Customizations = (Array)customizationsForChar.ToList(); + charInfo.Customizations = new Array(customizationsForChar.ToArray()); Log.outInfo(LogFilter.Network, "Loading Character {0} from account {1}.", charInfo.Guid.ToString(), GetAccountId()); @@ -194,7 +192,7 @@ namespace Game if (checkRequiredDependentChoices) { var requiredChoices = Global.DB2Mgr.GetRequiredCustomizationChoices(req.Id); - if (!requiredChoices.Empty()) + if (requiredChoices != null) { foreach (var key in requiredChoices.Keys) { diff --git a/Source/Game/Networking/Packets/SpellPackets.cs b/Source/Game/Networking/Packets/SpellPackets.cs index 9a63d293f..f40f322f8 100644 --- a/Source/Game/Networking/Packets/SpellPackets.cs +++ b/Source/Game/Networking/Packets/SpellPackets.cs @@ -1784,7 +1784,7 @@ namespace Game.Networking.Packets data.WritePackedGuid(OriginalCastID); data.WriteInt32(SpellID); - Visual.Read(data); + Visual.Write(data); data.WriteUInt32((uint)CastFlags); data.WriteUInt32((uint)CastFlagsEx); diff --git a/Source/Game/Networking/WorldSocket.cs b/Source/Game/Networking/WorldSocket.cs index 473b02c43..bfdb32454 100644 --- a/Source/Game/Networking/WorldSocket.cs +++ b/Source/Game/Networking/WorldSocket.cs @@ -196,7 +196,7 @@ namespace Game.Networking if (_headerBuffer.GetRemainingSpace() > 0) { // need to receive the header - int readHeaderSize = Math.Min(args.BytesTransferred, _headerBuffer.GetRemainingSpace()); + int readHeaderSize = Math.Min(args.BytesTransferred - currentReadIndex, _headerBuffer.GetRemainingSpace()); _headerBuffer.Write(args.Buffer, currentReadIndex, readHeaderSize); currentReadIndex += readHeaderSize; @@ -215,7 +215,7 @@ namespace Game.Networking if (_packetBuffer.GetRemainingSpace() > 0) { // need more data in the payload - int readDataSize = Math.Min(args.BytesTransferred, _packetBuffer.GetRemainingSpace()); + int readDataSize = Math.Min(args.BytesTransferred - currentReadIndex, _packetBuffer.GetRemainingSpace()); _packetBuffer.Write(args.Buffer, currentReadIndex, readDataSize); currentReadIndex += readDataSize; diff --git a/Source/Game/Scenarios/ScenarioManager.cs b/Source/Game/Scenarios/ScenarioManager.cs index 075ff1505..2071db4b1 100644 --- a/Source/Game/Scenarios/ScenarioManager.cs +++ b/Source/Game/Scenarios/ScenarioManager.cs @@ -214,7 +214,7 @@ namespace Game.Scenarios } while (result.NextRow()); - Log.outInfo(LogFilter.ServerLoading, "Loaded {count} scenario POI definitions in {Time.GetMSTimeDiffToNow(oldMSTime)} ms"); + Log.outInfo(LogFilter.ServerLoading, $"Loaded {count} scenario POI definitions in {Time.GetMSTimeDiffToNow(oldMSTime)} ms"); } public List GetScenarioPOIs(uint CriteriaTreeID)