public static bool IsTileTheSame(Tile tile1, Tile tile2) { if (tile1.active() != tile2.active()) return false; if (tile1.active()) { if (tile1.type != tile2.type) return false; if (Main.tileFrameImportant[(int)tile1.type]) { if ((tile1.frameX != tile2.frameX) || (tile1.frameX != tile2.frameX)) return false; } } return tile1.wall == tile2.wall && tile1.liquid == tile2.liquid && tile1.lava() == tile2.lava() && tile1.wire() == tile2.wire() && tile1.wire2() == tile2.wire2() && tile1.wire3() == tile2.wire3(); }
public bool isTheSameAs(Tile compTile) { if (compTile == null) { return(false); } if (this.active() != compTile.active()) { return(false); } if (this.active()) { if (this.type != compTile.type) { return(false); } if (Main.tileFrameImportant[(int)this.type]) { if (this.frameX != compTile.frameX) { return(false); } if (this.frameY != compTile.frameY) { return(false); } } } if (this.wall != compTile.wall) { return(false); } if (this.liquid != compTile.liquid) { return(false); } if (this.liquid > 0) { if (this.lava() != compTile.lava()) { return(false); } if (this.honey() != compTile.honey()) { return(false); } } return(this.wire() == compTile.wire() && this.wire2() == compTile.wire2() && this.wire3() == compTile.wire3() && this.halfBrick() == compTile.halfBrick() && this.actuator() == compTile.actuator() && this.inActive() == compTile.inActive() && this.wallColor() == compTile.wallColor() && this.color() == compTile.color() && this.slope() == compTile.slope()); }
public bool isTheSameAs(Tile compTile) { if (compTile == null) { return false; } if (this.active() != compTile.active()) { return false; } if (this.active()) { if (this.type != compTile.type) { return false; } if (Main.tileFrameImportant[(int)this.type]) { if (this.frameX != compTile.frameX) { return false; } if (this.frameY != compTile.frameY) { return false; } } } if (this.wall != compTile.wall) { return false; } if (this.liquid != compTile.liquid) { return false; } if (this.liquid > 0) { if (this.lava() != compTile.lava()) { return false; } if (this.honey() != compTile.honey()) { return false; } } return this.wire() == compTile.wire() && this.wire2() == compTile.wire2() && this.wire3() == compTile.wire3() && this.halfBrick() == compTile.halfBrick() && this.actuator() == compTile.actuator() && this.inActive() == compTile.inActive() && this.wallColor() == compTile.wallColor() && this.color() == compTile.color() && this.slope() == compTile.slope(); }
public static bool validateWorld(string validatePath) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); if (WorldGen.genRand == null) { WorldGen.genRand = new Random((int)DateTime.Now.Ticks); } bool result; using (FileStream fileStream = new FileStream(validatePath, FileMode.Open)) { using (BinaryReader binaryReader = new BinaryReader(fileStream)) { try { int num = binaryReader.ReadInt32(); if (num > Main.curRelease) { try { binaryReader.Close(); fileStream.Close(); } catch { } result = false; } else { string b = binaryReader.ReadString(); int num2 = binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); int num4 = binaryReader.ReadInt32(); if (num >= 63) { binaryReader.ReadByte(); } if (num >= 44) { binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); } if (num >= 60) { binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); if (num >= 61) { binaryReader.ReadInt32(); binaryReader.ReadInt32(); } } binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadDouble(); binaryReader.ReadDouble(); binaryReader.ReadDouble(); binaryReader.ReadBoolean(); binaryReader.ReadInt32(); binaryReader.ReadBoolean(); if (num >= 70) { binaryReader.ReadBoolean(); } binaryReader.ReadInt32(); binaryReader.ReadInt32(); if (num >= 56) { binaryReader.ReadBoolean(); } binaryReader.ReadBoolean(); binaryReader.ReadBoolean(); binaryReader.ReadBoolean(); if (num >= 66) { binaryReader.ReadBoolean(); } if (num >= 44) { binaryReader.ReadBoolean(); binaryReader.ReadBoolean(); binaryReader.ReadBoolean(); binaryReader.ReadBoolean(); } if (num >= 64) { binaryReader.ReadBoolean(); binaryReader.ReadBoolean(); } if (num >= 29) { binaryReader.ReadBoolean(); binaryReader.ReadBoolean(); if (num >= 34) { binaryReader.ReadBoolean(); } binaryReader.ReadBoolean(); } if (num >= 32) { binaryReader.ReadBoolean(); } if (num >= 37) { binaryReader.ReadBoolean(); } if (num >= 56) { binaryReader.ReadBoolean(); } binaryReader.ReadBoolean(); binaryReader.ReadBoolean(); binaryReader.ReadByte(); if (num >= 23) { binaryReader.ReadInt32(); binaryReader.ReadBoolean(); } binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadDouble(); if (num >= 53) { binaryReader.ReadBoolean(); binaryReader.ReadInt32(); binaryReader.ReadSingle(); } if (num >= 54) { binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); } if (num >= 55) { binaryReader.ReadByte(); binaryReader.ReadByte(); binaryReader.ReadByte(); } if (num >= 60) { binaryReader.ReadByte(); binaryReader.ReadByte(); binaryReader.ReadByte(); binaryReader.ReadByte(); binaryReader.ReadByte(); } if (num >= 60) { binaryReader.ReadInt32(); } if (num >= 62) { binaryReader.ReadInt16(); binaryReader.ReadSingle(); } for (int i = 0; i < num4; i++) { float num5 = (float)i / (float)Main.maxTilesX; Main.statusText = string.Concat(new object[] { Lang.gen[73], " ", (int)(num5 * 100f + 1f), "%" }); for (int j = 0; j < num3; j++) { Tile tile = new Tile(); tile.active(binaryReader.ReadBoolean()); if (tile.active()) { tile.type = binaryReader.ReadByte(); if (tile.type == 127) { tile.active(false); } if (num < 72 && (tile.type == 35 || tile.type == 36 || tile.type == 170 || tile.type == 171 || tile.type == 172)) { tile.frameX = binaryReader.ReadInt16(); tile.frameY = binaryReader.ReadInt16(); } else if (Main.tileFrameImportant[(int)tile.type]) { if (num < 28 && tile.type == 4) { tile.frameX = 0; tile.frameY = 0; } else if (num < 40 && tile.type == 19) { tile.frameX = 0; tile.frameY = 0; } else { tile.frameX = binaryReader.ReadInt16(); tile.frameY = binaryReader.ReadInt16(); if (tile.type == 144) { tile.frameY = 0; } } } else { tile.frameX = -1; tile.frameY = -1; } if (num >= 48 && binaryReader.ReadBoolean()) { tile.color(binaryReader.ReadByte()); } } if (num <= 25) { binaryReader.ReadBoolean(); } if (binaryReader.ReadBoolean()) { tile.wall = binaryReader.ReadByte(); if (num >= 48 && binaryReader.ReadBoolean()) { tile.wallColor(binaryReader.ReadByte()); } } if (binaryReader.ReadBoolean()) { tile.liquid = binaryReader.ReadByte(); tile.lava(binaryReader.ReadBoolean()); if (num >= 51) { tile.honey(binaryReader.ReadBoolean()); } } if (num >= 33) { tile.wire(binaryReader.ReadBoolean()); } if (num >= 43) { tile.wire2(binaryReader.ReadBoolean()); tile.wire3(binaryReader.ReadBoolean()); } if (num >= 41) { tile.halfBrick(binaryReader.ReadBoolean()); if (!Main.tileSolid[(int)tile.type]) { tile.halfBrick(false); } if (num >= 49) { tile.slope(binaryReader.ReadByte()); if (!Main.tileSolid[(int)tile.type]) { tile.slope(0); } } } if (num >= 42) { tile.actuator(binaryReader.ReadBoolean()); tile.inActive(binaryReader.ReadBoolean()); } if (num >= 25) { int num6 = (int)binaryReader.ReadInt16(); j += num6; } } } int num7 = 40; if (num < 58) { num7 = 20; } for (int k = 0; k < 1000; k++) { if (binaryReader.ReadBoolean()) { binaryReader.ReadInt32(); binaryReader.ReadInt32(); for (int l = 0; l < 40; l++) { if (l < num7) { int num8; if (num >= 59) { num8 = (int)binaryReader.ReadInt16(); } else { num8 = (int)binaryReader.ReadByte(); } if (num8 > 0) { if (num >= 38) { binaryReader.ReadInt32(); } else { binaryReader.ReadString(); } binaryReader.ReadByte(); } } } } } for (int m = 0; m < 1000; m++) { if (binaryReader.ReadBoolean()) { binaryReader.ReadString(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); } } bool flag = binaryReader.ReadBoolean(); int num9 = 0; while (flag) { binaryReader.ReadString(); binaryReader.ReadSingle(); binaryReader.ReadSingle(); binaryReader.ReadBoolean(); binaryReader.ReadInt32(); binaryReader.ReadInt32(); flag = binaryReader.ReadBoolean(); num9++; } if (num >= 31) { binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); if (num >= 35) { binaryReader.ReadString(); if (num >= 65) { binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); binaryReader.ReadString(); } } } if (num >= 7) { bool flag2 = binaryReader.ReadBoolean(); string text = binaryReader.ReadString(); int num10 = binaryReader.ReadInt32(); if (!flag2 || (!(text == b) && num10 != num2)) { binaryReader.Close(); fileStream.Close(); result = false; return result; } } binaryReader.Close(); fileStream.Close(); result = true; } } catch { try { binaryReader.Close(); fileStream.Close(); } catch { } result = false; } } } return result; }
private void Tile(Tile tile) { byte flags = 0; var active = tile.active(); var wall = tile.wall; var liquid = tile.liquid; if (active) flags += 1; //if (tile.Lighted) flags += 2; //UNUSED if (wall > 0) flags += 4; if (liquid > 0) flags += 8; if (tile.wire()) flags += 16; if (tile.halfBrick()) flags += 32; if (tile.actuator()) flags += 64; if (tile.inActive()) flags += 128; Byte(flags); byte tileColour = 0, wallColour = 0; flags = 0; if (tile.wire2()) flags += 1; if (tile.wire3()) flags += 2; if (tile.active() && tile.color() > 0) { flags += 4; tileColour = tile.color(); } if (tile.wall > 0 && tile.wallColor() > 0) { flags += 8; wallColour = tile.wallColor(); } Byte(flags + (byte)(tile.slope() << 4)); if (tileColour > 0) Byte(tileColour); if (wallColour > 0) Byte(wallColour); if (tile.active()) { UShort(tile.type); if (Main.tileFrameImportant[(int)tile.type]) { Short(tile.frameX); Short(tile.frameY); } } if (tile.wall > 0) Byte(tile.wall); if (tile.liquid > 0) { Byte(tile.liquid); Byte(tile.liquidType()); } }