Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub SwitchMap(ByVal Map As Integer)
- Dim Y As Long
- Dim X As Long
- Dim handle As Integer
- Dim Reader As New CsBuffer
- Dim data() As Byte
- Dim ByFlags As Byte
- handle = FreeFile()
- Open DirMapas & "Mapa" & Map & ".mcl" For Binary As handle
- Seek handle, 1
- ReDim data(0 To LOF(handle) - 1) As Byte
- Get handle, , data
- Close handle
- Call Reader.Wrap(data)
- 'map :poop: Header
- MapInfo.MapVersion = Reader.ReadInteger
- Dim i As Long
- 'Load arrays
- For Y = YMinMapSize To YMaxMapSize
- For X = XMinMapSize To XMaxMapSize
- With MapData(X, Y)
- ByFlags = Reader.ReadByte
- .Blocked = ByFlags And 1
- .Graphic(1).GrhIndex = Reader.ReadInteger
- Call InitGrh(.Graphic(1), .Graphic(1).GrhIndex)
- For i = 2 To 4
- If ByFlags And (2 ^ (i - 1)) Then
- .Graphic(i).GrhIndex = Reader.ReadInteger
- Call InitGrh(.Graphic(i), .Graphic(i).GrhIndex)
- Else
- .Graphic(i).GrhIndex = 0
- End If
- Next
- For i = 4 To 6
- If (ByFlags And 2 ^ i) Then .Trigger = .Trigger Or 2 ^ (i - 4)
- Next
- 'Erase NPCs
- If MapData(X, Y).CharIndex > 0 Then
- Call EraseChar(MapData(X, Y).CharIndex)
- End If
- 'Erase OBJs
- MapData(X, Y).ObjGrh.GrhIndex = 0
- End With
- Next X
- Next Y
- Set Reader = Nothing
- MapInfo.Name = ""
- MapInfo.Music = ""
- CurMap = Map
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement