From 7a3a857589b13a14c06c5a699c09d5ed6a68d6b9 Mon Sep 17 00:00:00 2001 From: danilo Date: Wed, 26 Feb 2020 01:24:29 -0300 Subject: [PATCH 01/15] - Adding files related to PluginZero solution files are --- Source/PluginZero/Plugin.cs | 402 +++++++++++++++++++ Source/PluginZero/PluginZero.csproj | 90 +++++ Source/PluginZero/Properties/AssemblyInfo.cs | 36 ++ 3 files changed, 528 insertions(+) create mode 100644 Source/PluginZero/Plugin.cs create mode 100644 Source/PluginZero/PluginZero.csproj create mode 100644 Source/PluginZero/Properties/AssemblyInfo.cs diff --git a/Source/PluginZero/Plugin.cs b/Source/PluginZero/Plugin.cs new file mode 100644 index 0000000..6070369 --- /dev/null +++ b/Source/PluginZero/Plugin.cs @@ -0,0 +1,402 @@ +#region Licence +/** +* Copyright © 2014-2019 OTTools +* +* 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 2 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, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +#endregion + +#region Using Statements +using ItemEditor; +using OTLib.Server.Items; +using PluginInterface; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +#endregion + +namespace PluginZero +{ + + internal enum ItemFlag : byte + { + Ground = 0x00, + GroundBorder = 0x01, + OnBottom = 0x02, + OnTop = 0x03, + Container = 0x04, + Stackable = 0x05, + ForceUse = 0x06, + MultiUse = 0x07, + Writable = 0x08, + WritableOnce = 0x09, + FluidContainer = 0x0A, + Fluid = 0x0B, + IsUnpassable = 0x0C, + IsUnmoveable = 0x0D, + BlockMissiles = 0x0E, + BlockPathfinder = 0x0F, + Pickupable = 0x10, + Hangable = 0x11, + IsHorizontal = 0x12, + IsVertical = 0x13, + Rotatable = 0x14, + HasLight = 0x15, + DontHide = 0x16, + FloorChange = 0x17, + HasOffset = 0x18, + HasElevation = 0x19, + Lying = 0x1A, + AnimateAlways = 0x1B, + Minimap = 0x1C, + LensHelp = 0x1D, + FullGround = 0x1E, + + LastFlag = 0xFF + } + + public class Plugin : IPlugin + { + #region Private Properties + + private Dictionary sprites; + private ushort itemCount; + + #endregion + + #region Constructor + + public Plugin() + { + this.Settings = new Settings(); + this.sprites = new Dictionary(); + this.Items = new ClientItems(); + this.SupportedClients = new List(); + } + + #endregion + + #region Public Properties + + // internal implementation + public Settings Settings { get; private set; } + + // IPlugin implementation + public IPluginHost Host { get; set; } + + public List SupportedClients { get; private set; } + + public ClientItems Items { get; set; } + + public ushort MinItemId { get { return 100; } } + + public ushort MaxItemId { get { return this.itemCount; } } + + public bool Loaded { get; private set; } + + #endregion + + #region Public Methods + + public bool LoadClient(SupportedClient client, bool extended, bool frameDurations, bool transparency, string datFullPath, string sprFullPath) + { + if (this.Loaded) + { + this.Dispose(); + } + + if (!LoadDat(datFullPath, client, extended, frameDurations)) + { + Trace.WriteLine("Failed to load dat."); + return false; + } + + if (!LoadSprites(sprFullPath, client, extended, transparency)) + { + Trace.WriteLine("Failed to load spr."); + return false; + } + + this.Loaded = true; + return true; + } + + public void Initialize() + { + this.Settings.Load("PluginZero.xml"); + this.SupportedClients = Settings.GetSupportedClientList(); + } + + public SupportedClient GetClientBySignatures(uint datSignature, uint sprSignature) + { + foreach (SupportedClient client in this.SupportedClients) + { + if (client.DatSignature == datSignature && client.SprSignature == sprSignature) + { + return client; + } + } + + return null; + } + + public ClientItem GetClientItem(ushort id) + { + if (this.Loaded && id >= 100 && id <= this.itemCount) + { + return this.Items[id]; + } + + return null; + } + + public void Dispose() + { + if (this.Loaded) + { + this.sprites.Clear(); + this.Items.Clear(); + this.itemCount = 0; + this.Loaded = false; + } + } + + public bool LoadSprites(string filename, SupportedClient client, bool extended, bool transparency) + { + return Sprite.LoadSprites(filename, ref sprites, client, extended, transparency); + } + + public bool LoadDat(string filename, SupportedClient client, bool extended, bool frameDurations) + { + using (FileStream fileStream = new FileStream(filename, FileMode.Open)) + { + BinaryReader reader = new BinaryReader(fileStream); + uint datSignature = reader.ReadUInt32(); + if (client.DatSignature != datSignature) + { + string message = "PluginZero: Bad dat signature. Expected signature is {0:X} and loaded signature is {1:X}."; + Trace.WriteLine(String.Format(message, client.DatSignature, datSignature)); + return false; + } + + // get max id + this.itemCount = reader.ReadUInt16(); + reader.ReadUInt16(); // skipping outfits count + reader.ReadUInt16(); // skipping effects count + reader.ReadUInt16(); // skipping missiles count + + ushort id = 100; + while (id <= this.itemCount) + { + ClientItem item = new ClientItem(); + item.ID = id; + this.Items[id] = item; + + // read the options until we find 0xff + ItemFlag flag; + do + { + flag = (ItemFlag)reader.ReadByte(); + + switch (flag) + { + case ItemFlag.Ground: + item.GroundSpeed = reader.ReadUInt16(); + item.Type = ServerItemType.Ground; + break; + + + case ItemFlag.GroundBorder: + item.HasStackOrder = true; + item.StackOrder = TileStackOrder.Border; + break; + + case ItemFlag.OnBottom: + item.HasStackOrder = true; + item.StackOrder = TileStackOrder.Bottom; + break; + + + case ItemFlag.OnTop: + item.HasStackOrder = true; + item.StackOrder = TileStackOrder.Top; + break; + + case ItemFlag.Container: + item.Type = ServerItemType.Container; + break; + + case ItemFlag.Stackable: + item.Stackable = true; + break; + + case ItemFlag.ForceUse: + break; + + case ItemFlag.MultiUse: + item.MultiUse = true; + break; + + case ItemFlag.Writable: + item.Readable = true; + item.MaxReadWriteChars = reader.ReadUInt16(); + break; + + case ItemFlag.WritableOnce: + item.Readable = true; + item.MaxReadChars = reader.ReadUInt16(); + break; + + case ItemFlag.FluidContainer: + item.Type = ServerItemType.Fluid; + break; + + case ItemFlag.Fluid: + item.Type = ServerItemType.Splash; + break; + + case ItemFlag.IsUnpassable: + item.Unpassable = true; + break; + + case ItemFlag.IsUnmoveable: + item.Movable = false; + break; + + case ItemFlag.BlockMissiles: + item.BlockMissiles = true; + break; + + case ItemFlag.BlockPathfinder: + item.BlockPathfinder = true; + break; + + case ItemFlag.Pickupable: + item.Pickupable = true; + break; + + case ItemFlag.Hangable: + item.Hangable = true; + break; + + case ItemFlag.IsHorizontal: + item.HookEast = true; + break; + + case ItemFlag.IsVertical: + item.HookSouth = true; + break; + + case ItemFlag.Rotatable: + item.Rotatable = true; + break; + + case ItemFlag.HasLight: + item.LightLevel = reader.ReadUInt16(); + item.LightColor = reader.ReadUInt16(); + break; + + case ItemFlag.DontHide: + break; + + case ItemFlag.FloorChange: + break; + + case ItemFlag.HasOffset: + reader.ReadUInt16(); // OffsetX + reader.ReadUInt16(); // OffsetY + break; + + case ItemFlag.HasElevation: + item.HasElevation = true; + reader.ReadUInt16(); // Height + break; + + case ItemFlag.Lying: + break; + + case ItemFlag.AnimateAlways: + break; + + case ItemFlag.Minimap: + item.MinimapColor = reader.ReadUInt16(); + break; + + case ItemFlag.LensHelp: + ushort opt = reader.ReadUInt16(); + if (opt == 1112) + { + item.Readable = true; + } + break; + + case ItemFlag.FullGround: + break; + + case ItemFlag.LastFlag: + break; + + default: + Trace.WriteLine(String.Format("PluginZero: Error while parsing, unknown flag 0x{0:X} at id {1}.", flag, id)); + return false; + + } + + } while (flag != ItemFlag.LastFlag); + + + item.Width = reader.ReadByte(); + item.Height = reader.ReadByte(); + + if ((item.Width > 1) || (item.Height > 1)) + { + reader.BaseStream.Position++; + } + + item.Layers = reader.ReadByte(); + item.PatternX = reader.ReadByte(); + item.PatternY = reader.ReadByte(); + item.PatternZ = reader.ReadByte(); + item.Frames = reader.ReadByte(); + item.IsAnimation = item.Frames > 1; + item.NumSprites = (uint)item.Width * item.Height * item.Layers * item.PatternX * item.PatternY * item.PatternZ * item.Frames; + + // Read the sprite ids + for (UInt32 i = 0; i < item.NumSprites; ++i) + { + UInt16 spriteId = reader.ReadUInt16(); + Sprite sprite; + if (!sprites.TryGetValue(spriteId, out sprite)) + { + sprite = new Sprite(); + sprite.ID = spriteId; + sprites[spriteId] = sprite; + } + + item.SpriteList.Add(sprite); + } + + ++id; + + + } + } + + return true; + } + #endregion + } +} \ No newline at end of file diff --git a/Source/PluginZero/PluginZero.csproj b/Source/PluginZero/PluginZero.csproj new file mode 100644 index 0000000..90eb849 --- /dev/null +++ b/Source/PluginZero/PluginZero.csproj @@ -0,0 +1,90 @@ + + + + + Debug + AnyCPU + {A6AC9F32-8478-4543-8772-0AD590E94140} + Library + Properties + PluginZero + PluginZero + v4.8 + 512 + true + + + true + full + false + ..\bin\Debug\Plugins\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\bin\Release\Plugins\ + TRACE + prompt + 4 + + + true + ..\bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + + + ..\bin\x86\Release\Plugins\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + + + true + ..\bin\x64\Debug\Plugins\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + + + ..\bin\x64\Release\Plugins\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + + + + + + + + + + + + + + + + + + {cef21172-258c-4d0d-b024-ed7ef99612a2} + PluginInterface + + + + \ No newline at end of file diff --git a/Source/PluginZero/Properties/AssemblyInfo.cs b/Source/PluginZero/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f3dee6c --- /dev/null +++ b/Source/PluginZero/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PluginZero")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PluginZero")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a6ac9f32-8478-4543-8772-0ad590e94140")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] From 7a8bd5dd3d6c57c2631ab537c81dfedfdd7bff1f Mon Sep 17 00:00:00 2001 From: danilo Date: Wed, 26 Feb 2020 01:32:40 -0300 Subject: [PATCH 02/15] Changes related to OTBVersion on write/save - Changed OtbWriter.cs vi.BuildNumber now increments - OTB Major version are saved according to clients.xml in Remeres Map Editor. Version = 1 to version <=792, version = 2 to 800 to 811 and version = 3 on later versions -Few changes in csprojs related to framework version --- ItemEditor.sln | 21 +++++++++++++++++-- Source/ItemEditor.csproj | 2 +- Source/MainForm.cs | 17 +++++++++++++-- Source/PluginInterface/OTLib/OTB/OtbWriter.cs | 2 +- Source/PluginInterface/PluginInterface.csproj | 8 +++---- .../Properties/Resources.Designer.cs | 2 +- Source/PluginOne/Plugin.cs | 2 +- Source/PluginOne/PluginOne.csproj | 2 +- Source/PluginThree/PluginThree.csproj | 4 ++-- Source/PluginTwo/PluginTwo.csproj | 2 +- Source/Properties/Resources.Designer.cs | 2 +- Source/Properties/Settings.Designer.cs | 2 +- Source/app.config | 4 ++-- 13 files changed, 50 insertions(+), 20 deletions(-) diff --git a/ItemEditor.sln b/ItemEditor.sln index 12d7033..bcb4c8b 100644 --- a/ItemEditor.sln +++ b/ItemEditor.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.1022 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ItemEditor", "Source\ItemEditor.csproj", "{9A90BE1A-4A8F-4BFE-92E7-2C0EF64D850C}" ProjectSection(ProjectDependencies) = postProject @@ -16,6 +16,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginTwo", "Source\PluginT EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginInterface", "Source\PluginInterface\PluginInterface.csproj", "{CEF21172-258C-4D0D-B024-ED7EF99612A2}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginZero", "Source\PluginZero\PluginZero.csproj", "{A6AC9F32-8478-4543-8772-0AD590E94140}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -86,8 +88,23 @@ Global {CEF21172-258C-4D0D-B024-ED7EF99612A2}.Release|x64.Build.0 = Release|x64 {CEF21172-258C-4D0D-B024-ED7EF99612A2}.Release|x86.ActiveCfg = Release|x86 {CEF21172-258C-4D0D-B024-ED7EF99612A2}.Release|x86.Build.0 = Release|x86 + {A6AC9F32-8478-4543-8772-0AD590E94140}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A6AC9F32-8478-4543-8772-0AD590E94140}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A6AC9F32-8478-4543-8772-0AD590E94140}.Debug|x64.ActiveCfg = Debug|x64 + {A6AC9F32-8478-4543-8772-0AD590E94140}.Debug|x64.Build.0 = Debug|x64 + {A6AC9F32-8478-4543-8772-0AD590E94140}.Debug|x86.ActiveCfg = Debug|x86 + {A6AC9F32-8478-4543-8772-0AD590E94140}.Debug|x86.Build.0 = Debug|x86 + {A6AC9F32-8478-4543-8772-0AD590E94140}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A6AC9F32-8478-4543-8772-0AD590E94140}.Release|Any CPU.Build.0 = Release|Any CPU + {A6AC9F32-8478-4543-8772-0AD590E94140}.Release|x64.ActiveCfg = Release|x64 + {A6AC9F32-8478-4543-8772-0AD590E94140}.Release|x64.Build.0 = Release|x64 + {A6AC9F32-8478-4543-8772-0AD590E94140}.Release|x86.ActiveCfg = Release|x86 + {A6AC9F32-8478-4543-8772-0AD590E94140}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C55FD5F8-D261-4324-9C5B-B9C8E1256302} + EndGlobalSection EndGlobal diff --git a/Source/ItemEditor.csproj b/Source/ItemEditor.csproj index 6918f63..a487858 100644 --- a/Source/ItemEditor.csproj +++ b/Source/ItemEditor.csproj @@ -10,7 +10,7 @@ Properties ItemEditor ItemEditor - v4.5.2 + v4.8 512 diff --git a/Source/MainForm.cs b/Source/MainForm.cs index 841071b..e187284 100644 --- a/Source/MainForm.cs +++ b/Source/MainForm.cs @@ -350,7 +350,20 @@ public void CreateEmptyOTB(string filePath, SupportedClient client, bool isTempo item.ID = 100; ServerItemList items = new ServerItemList(); - items.MajorVersion = 3; + + if (client.Version >= 740 && client.Version <= 792) + { + items.MajorVersion = 1; + } + else if (client.Version >= 800 && client.Version <= 811) + { + items.MajorVersion = 2; + } + else + { + items.MajorVersion = 3; + } + items.MinorVersion = client.OtbVersion; items.BuildNumber = 1; items.ClientVersion = client.Version; @@ -856,7 +869,7 @@ private bool LoadClient(Plugin plugin, uint otbVersion) return false; } - Trace.WriteLine(string.Format("OTB version {0}.", otbVersion)); + Trace.WriteLine(string.Format("OTB version {0}. Tibia client version {1}", otbVersion, client.Version)); bool result; diff --git a/Source/PluginInterface/OTLib/OTB/OtbWriter.cs b/Source/PluginInterface/OTLib/OTB/OtbWriter.cs index d088826..33211d6 100644 --- a/Source/PluginInterface/OTLib/OTB/OtbWriter.cs +++ b/Source/PluginInterface/OTLib/OTB/OtbWriter.cs @@ -78,7 +78,7 @@ public bool Write(string path) vi.MajorVersion = this.Items.MajorVersion; vi.MinorVersion = this.Items.MinorVersion; - vi.BuildNumber = this.Items.BuildNumber; + vi.BuildNumber = this.Items.BuildNumber + 1; vi.CSDVersion = string.Format("OTB {0}.{1}.{2}-{3}.{4}", vi.MajorVersion, vi.MinorVersion, vi.BuildNumber, this.Items.ClientVersion / 100, this.Items.ClientVersion % 100); MemoryStream ms = new MemoryStream(); diff --git a/Source/PluginInterface/PluginInterface.csproj b/Source/PluginInterface/PluginInterface.csproj index bf2f3e0..e170fd5 100644 --- a/Source/PluginInterface/PluginInterface.csproj +++ b/Source/PluginInterface/PluginInterface.csproj @@ -10,7 +10,7 @@ Properties PluginInterface PluginInterface - v4.5.2 + v4.8 512 @@ -71,8 +71,8 @@ - - lib\System.Xml.dll + + lib\System.Xml.dll @@ -117,4 +117,4 @@ --> - + \ No newline at end of file diff --git a/Source/PluginInterface/Properties/Resources.Designer.cs b/Source/PluginInterface/Properties/Resources.Designer.cs index b8f0945..bc6b924 100644 --- a/Source/PluginInterface/Properties/Resources.Designer.cs +++ b/Source/PluginInterface/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace PluginInterface.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/Source/PluginOne/Plugin.cs b/Source/PluginOne/Plugin.cs index 0f8e904..bdd401f 100644 --- a/Source/PluginOne/Plugin.cs +++ b/Source/PluginOne/Plugin.cs @@ -1,4 +1,4 @@ -#region Licence +#region Licence /** * Copyright © 2014-2019 OTTools * diff --git a/Source/PluginOne/PluginOne.csproj b/Source/PluginOne/PluginOne.csproj index b67ab05..016fbaa 100644 --- a/Source/PluginOne/PluginOne.csproj +++ b/Source/PluginOne/PluginOne.csproj @@ -10,7 +10,7 @@ Properties PluginOne PluginOne - v4.5.2 + v4.8 512 diff --git a/Source/PluginThree/PluginThree.csproj b/Source/PluginThree/PluginThree.csproj index 788e6f3..ea1556b 100644 --- a/Source/PluginThree/PluginThree.csproj +++ b/Source/PluginThree/PluginThree.csproj @@ -9,7 +9,7 @@ Properties PluginThree PluginThree - v4.5.2 + v4.8 512 @@ -30,7 +30,7 @@ TRACE prompt 4 - AnyCPU + x64 false diff --git a/Source/PluginTwo/PluginTwo.csproj b/Source/PluginTwo/PluginTwo.csproj index 5b6f663..342647c 100644 --- a/Source/PluginTwo/PluginTwo.csproj +++ b/Source/PluginTwo/PluginTwo.csproj @@ -10,7 +10,7 @@ Properties PluginTwo PluginTwo - v4.5.2 + v4.8 512 diff --git a/Source/Properties/Resources.Designer.cs b/Source/Properties/Resources.Designer.cs index fc82310..7fc7f51 100644 --- a/Source/Properties/Resources.Designer.cs +++ b/Source/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace ItemEditor.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { diff --git a/Source/Properties/Settings.Designer.cs b/Source/Properties/Settings.Designer.cs index d4187f9..6fccd8c 100644 --- a/Source/Properties/Settings.Designer.cs +++ b/Source/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace ItemEditor.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/Source/app.config b/Source/app.config index 7f0611c..e4e1373 100644 --- a/Source/app.config +++ b/Source/app.config @@ -6,12 +6,12 @@ - + - + False From d0f040a78450867910a5907cac2b824263e4eb2c Mon Sep 17 00:00:00 2001 From: danilo Date: Wed, 26 Feb 2020 02:24:17 -0300 Subject: [PATCH 03/15] Solving PluginZero project configurations and adding PluginZero.xml --- Source/PluginZero/PluginZero.csproj | 68 +++++++++++++++++------------ Source/PluginZero/PluginZero.xml | 5 +++ 2 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 Source/PluginZero/PluginZero.xml diff --git a/Source/PluginZero/PluginZero.csproj b/Source/PluginZero/PluginZero.csproj index 90eb849..c2985b3 100644 --- a/Source/PluginZero/PluginZero.csproj +++ b/Source/PluginZero/PluginZero.csproj @@ -1,17 +1,19 @@  - - + Debug AnyCPU - {A6AC9F32-8478-4543-8772-0AD590E94140} + 8.0.30703 + 2.0 + {A6AC9F32-8478-4543-8772-0AD590E94140} Library Properties PluginZero PluginZero v4.8 512 - true + + true @@ -21,6 +23,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -29,51 +32,47 @@ TRACE prompt 4 + false - true - ..\bin\x86\Debug\ - DEBUG;TRACE - full x86 - prompt - MinimumRecommendedRules.ruleset + ..\bin\x86\Debug\Plugins\ + false + DEBUG;TRACE + false + x86 ..\bin\x86\Release\Plugins\ - TRACE true - pdbonly - x86 - prompt - MinimumRecommendedRules.ruleset + TRACE + false true ..\bin\x64\Debug\Plugins\ - DEBUG;TRACE - full + x64 - prompt + MinimumRecommendedRules.ruleset + TRACE;DEBUG + false ..\bin\x64\Release\Plugins\ - TRACE + true - pdbonly + x64 - prompt + MinimumRecommendedRules.ruleset + TRACE + false - - - - + - @@ -82,9 +81,22 @@ - {cef21172-258c-4d0d-b024-ed7ef99612a2} + {CEF21172-258C-4D0D-B024-ED7EF99612A2} PluginInterface + False + + + PreserveNewest + + - \ No newline at end of file + + diff --git a/Source/PluginZero/PluginZero.xml b/Source/PluginZero/PluginZero.xml new file mode 100644 index 0000000..aa799ea --- /dev/null +++ b/Source/PluginZero/PluginZero.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file From 95688d4783dbdfdd6667ee963626d08ec8b42bda Mon Sep 17 00:00:00 2001 From: Danilo Pucci Date: Thu, 16 Apr 2020 21:31:23 -0300 Subject: [PATCH 04/15] Update README.md editting download link on README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 08ae68d..8c62894 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,12 @@ ItemEditor is a program used to edit the OTB data files. Supported versions: ---- -* 8.00 - 10.77 +* 7.40 - 10.77 Download ---- -[ItemEditor 0.4](https://github.com/ottools/ItemEditor/releases/tag/v0.4) +[ItemEditor 0.43](https://github.com/danilopucci/ItemEditor/releases/download/v0.4.3/ItemEditor_v043.zip) Compiling ---- From 567e0750e0e0c5dce4c51fcf5c9f150fe432e85b Mon Sep 17 00:00:00 2001 From: Danilo Date: Tue, 16 Feb 2021 22:28:53 -0300 Subject: [PATCH 05/15] Update PluginZero.xml Adding 7.x client, otb versions and spr, dat signatures --- Source/PluginZero/PluginZero.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/PluginZero/PluginZero.xml b/Source/PluginZero/PluginZero.xml index aa799ea..c6f3d20 100644 --- a/Source/PluginZero/PluginZero.xml +++ b/Source/PluginZero/PluginZero.xml @@ -1,5 +1,14 @@ + + + + + + + + + \ No newline at end of file From 3e2329a44cdb80064ae0340a8bede1fc93a0026f Mon Sep 17 00:00:00 2001 From: Danilo Date: Thu, 18 Feb 2021 23:44:16 -0300 Subject: [PATCH 06/15] - Reverting some project conf files, which caused conflicts to main repo --- ItemEditor.sln | 4 ++-- Source/ItemEditor.csproj | 2 +- Source/PluginInterface/PluginInterface.csproj | 8 ++++---- Source/PluginInterface/Properties/Resources.Designer.cs | 2 +- Source/PluginOne/PluginOne.csproj | 2 +- Source/PluginThree/PluginThree.csproj | 4 ++-- Source/PluginTwo/PluginTwo.csproj | 2 +- Source/Properties/Resources.Designer.cs | 2 +- Source/Properties/Settings.Designer.cs | 2 +- Source/app.config | 4 ++-- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ItemEditor.sln b/ItemEditor.sln index bcb4c8b..2413304 100644 --- a/ItemEditor.sln +++ b/ItemEditor.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.1022 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ItemEditor", "Source\ItemEditor.csproj", "{9A90BE1A-4A8F-4BFE-92E7-2C0EF64D850C}" ProjectSection(ProjectDependencies) = postProject diff --git a/Source/ItemEditor.csproj b/Source/ItemEditor.csproj index a487858..6918f63 100644 --- a/Source/ItemEditor.csproj +++ b/Source/ItemEditor.csproj @@ -10,7 +10,7 @@ Properties ItemEditor ItemEditor - v4.8 + v4.5.2 512 diff --git a/Source/PluginInterface/PluginInterface.csproj b/Source/PluginInterface/PluginInterface.csproj index e170fd5..bf2f3e0 100644 --- a/Source/PluginInterface/PluginInterface.csproj +++ b/Source/PluginInterface/PluginInterface.csproj @@ -10,7 +10,7 @@ Properties PluginInterface PluginInterface - v4.8 + v4.5.2 512 @@ -71,8 +71,8 @@ - - lib\System.Xml.dll + + lib\System.Xml.dll @@ -117,4 +117,4 @@ --> - \ No newline at end of file + diff --git a/Source/PluginInterface/Properties/Resources.Designer.cs b/Source/PluginInterface/Properties/Resources.Designer.cs index bc6b924..b8f0945 100644 --- a/Source/PluginInterface/Properties/Resources.Designer.cs +++ b/Source/PluginInterface/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace PluginInterface.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/Source/PluginOne/PluginOne.csproj b/Source/PluginOne/PluginOne.csproj index 016fbaa..b67ab05 100644 --- a/Source/PluginOne/PluginOne.csproj +++ b/Source/PluginOne/PluginOne.csproj @@ -10,7 +10,7 @@ Properties PluginOne PluginOne - v4.8 + v4.5.2 512 diff --git a/Source/PluginThree/PluginThree.csproj b/Source/PluginThree/PluginThree.csproj index ea1556b..788e6f3 100644 --- a/Source/PluginThree/PluginThree.csproj +++ b/Source/PluginThree/PluginThree.csproj @@ -9,7 +9,7 @@ Properties PluginThree PluginThree - v4.8 + v4.5.2 512 @@ -30,7 +30,7 @@ TRACE prompt 4 - x64 + AnyCPU false diff --git a/Source/PluginTwo/PluginTwo.csproj b/Source/PluginTwo/PluginTwo.csproj index 342647c..5b6f663 100644 --- a/Source/PluginTwo/PluginTwo.csproj +++ b/Source/PluginTwo/PluginTwo.csproj @@ -10,7 +10,7 @@ Properties PluginTwo PluginTwo - v4.8 + v4.5.2 512 diff --git a/Source/Properties/Resources.Designer.cs b/Source/Properties/Resources.Designer.cs index 7fc7f51..fc82310 100644 --- a/Source/Properties/Resources.Designer.cs +++ b/Source/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace ItemEditor.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { diff --git a/Source/Properties/Settings.Designer.cs b/Source/Properties/Settings.Designer.cs index 6fccd8c..d4187f9 100644 --- a/Source/Properties/Settings.Designer.cs +++ b/Source/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace ItemEditor.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/Source/app.config b/Source/app.config index e4e1373..7f0611c 100644 --- a/Source/app.config +++ b/Source/app.config @@ -6,12 +6,12 @@ - + - + False From 64619c9932a68c96d8981de3b4033512632715f2 Mon Sep 17 00:00:00 2001 From: Danilo Date: Thu, 18 Feb 2021 23:48:28 -0300 Subject: [PATCH 07/15] - Updating PluginZero proj file to the same framework version as others --- Source/PluginZero/PluginZero.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/PluginZero/PluginZero.csproj b/Source/PluginZero/PluginZero.csproj index c2985b3..dc63350 100644 --- a/Source/PluginZero/PluginZero.csproj +++ b/Source/PluginZero/PluginZero.csproj @@ -10,7 +10,7 @@ Properties PluginZero PluginZero - v4.8 + v4.5.2 512 From ede1021a9790ab69d7c088bf2e22072432a20aec Mon Sep 17 00:00:00 2001 From: Danilo Date: Sun, 21 Feb 2021 00:33:30 -0300 Subject: [PATCH 08/15] Adding checkages of client version while loading .dat The flags of .dat files on versions 7.x are bit different on their values. Using OTClient sources as a reference, I added the checkages on versions to load that correctly. --- Source/PluginZero/Plugin.cs | 76 +++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 3 deletions(-) diff --git a/Source/PluginZero/Plugin.cs b/Source/PluginZero/Plugin.cs index 6070369..cbf1067 100644 --- a/Source/PluginZero/Plugin.cs +++ b/Source/PluginZero/Plugin.cs @@ -211,6 +211,67 @@ public bool LoadDat(string filename, SupportedClient client, bool extended, bool { flag = (ItemFlag)reader.ReadByte(); + //flags need to be adjusted before. + if (client.Version >= 780) + { + /* In 7.80-8.54 all attributes from 8 and higher were + * incremented by 1 to make space for 8 as + * "Item Charges" flag. + */ + if (Convert.ToInt32(flag) == 8) + { + item.HasCharges = true; + continue; + } + else if (Convert.ToInt32(flag) > 8) + flag -= 1; + } + else if (client.Version >= 755) + { + /* In 7.55-7.72 attributes 23 is "Floor Change". */ + if (Convert.ToInt32(flag) == 23) + flag = ItemFlag.FloorChange; + } + else if (client.Version >= 740) + { + /* In 7.4-7.5 attribute "Ground Border" did not exist + * attributes 1-15 have to be adjusted. + * Several other changes in the format. + */ + if (Convert.ToInt32(flag) > 0 && Convert.ToInt32(flag) <= 15) + flag += 1; + else if (Convert.ToInt32(flag) == 16) + flag = ItemFlag.HasLight; + else if (Convert.ToInt32(flag) == 17) + flag = ItemFlag.FloorChange; + else if (Convert.ToInt32(flag) == 18) + flag = ItemFlag.FullGround; + else if (Convert.ToInt32(flag) == 19) + flag = ItemFlag.HasElevation; + else if (Convert.ToInt32(flag) == 20) + flag = ItemFlag.HasOffset; + else if (Convert.ToInt32(flag) == 22) + flag = ItemFlag.Minimap; + else if (Convert.ToInt32(flag) == 23) + flag = ItemFlag.Rotatable; + else if (Convert.ToInt32(flag) == 24) + flag = ItemFlag.Lying; + else if (Convert.ToInt32(flag) == 25) + flag = ItemFlag.Hangable; + else if (Convert.ToInt32(flag) == 26) + flag = ItemFlag.IsHorizontal; + else if (Convert.ToInt32(flag) == 27) + flag = ItemFlag.IsVertical; + else if (Convert.ToInt32(flag) == 28) + flag = ItemFlag.AnimateAlways; + + /* "Multi Use" and "Force Use" are swapped */ + if (flag == ItemFlag.MultiUse) + flag = ItemFlag.ForceUse; + else if (flag == ItemFlag.ForceUse) + flag = ItemFlag.MultiUse; + } + switch (flag) { case ItemFlag.Ground: @@ -222,6 +283,7 @@ public bool LoadDat(string filename, SupportedClient client, bool extended, bool case ItemFlag.GroundBorder: item.HasStackOrder = true; item.StackOrder = TileStackOrder.Border; + break; case ItemFlag.OnBottom: @@ -316,8 +378,11 @@ public bool LoadDat(string filename, SupportedClient client, bool extended, bool break; case ItemFlag.HasOffset: - reader.ReadUInt16(); // OffsetX - reader.ReadUInt16(); // OffsetY + if (client.Version >= 755) + { + reader.ReadUInt16(); // OffsetX + reader.ReadUInt16(); // OffsetY + } break; case ItemFlag.HasElevation: @@ -369,7 +434,12 @@ public bool LoadDat(string filename, SupportedClient client, bool extended, bool item.Layers = reader.ReadByte(); item.PatternX = reader.ReadByte(); item.PatternY = reader.ReadByte(); - item.PatternZ = reader.ReadByte(); + + if (client.Version >= 755) + item.PatternZ = reader.ReadByte(); + else + item.PatternZ = 1; + item.Frames = reader.ReadByte(); item.IsAnimation = item.Frames > 1; item.NumSprites = (uint)item.Width * item.Height * item.Layers * item.PatternX * item.PatternY * item.PatternZ * item.Frames; From 3c4b027b4f1faf872c28d7f5faa92c18de5f9e26 Mon Sep 17 00:00:00 2001 From: Danilo Date: Mon, 1 Mar 2021 23:01:04 -0300 Subject: [PATCH 09/15] Update MainForm.cs Changes in logic to find a compatible client. Previously there was only one OTB version to each Tibia version, with the new 7.x support there is more than one Tibia version to the same OTB version (710->730; 740->750 and 790 -> 792). With theese changes, now the logics consider a list instead of a single client, it reads the list and try to match it by the dat and spr signature --- Source/MainForm.cs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/Source/MainForm.cs b/Source/MainForm.cs index e187284..27465dc 100644 --- a/Source/MainForm.cs +++ b/Source/MainForm.cs @@ -807,13 +807,14 @@ private ServerItem CopyItem(ServerItem item) private bool LoadClient(Plugin plugin, uint otbVersion) { - SupportedClient client = plugin.Instance.SupportedClients.Find( + List clientList = plugin.Instance.SupportedClients.FindAll( delegate(SupportedClient sc) { return sc.OtbVersion == otbVersion; }); - if (client == null) + + if (clientList.Count == 0) { MessageBox.Show("The selected plugin does not support this version."); return false; @@ -822,16 +823,27 @@ private bool LoadClient(Plugin plugin, uint otbVersion) uint datSignature = (uint)Properties.Settings.Default["DatSignature"]; uint sprSignature = (uint)Properties.Settings.Default["SprSignature"]; - if (client.DatSignature != datSignature || client.SprSignature != sprSignature) + if (datSignature == 0 || sprSignature == 0) { - string message; - if (datSignature == 0 || sprSignature == 0) + MessageBox.Show("No client is selected. Please navigate to the client folder."); + return false; + } + + SupportedClient client = null; + + foreach (SupportedClient clientObject in clientList) + { + if (clientObject.DatSignature == datSignature && clientObject.SprSignature == sprSignature) { - message = "No client is selected. Please navigate to the client folder."; + client = clientObject; } - else + } + + if (client == null) + { + string message; { - message = string.Format("The selected client is not compatible with this OTB(version {0}). Please navigate to the folder of a compatible client {1}.", client.OtbVersion, client.Version); + message = string.Format("The selected client is not compatible with this OTB(version {0}). Please navigate to the folder of a compatible client.", otbVersion); } MessageBox.Show(message); From 5027e115a8cfa467c53c2d7c7bfd8e1f1eebdcc0 Mon Sep 17 00:00:00 2001 From: Danilo Date: Mon, 1 Mar 2021 23:01:23 -0300 Subject: [PATCH 10/15] Update PluginZero.xml Fixing typo in version 780 --- Source/PluginZero/PluginZero.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/PluginZero/PluginZero.xml b/Source/PluginZero/PluginZero.xml index c6f3d20..cb9534f 100644 --- a/Source/PluginZero/PluginZero.xml +++ b/Source/PluginZero/PluginZero.xml @@ -7,7 +7,7 @@ - + From 696f2779377b039b051bf606f15e0ce9c8bd76cd Mon Sep 17 00:00:00 2001 From: Danilo Pucci Date: Tue, 23 May 2023 23:40:00 -0300 Subject: [PATCH 11/15] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8c62894..c6fb439 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Supported versions: Download ---- -[ItemEditor 0.43](https://github.com/danilopucci/ItemEditor/releases/download/v0.4.3/ItemEditor_v043.zip) +[ItemEditor 0.43](https://github.com/danilopucci/ItemEditor/releases/download/v0.4.3/ItemEditor_v0432.zip) Compiling ---- From cd1d14a17731e6b4df1b9d04bfefaf9f11817a02 Mon Sep 17 00:00:00 2001 From: Danilo Pucci Date: Sat, 3 Feb 2024 16:43:54 -0300 Subject: [PATCH 12/15] - improve compatibility with older versions --- Source/PluginZero/Plugin.cs | 577 +++++++++++++++++++++++------------- 1 file changed, 377 insertions(+), 200 deletions(-) diff --git a/Source/PluginZero/Plugin.cs b/Source/PluginZero/Plugin.cs index cbf1067..e026455 100644 --- a/Source/PluginZero/Plugin.cs +++ b/Source/PluginZero/Plugin.cs @@ -1,4 +1,4 @@ -#region Licence +#region Licence /** * Copyright © 2014-2019 OTTools * @@ -51,8 +51,8 @@ internal enum ItemFlag : byte BlockPathfinder = 0x0F, Pickupable = 0x10, Hangable = 0x11, - IsHorizontal = 0x12, - IsVertical = 0x13, + IsVertical = 0x12, + IsHorizontal = 0x13, Rotatable = 0x14, HasLight = 0x15, DontHide = 0x16, @@ -210,263 +210,440 @@ public bool LoadDat(string filename, SupportedClient client, bool extended, bool do { flag = (ItemFlag)reader.ReadByte(); + flag = convertItemFlag(client.Version, flag); - //flags need to be adjusted before. - if (client.Version >= 780) + if (client.Version >= 740 && client.Version <= 750) { - /* In 7.80-8.54 all attributes from 8 and higher were - * incremented by 1 to make space for 8 as - * "Item Charges" flag. - */ - if (Convert.ToInt32(flag) == 8) + if (!readAndSetAttribute_740_750(reader, item, flag)) { - item.HasCharges = true; - continue; + Trace.WriteLine(String.Format("PluginZero: Error while parsing, unknown flag 0x{0:X} at id {1}.", flag, id)); } - else if (Convert.ToInt32(flag) > 8) - flag -= 1; } - else if (client.Version >= 755) + else if (client.Version >= 755 && client.Version <= 772) { - /* In 7.55-7.72 attributes 23 is "Floor Change". */ - if (Convert.ToInt32(flag) == 23) - flag = ItemFlag.FloorChange; + if (!readAndSetAttribute_755_772(reader, item, flag)) + { + Trace.WriteLine(String.Format("PluginZero: Error while parsing, unknown flag 0x{0:X} at id {1}.", flag, id)); + } } - else if (client.Version >= 740) + else { - /* In 7.4-7.5 attribute "Ground Border" did not exist - * attributes 1-15 have to be adjusted. - * Several other changes in the format. - */ - if (Convert.ToInt32(flag) > 0 && Convert.ToInt32(flag) <= 15) - flag += 1; - else if (Convert.ToInt32(flag) == 16) - flag = ItemFlag.HasLight; - else if (Convert.ToInt32(flag) == 17) - flag = ItemFlag.FloorChange; - else if (Convert.ToInt32(flag) == 18) - flag = ItemFlag.FullGround; - else if (Convert.ToInt32(flag) == 19) - flag = ItemFlag.HasElevation; - else if (Convert.ToInt32(flag) == 20) - flag = ItemFlag.HasOffset; - else if (Convert.ToInt32(flag) == 22) - flag = ItemFlag.Minimap; - else if (Convert.ToInt32(flag) == 23) - flag = ItemFlag.Rotatable; - else if (Convert.ToInt32(flag) == 24) - flag = ItemFlag.Lying; - else if (Convert.ToInt32(flag) == 25) - flag = ItemFlag.Hangable; - else if (Convert.ToInt32(flag) == 26) - flag = ItemFlag.IsHorizontal; - else if (Convert.ToInt32(flag) == 27) - flag = ItemFlag.IsVertical; - else if (Convert.ToInt32(flag) == 28) - flag = ItemFlag.AnimateAlways; - - /* "Multi Use" and "Force Use" are swapped */ - if (flag == ItemFlag.MultiUse) - flag = ItemFlag.ForceUse; - else if (flag == ItemFlag.ForceUse) - flag = ItemFlag.MultiUse; + Trace.WriteLine(String.Format("PluginZero: Error while parsing, not supported client version {1}.", client.Version)); } - switch (flag) + } while (flag != ItemFlag.LastFlag); + + + item.Width = reader.ReadByte(); + item.Height = reader.ReadByte(); + + if ((item.Width > 1) || (item.Height > 1)) + { + reader.BaseStream.Position++; + } + + item.Layers = reader.ReadByte(); + item.PatternX = reader.ReadByte(); + item.PatternY = reader.ReadByte(); + + if (client.Version >= 755) + item.PatternZ = reader.ReadByte(); + else + item.PatternZ = 1; + + item.Frames = reader.ReadByte(); + item.IsAnimation = item.Frames > 1; + item.NumSprites = (uint)item.Width * item.Height * item.Layers * item.PatternX * item.PatternY * item.PatternZ * item.Frames; + + // Read the sprite ids + for (UInt32 i = 0; i < item.NumSprites; ++i) + { + UInt16 spriteId = reader.ReadUInt16(); + Sprite sprite; + if (!sprites.TryGetValue(spriteId, out sprite)) { - case ItemFlag.Ground: - item.GroundSpeed = reader.ReadUInt16(); - item.Type = ServerItemType.Ground; - break; + sprite = new Sprite(); + sprite.ID = spriteId; + sprites[spriteId] = sprite; + } + + item.SpriteList.Add(sprite); + } + + ++id; + + + } + } + + return true; + } + private ItemFlag convertItemFlag(uint clientVersion, ItemFlag flag) + { + ItemFlag resultFlag = flag; - case ItemFlag.GroundBorder: - item.HasStackOrder = true; - item.StackOrder = TileStackOrder.Border; + if (clientVersion >= 740 && clientVersion <= 750) + { + /* + * - In 7.4-7.5 attribute "Ground Border" did not exist, so attributes 1-15 have to be adjusted. + * - Several other changes in the format. + * - "Multi Use" and "Force Use" are swapped + */ + if (Convert.ToInt32(flag) > 0 && Convert.ToInt32(flag) <= 15) + { + resultFlag = flag + 1; + } + else if (Convert.ToInt32(flag) == 16) + { + resultFlag = ItemFlag.HasLight; + } + else if (Convert.ToInt32(flag) == 17) + { + resultFlag = ItemFlag.FloorChange; + } + else if (Convert.ToInt32(flag) == 18) + { + resultFlag = ItemFlag.FullGround; + } + else if (Convert.ToInt32(flag) == 19) + { + resultFlag = ItemFlag.HasElevation; + } + else if (Convert.ToInt32(flag) == 20) + { + resultFlag = ItemFlag.HasOffset; + } + else if (Convert.ToInt32(flag) == 22) + { + resultFlag = ItemFlag.Minimap; + } + else if (Convert.ToInt32(flag) == 23) + { + resultFlag = ItemFlag.Rotatable; + } + else if (Convert.ToInt32(flag) == 24) + { + resultFlag = ItemFlag.Lying; + } + else if (Convert.ToInt32(flag) == 25) + { + resultFlag = ItemFlag.Hangable; + } + else if (Convert.ToInt32(flag) == 26) + { + resultFlag = ItemFlag.IsHorizontal; + } + else if (Convert.ToInt32(flag) == 27) + { + resultFlag = ItemFlag.IsVertical; + } + else if (Convert.ToInt32(flag) == 28) + { + resultFlag = ItemFlag.AnimateAlways; + } + else if (flag == ItemFlag.MultiUse) + { + resultFlag = ItemFlag.ForceUse; + } + else if (flag == ItemFlag.ForceUse) + { + resultFlag = ItemFlag.MultiUse; + } - break; + } + return resultFlag; + } - case ItemFlag.OnBottom: - item.HasStackOrder = true; - item.StackOrder = TileStackOrder.Bottom; - break; + private bool readAndSetAttribute_740_750(BinaryReader reader, ClientItem item, ItemFlag flag) + { + switch (flag) + { + case ItemFlag.Ground: + item.GroundSpeed = reader.ReadUInt16(); + item.Type = ServerItemType.Ground; + break; - case ItemFlag.OnTop: - item.HasStackOrder = true; - item.StackOrder = TileStackOrder.Top; - break; + case ItemFlag.OnBottom: + item.HasStackOrder = true; + item.StackOrder = TileStackOrder.Bottom; + break; - case ItemFlag.Container: - item.Type = ServerItemType.Container; - break; - case ItemFlag.Stackable: - item.Stackable = true; - break; + case ItemFlag.OnTop: + item.HasStackOrder = true; + item.StackOrder = TileStackOrder.Top; + break; - case ItemFlag.ForceUse: - break; + case ItemFlag.Container: + item.Type = ServerItemType.Container; + break; - case ItemFlag.MultiUse: - item.MultiUse = true; - break; + case ItemFlag.Stackable: + item.Stackable = true; + break; - case ItemFlag.Writable: - item.Readable = true; - item.MaxReadWriteChars = reader.ReadUInt16(); - break; + case ItemFlag.MultiUse: + item.MultiUse = true; + break; - case ItemFlag.WritableOnce: - item.Readable = true; - item.MaxReadChars = reader.ReadUInt16(); - break; + case ItemFlag.ForceUse: + item.ForceUse = true; + break; - case ItemFlag.FluidContainer: - item.Type = ServerItemType.Fluid; - break; + case ItemFlag.Writable: + item.Readable = true; + item.MaxReadWriteChars = reader.ReadUInt16(); + break; - case ItemFlag.Fluid: - item.Type = ServerItemType.Splash; - break; + case ItemFlag.WritableOnce: + item.Readable = true; + item.MaxReadChars = reader.ReadUInt16(); + break; - case ItemFlag.IsUnpassable: - item.Unpassable = true; - break; + case ItemFlag.FluidContainer: + item.Type = ServerItemType.Fluid; + break; - case ItemFlag.IsUnmoveable: - item.Movable = false; - break; + case ItemFlag.Fluid: + item.Type = ServerItemType.Splash; + break; - case ItemFlag.BlockMissiles: - item.BlockMissiles = true; - break; + case ItemFlag.IsUnpassable: + item.Unpassable = true; + break; - case ItemFlag.BlockPathfinder: - item.BlockPathfinder = true; - break; + case ItemFlag.IsUnmoveable: + item.Movable = false; + break; - case ItemFlag.Pickupable: - item.Pickupable = true; - break; + case ItemFlag.BlockMissiles: + item.BlockMissiles = true; + break; - case ItemFlag.Hangable: - item.Hangable = true; - break; + case ItemFlag.BlockPathfinder: + item.BlockPathfinder = true; + break; - case ItemFlag.IsHorizontal: - item.HookEast = true; - break; + case ItemFlag.Pickupable: + item.Pickupable = true; + break; - case ItemFlag.IsVertical: - item.HookSouth = true; - break; + case ItemFlag.HasLight: + item.LightLevel = reader.ReadUInt16(); + item.LightColor = reader.ReadUInt16(); + break; - case ItemFlag.Rotatable: - item.Rotatable = true; - break; + case ItemFlag.FloorChange: + break; - case ItemFlag.HasLight: - item.LightLevel = reader.ReadUInt16(); - item.LightColor = reader.ReadUInt16(); - break; + case ItemFlag.FullGround: + item.FullGround = true; + break; - case ItemFlag.DontHide: - break; + case ItemFlag.HasElevation: + item.HasElevation = true; + reader.ReadUInt16(); // Height + break; - case ItemFlag.FloorChange: - break; + case ItemFlag.HasOffset: + break; - case ItemFlag.HasOffset: - if (client.Version >= 755) - { - reader.ReadUInt16(); // OffsetX - reader.ReadUInt16(); // OffsetY - } - break; + case ItemFlag.Minimap: + item.MinimapColor = reader.ReadUInt16(); + break; - case ItemFlag.HasElevation: - item.HasElevation = true; - reader.ReadUInt16(); // Height - break; + case ItemFlag.Rotatable: + item.Rotatable = true; + break; - case ItemFlag.Lying: - break; - - case ItemFlag.AnimateAlways: - break; - - case ItemFlag.Minimap: - item.MinimapColor = reader.ReadUInt16(); - break; - - case ItemFlag.LensHelp: - ushort opt = reader.ReadUInt16(); - if (opt == 1112) - { - item.Readable = true; - } - break; - - case ItemFlag.FullGround: - break; - - case ItemFlag.LastFlag: - break; - - default: - Trace.WriteLine(String.Format("PluginZero: Error while parsing, unknown flag 0x{0:X} at id {1}.", flag, id)); - return false; + case ItemFlag.Lying: + break; - } + case ItemFlag.Hangable: + item.Hangable = true; + break; - } while (flag != ItemFlag.LastFlag); + case ItemFlag.IsVertical: + item.HookSouth = true; + break; + case ItemFlag.IsHorizontal: + item.HookEast = true; + break; - item.Width = reader.ReadByte(); - item.Height = reader.ReadByte(); + case ItemFlag.AnimateAlways: + break; - if ((item.Width > 1) || (item.Height > 1)) + case ItemFlag.LensHelp: + ushort opt = reader.ReadUInt16(); + if (opt == 1112) { - reader.BaseStream.Position++; + item.Readable = true; } + break; - item.Layers = reader.ReadByte(); - item.PatternX = reader.ReadByte(); - item.PatternY = reader.ReadByte(); + case ItemFlag.LastFlag: + break; - if (client.Version >= 755) - item.PatternZ = reader.ReadByte(); - else - item.PatternZ = 1; + default: + return false; + } - item.Frames = reader.ReadByte(); - item.IsAnimation = item.Frames > 1; - item.NumSprites = (uint)item.Width * item.Height * item.Layers * item.PatternX * item.PatternY * item.PatternZ * item.Frames; + return true; + } - // Read the sprite ids - for (UInt32 i = 0; i < item.NumSprites; ++i) - { - UInt16 spriteId = reader.ReadUInt16(); - Sprite sprite; - if (!sprites.TryGetValue(spriteId, out sprite)) - { - sprite = new Sprite(); - sprite.ID = spriteId; - sprites[spriteId] = sprite; - } - item.SpriteList.Add(sprite); + private bool readAndSetAttribute_755_772(BinaryReader reader, ClientItem item, ItemFlag flag) { + + switch (flag) + { + case ItemFlag.Ground: + item.GroundSpeed = reader.ReadUInt16(); + item.Type = ServerItemType.Ground; + break; + + + case ItemFlag.GroundBorder: + item.HasStackOrder = true; + item.StackOrder = TileStackOrder.Border; + + break; + + case ItemFlag.OnBottom: + item.HasStackOrder = true; + item.StackOrder = TileStackOrder.Bottom; + break; + + + case ItemFlag.OnTop: + item.HasStackOrder = true; + item.StackOrder = TileStackOrder.Top; + break; + + case ItemFlag.Container: + item.Type = ServerItemType.Container; + break; + + case ItemFlag.Stackable: + item.Stackable = true; + break; + + case ItemFlag.MultiUse: + item.MultiUse = true; + break; + + case ItemFlag.ForceUse: + item.ForceUse = true; + break; + + case ItemFlag.Writable: + item.Readable = true; + item.MaxReadWriteChars = reader.ReadUInt16(); + break; + + case ItemFlag.WritableOnce: + item.Readable = true; + item.MaxReadChars = reader.ReadUInt16(); + break; + + case ItemFlag.FluidContainer: + item.Type = ServerItemType.Fluid; + break; + + case ItemFlag.Fluid: + item.Type = ServerItemType.Splash; + break; + + case ItemFlag.IsUnpassable: + item.Unpassable = true; + break; + + case ItemFlag.IsUnmoveable: + item.Movable = false; + break; + + case ItemFlag.BlockMissiles: + item.BlockMissiles = true; + break; + + case ItemFlag.BlockPathfinder: + item.BlockPathfinder = true; + break; + + case ItemFlag.Pickupable: + item.Pickupable = true; + break; + + case ItemFlag.Hangable: + item.Hangable = true; + break; + + case ItemFlag.IsVertical: + item.HookEast = true; + break; + + case ItemFlag.IsHorizontal: + item.HookSouth = true; + break; + + case ItemFlag.Rotatable: + item.Rotatable = true; + break; + + case ItemFlag.HasLight: + item.LightLevel = reader.ReadUInt16(); + item.LightColor = reader.ReadUInt16(); + break; + + case ItemFlag.DontHide: + break; + + case ItemFlag.FloorChange: + break; + + case ItemFlag.HasOffset: + reader.ReadUInt16(); // OffsetX + reader.ReadUInt16(); // OffsetY + break; + + case ItemFlag.HasElevation: + item.HasElevation = true; + reader.ReadUInt16(); // Height + break; + + case ItemFlag.Lying: + break; + + case ItemFlag.AnimateAlways: + break; + + case ItemFlag.Minimap: + item.MinimapColor = reader.ReadUInt16(); + break; + + case ItemFlag.LensHelp: + ushort opt = reader.ReadUInt16(); + if (opt == 1112) + { + item.Readable = true; } + break; - ++id; + case ItemFlag.FullGround: + break; + case ItemFlag.LastFlag: + break; - } + default: + return false; } return true; } + #endregion } } \ No newline at end of file From 0e6015f5c7412a62de8ed1d7103ccca14889f21d Mon Sep 17 00:00:00 2001 From: Danilo Pucci Date: Sat, 3 Feb 2024 16:51:53 -0300 Subject: [PATCH 13/15] - move 7.8+ to Plugin One --- Source/PluginOne/PluginOne.xml | 3 +++ Source/PluginZero/PluginZero.xml | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/PluginOne/PluginOne.xml b/Source/PluginOne/PluginOne.xml index 624c6b0..2c145b4 100644 --- a/Source/PluginOne/PluginOne.xml +++ b/Source/PluginOne/PluginOne.xml @@ -1,5 +1,8 @@ + + + diff --git a/Source/PluginZero/PluginZero.xml b/Source/PluginZero/PluginZero.xml index cb9534f..fe95444 100644 --- a/Source/PluginZero/PluginZero.xml +++ b/Source/PluginZero/PluginZero.xml @@ -7,8 +7,5 @@ - - - \ No newline at end of file From 4203094d69a7c09166bcd6af91c67cb128f5fbb5 Mon Sep 17 00:00:00 2001 From: Danilo Pucci Date: Sat, 3 Feb 2024 23:09:35 -0300 Subject: [PATCH 14/15] - remove empty line --- Source/PluginZero/Plugin.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/PluginZero/Plugin.cs b/Source/PluginZero/Plugin.cs index e026455..f1bd978 100644 --- a/Source/PluginZero/Plugin.cs +++ b/Source/PluginZero/Plugin.cs @@ -30,7 +30,6 @@ namespace PluginZero { - internal enum ItemFlag : byte { Ground = 0x00, From 011744076cdaecb7d6c2f8d4bccc7a79abb04bad Mon Sep 17 00:00:00 2001 From: Danilo Pucci Date: Sat, 3 Feb 2024 23:46:01 -0300 Subject: [PATCH 15/15] - bump version 0.4.4 --- Source/PluginInterface/Properties/AssemblyInfo.cs | 4 ++-- Source/PluginOne/Properties/AssemblyInfo.cs | 4 ++-- Source/PluginThree/Properties/AssemblyInfo.cs | 4 ++-- Source/PluginTwo/Properties/AssemblyInfo.cs | 4 ++-- Source/PluginZero/Properties/AssemblyInfo.cs | 4 ++-- Source/Properties/AssemblyInfo.cs | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/PluginInterface/Properties/AssemblyInfo.cs b/Source/PluginInterface/Properties/AssemblyInfo.cs index 43f4139..67c1f6e 100644 --- a/Source/PluginInterface/Properties/AssemblyInfo.cs +++ b/Source/PluginInterface/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.4.3.0")] -[assembly: AssemblyFileVersion("0.4.3.0")] +[assembly: AssemblyVersion("0.4.4.0")] +[assembly: AssemblyFileVersion("0.4.4.0")] diff --git a/Source/PluginOne/Properties/AssemblyInfo.cs b/Source/PluginOne/Properties/AssemblyInfo.cs index 37a2104..a3c7b27 100644 --- a/Source/PluginOne/Properties/AssemblyInfo.cs +++ b/Source/PluginOne/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.4.3.0")] -[assembly: AssemblyFileVersion("0.4.3.0")] +[assembly: AssemblyVersion("0.4.4.0")] +[assembly: AssemblyFileVersion("0.4.4.0")] diff --git a/Source/PluginThree/Properties/AssemblyInfo.cs b/Source/PluginThree/Properties/AssemblyInfo.cs index ea65dac..e4ab26d 100644 --- a/Source/PluginThree/Properties/AssemblyInfo.cs +++ b/Source/PluginThree/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.4.3.0")] -[assembly: AssemblyFileVersion("0.4.3.0")] +[assembly: AssemblyVersion("0.4.4.0")] +[assembly: AssemblyFileVersion("0.4.4.0")] diff --git a/Source/PluginTwo/Properties/AssemblyInfo.cs b/Source/PluginTwo/Properties/AssemblyInfo.cs index 8a77fb3..99db262 100644 --- a/Source/PluginTwo/Properties/AssemblyInfo.cs +++ b/Source/PluginTwo/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.4.3.0")] -[assembly: AssemblyFileVersion("0.4.3.0")] +[assembly: AssemblyVersion("0.4.4.0")] +[assembly: AssemblyFileVersion("0.4.4.0")] diff --git a/Source/PluginZero/Properties/AssemblyInfo.cs b/Source/PluginZero/Properties/AssemblyInfo.cs index f3dee6c..5259570 100644 --- a/Source/PluginZero/Properties/AssemblyInfo.cs +++ b/Source/PluginZero/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("0.4.3.3")] +[assembly: AssemblyFileVersion("0.4.3.3")] diff --git a/Source/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs index e109f21..464ee20 100644 --- a/Source/Properties/AssemblyInfo.cs +++ b/Source/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.4.3.0")] -[assembly: AssemblyFileVersion("0.4.3.0")] +[assembly: AssemblyVersion("0.4.4.0")] +[assembly: AssemblyFileVersion("0.4.4.0")]