mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 03:55:19 -04:00
Merge branch 'master' of github.com:UnknownShadow200/ClassicalSharp
This commit is contained in:
commit
c2658dfced
@ -17,8 +17,11 @@ namespace ClassicalSharp.Map {
|
|||||||
World map;
|
World map;
|
||||||
|
|
||||||
public byte[] Load( Stream stream, Game game, out int width, out int height, out int length ) {
|
public byte[] Load( Stream stream, Game game, out int width, out int height, out int length ) {
|
||||||
using( GZipStream wrapper = new GZipStream( stream, CompressionMode.Decompress ) ) {
|
GZipHeaderReader gsHeader = new GZipHeaderReader();
|
||||||
reader = new BinaryReader( wrapper );
|
while( !gsHeader.ReadHeader( stream ) ) { }
|
||||||
|
|
||||||
|
using( DeflateStream gs = new DeflateStream( stream, CompressionMode.Decompress ) ) {
|
||||||
|
reader = new BinaryReader( gs );
|
||||||
if( reader.ReadByte() != (byte)NbtTagType.Compound )
|
if( reader.ReadByte() != (byte)NbtTagType.Compound )
|
||||||
throw new InvalidDataException( "Nbt file must start with Tag_Compound" );
|
throw new InvalidDataException( "Nbt file must start with Tag_Compound" );
|
||||||
this.game = game;
|
this.game = game;
|
||||||
|
@ -5,6 +5,7 @@ using System.IO.Compression;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using ClassicalSharp.Entities;
|
using ClassicalSharp.Entities;
|
||||||
|
using ClassicalSharp.Net;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
|
||||||
namespace ClassicalSharp.Map {
|
namespace ClassicalSharp.Map {
|
||||||
@ -25,8 +26,10 @@ namespace ClassicalSharp.Map {
|
|||||||
length = 0;
|
length = 0;
|
||||||
LocalPlayer p = game.LocalPlayer;
|
LocalPlayer p = game.LocalPlayer;
|
||||||
p.Spawn = Vector3.Zero;
|
p.Spawn = Vector3.Zero;
|
||||||
|
GZipHeaderReader gsHeader = new GZipHeaderReader();
|
||||||
|
while( !gsHeader.ReadHeader( stream ) ) { }
|
||||||
|
|
||||||
using( GZipStream gs = new GZipStream( stream, CompressionMode.Decompress ) ) {
|
using( DeflateStream gs = new DeflateStream( stream, CompressionMode.Decompress ) ) {
|
||||||
reader = new BinaryReader( gs );
|
reader = new BinaryReader( gs );
|
||||||
ClassDescription obj = ReadData();
|
ClassDescription obj = ReadData();
|
||||||
for( int i = 0; i < obj.Fields.Length; i++ ) {
|
for( int i = 0; i < obj.Fields.Length; i++ ) {
|
||||||
|
@ -5,6 +5,7 @@ using System.IO;
|
|||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using ClassicalSharp.Entities;
|
using ClassicalSharp.Entities;
|
||||||
|
using ClassicalSharp.Net;
|
||||||
|
|
||||||
namespace ClassicalSharp.Map {
|
namespace ClassicalSharp.Map {
|
||||||
|
|
||||||
@ -13,7 +14,10 @@ namespace ClassicalSharp.Map {
|
|||||||
|
|
||||||
const int Version = 1874;
|
const int Version = 1874;
|
||||||
public byte[] Load( Stream stream, Game game, out int width, out int height, out int length ) {
|
public byte[] Load( Stream stream, Game game, out int width, out int height, out int length ) {
|
||||||
using( GZipStream gs = new GZipStream( stream, CompressionMode.Decompress ) ) {
|
GZipHeaderReader gsHeader = new GZipHeaderReader();
|
||||||
|
while( !gsHeader.ReadHeader( stream ) ) { }
|
||||||
|
|
||||||
|
using( DeflateStream gs = new DeflateStream( stream, CompressionMode.Decompress ) ) {
|
||||||
BinaryReader reader = new BinaryReader( gs );
|
BinaryReader reader = new BinaryReader( gs );
|
||||||
ushort header = reader.ReadUInt16();
|
ushort header = reader.ReadUInt16();
|
||||||
|
|
||||||
@ -40,15 +44,15 @@ namespace ClassicalSharp.Map {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadCustomBlocks( GZipStream gs, int width, int height, int length, byte[] blocks ) {
|
void ReadCustomBlocks( Stream s, int width, int height, int length, byte[] blocks ) {
|
||||||
byte[] chunk = new byte[16 * 16 * 16];
|
byte[] chunk = new byte[16 * 16 * 16];
|
||||||
|
|
||||||
for( int y = 0; y < height; y += 16 )
|
for( int y = 0; y < height; y += 16 )
|
||||||
for( int z = 0; z < length; z += 16 )
|
for( int z = 0; z < length; z += 16 )
|
||||||
for( int x = 0; x < width; x += 16 )
|
for( int x = 0; x < width; x += 16 )
|
||||||
{
|
{
|
||||||
if( gs.ReadByte() != 1 ) continue;
|
if( s.ReadByte() != 1 ) continue;
|
||||||
gs.Read( chunk, 0, chunk.Length );
|
s.Read( chunk, 0, chunk.Length );
|
||||||
|
|
||||||
int baseIndex = (y * length + z) * width + x;
|
int baseIndex = (y * length + z) * width + x;
|
||||||
for( int i = 0; i < chunk.Length; i++ ) {
|
for( int i = 0; i < chunk.Length; i++ ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user