From 32330d557c2e8f8fe76c4839be685999ecb6b54d Mon Sep 17 00:00:00 2001 From: Yogurt Date: Sat, 8 Jun 2019 21:11:51 -0700 Subject: [PATCH 1/2] Small command fixes fix "You learn [command]." message not printing the name of the command and enable message. Make database save the short version of command id in hotbar table --- FFXIVClassic Map Server/Database.cs | 6 +++--- FFXIVClassic Map Server/WorldManager.cs | 8 ++++---- .../actors/chara/player/Player.cs | 18 ++++++++---------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/FFXIVClassic Map Server/Database.cs b/FFXIVClassic Map Server/Database.cs index a9577c3c..aebcfede 100644 --- a/FFXIVClassic Map Server/Database.cs +++ b/FFXIVClassic Map Server/Database.cs @@ -1247,7 +1247,7 @@ namespace FFXIVClassic_Map_Server } public static void EquipAbility(Player player, byte classId, ushort hotbarSlot, uint commandId, uint recastTime) { - commandId ^= 0xA0F00000; + commandId &= 0xFFFF; if (commandId > 0) { using (MySqlConnection conn = new MySqlConnection( @@ -2374,7 +2374,7 @@ namespace FFXIVClassic_Map_Server } } - public static void LoadGlobalBattleCommandList(Dictionary battleCommandDict, Dictionary, List> battleCommandIdByLevel) + public static void LoadGlobalBattleCommandList(Dictionary battleCommandDict, Dictionary, List> battleCommandIdByLevel) { using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD))) { @@ -2469,7 +2469,7 @@ namespace FFXIVClassic_Map_Server } else { - List list = new List() { id }; + List list = new List() { id }; battleCommandIdByLevel.Add(tuple, list); } count++; diff --git a/FFXIVClassic Map Server/WorldManager.cs b/FFXIVClassic Map Server/WorldManager.cs index 65b53d09..ba4ca7a0 100644 --- a/FFXIVClassic Map Server/WorldManager.cs +++ b/FFXIVClassic Map Server/WorldManager.cs @@ -33,7 +33,7 @@ namespace FFXIVClassic_Map_Server private Dictionary currentPlayerParties = new Dictionary(); //GroupId, Party object private Dictionary statusEffectList = new Dictionary(); private Dictionary battleCommandList = new Dictionary(); - private Dictionary, List> battleCommandIdByLevel = new Dictionary, List>();//Holds battle command ids keyed by class id and level (in that order) + private Dictionary, List> battleCommandIdByLevel = new Dictionary, List>();//Holds battle command ids keyed by class id and level (in that order) private Dictionary battleTraitList = new Dictionary(); private Dictionary> battleTraitIdsForClass = new Dictionary>(); private Dictionary battleNpcGenusMods = new Dictionary(); @@ -1967,10 +1967,10 @@ namespace FFXIVClassic_Map_Server return battleCommandList.TryGetValue((ushort)id, out battleCommand) ? battleCommand.Clone() : null; } - public List GetBattleCommandIdByLevel(byte classId, short level) + public List GetBattleCommandIdByLevel(byte classId, short level) { - List ids; - return battleCommandIdByLevel.TryGetValue(Tuple.Create(classId, level), out ids) ? ids : new List(); + List ids; + return battleCommandIdByLevel.TryGetValue(Tuple.Create(classId, level), out ids) ? ids : new List(); } public BattleTrait GetBattleTrait(ushort id) diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index 5c94d1d8..3eba884d 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -2060,7 +2060,7 @@ namespace FFXIVClassic_Map_Server.Actors public void EquipAbility(byte classId, uint commandId, ushort hotbarSlot, bool printMessage = true) { var ability = Server.GetWorldManager().GetBattleCommand(commandId); - uint trueCommandId = 0xA0F00000 + commandId; + uint trueCommandId = 0xA0F00000 | commandId; ushort lowHotbarSlot = (ushort)(hotbarSlot - charaWork.commandBorder); ushort maxRecastTime = (ushort)(ability != null ? ability.maxRecastTimeSeconds : 5); uint recastEnd = Utils.UnixTimeStampUTC() + maxRecastTime; @@ -2441,7 +2441,7 @@ namespace FFXIVClassic_Map_Server.Actors while (exp >= diff && GetLevel() < charaWork.battleSave.skillLevelCap[classId]) { //Level up - LevelUp(classId); + LevelUp(classId, actionList); leveled = true; //Reduce exp based on how much exp is needed to level exp -= diff; @@ -2459,8 +2459,6 @@ namespace FFXIVClassic_Map_Server.Actors expPropertyPacket2.AddProperty("charaWork.parameterSave.state_mainSkillLevel"); QueuePackets(expPropertyPacket2.Done()); QueuePackets(expPropertyPacket3.Done()); - //play levelup animation (do this outside LevelUp so that it only plays once if multiple levels are earned - //also i dunno how to do this Database.SetLevel(this, classId, GetLevel()); Database.SavePlayerCurrentClass(this); @@ -2486,13 +2484,13 @@ namespace FFXIVClassic_Map_Server.Actors charaWork.battleSave.skillLevel[classId - 1]++; charaWork.parameterSave.state_mainSkillLevel++; - //33909: You gain level [level] + //33909: You attain level [level]. if (actionList != null) - actionList.Add(new CommandResult(actorId, 33909, 0, (ushort) charaWork.battleSave.skillLevel[classId - 1])); + actionList.Add(new CommandResult(actorId, 33909, 0, (ushort)charaWork.battleSave.skillLevel[classId - 1])); //If there's any abilites that unlocks at this level, equip them. - List commandIds = Server.GetWorldManager().GetBattleCommandIdByLevel(classId, GetLevel()); - foreach(uint commandId in commandIds) + List commandIds = Server.GetWorldManager().GetBattleCommandIdByLevel(classId, GetLevel()); + foreach (ushort commandId in commandIds) { EquipAbilityInFirstOpenSlot(classId, commandId, false); byte jobId = ConvertClassIdToJobId(classId); @@ -2502,8 +2500,8 @@ namespace FFXIVClassic_Map_Server.Actors //33926: You learn [command]. if (actionList != null) { - if(classId == GetCurrentClassOrJob() || jobId == GetCurrentClassOrJob()) - actionList.Add(new CommandResult(actorId, 33926, commandId)); + if (classId == GetCurrentClassOrJob() || jobId == GetCurrentClassOrJob()) + actionList.Add(new CommandResult(actorId, 33926, 0, commandId)); } } } From a996797bebcf435359bd70ea6307653750f33173 Mon Sep 17 00:00:00 2001 From: Yogurt Date: Sat, 8 Jun 2019 21:44:06 -0700 Subject: [PATCH 2/2] Level 0 class fixes Add level 1 abilities when switching to level 0 class Fix client error when switching to level 0 class --- .../actors/chara/player/Player.cs | 63 ++++++++++--------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index 3eba884d..150057d0 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -991,11 +991,7 @@ namespace FFXIVClassic_Map_Server.Actors } public void PrepareClassChange(byte classId) - { - //If new class, init abilties and level - if (charaWork.battleSave.skillLevel[classId - 1] <= 0) - UpdateClassLevel(classId, 1); - + { SendCharaExpInfo(); } @@ -1037,6 +1033,13 @@ namespace FFXIVClassic_Map_Server.Actors charaWork.commandCategory[i] = 0; } + //If new class, init abilties and level + if (charaWork.battleSave.skillLevel[classId - 1] <= 0) + { + UpdateClassLevel(classId, 1); + EquipAbilitiesAtLevel(classId, 1); + } + ActorPropertyPacketUtil propertyBuilder = new ActorPropertyPacketUtil("charaWork/stateForAll", this); propertyBuilder.AddProperty("charaWork.parameterSave.state_mainSkill[0]"); @@ -1071,7 +1074,7 @@ namespace FFXIVClassic_Map_Server.Actors { Database.PlayerCharacterUpdateClassLevel(this, classId, level); charaWork.battleSave.skillLevel[classId - 1] = level; - ActorPropertyPacketUtil propertyBuilder = new ActorPropertyPacketUtil("charaWork/exp", this); + ActorPropertyPacketUtil propertyBuilder = new ActorPropertyPacketUtil("charaWork/stateForAll", this); propertyBuilder.AddProperty(String.Format("charaWork.battleSave.skillLevel[{0}]", classId-1)); List packets = propertyBuilder.Done(); QueuePackets(packets); @@ -2453,12 +2456,10 @@ namespace FFXIVClassic_Map_Server.Actors //Set exp to current class to 0 so that exp is added correctly charaWork.battleSave.skillPoint[classId - 1] = 0; //send new level - ActorPropertyPacketUtil expPropertyPacket2 = new ActorPropertyPacketUtil("charaWork/exp", this); - ActorPropertyPacketUtil expPropertyPacket3 = new ActorPropertyPacketUtil("charaWork/stateForAll", this); - expPropertyPacket2.AddProperty(String.Format("charaWork.battleSave.skillLevel[{0}]", classId - 1)); - expPropertyPacket2.AddProperty("charaWork.parameterSave.state_mainSkillLevel"); - QueuePackets(expPropertyPacket2.Done()); - QueuePackets(expPropertyPacket3.Done()); + ActorPropertyPacketUtil levelPropertyPacket = new ActorPropertyPacketUtil("charaWork/stateForAll", this); + levelPropertyPacket.AddProperty(String.Format("charaWork.battleSave.skillLevel[{0}]", classId - 1)); + levelPropertyPacket.AddProperty("charaWork.parameterSave.state_mainSkillLevel"); + QueuePackets(levelPropertyPacket.Done()); Database.SetLevel(this, classId, GetLevel()); Database.SavePlayerCurrentClass(this); @@ -2475,6 +2476,27 @@ namespace FFXIVClassic_Map_Server.Actors return actionList; } + //Equips any abilities for the given classId at the given level. If actionList is not null, adds a "You learn Command" message + private void EquipAbilitiesAtLevel(byte classId, short level, List actionList = null) + { + //If there's any abilites that unlocks at this level, equip them. + List commandIds = Server.GetWorldManager().GetBattleCommandIdByLevel(classId, GetLevel()); + foreach (ushort commandId in commandIds) + { + EquipAbilityInFirstOpenSlot(classId, commandId, false); + byte jobId = ConvertClassIdToJobId(classId); + if (jobId != classId) + EquipAbilityInFirstOpenSlot(jobId, commandId, false); + + //33926: You learn [command]. + if (actionList != null) + { + if (classId == GetCurrentClassOrJob() || jobId == GetCurrentClassOrJob()) + actionList.Add(new CommandResult(actorId, 33926, 0, commandId)); + } + } + } + //Increaess level of current class and equips new abilities earned at that level public void LevelUp(byte classId, List actionList = null) { @@ -2488,22 +2510,7 @@ namespace FFXIVClassic_Map_Server.Actors if (actionList != null) actionList.Add(new CommandResult(actorId, 33909, 0, (ushort)charaWork.battleSave.skillLevel[classId - 1])); - //If there's any abilites that unlocks at this level, equip them. - List commandIds = Server.GetWorldManager().GetBattleCommandIdByLevel(classId, GetLevel()); - foreach (ushort commandId in commandIds) - { - EquipAbilityInFirstOpenSlot(classId, commandId, false); - byte jobId = ConvertClassIdToJobId(classId); - if (jobId != classId) - EquipAbilityInFirstOpenSlot(jobId, commandId, false); - - //33926: You learn [command]. - if (actionList != null) - { - if (classId == GetCurrentClassOrJob() || jobId == GetCurrentClassOrJob()) - actionList.Add(new CommandResult(actorId, 33926, 0, commandId)); - } - } + EquipAbilitiesAtLevel(classId, GetLevel(), actionList); } }