好吧,我正在尝试将各种数据“字节”转换为“长”。而且它似乎很慢......
代码:
For X = 0 To Map.MaxX
For Y = 0 To Map.MaxY
Map.Tile(X, Y).Data1 = Buffer.ReadLong
Map.Tile(X, Y).Data2 = Buffer.ReadLong
Map.Tile(X, Y).Data3 = Buffer.ReadLong
Map.Tile(X, Y).DirBlock = Buffer.ReadLong
ReDim Map.Tile(X, Y).Layer(0 To MapLayer.Layer_Count - 1)
For i = 0 To MapLayer.Layer_Count - 1
Map.Tile(X, Y).Layer(i).tileset = Buffer.ReadLong
Map.Tile(X, Y).Layer(i).X = Buffer.ReadLong
Map.Tile(X, Y).Layer(i).Y = Buffer.ReadLong
Next
Map.Tile(X, Y).Type = Buffer.ReadLong
Next
Next
转换器:
Public Function ReadLong(Optional ByVal peek As Boolean = True) As Long
If Buff.Count > readpos Then 'check to see if this passes the byte count
Dim ret As Long = BitConverter.ToInt64(Buff.ToArray, readpos)
If peek And Buff.Count > readpos Then
readpos += 8
End If
Return ret
Else
Throw New Exception("Byte Buffer Past Limit!") 'past byte count throw a new exception
End If
End Function
有人有提示或解决方案吗?