Jump to content

Errors on map resize.


Recoil

Recommended Posts

So yeah, when we make the map a smaller size everything is fine...but not making it larger.  We are receiving issues in 2 different spots.  Damian's error is under here:

Public Sub DrawMapTile(ByVal locX As Long, ByVal locY As Long)
        Dim i As Long
        Dim srcrect As New Rectangle(0, 0, 0, 0)
        Dim tmpSprite As Sprite
        If GettingMap Then Exit Sub
        With Map.Tile(locX, locY)
            For i = Enumerations.MapLayer.Ground To Enumerations.MapLayer.Mask2
                ' skip tile if tileset isn't set
                ' Here
                If .Layer(i).Tileset > 0 Then
                    With srcrect
                        .X = Map.Tile(locX, locY).Layer(i).X * 32
                        .Y = Map.Tile(locX, locY).Layer(i).Y * 32
                        .Width = 32
                        .Height = 32
                    End With
                    tmpSprite = New Sprite(TileSetTexture(.Layer(i).Tileset))
                    tmpSprite.TextureRect = New IntRect(srcrect.X, srcrect.Y, srcrect.Width, srcrect.Height)
                    tmpSprite.Position = New Vector2f(ConvertMapX(locX * PIC_X), ConvertMapY(locY * PIC_Y))
                    GameWindow.Draw(tmpSprite)
                End If
            Next
        End With
    End Sub

Mine is under here:

Public Sub SendMap()
        Dim X As Long
        Dim Y As Long
        Dim i As Long
        Dim data() As Byte
        Dim Buffer As ByteBuffer
        Buffer = New ByteBuffer
        CanMoveNow = False

        Buffer.WriteString(Trim$(Map.Name))
        Buffer.WriteString(Trim$(Map.Music))
        Buffer.WriteLong(Map.Moral)
        Buffer.WriteLong(Map.Weather)
        Buffer.WriteLong(Map.Tileset)
        Buffer.WriteLong(Map.Up)
        Buffer.WriteLong(Map.Down)
        Buffer.WriteLong(Map.Left)
        Buffer.WriteLong(Map.Right)
        Buffer.WriteLong(Map.BootMap)
        Buffer.WriteLong(Map.BootX)
        Buffer.WriteLong(Map.BootY)
        Buffer.WriteLong(Map.MaxX)
        Buffer.WriteLong(Map.MaxY)



        For i = 1 To MaxMapNpcs
            Buffer.WriteLong(Map.Npc(i))
        Next

        For X = 0 To Map.MaxX
            For Y = 0 To Map.MaxY
                Buffer.WriteLong(Map.Tile(X, Y).Data1)
                Buffer.WriteLong(Map.Tile(X, Y).Data2)
                Buffer.WriteLong(Map.Tile(X, Y).Data3)
                Buffer.WriteLong(Map.Tile(X, Y).DirBlock)
                For i = 0 To MapLayer.LayerCount - 1
                    ' Here
                    Buffer.WriteLong(Map.Tile(X, Y).Layer(i).Tileset)
                    Buffer.WriteLong(Map.Tile(X, Y).Layer(i).X)
                    Buffer.WriteLong(Map.Tile(X, Y).Layer(i).Y)
                Next
                Buffer.WriteLong(Map.Tile(X, Y).Type)
            Next
        Next

        data = Buffer.ToArray

        Buffer = New ByteBuffer
        Buffer.WriteLong(ClientPackets.CMapData)
        Buffer.WriteBytes(Compress(data))

        SendData(Buffer.ToArray())
        Buffer = Nothing
    End Sub

I know it has something to do with trying to change the size of the map array in memory, but I have no clue on how to fix.  Apparently I am unable to redim the sizes in these locations.  We needs helpz plz.

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
×
×
  • Create New...