Skip to content

Commit

Permalink
Fix .cw maps with dimensions between 32768-65535 not importing
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Aug 13, 2020
1 parent 5f5614b commit 0df12fb
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions MCGalaxy/Blocks/Block.Convert.cs
Expand Up @@ -82,8 +82,8 @@ public static partial class Block {
case LightPink: return Pink;
case ForestGreen: return Green;
case Brown: return Dirt;
case deepblue: return Blue;
case turquoise: return Cyan;
case DeepBlue: return Blue;
case Turquoise: return Cyan;
case Ice: return Glass;
case CeramicTile: return Iron;
case MagmaBlock: return Obsidian;
Expand Down
2 changes: 1 addition & 1 deletion MCGalaxy/Blocks/Block.CoreProps.cs
Expand Up @@ -60,7 +60,7 @@ public static partial class Block {
props.LavaKills = b == Wood || b == Log
|| b == Sponge || b == Bookshelf || b == Leaves || b == Crate;

if ((b >= Red && b <= White) || (b >= LightPink && b <= turquoise)) {
if ((b >= Red && b <= White) || (b >= LightPink && b <= Turquoise)) {
props.LavaKills = true;
}
if (b == Air || b == Sapling || (b >= Dandelion && b <= RedMushroom)) {
Expand Down
4 changes: 2 additions & 2 deletions MCGalaxy/Blocks/Block.ID.cs
Expand Up @@ -119,8 +119,8 @@ public static partial class Block {
public const byte LightPink = 55;
public const byte ForestGreen = 56;
public const byte Brown = 57;
public const byte deepblue = 58;
public const byte turquoise = 59;
public const byte DeepBlue = 58;
public const byte Turquoise = 59;
public const byte Ice = 60;
public const byte CeramicTile = 61;
public const byte MagmaBlock = 62;
Expand Down
2 changes: 1 addition & 1 deletion MCGalaxy/Blocks/DefaultSet.cs
Expand Up @@ -110,7 +110,7 @@ public static class DefaultSet {

if (b >= Block.Red && b <= Block.White)
return SoundType.Cloth;
if (b >= Block.LightPink && b <= Block.turquoise)
if (b >= Block.LightPink && b <= Block.Turquoise)
return SoundType.Cloth;
if (b == Block.Iron || b == Block.Gold)
return SoundType.Metal;
Expand Down
9 changes: 4 additions & 5 deletions MCGalaxy/Levels/IO/Importers/CwImporter.cs
Expand Up @@ -48,11 +48,10 @@ public sealed class CwImporter : IMapImporter {
if (root["FormatVersion"].ByteValue > 1)
throw new NotSupportedException("Only version 1 of ClassicWorld format is supported.");

short x = root["X"].ShortValue, y = root["Y"].ShortValue, z = root["Z"].ShortValue;
if (x <= 0 || y <= 0 || z <= 0)
throw new InvalidDataException("Level dimensions must be > 0.");

lvl = new Level(name, (ushort)x, (ushort)y, (ushort)z);
ushort width = (ushort)root["X"].ShortValue;
ushort height = (ushort)root["Y"].ShortValue;
ushort length = (ushort)root["Z"].ShortValue;
lvl = new Level(name, width, height, length);
lvl.blocks = root["BlockArray"].ByteArrayValue;
ReadSpawn(root, lvl);

Expand Down
2 changes: 1 addition & 1 deletion MCGalaxy/Levels/IO/Importers/FcmImporter.cs
Expand Up @@ -82,7 +82,7 @@ public sealed class FcmImporter : IMapImporter {
}

static string ReadString(BinaryReader reader) {
int length = reader.ReadUInt16();
int length = reader.ReadUInt16();
byte[] data = reader.ReadBytes(length);
return Encoding.ASCII.GetString(data);
}
Expand Down
2 changes: 1 addition & 1 deletion MCGalaxy/Levels/Level.cs
Expand Up @@ -75,7 +75,7 @@ public sealed partial class Level : IDisposable {

VisitAccess = new LevelAccessController(Config, name, true);
BuildAccess = new LevelAccessController(Config, name, false);
listCheckExists = new SparseBitSet(Width, Height, Length);
listCheckExists = new SparseBitSet(Width, Height, Length);
listUpdateExists = new SparseBitSet(Width, Height, Length);
}

Expand Down

0 comments on commit 0df12fb

Please sign in to comment.