Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Changing Map Name Length (SOLVED)


Kimimaru
 Share

Recommended Posts

This is what I've done so far:

I've created another MapRec, MapRecA. This is what it looks like in my **ModTypes** right now:

```
Type MapRec
    Name As String * 20
    Revision As Integer
    Moral As Byte
    Up As Integer
    Down As Integer
    Left As Integer
    Right As Integer
    music As String
    BootMap As Integer
    BootX As Byte
    BootY As Byte
    Shop As Integer
    Indoors As Byte
    Tile() As TileRec
    Npc(1 To 15) As Integer
    SpawnX(1 To 15) As Byte
    SpawnY(1 To 15) As Byte
    owner As String
    scrolling As Byte
    Weather As Integer
End Type

Type MapRecA
    Name As String * 50
    Revision As Integer
    Moral As Byte
    Up As Integer
    Down As Integer
    Left As Integer
    Right As Integer
    music As String
    BootMap As Integer
    BootX As Byte
    BootY As Byte
    Shop As Integer
    Indoors As Byte
    Tile() As TileRec
    Npc(1 To 15) As Integer
    SpawnX(1 To 15) As Byte
    SpawnY(1 To 15) As Byte
    owner As String
    scrolling As Byte
    Weather As Integer
End Type
```
I think I know what you mean by the second part of your post, but I'm not exactly sure. Can you please explain the loading, converting, and saving in more detail? I think I know what you're saying, but I want to confirm it.
Link to comment
Share on other sites

> Basically, load each map one by one.

I hope you meant: load old map > make new rec > clean old map > save new map > clean new map > go back to load old map.

It's just going through the two structures and setting each variable/element.

Like:
```
Map.Name = OldMap.Name
Map.Revision = OldMap.Revision
Map.Moral = OldMap.Moral
Map.Up = OldMap.Up
' etc.
```

Regards,
  Godlord.
Link to comment
Share on other sites

@Godlord:

> I hope you meant: load old map > make new rec > clean old map > save new map > clean new map > go back to load old map.
>
> It's just going through the two structures and setting each variable/element.
>
> Like:
> ```
> Map.Name = OldMap.Name
> Map.Revision = OldMap.Revision
> Map.Moral = OldMap.Moral
> Map.Up = OldMap.Up
> ' etc.
> ```
>
> Regards,
>   Godlord.

Okay, thanks guys, but I'm still a little confused. Should I create a new MapRec in both the Client and Server? Also, what do you mean by "loading the old map"? Do I just go on it in the Client? Additionally, where would I put the code that you're telling me to use?
Link to comment
Share on other sites

Fixed length strings just for easier saving is lazy.

Don't dump the UDT into a .bin file for the lulz, do it line-by-line.

```
' Read string length
Get #nFileNum, , sLen
' Set string size, then read string
STRING = Space$(sLen)
Get #nFileNum, , STRING

```
```
' Store string size for variable length
Put #nFileNum, , CLng(Len(STRING))
' Store string
Put #nFileNum, , STRING

```
Link to comment
Share on other sites

@Robin:

> Fixed length strings just for easier saving is lazy.
>
> Don't dump the UDT into a .bin file for the lulz, do it line-by-line.
>
> ```
> ' Read string length
> Get #nFileNum, , sLen
> ' Set string size, then read string
> STRING = Space$(sLen)
> Get #nFileNum, , STRING
>
> ```
> ```
> ' Store string size for variable length
> Put #nFileNum, , CLng(Len(STRING))
> ' Store string
> Put #nFileNum, , STRING
>
> ```

Or actually write a file format so it's actually cross-platform and easily modifiable.

@Kimimaru:

> Okay, thanks guys, but I'm still a little confused. Should I create a new MapRec in both the Client and Server? Also, what do you mean by "loading the old map"? Do I just go on it in the Client? Additionally, where would I put the code that you're telling me to use?

Your old maps are the maps with the 20 as length, your new maps will be the maps with the 50 as name length.

Regards,
  Godlord.
Link to comment
Share on other sites

@Godlord:

> Or actually write a file format so it's actually cross-platform and easily modifiable.

Yeah, because cross-platform file formats are really important in **Visual Basic** projects. ;P

I was just pointing out how people can write a binary system without having to fuck around with fixed-length strings all the time.
Link to comment
Share on other sites

@Godlord:

> Or actually write a file format so it's actually cross-platform and easily modifiable.
> Your old maps are the maps with the 20 as length, your new maps will be the maps with the 50 as name length.
>
> Regards,
>   Godlord.

Well, I know that, but I don't believe you answered any of my questions.
Link to comment
Share on other sites

@Robin:

> Yeah, because cross-platform file formats are really important in **Visual Basic** projects. ;P

If you're ever going to port it and you forgot something:
@Godlord:

> Or actually write a file format so it's actually cross-platform and **easily modifiable**.

Also it supports older and newer versions if done well. So no, it's not only for cross-platform usage.

@Kimimaru:

> Well, I know that, but I don't believe you answered any of my questions.

It's really obvious though. You only need to know how to read binary files, write them and how to use "Type" or structures.

Regards,
  Godlord.
Link to comment
Share on other sites

@Robin:

> He wants to know how to save strings with different lengths in binary. Not how to future-proof his project for possible language ports.

Yeah, accuse me for stating that you can better save it in an actual file format instead of pure binary. Not to mention that you could save a string entry prefixed with a **length**.

Regards,
  Godlord.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...