Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. Public Sub SwitchMap(ByVal Map As Integer)
  2. Dim Y As Long
  3. Dim X As Long
  4. Dim handle As Integer
  5. Dim Reader As New CsBuffer
  6. Dim data() As Byte
  7. Dim ByFlags As Byte
  8.  
  9. handle = FreeFile()
  10.  
  11. Open DirMapas & "Mapa" & Map & ".mcl" For Binary As handle
  12. Seek handle, 1
  13. ReDim data(0 To LOF(handle) - 1) As Byte
  14.  
  15. Get handle, , data
  16. Close handle
  17.  
  18. Call Reader.Wrap(data)
  19.  
  20. 'map :poop: Header
  21. MapInfo.MapVersion = Reader.ReadInteger
  22.  
  23. Dim i As Long
  24.  
  25. 'Load arrays
  26. For Y = YMinMapSize To YMaxMapSize
  27. For X = XMinMapSize To XMaxMapSize
  28.  
  29. With MapData(X, Y)
  30. ByFlags = Reader.ReadByte
  31.  
  32. .Blocked = ByFlags And 1
  33.  
  34. .Graphic(1).GrhIndex = Reader.ReadInteger
  35. Call InitGrh(.Graphic(1), .Graphic(1).GrhIndex)
  36.  
  37. For i = 2 To 4
  38. If ByFlags And (2 ^ (i - 1)) Then
  39. .Graphic(i).GrhIndex = Reader.ReadInteger
  40. Call InitGrh(.Graphic(i), .Graphic(i).GrhIndex)
  41.  
  42. Else
  43. .Graphic(i).GrhIndex = 0
  44. End If
  45. Next
  46.  
  47. For i = 4 To 6
  48. If (ByFlags And 2 ^ i) Then .Trigger = .Trigger Or 2 ^ (i - 4)
  49. Next
  50.  
  51. 'Erase NPCs
  52. If MapData(X, Y).CharIndex > 0 Then
  53. Call EraseChar(MapData(X, Y).CharIndex)
  54. End If
  55.  
  56. 'Erase OBJs
  57. MapData(X, Y).ObjGrh.GrhIndex = 0
  58.  
  59. End With
  60. Next X
  61. Next Y
  62.  
  63. Set Reader = Nothing
  64.  
  65.  
  66. MapInfo.Name = ""
  67. MapInfo.Music = ""
  68.  
  69. CurMap = Map
  70. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement