Jump to content

boasfesta

Members
  • Content Count

    34
  • Donations

    $0.00 
  • Joined

  • Last visited

  • Days Won

    3

boasfesta last won the day on November 9 2016

boasfesta had the most liked content!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. boasfesta

    Data Serialization (Network)

    Objective: Serialize all object data through network Difficulty: Advanced This tutorial is a second part of serialization system, described on this tutorial, so if you did'nt added yet, do it before you continue. In the past tutorial we learned how to serialize our objects for storage, so we don't need to update the structures fields every time we add a new one. But storage systems is not the only methods we must to add structure fields one by one, we also need to update the Send and Receive object packets through network. The actual Orion+ communications steps are: When someone login: Server send (some) game data on SendGameData sub and Client/Editor receive them on Packet_GameData When a object is modified: Editor send its data on SendSaveObject sub and Server receive it on Packet_SaveObject. Also when this occurs, Server send the data update for other connected clients on methods SendObjectUpdateTo and SendObjectUpdateToAll, the Client/Editors receive them on a unique method Packet_UpdateObject. Considering this, those methods is our target methods for every object we want to serialize. Preparing to Serialize First we must to create our Serialization class, but there is a important thing we must to know first. Every time we use Serialization, the object is "assigned" with the solution, module and structure name, so we can't send it through the solutions without update our formatter binder, otherwise the VS will return us a exception. Also, for structures that have his own modules (Like quests, pets, projectiles...) must have the SAME MODULE NAME, so you need to rename the ServerQuests to modQuests (Like the Editor and Client class) for example. Its important to note that this system is Sensitive Case, what mean that Upper and Lower cases makes difference. Some modules like modQuests starts with Uppercase on first letter (ModQuests) on Client, but starts with Lowercase on first letter (modQuests) on Editor (Thank you Damien666 you asshole i love you), so you need to check and rename those modules to have EXACTLY THE SAME NAME. To resolve that "assign" problem, we must rewrite the formatter binder by creating our own binder and overriding its bind method. So add ServerBinder.vb class on Server Public Class ServerBinder Inherits Runtime.Serialization.SerializationBinder Overrides Function BindToType(assemblyName As String, typeName As String) As Type assemblyName = assemblyName.Replace("Orion+ Client", "Orion+ Server") assemblyName = assemblyName.Replace("Editors", "Orion+ Server") Return Type.GetType(String.Format("{0}, {1}", typeName, assemblyName)) End Function End Class Add EditorsBinder.vb class on Editor Public Class EditorsBinder Inherits Runtime.Serialization.SerializationBinder Overrides Function BindToType(assemblyName As String, typeName As String) As Type assemblyName = assemblyName.Replace("Orion+ Server", "Editors") Return Type.GetType(String.Format("{0}, {1}", typeName, assemblyName)) End Function End Class Add ClientBinder.vb class on Client Public Class ClientBinder Inherits Runtime.Serialization.SerializationBinder Overrides Function BindToType(assemblyName As String, typeName As String) As Type assemblyName = assemblyName.Replace("Orion+ Server", "Orion+ Client") Return Type.GetType(String.Format("{0}, {1}", typeName, assemblyName)) End Function End Class Notes: If you changed your solutions Assembly Name on properties, you must replace them on this binder classes. After that, you must create Serialization.vb class for every solution JUST CHANGING ITS BINDER. Module Serialization Function Serialize(ByVal Entity As Object) As Byte() Dim formatter As New Runtime.Serialization.Formatters.Binary.BinaryFormatter() Using ms = New System.IO.MemoryStream() formatter.Serialize(ms, Entity) Return ms.GetBuffer() End Using End Function Public Sub Deserialize(ByRef Entity As Object, data As Byte()) Dim formatter = New Runtime.Serialization.Formatters.Binary.BinaryFormatter() Using ms = New System.IO.MemoryStream(data) formatter.Binder = New ClientBinder() 'CHANGE THIS BINDER FOR SERVER AND EDITOR Entity = formatter.Deserialize(ms) End Using End Sub Function SerializeData(Element As Object) As Byte() Dim buffer As New ASFW.ByteStream(4) Dim SerializedData As Byte() = Serialize(Element) buffer.WriteInt32(SerializedData.Length) buffer.WriteBlock(SerializedData) Return buffer.ToArray End Function Function DeserializeData(ByRef buffer As ASFW.ByteStream) As Object Dim byteCount As Integer = buffer.ReadInt32 Dim element As Object Deserialize(element, buffer.ReadBlock(byteCount)) Return element End Function End Module Serializing objects through network Now lets update the Send and Receive methods to correspond for our serialization system, for a first example we will use the Skill object, but you must to do these steps for every object you want to serialize on your game (such like Quests, Items, Npcs...) As i described about the methods order, the first method is SendGameData on Server, so lets begin our modifications. SendGameData uses a function for get objects data, named like ObjectsData as default, in our case SkillsData. That function makes a "for" instruction writing every Skill data in the buffer calling the SkillData function. So we don't even need to access Sub SendGameData or SkillsData, just modify SkillData function. For serialize our object on a buffer, we just need to call SerializeData(Object) function. Also you must remove whole old buffer code (leaving just skillnum in this case): Function SkillData before serialization: Function SkillData(skillnum As Integer) As Byte() Dim buffer As New ByteStream(4) buffer.WriteInt32(skillnum) buffer.WriteInt32(Skill(skillnum).AccessReq) buffer.WriteInt32(Skill(skillnum).AoE) buffer.WriteInt32(Skill(skillnum).CastAnim) buffer.WriteInt32(Skill(skillnum).CastTime) buffer.WriteInt32(Skill(skillnum).CdTime) buffer.WriteInt32(Skill(skillnum).ClassReq) buffer.WriteInt32(Skill(skillnum).Dir) buffer.WriteInt32(Skill(skillnum).Duration) buffer.WriteInt32(Skill(skillnum).Icon) buffer.WriteInt32(Skill(skillnum).Interval) buffer.WriteInt32(Skill(skillnum).IsAoE) buffer.WriteInt32(Skill(skillnum).LevelReq) buffer.WriteInt32(Skill(skillnum).Map) buffer.WriteInt32(Skill(skillnum).MpCost) buffer.WriteString((Skill(skillnum).Name)) buffer.WriteInt32(Skill(skillnum).Range) buffer.WriteInt32(Skill(skillnum).SkillAnim) buffer.WriteInt32(Skill(skillnum).StunDuration) buffer.WriteInt32(Skill(skillnum).Type) buffer.WriteInt32(Skill(skillnum).Vital) buffer.WriteInt32(Skill(skillnum).X) buffer.WriteInt32(Skill(skillnum).Y) buffer.WriteInt32(Skill(skillnum).IsProjectile) buffer.WriteInt32(Skill(skillnum).Projectile) buffer.WriteInt32(Skill(skillnum).KnockBack) buffer.WriteInt32(Skill(skillnum).KnockBackTiles) Return buffer.ToArray End Function Function SkillData after serialization: Function SkillData(skillnum As Integer) As Byte() Dim buffer As New ByteStream(4) buffer.WriteInt32(skillnum) buffer.WriteBlock(SerializeData(Skill(skillnum))) Return buffer.ToArray End Function Lets enjoy we are on Server now and just update the other methods too. When we receive a object from editor, it reaches the Packet_SaveSkill on ServerNetworkReceive module. As we want to serialize that data too, lets make the Deserialize process on it. To deserialize a object through network, just replace the old code by Object = DeserializeData(buffer). REMEMBER TO NOT REMOVE OBJECTNUM = BUFFER.READINT32 Packet_SaveSkill before serialization: Sub Packet_SaveSkill(index as integer, ByRef data() As Byte) Dim skillnum As Integer Dim buffer As New ByteStream(data) AddDebug("Recieved EMSG: SaveSkill") skillnum = Buffer.ReadInt32 ' Prevent hacking If skillnum < 0 OrElse skillnum > MAX_SKILLS Then Exit Sub Skill(skillnum).AccessReq = Buffer.ReadInt32() Skill(skillnum).AoE = Buffer.ReadInt32() Skill(skillnum).CastAnim = Buffer.ReadInt32() Skill(skillnum).CastTime = Buffer.ReadInt32() Skill(skillnum).CdTime = Buffer.ReadInt32() Skill(skillnum).ClassReq = Buffer.ReadInt32() Skill(skillnum).Dir = Buffer.ReadInt32() Skill(skillnum).Duration = Buffer.ReadInt32() Skill(skillnum).Icon = Buffer.ReadInt32() Skill(skillnum).Interval = Buffer.ReadInt32() Skill(skillnum).IsAoE = Buffer.ReadInt32() Skill(skillnum).LevelReq = Buffer.ReadInt32() Skill(skillnum).Map = Buffer.ReadInt32() Skill(skillnum).MpCost = Buffer.ReadInt32() Skill(skillnum).Name = Buffer.ReadString() Skill(skillnum).Range = Buffer.ReadInt32() Skill(skillnum).SkillAnim = Buffer.ReadInt32() Skill(skillnum).StunDuration = Buffer.ReadInt32() Skill(skillnum).Type = Buffer.ReadInt32() Skill(skillnum).Vital = Buffer.ReadInt32() Skill(skillnum).X = Buffer.ReadInt32() Skill(skillnum).Y = Buffer.ReadInt32() 'projectiles Skill(skillnum).IsProjectile = Buffer.ReadInt32() Skill(skillnum).Projectile = Buffer.ReadInt32() Skill(skillnum).KnockBack = Buffer.ReadInt32() Skill(skillnum).KnockBackTiles = Buffer.ReadInt32() ' Save it SendUpdateSkillToAll(skillnum) SaveSkill(skillnum) Addlog(GetPlayerLogin(Index) & " saved Skill #" & skillnum & ".", ADMIN_LOG) Buffer.Dispose() End Sub Packet_SaveSkill after serialization Sub Packet_SaveSkill(index As Integer, ByRef data() As Byte) Dim skillnum As Integer Dim buffer As New ByteStream(data) AddDebug("Recieved EMSG: SaveSkill") skillnum = buffer.ReadInt32 ' <- Keep dat xit ' Prevent hacking If skillnum < 0 OrElse skillnum > MAX_SKILLS Then Exit Sub Skill(skillnum) = DeserializeData(buffer) ' Save it SendUpdateSkillToAll(skillnum) SaveSkill(skillnum) Addlog(GetPlayerLogin(index) & " saved Skill #" & skillnum & ".", ADMIN_LOG) buffer.Dispose() End Sub As you can see, the Packet_SaveSkill calls the SendUpdateSkillToAll sub, also there is a SendUpdateSkillTo for send to a individual client, we must update those Subs too on ServerNetworkSend. For do that, you just need to replace the whole old code for buffer.WriteBlock(ObjectData(objectnum)). Since we already serialized the object on that function, we don't need to serialize it again. For our case, we use buffer.WriteBlock(SkillData(skillnum)). Remember to do that for both SendUpdateSkillTo and SendUpdateSkillToAll!. SendUpdateSkillToAll and SendUpdateSkillTo before serialization Sub SendUpdateSkillTo(index As Integer, skillnum As Integer) Dim buffer As ByteStream buffer = New ByteStream(4) buffer.WriteInt32(ServerPackets.SUpdateSkill) buffer.WriteInt32(skillnum) buffer.WriteInt32(Skill(skillnum).AccessReq) buffer.WriteInt32(Skill(skillnum).AoE) buffer.WriteInt32(Skill(skillnum).CastAnim) buffer.WriteInt32(Skill(skillnum).CastTime) buffer.WriteInt32(Skill(skillnum).CdTime) buffer.WriteInt32(Skill(skillnum).ClassReq) buffer.WriteInt32(Skill(skillnum).Dir) buffer.WriteInt32(Skill(skillnum).Duration) buffer.WriteInt32(Skill(skillnum).Icon) buffer.WriteInt32(Skill(skillnum).Interval) buffer.WriteInt32(Skill(skillnum).IsAoE) buffer.WriteInt32(Skill(skillnum).LevelReq) buffer.WriteInt32(Skill(skillnum).Map) buffer.WriteInt32(Skill(skillnum).MpCost) buffer.WriteString((Trim(Skill(skillnum).Name))) buffer.WriteInt32(Skill(skillnum).Range) buffer.WriteInt32(Skill(skillnum).SkillAnim) buffer.WriteInt32(Skill(skillnum).StunDuration) buffer.WriteInt32(Skill(skillnum).Type) buffer.WriteInt32(Skill(skillnum).Vital) buffer.WriteInt32(Skill(skillnum).X) buffer.WriteInt32(Skill(skillnum).Y) AddDebug("Sent SMSG: SUpdateSkill") 'projectiles buffer.WriteInt32(Skill(skillnum).IsProjectile) buffer.WriteInt32(Skill(skillnum).Projectile) buffer.WriteInt32(Skill(skillnum).KnockBack) buffer.WriteInt32(Skill(skillnum).KnockBackTiles) Socket.SendDataTo(index, buffer.Data, buffer.Head) buffer.Dispose() End Sub Sub SendUpdateSkillToAll(skillnum As Integer) Dim buffer As ByteStream buffer = New ByteStream(4) buffer.WriteInt32(ServerPackets.SUpdateSkill) buffer.WriteInt32(skillnum) buffer.WriteInt32(Skill(skillnum).AccessReq) buffer.WriteInt32(Skill(skillnum).AoE) buffer.WriteInt32(Skill(skillnum).CastAnim) buffer.WriteInt32(Skill(skillnum).CastTime) buffer.WriteInt32(Skill(skillnum).CdTime) buffer.WriteInt32(Skill(skillnum).ClassReq) buffer.WriteInt32(Skill(skillnum).Dir) buffer.WriteInt32(Skill(skillnum).Duration) buffer.WriteInt32(Skill(skillnum).Icon) buffer.WriteInt32(Skill(skillnum).Interval) buffer.WriteInt32(Skill(skillnum).IsAoE) buffer.WriteInt32(Skill(skillnum).LevelReq) buffer.WriteInt32(Skill(skillnum).Map) buffer.WriteInt32(Skill(skillnum).MpCost) buffer.WriteString((Skill(skillnum).Name)) buffer.WriteInt32(Skill(skillnum).Range) buffer.WriteInt32(Skill(skillnum).SkillAnim) buffer.WriteInt32(Skill(skillnum).StunDuration) buffer.WriteInt32(Skill(skillnum).Type) buffer.WriteInt32(Skill(skillnum).Vital) buffer.WriteInt32(Skill(skillnum).X) buffer.WriteInt32(Skill(skillnum).Y) AddDebug("Sent SMSG: SUpdateSkill To All") 'projectiles buffer.WriteInt32(Skill(skillnum).IsProjectile) buffer.WriteInt32(Skill(skillnum).Projectile) buffer.WriteInt32(Skill(skillnum).KnockBack) buffer.WriteInt32(Skill(skillnum).KnockBackTiles) SendDataToAll(buffer.Data, buffer.Head) buffer.Dispose() End Sub SendUpdateSkillToAll and SendUpdateSkillTo after serialization Sub SendUpdateSkillTo(index As Integer, skillnum As Integer) Dim buffer As ByteStream buffer = New ByteStream(4) buffer.WriteInt32(ServerPackets.SUpdateSkill) buffer.WriteBlock(SkillData(skillnum)) Socket.SendDataTo(index, buffer.Data, buffer.Head) buffer.Dispose() End Sub Sub SendUpdateSkillToAll(skillnum As Integer) Dim buffer As ByteStream buffer = New ByteStream(4) buffer.WriteInt32(ServerPackets.SUpdateSkill) buffer.WriteBlock(SkillData(skillnum)) SendDataToAll(buffer.Data, buffer.Head) buffer.Dispose() End Sub Now we are done with de Server, lets begin the Editors process. The difference between Editors and Client, is that we can send objects for Server. So lets start with the Editor Side by modifing the SendSaveSkill method on modNetworkSend. To update that method, keep the "objectnum" buffer writing and just replace the whole old code for buffer.WriteBlock(SerializeData(Object(objectnum))). in our case is buffer.WriteBlock(SerializeData(Skill(skillnum))). SendSaveSkill before serialization Friend Sub SendSaveSkill(skillnum As Integer) Dim buffer As New ByteStream(4) buffer.WriteInt32(EditorPackets.SaveSkill) buffer.WriteInt32(skillnum) buffer.WriteInt32(Skill(skillnum).AccessReq) buffer.WriteInt32(Skill(skillnum).AoE) buffer.WriteInt32(Skill(skillnum).CastAnim) buffer.WriteInt32(Skill(skillnum).CastTime) buffer.WriteInt32(Skill(skillnum).CdTime) buffer.WriteInt32(Skill(skillnum).ClassReq) buffer.WriteInt32(Skill(skillnum).Dir) buffer.WriteInt32(Skill(skillnum).Duration) buffer.WriteInt32(Skill(skillnum).Icon) buffer.WriteInt32(Skill(skillnum).Interval) buffer.WriteInt32(Skill(skillnum).IsAoE) buffer.WriteInt32(Skill(skillnum).LevelReq) buffer.WriteInt32(Skill(skillnum).Map) buffer.WriteInt32(Skill(skillnum).MpCost) buffer.WriteString((Skill(skillnum).Name)) buffer.WriteInt32(Skill(skillnum).Range) buffer.WriteInt32(Skill(skillnum).SkillAnim) buffer.WriteInt32(Skill(skillnum).StunDuration) buffer.WriteInt32(Skill(skillnum).Type) buffer.WriteInt32(Skill(skillnum).Vital) buffer.WriteInt32(Skill(skillnum).X) buffer.WriteInt32(Skill(skillnum).Y) buffer.WriteInt32(Skill(skillnum).IsProjectile) buffer.WriteInt32(Skill(skillnum).Projectile) buffer.WriteInt32(Skill(skillnum).KnockBack) buffer.WriteInt32(Skill(skillnum).KnockBackTiles) Socket.SendData(buffer.Data, buffer.Head) buffer.Dispose() End Sub SendSaveSkill after serialization Friend Sub SendSaveSkill(skillnum As Integer) Dim buffer As New ByteStream(4) buffer.WriteInt32(EditorPackets.SaveSkill) buffer.WriteInt32(skillnum) ' <- Keep dat xit buffer.WriteBlock(SerializeData(Skill(skillnum))) Socket.SendData(buffer.Data, buffer.Head) buffer.Dispose() End Sub Now we must update the object receiving on GameData and UpdateObject methods. They're found on Client and Editors, so you must make these steps FOR BOTH. Go to ClientNetworkReceive (or modNetworkReceive on Editors) and find Packet_GameData sub. After that, you must find you object specific data reading section. In our case, its Skills data: '\\\Read Skills Data\\\\\\\\\\ x = Buffer.ReadInt32 For i = 1 To x n = Buffer.ReadInt32 Skill(n).AccessReq = Buffer.ReadInt32() Skill(n).AoE = Buffer.ReadInt32() Skill(n).CastAnim = Buffer.ReadInt32() Skill(n).CastTime = Buffer.ReadInt32() Skill(n).CdTime = Buffer.ReadInt32() Skill(n).ClassReq = Buffer.ReadInt32() Skill(n).Dir = Buffer.ReadInt32() Skill(n).Duration = Buffer.ReadInt32() Skill(n).Icon = Buffer.ReadInt32() Skill(n).Interval = Buffer.ReadInt32() Skill(n).IsAoE = Buffer.ReadInt32() Skill(n).LevelReq = Buffer.ReadInt32() Skill(n).Map = Buffer.ReadInt32() Skill(n).MpCost = Buffer.ReadInt32() Skill(n).Name = Trim(Buffer.ReadString()) Skill(n).Range = Buffer.ReadInt32() Skill(n).SkillAnim = Buffer.ReadInt32() Skill(n).StunDuration = Buffer.ReadInt32() Skill(n).Type = Buffer.ReadInt32() Skill(n).Vital = Buffer.ReadInt32() Skill(n).X = Buffer.ReadInt32() Skill(n).Y = Buffer.ReadInt32() Skill(n).IsProjectile = Buffer.ReadInt32() Skill(n).Projectile = Buffer.ReadInt32() Skill(n).KnockBack = Buffer.ReadInt32() Skill(n).KnockBackTiles = Buffer.ReadInt32() If Skill(n).Name Is Nothing Then Skill(n).Name = "" Next Like other examples, just replace the whole old code setting by Object = DeserializeData(buffer), in our case is Skill(n) = DeserializeData(buffer). '\\\Read Skills Data\\\\\\\\\\ x = buffer.ReadInt32 For i = 1 To x n = buffer.ReadInt32 ' <- Dont forget to keep dat xit Skill(n) = DeserializeData(buffer) If Skill(n).Name Is Nothing Then Skill(n).Name = "" Next i = 0 x = 0 n = 0 z = 0 '\\\End Read Skills Data\\\\\\\\\\ And for last, we must update the Packet_UpdateSkill located on the same module. Just keep the same logic, you don't need to remove the objectnum = Buffer.ReadInt32 line, just the old code related to data reading. Like this: Packet_UpdateSkill before serialization Private Sub Packet_UpdateSkill(ByRef data() As Byte) Dim skillnum As Integer dim buffer as New ByteStream(Data) skillnum = Buffer.ReadInt32 Skill(skillnum).AccessReq = Buffer.ReadInt32() Skill(skillnum).AoE = Buffer.ReadInt32() Skill(skillnum).CastAnim = Buffer.ReadInt32() Skill(skillnum).CastTime = Buffer.ReadInt32() Skill(skillnum).CdTime = Buffer.ReadInt32() Skill(skillnum).ClassReq = Buffer.ReadInt32() Skill(skillnum).Dir = Buffer.ReadInt32() Skill(skillnum).Duration = Buffer.ReadInt32() Skill(skillnum).Icon = Buffer.ReadInt32() Skill(skillnum).Interval = Buffer.ReadInt32() Skill(skillnum).IsAoE = Buffer.ReadInt32() Skill(skillnum).LevelReq = Buffer.ReadInt32() Skill(skillnum).Map = Buffer.ReadInt32() Skill(skillnum).MpCost = Buffer.ReadInt32() Skill(skillnum).Name = Trim(Buffer.ReadString()) Skill(skillnum).Range = Buffer.ReadInt32() Skill(skillnum).SkillAnim = Buffer.ReadInt32() Skill(skillnum).StunDuration = Buffer.ReadInt32() Skill(skillnum).Type = Buffer.ReadInt32() Skill(skillnum).Vital = Buffer.ReadInt32() Skill(skillnum).X = Buffer.ReadInt32() Skill(skillnum).Y = Buffer.ReadInt32() Skill(skillnum).IsProjectile = Buffer.ReadInt32() Skill(skillnum).Projectile = Buffer.ReadInt32() Skill(skillnum).KnockBack = Buffer.ReadInt32() Skill(skillnum).KnockBackTiles = Buffer.ReadInt32() If Skill(skillnum).Name Is Nothing Then Skill(skillnum).Name = "" Buffer.Dispose() End Sub Packet_UpdateSkill after serialization Private Sub Packet_UpdateSkill(ByRef data() As Byte) Dim skillnum As Integer Dim buffer As New ByteStream(data) skillnum = buffer.ReadInt32 ' <- Keep dat xit again Skill(skillnum) = DeserializeData(buffer) If Skill(skillnum).Name Is Nothing Then Skill(skillnum).Name = "" buffer.Dispose() End Sub WHOOOOOOOA THATS IT! WE'RE DONE! Well, at this point all your Skills must be correctly serializated through network packets. As it only virtual communication, you don't need to erase your existing skills on database. Notes: As serialization allocate every field in bytes, your packets should get bigger than usual, but nothing so huge. As always, any problems related or question you can send me a PM or leave a comment on this post. Thank you and til next time!. If i was useful, feel free to make a donation!
  2. boasfesta

    Data Serialization (Storage)

    Objective: Serialize all objects for storage Difficulty: Advanced Hello guys! As you know, Orion+ doesn't have object serialization implemented by default, what makes us to update a number of methods every time we add a new field on any object. Since you get here i suppose you're a advanced programmer and you know what serialization means, but if don't: In practice means you don't need to update Send/Get/Save/Load methods every time you add a new field to your object (Like a Skill level on SkillRec for example), with this system you do those things automatically by manipulating your data in bits. If you want to know more about serialization, read this article on Wikipedia. A new Orion+ user doesn't need to care about serialization, since everything works exactly the same on game. But if you're a expert user i think it would be very useful, so i'll gonna make this tutorial assuming you already know how to code. In case of any problems or questions sent me a PM. Preparing your code for Serialization Before starting this tutorial steps, you must mark all your desired structure types as serializable, you can do this by adding <Serializable()> before the structure declaration, like this: <Serializable()> Friend Structure ResourceSkillsRec Dim SkillLevel As Integer Dim SkillCurExp As Integer Dim SkillNextLvlExp As Integer End Structure Notes: Structures inside other structures also must be marked as serializable. Storage Serialization Let's start with easy part first, in this section we will serialize our objects on Save and Load methods. Notes: Complex and huge Datas like Maps should'nt be serialized, since serialization process allocate too much bytes. All your database must be deleted before serialize your storage methods, or you can convert it on your own. ~Server Side Open ServerDatabase.vb and add this region above End Module #Region "Serialization" Sub LoadObject(ByRef Element As Object, ByVal Filename As String) Dim stream As FileStream Dim formatter As New Runtime.Serialization.Formatters.Binary.BinaryFormatter() stream = File.OpenRead(Filename) Element = formatter.Deserialize(stream) stream.Close() End Sub Sub SaveObject(ByVal Element As Object, ByVal Filename As String) Dim stream As FileStream = File.Create(Filename) Dim formatter As New Runtime.Serialization.Formatters.Binary.BinaryFormatter() formatter.Serialize(stream, Element) stream.Close() End Sub #End Region For every Save method you must remove the ByteStream related codes, leaving just the Filename variable. After that, use SaveObject(Object, Filename) method to serialize your object. Here is a little example using Skill: Before method (without serialization) Sub SaveSkill(skillnum As Integer) Dim filename As String filename = Path.Combine(Application.StartupPath, "data", "skills", String.Format("skills{0}.dat", skillnum)) Dim writer As New ByteStream(100) writer.WriteString(Skill(skillnum).Name) writer.WriteByte(Skill(skillnum).Type) writer.WriteInt32(Skill(skillnum).MpCost) writer.WriteInt32(Skill(skillnum).LevelReq) writer.WriteInt32(Skill(skillnum).AccessReq) writer.WriteInt32(Skill(skillnum).ClassReq) writer.WriteInt32(Skill(skillnum).CastTime) writer.WriteInt32(Skill(skillnum).CdTime) writer.WriteInt32(Skill(skillnum).Icon) writer.WriteInt32(Skill(skillnum).Map) writer.WriteInt32(Skill(skillnum).X) writer.WriteInt32(Skill(skillnum).Y) writer.WriteByte(Skill(skillnum).Dir) writer.WriteInt32(Skill(skillnum).Vital) writer.WriteInt32(Skill(skillnum).Duration) writer.WriteInt32(Skill(skillnum).Interval) writer.WriteInt32(Skill(skillnum).Range) writer.WriteBoolean(Skill(skillnum).IsAoE) writer.WriteInt32(Skill(skillnum).AoE) writer.WriteInt32(Skill(skillnum).CastAnim) writer.WriteInt32(Skill(skillnum).SkillAnim) writer.WriteInt32(Skill(skillnum).StunDuration) writer.WriteInt32(Skill(skillnum).IsProjectile) writer.WriteInt32(Skill(skillnum).Projectile) writer.WriteByte(Skill(skillnum).KnockBack) writer.WriteByte(Skill(skillnum).KnockBackTiles) BinaryFile.Save(filename, writer) End Sub After method (using serialization): Sub SaveSkill(skillnum As Integer) Dim filename As String filename = Path.Combine(Application.StartupPath, "data", "skills", String.Format("skills{0}.dat", skillnum)) SaveObject(Skill(skillnum), filename) End Sub Also you must update the Load methods. The process is almost the same, but use LoadObject(Object, filename) instead. Here is another example with Skill again: Before method (without serialization): Sub LoadSkill(SkillNum As Integer) Dim filename As String filename = Path.Combine(Application.StartupPath, "data", "skills", String.Format("skills{0}.dat", SkillNum)) Dim reader As New ByteStream() BinaryFile.Load(filename, reader) Skill(SkillNum).Name = reader.ReadString() Skill(SkillNum).Type = reader.ReadByte() Skill(SkillNum).MpCost = reader.ReadInt32() Skill(SkillNum).LevelReq = reader.ReadInt32() Skill(SkillNum).AccessReq = reader.ReadInt32() Skill(SkillNum).ClassReq = reader.ReadInt32() Skill(SkillNum).CastTime = reader.ReadInt32() Skill(SkillNum).CdTime = reader.ReadInt32() Skill(SkillNum).Icon = reader.ReadInt32() Skill(SkillNum).Map = reader.ReadInt32() Skill(SkillNum).X = reader.ReadInt32() Skill(SkillNum).Y = reader.ReadInt32() Skill(SkillNum).Dir = reader.ReadByte() Skill(SkillNum).Vital = reader.ReadInt32() Skill(SkillNum).Duration = reader.ReadInt32() Skill(SkillNum).Interval = reader.ReadInt32() Skill(SkillNum).Range = reader.ReadInt32() Skill(SkillNum).IsAoE = reader.ReadBoolean() Skill(SkillNum).AoE = reader.ReadInt32() Skill(SkillNum).CastAnim = reader.ReadInt32() Skill(SkillNum).SkillAnim = reader.ReadInt32() Skill(SkillNum).StunDuration = reader.ReadInt32() Skill(SkillNum).IsProjectile = reader.ReadInt32() Skill(SkillNum).Projectile = reader.ReadInt32() Skill(SkillNum).KnockBack = reader.ReadByte() Skill(SkillNum).KnockBackTiles = reader.ReadByte() End Sub After method (with serialization): Sub LoadSkill(SkillNum As Integer) Dim filename As String filename = Path.Combine(Application.StartupPath, "data", "skills", String.Format("skills{0}.dat", SkillNum)) LoadObject(Skill(SkillNum), filename) End Sub With this code replaced on your Load and Save methods, all your objects will be automatically serializeds and you don't need to update them anymore when a new field is added on structure. Notes: Serialization allocate all your fields in bytes, even if they values is zero or null, so your files should get a little bigger. For that reason, huge and complex data should'nt be serialized like i said before, such like maps and map events, also they're dinamically saved and loaded using less memory on actual Orion+ version. Every time you add a new field you must insert it ON THE END of your structure, so you won't need to delete your saved objects again. Changing a array size in your structure (unless it is the last element) forces you to delete all your saved objects or convert it for your new structure. Anyway, this is a new system i implemented on my project and work aswell. Any problems related will be fixed and notified on this tutorial, so stay tuned. Again, any problems you can send me a PM or leave a comment on this post. If you want to continue serializing your objects through network, check out the second part of this tutorial! If i was useful, feel free to donate!
  3. boasfesta

    Server Manager

    How strange, it works perfect for me, ill check it with other devices If any 1 get more messages, notify here please
  4. boasfesta

    Server Manager

    Did you test it with internet access? Its 3G or Wi fi?
  5. boasfesta

    Auto Mapper

    You can just access the Orion source code, not Intersect :/ Anyway check your Resource Frequency on map editor configs, a higher number means less resources. (I think i made it inverted, dont remember) It only make islands actually, for future releases i want to make dungeons and similar things. If you dont want a island you can just block the beachs warps and it works hahaha
  6. boasfesta

    Server Manager

    What version it is? And what message you get?
  7. boasfesta

    Server Manager

    Wow awesome! Soon i'll release the source so you can use it for Intersect if you want! It will be a pleasure to help
  8. boasfesta

    Auto Mapper

    Sorry for the late answer. Did you config the resources used by the Automapper in the editor? Also, did you used the Damian adaptation for Orion or you adapted the code by yourself?
  9. boasfesta

    Server Manager

    Hello developers! Some days ago i wanna try my Java skills, so i made this. For any engine you use, or any gender of game you make, there is always problem when you release a game: Anytime your server can crash, and in the worst situation, you're not at home. You cant leave your players alone, and you cant close the game without seeing that error message for fixing it later. Sure you can use Team Viewer, but in some cases you don't have much internet speed or limit (Cause Team Viewer consume it a lot). So to resolve that, i've made an app for android that can check your server status, and also restart it if doesn't, using low internet costs. Here is the Server Manager! Releases Version 1.0 Download How to use Extract the rar file on your server folder Open the config.ini file Configure the executable name and put your server port Open the Server Manager.bat Enter the Server Manager App folder Send the apk for your android device Install it Configure with your connection information Patch Notes Version 1.0 Check server status button Restart server button Screenshots If you like it, leave a comment with suggestions for future releases! If you love it, Make a donation!
  10. boasfesta

    Dragonball Z: Resurrection Online! [Now Recruiting]

    hahahah Im very greateful for that! I just didnt recognize your nickname, sorry
  11. boasfesta

    Dragonball Z: Resurrection Online! [Now Recruiting]

    @LegendarySaiyanMan There is no problem for you to use my videos for showing your future systems, i just wanted to be noticed before hahahha Anyway, if you could just add and a little credit mark it would be good for both of us, since the topic shows that game is an different one haha. Im here for anything you need
  12. boasfesta

    Automapper System Sourcecode (VB6)

    It would steal my job, and robots can rule the world! Sure Will Smith won't like that.
  13. boasfesta

    Automapper System Sourcecode (VB6)

    Next objective: Autogame System hahaha I think it would be a exciting system to develop, like selecting item graphics and giving rarity to them, so the program make equipments for every class along the levels updating its data to be stronger and selecting its graphic based on rarities, same for npcs...OH NO! MAKE IT STOP I DONT WANT TO DO THAT!
  14. boasfesta

    Automapper System Sourcecode (VB6)

    Sure! I sent you a PM
  15. boasfesta

    Automapper System Sourcecode (VB6)

    Well so there is something different in Orion autotile system, i will install VB.NET on my pc and check it out @jcsnider@Kibbelz if you guys want to add the automapper system to Intersect i can make a conversion to C#, so it won't waste your time working on a done system and you can work in new ones. Will be good to help me study it and will be a honor have my system on a official Intersect release
×