[EO 3.0] Data File Conversions

So, basically I got a bit fed up with my limited space for map names, item names, and such. I wanted to extend it; but I already have a good bit of work poured into mapping/making items/resources, the works.

Bear in mind I am no experienced programmer; the most I’ve really done with these engines is that old SadScript nonsense, and the most I’ve done programming in general is some program assignments in my college classes, none of which were really advanced. EO is my first time actually handling vb6, and I’m learning as I go here along with doing some researching online.

So yes, if I change NAME_LENGTH in modConstants (server & client) from 20 to say… 50, I’d have to convert my stuff, since I really want to shy away from deleting all of it (if possible) and learn how to actually convert it in case I potentially change anything else in the future.

Where exactly would I start with this?

Use both UDTs, the old one and the new one. Load a data file with the old UDT and just assign the values to the new UDT and save it.

NewUDT.Name = OldUDT.Name

Alright, I understand the gist of it then, but I’m gonna need more info. My experience with this is… very basic (I tend to be bad with syntax).

I’m assuming this would be done as the server loads the files? I’m looking at how it loads things and I’m not really too sure where to go with it.

I’ve already made backups in case anything goes wrong, but I don’t really wanna play russian roulette with it and end up not completely understanding how it works.

I’m writing you up an example. ^_^ Sit tight!

EDIT: Alright. Here’s the converter. Let me know if you have any questions!

Awesome, that helps a lot. I have an understanding as to how exactly this works.

But I do have some questions; specifically, what values would I use? I’m gonna be converting both .bin (accounts and such) and .dat (maps, items, NPCs) files to accomodate for the new size of NAME_LENGTH.

Would I simply alter the code depending on the file I’m converting? (I figured this since you mentioned MAX_VALUE can be made to be anything I change).

I apologize for not really having a grasp on it (and for the late response), but I’m really trying here. This has been immensely helpful so far.

Awesome, that helps a lot. I have an understanding as to how exactly this works.

But I do have some questions; specifically, what values would I use? I’m gonna be converting both .bin (accounts and such) and .dat (maps, items, NPCs) files to accomodate for the new size of NAME_LENGTH.

Would I simply alter the code depending on the file I’m converting? (I figured this since you mentioned MAX_VALUE can be made to be anything I change).

I apologize for not really having a grasp on it (and for the late response), but I’m really trying here. This has been immensely helpful so far.

No worries at all! I enjoy teaching those who are willing to learn at every level!

If you’re going to convert your data, you need to bring in all the constants (found in modConstants) and enumerations (found in modEnumerations) your UDT uses.

NAME_LENGTH is a constant whose only use is to represent how many characters a string variable can hold.


Example as string * NAME_LENGTH

This poses a slight problem because you need this constant to stay the same for loading, but increase on saving. The easiest thing to do is just make an extra constant anywhere in the code with the desired value you want. Then in the UDT that is to hold the converted data, change NAME_LENGTH to the name of the new variable.

Let me know if that helps, and if you need me to explain anything else ^_^

It was all helpful, thank you.

So, lets for example, say I wanted to update my maps to the new NAME_LENGTH constant.

I would just bring in everything under this:


' Map constants
Public Const MAX_MAPS As Long = 900
Public Const MAX_MAPX As Byte = 50
Public Const MAX_MAPY As Byte = 50
Public Const MAP_MORAL_NONE As Byte = 0
Public Const MAP_MORAL_SAFE As Byte = 1
Public Const MAP_MORAL_ARENA As Byte = 2

from modConstants?

From modEnumerations though, I’m not really sure what to look for.

As for changing NAME_LENGTH itself; I’m not really sure where to go with that either. So I would essentially change the new UDT’s NAME_LENGTH definition equal to 50, and then changing it to 50 on the server/client side so it matches up? Or would I have to use a variable (call it lengthvalue) and set that equal to 50, then change the new UDT to have a variable called lengthvalue equal to 50?

Using your converter example, would it look something like this?


' States that UDT_Old is the beginning of the structure. The continuation is UDT_OldRec.
' This is what the old UDT should be. We'll be loading the data and putting it in this structure
Public UDT_Old(1 To MAX_VALUE) As UDT_OldRec

Private Type UDT_OldRec
Public Const MAX_MAPS As Long = 900
Public Const MAX_MAPX As Byte = 50
Public Const MAX_MAPY As Byte = 50
Public Const MAP_MORAL_NONE As Byte = 0
Public Const MAP_MORAL_SAFE As Byte = 1
Public Const MAP_MORAL_ARENA As Byte = 2
End Type

' States that UDT_New is the beginning of the structure. The continuation is UDT_NewRec.
' We'll be transfering all the data we loaded to this structure. Note there's an extra variable called "Value3".
Public UDT_New(1 To MAX_VALUE) As UDT_NewRec

Private Type UDT_NewRec
Public Const MAX_MAPS As Long = 900
Public Const MAX_MAPX As Byte = 50
Public Const MAX_MAPY As Byte = 50
Public Const MAP_MORAL_NONE As Byte = 0
Public Const MAP_MORAL_SAFE As Byte = 1
Public Const MAP_MORAL_ARENA As Byte = 2
lengthvalue as Byte
End Type

I don’t think you understand what public constants do, which is okay! ^_^ I’ll be happy to teach you.

Something you’ll see quite often in programming are the words “Public” and “Private”. These generally state that whatever they’re associated with, whether it’s a variable or sub of code, is going to be either public or private. Something that’s public is accessible everywhere throughout the project, and something that’s private is only accessible inside that module, or form, etc.

A constant in programming is like a variable that never changes, which gives it the name “Constant”. The value of it never changes. So, if we want to declare a variable, all we have to do is place in a module and outside of any sub or function. You found constants that indeed were necessary to use in the converter, but you put them in the wrong place. If you look near the top of modTypes, you’ll see I already declared a constant called MAX_VALUE. You can replace MAX_VALUE with all the constants you mentioned earlier. Your modTypes should look something like this.


' The max value of the index. Replace this value with whatever index you need. Like, MAX_MAPS.
Public Const MAX_MAPS As Long = 900
Public Const MAX_MAPX As Byte = 50
Public Const MAX_MAPY As Byte = 50
Public Const MAP_MORAL_NONE As Byte = 0
Public Const MAP_MORAL_SAFE As Byte = 1
Public Const MAP_MORAL_ARENA As Byte = 2

' States that UDT_Old is the beginning of the structure. The continuation is UDT_OldRec.
' This is what the old UDT should be. We'll be loading the data and putting it in this structure
Public UDT_Old(1 To MAX_VALUE) As UDT_OldRec

Private Type UDT_OldRec
    Value1 As Long
    Value2 As Long
End Type

' States that UDT_New is the beginning of the structure. The continuation is UDT_NewRec.
' We'll be transfering all the data we loaded to this structure. Note there's an extra variable called "Value3".
Public UDT_New(1 To MAX_VALUE) As UDT_NewRec

Private Type UDT_NewRec
    Value1 As Long
    Value2 As Long
    Value3 As Long
End Type

You’ll also want to replace the old types I have there with your map types. Ideally, it’d be nice for you to understand how User Defined Types work. If you already do, then just skip this bit. In other programming languages, they are commonly refereed to as a more appropriate name: Structures.

A structure is a dynamic system of variables joined under at one grouping name. It’s the core of storing data on Eclipse. For example, if you want to find the name of a player who is online, you would type out something like this.


Player(1).Name

Why do we have the 1 there? Well, because the server holds data for many players who are online. So, imagine it like this.


Player(Which one?).Name

Why is the period there? Imagine it like the folder system on your computer. The period acts in the same way as the slashes do for paths to files on your computer. We’re entering the “Player” folder and accessing the “files” inside which in this case are variables.

In modTypes in the example,  you see the statement


Public UDT_Old(1 to MAX_VALUE) as UDT_OldRec

This basically says that whenever you type out “UDT_Old” in your code, you’re referring to that structure. If you look just a bit further down, you’ll see


Private Type UDT_OldRec
    Value1 As Long
    Value2 As Long
End Type

This is the actual structure. This is what’s inside the UDT_Old “folder”.

So, you’ll want to replace the Structure declaration with the Type you want to use, such as Maps. It should look something like this


Public Map(1 to MAX_MAPS) as MapRec

And as for the actual structure, you should find it in your server’s source. It’s most probably under the name MapRec.

Keep in mind that you can have types inside your type. If you see something inside your ItemRec structure that’s referring to another Rec, you’ll want to copy that type into your source as well. For example,


Public Item(1 To MAX_ITEMS) As ItemRec

Private Type ExampleRec
    Value As Long
End Type

Private Type ItemRec
    Example As ExampleRec
End Type

Hope that’s not too confusing, and helped somehow. Let me know if you need more help! ^_^

I think I have a fair understanding of what to do now. I’m gonna give it a shot and attempt to get it to work.

Thanks for all the help! I’ll be sure to ask if I need anything else.

Glad to help! Let me know how it goes!

Log in to reply