07-03-2009, 08:56 PM
I know this is old.
Has anybody tried to get Spodis method working that he posted here? I have been messing around with it in a dynamic map system.
With all 4 default layers filling a 100x100 map with attributes randomly placed around and all 5 npcs the default MS saving scheme saves the file as 153,063 bytes. But with Spodis bit of code here it's cut it down to 42,525 bytes. Which is quite good.
I am having a problem with loading it though. The Npcs aren't loading when you first get warped to a map but it seems as if everything else is loading properly. When I open the map editor it's all there and when I click send the Npcs spawn and show up. Here is my loading sub. The saving one is almost exactly the same as the one Spodi posted before. I am using the independent tile encoding, not the delta.
Can anybody see anything that's incorrect here? Thanks guys.
Has anybody tried to get Spodis method working that he posted here? I have been messing around with it in a dynamic map system.
With all 4 default layers filling a 100x100 map with attributes randomly placed around and all 5 npcs the default MS saving scheme saves the file as 153,063 bytes. But with Spodis bit of code here it's cut it down to 42,525 bytes. Which is quite good.
I am having a problem with loading it though. The Npcs aren't loading when you first get warped to a map but it seems as if everything else is loading properly. When I open the map editor it's all there and when I click send the Npcs spawn and show up. Here is my loading sub. The saving one is almost exactly the same as the one Spodi posted before. I am using the independent tile encoding, not the delta.
Code:
Sub LoadMaps()
Dim F As Long
Dim HeaderBitFlags As Integer
Dim MapNPCCount As Byte
Dim NpcNum As Byte
Dim i As Long
Dim x As Long
Dim y As Long
Dim TileBitFlags As Byte
Call CheckMaps
F = FreeFile
For i = 1 To MAX_MAPS
Open App.Path & "\Data\maps\map" & i & ".dat" For Binary As #F
With Map(i)
' Static header
Get #F, , .Name
Get #F, , .Revision
' Dynamic header
For NpcNum = 1 To MAX_MAP_NPCS
If .Npc(NpcNum) 0 Then MapNPCCount = MapNPCCount + 1
Next
If .Moral 0 Then HeaderBitFlags = HeaderBitFlags Or 1
If .TileSet 1 Then HeaderBitFlags = HeaderBitFlags Or 2
If .Up 0 Then HeaderBitFlags = HeaderBitFlags Or 4
If .Down 0 Then HeaderBitFlags = HeaderBitFlags Or 8
If .Left 0 Then HeaderBitFlags = HeaderBitFlags Or 16
If .Right 0 Then HeaderBitFlags = HeaderBitFlags Or 32
If .Music 0 Then HeaderBitFlags = HeaderBitFlags Or 64
If .BootMap 0 Then HeaderBitFlags = HeaderBitFlags Or 128
If .BootX 0 Then HeaderBitFlags = HeaderBitFlags Or 256
If .BootY 0 Then HeaderBitFlags = HeaderBitFlags Or 512
If .Shop 0 Then HeaderBitFlags = HeaderBitFlags Or 1024
If .MaxX MAX_MAPX Then HeaderBitFlags = HeaderBitFlags Or 2048
If .MaxY MAX_MAPY Then HeaderBitFlags = HeaderBitFlags Or 4096
If MapNPCCount 0 Then HeaderBitFlags = HeaderBitFlags Or 8192
Get #F, , HeaderBitFlags
If HeaderBitFlags And 1 Then Get #F, , .Moral
If HeaderBitFlags And 2 Then Get #F, , .TileSet
If HeaderBitFlags And 4 Then Get #F, , .Up
If HeaderBitFlags And 8 Then Get #F, , .Down
If HeaderBitFlags And 16 Then Get #F, , .Left
If HeaderBitFlags And 32 Then Get #F, , .Right
If HeaderBitFlags And 64 Then Get #F, , .Music
If HeaderBitFlags And 128 Then Get #F, , .BootMap
If HeaderBitFlags And 256 Then Get #F, , .BootX
If HeaderBitFlags And 512 Then Get #F, , .BootY
If HeaderBitFlags And 1024 Then Get #F, , .Shop
If HeaderBitFlags And 2048 Then Get #F, , .MaxX
If HeaderBitFlags And 4096 Then Get #F, , .MaxY
If HeaderBitFlags And 8192 Then
Get #F, , MapNPCCount
For NpcNum = 1 To MAX_MAP_NPCS
If .Npc(NpcNum) 0 Then Get #F, , .Npc(NpcNum)
Next
End If
' Tile decoding
' Have to set the tile()
ReDim Map(i).Tile(0 To Map(i).MaxX, 0 To Map(i).MaxY)
For y = 0 To Map(i).MaxY
For x = 0 To Map(i).MaxX
TileBitFlags = 0
With .Tile(x, y)
If .Ground 0 Then TileBitFlags = TileBitFlags Or 1
If .Mask 0 Then TileBitFlags = TileBitFlags Or 2
If .Anim 0 Then TileBitFlags = TileBitFlags Or 4
If .Fringe 0 Then TileBitFlags = TileBitFlags Or 8
If .Type 0 Then TileBitFlags = TileBitFlags Or 16
If .Data1 0 Then TileBitFlags = TileBitFlags Or 32
If .Data2 0 Then TileBitFlags = TileBitFlags Or 64
If .Data3 0 Then TileBitFlags = TileBitFlags Or 128
Get #F, , TileBitFlags
If TileBitFlags And 1 Then Get #F, , .Ground
If TileBitFlags And 2 Then Get #F, , .Mask
If TileBitFlags And 4 Then Get #F, , .Anim
If TileBitFlags And 8 Then Get #F, , .Fringe
If TileBitFlags And 16 Then Get #F, , .Type
If TileBitFlags And 32 Then Get #F, , .Data1
If TileBitFlags And 64 Then Get #F, , .Data2
If TileBitFlags And 128 Then Get #F, , .Data3
End With
Next
Next
End With
Close #F
ClearTempTile i
DoEvents
Next
End Sub
Can anybody see anything that's incorrect here? Thanks guys.