public void Accepted() { ACCEPTED = true; //SP.Stop(); //DSrest.Accept(seplayer.Name, MMID); _mmrep.Accept(seplayer.Name, MMID.ToString()); }
public void Declined() { DECLINED = true; //SP.Stop(); //DSrest.Decline(seplayer.Name, MMID); _mmrep.Decline(seplayer.Name, MMID.ToString()); Reset(); }
public void Read() { if (Type == ADTType.Normal) { ADTObjects = new ADT(World, X, Y, ADTType.Objects); ADTObjects.Read(); //ADTTextures = new ADT(World, X, Y, ADTType.Textures); //ADTTextures.Read(); } MapChunks = new MapChunk[16 * 16]; int mcIdx = 0; foreach (var subChunk in Data.Chunks) { switch (subChunk.Name) { case "MHDR": MHDR = new MHDR(subChunk); break; case "MMDX": MMDX = new MMDX(subChunk); break; case "MMID": MMID = new MMID(subChunk); ReadDoodads(); break; case "MWMO": MWMO = new MWMO(subChunk); break; case "MWID": MWID = new MWID(subChunk); ReadModels(); break; case "MDDF": MDDF = new MDDF(subChunk); break; case "MODF": MODF = new MODF(subChunk); break; case "MH2O": Liquid = new LiquidChunk(this, subChunk); break; case "MCNK": MapChunks[mcIdx++] = new MapChunk(this, subChunk); break; } } }
public override int GetHashCode() { unchecked { var hash = 17; hash = hash * 29 + MMID.GetHashCode(); hash = hash * 29 + Description.GetHashCode(); return(hash); } }
private MMID ReadMMIDChunk(BlizzHeader chunk, BinaryReader bin) { var count = chunk.Size / 4; MMID mmid = new MMID(); mmid.offsets = new uint[count]; for (int i = 0; i < count; i++) { mmid.offsets[i] = bin.ReadUInt32(); } return(mmid); }
private MMID ReadMMIDChunk(uint size, BinaryReader bin) { var count = size / 4; MMID mmid = new MMID() { offsets = new uint[count] }; for (int i = 0; i < count; i++) { mmid.offsets[i] = bin.ReadUInt32(); } return(mmid); }
public OBJ1(Files.WOTLK.ADT wotlk) { ADTfileInfo = new FileInfo(wotlk.ADTfileInfo.Name.Split('.')[0] + "_obj1.adt"); Logger.log(ADTfileInfo.Name, Logger.Type.CONVERT, "<- " + wotlk.ADTfileInfo.Name); MVER = new MVER(wotlk.MVER); MLFD = new MLFD(wotlk.MDDF, wotlk.MODF); //I'm not sure the chunk is really needed. MMDX = new MMDX(wotlk.MMDX); MMID = new MMID(wotlk.MMID); MWMO = new MWMO(wotlk.MWMO); MWID = new MWID(wotlk.MWID); MLDD = new MLDD(wotlk.MDDF); MLDX = new MLDX(wotlk.MDDF); MLMD = new MLMD(wotlk.MODF); MLMX = new MLMX(wotlk.MODF); }
public override int GetHashCode() { unchecked { var hash = 17; hash = hash * 29 + MessageType.GetHashCode(); hash = hash * 29 + Symbol.GetHashCode(); hash = hash * 29 + OrderId.GetHashCode(); hash = hash * 29 + MMID.GetHashCode(); hash = hash * 29 + Side.GetHashCode(); hash = hash * 29 + Price.GetHashCode(); hash = hash * 29 + Size.GetHashCode(); hash = hash * 29 + OrderPriority.GetHashCode(); hash = hash * 29 + Precision.GetHashCode(); hash = hash * 29 + OrderTime.GetHashCode(); hash = hash * 29 + OrderDate.GetHashCode(); return(hash); } }
public OBJ0(Files.WOTLK.ADT wotlk) { ADTfileInfo = new FileInfo(wotlk.ADTfileInfo.Name.Split('.')[0] + "_obj0.adt"); Logger.log(ADTfileInfo.Name, Logger.Type.CONVERT, "<- " + wotlk.ADTfileInfo.Name); MVER = new MVER(wotlk.MVER); MMDX = new MMDX(wotlk.MMDX); MMID = new MMID(wotlk.MMID); MWMO = new MWMO(wotlk.MWMO); MWID = new MWID(wotlk.MWID); MDDF = new MDDF(wotlk.MDDF); MODF = new MODF(wotlk.MODF); foreach (Files.WOTLK.Chunks.MCNK x in wotlk.MCNKs) { MCNKs.Add(new MCNK_OBJ0(x)); MCNKLength += MCNKs[MCNKs.Count - 1].GetBytes().Length; } Logger.log("MCNK[]", Logger.Type.LEVEL1); }
public override int GetHashCode() { unchecked { var hash = 17; hash = hash * 29 + Symbol.GetHashCode(); hash = hash * 29 + MMID.GetHashCode(); hash = hash * 29 + Bid.GetHashCode(); hash = hash * 29 + Ask.GetHashCode(); hash = hash * 29 + BidSize.GetHashCode(); hash = hash * 29 + AskSize.GetHashCode(); hash = hash * 29 + BidTime.GetHashCode(); hash = hash * 29 + BidSize.GetHashCode(); hash = hash * 29 + Date.GetHashCode(); hash = hash * 29 + ConditionCode.GetHashCode(); hash = hash * 29 + AskTime.GetHashCode(); hash = hash * 29 + BidInfoValid.GetHashCode(); hash = hash * 29 + AskInfoValid.GetHashCode(); hash = hash * 29 + EndOfMessageGroup.GetHashCode(); return(hash); } }
public ADT(string filePath) { ADTfileInfo = new FileInfo(filePath); Logger.log(ADTfileInfo.Name, Logger.Type.READ, ADTfileInfo.DirectoryName); //Start reading the .ADT File using (BinaryReader reader = new BinaryReader(ADTfileInfo.Open(FileMode.Open))) { Length = (int)reader.BaseStream.Length; reader.BaseStream.Seek(0, SeekOrigin.Begin); int MCNK_counter = 0; int MCNK_size = 0; while (reader.BaseStream.Position < reader.BaseStream.Length) { byte[] ChunkMagic = reader.ReadBytes(4); byte[] ChunkSize = reader.ReadBytes(4); byte[] ChunkContent = reader.ReadBytes(BitConverter.ToInt32(ChunkSize, 0)); string ChunkMagicString = MagicBytesToString(ChunkMagic); //read the chunks switch (ChunkMagicString) { case "MVER": MVER = new MVER(MagicBytesToChars(ChunkMagic), ChunkSize, ChunkContent); break; case "MHDR": MHDR = new MHDR(MagicBytesToChars(ChunkMagic), ChunkSize, ChunkContent); break; case "MCIN": MCIN = new MCIN(MagicBytesToChars(ChunkMagic), ChunkSize, ChunkContent); break; case "MTEX": MTEX = new MTEX(MagicBytesToChars(ChunkMagic), ChunkSize, ChunkContent); break; case "MMDX": MMDX = new MMDX(MagicBytesToChars(ChunkMagic), ChunkSize, ChunkContent); break; case "MMID": MMID = new MMID(MagicBytesToChars(ChunkMagic), ChunkSize, ChunkContent); break; case "MWMO": MWMO = new MWMO(MagicBytesToChars(ChunkMagic), ChunkSize, ChunkContent); break; case "MWID": MWID = new MWID(MagicBytesToChars(ChunkMagic), ChunkSize, ChunkContent); break; case "MDDF": MDDF = new MDDF(MagicBytesToChars(ChunkMagic), ChunkSize, ChunkContent); break; case "MODF": MODF = new MODF(MagicBytesToChars(ChunkMagic), ChunkSize, ChunkContent); break; case "MH2O": MH2O = new MH2O(MagicBytesToChars(ChunkMagic), ChunkSize, ChunkContent); break; case "MCNK": MCNKs.Add(new MCNK(MagicBytesToChars(ChunkMagic), ChunkSize, ChunkContent)); break; case "MFBO": MFBO = new MFBO(MagicBytesToChars(ChunkMagic), ChunkSize, ChunkContent); break; } if (ChunkMagicString == "MCNK") { MCNK_counter++; MCNK_size += BitConverter.ToInt32(ChunkSize, 0); } else if (ChunkMagicString == "\0\0\0\0") /*Logger.log("0 Byte Chunk", Logger.Direction.WARNING);*/ } { } if (MCNK_counter > 0) { Logger.log("MCNK[]", Logger.Type.LEVEL1, MCNK_size + " byte"); } } }
public void Write() { using (var writer = new BinaryWriter(File.OpenWrite("test.adt"))) { // MVER writer.Write(MVER.GetChunkHeaderBytes()); writer.Write(MVER.GetChunkBytes()); // Write MHDR later when we got all offsets var positionBeforeMHDR = writer.BaseStream.Position; writer.BaseStream.Position += _HeaderSize + MHDR.ChunkSize; // MTEX MHDR.OffsetMTEX = (uint)writer.BaseStream.Position; writer.Write(MTEX.GetChunkHeaderBytes()); writer.Write(MTEX.GetChunkBytes()); // MMDX MHDR.OffsetMMDX = (uint)writer.BaseStream.Position; writer.Write(MMDX.GetChunkHeaderBytes()); writer.Write(MMDX.GetChunkBytes()); // MMID MHDR.OffsetMMID = (uint)writer.BaseStream.Position; writer.Write(MMID.GetChunkHeaderBytes()); writer.Write(MMID.GetChunkBytes()); // MWMO MHDR.OffsetMWMO = (uint)writer.BaseStream.Position; writer.Write(MWMO.GetChunkHeaderBytes()); writer.Write(MWMO.GetChunkBytes()); // MWID MHDR.OffsetMWID = (uint)writer.BaseStream.Position; writer.Write(MWID.GetChunkHeaderBytes()); writer.Write(MWID.GetChunkBytes()); // MDDF MHDR.OffsetMDDF = (uint)writer.BaseStream.Position; writer.Write(MDDF.GetChunkHeaderBytes()); writer.Write(MDDF.GetChunkBytes()); // MODF MHDR.OffsetMODF = (uint)writer.BaseStream.Position; writer.Write(MODF.GetChunkHeaderBytes()); writer.Write(MODF.GetChunkBytes()); // MH2O MHDR.OffsetMH2O = (uint)writer.BaseStream.Position; writer.Write(MH2O.GetChunkHeaderBytes()); writer.Write(MH2O.GetChunkBytes()); // MCNK for (int i = 0; i < MCIN.Entries.Length; i++) { MCIN.Entries[i].OffsetMCNK = (uint)writer.BaseStream.Position; MCIN.Entries[i].ChunkSize = MCNK[i].ChunkSize; writer.Write(MCNK[i].GetChunkHeaderBytes()); writer.Write(MCNK[i].GetChunkBytes()); } // MCIN MHDR.OffsetMCIN = (uint)writer.BaseStream.Position; writer.Write(MCIN.GetChunkHeaderBytes()); writer.Write(MCIN.GetChunkBytes()); // MFBO if (MHDR.Flags.HasFlag(MHDRFlags.MFBO)) { MHDR.OffsetMFBO = (uint)writer.BaseStream.Position; writer.Write(MFBO.GetChunkHeaderBytes()); writer.Write(MFBO.GetChunkBytes()); } else { MHDR.OffsetMFBO = 0; } // MTXF MHDR.OffsetMTXF = (uint)writer.BaseStream.Position; writer.Write(MTXF.GetChunkHeaderBytes()); writer.Write(MTXF.GetChunkBytes()); // MHDR writer.BaseStream.Position = positionBeforeMHDR; writer.Write(MHDR.GetChunkHeaderBytes()); writer.Write(MHDR.GetChunkBytes()); } }
public void Accept(int id) { MMgame game = new MMgame(); while (ALL_ACCEPTED == false && ALL_DECLINED == false) { Thread.Sleep(500); Info = "Waiting for all players to accept ..."; //game = DSrest.Status(id); game = _mmrep.Status(id.ToString()).Result; preGame = game; if (game == null) { //Console.WriteLine("game = null {0} => ({1})", seplayer.Name, id); if (DECLINED == false && ACCEPTED == true) { ALL_DECLINED = true; Info = "# Game not found :( - Searching again .."; Thread.Sleep(2500); GAMEFOUND = false; Task.Run(() => { Searching(); }); return; } } else if (game.Declined == true) { //Console.WriteLine("game = declined {0} => {1} ({2})", seplayer.Name, game.ID, id); List <BasePlayer> ilist = new List <BasePlayer>(); ilist.AddRange(game.Team1); ilist.AddRange(game.Team2); Lobby.Clear(); foreach (var pl in ilist) { Lobby.TryAdd(pl.Name, pl.Accepted); } Thread.Sleep(1500); if (DECLINED == false && ACCEPTED == true) { ALL_DECLINED = true; Info = "# Someone declined :( - Searching again .."; Thread.Sleep(2500); GAMEFOUND = false; Task.Run(() => { Searching(); }); return; } } else { //Console.WriteLine("Some accepted = true {0} => {1} ({2})", seplayer.Name, game.ID, id); List <BasePlayer> ilist = new List <BasePlayer>(); ilist.AddRange(game.Team1); ilist.AddRange(game.Team2); Lobby.Clear(); foreach (var pl in ilist) { Lobby.TryAdd(pl.Name, pl.Accepted); } if (game.Accepted == true) { GAMEFOUND = false; Lobby.Clear(); Info = "Game ready!"; ALL_ACCEPTED = true; GameReady(game); return; } } if (Done > 100) { Reset(); } else if (Done > 85) { if (ACCEPTED == false) { Declined(); } } if (DECLINED == true) { Info = "We declined/timed out :("; GAMEFOUND = false; //DSrest.Decline(seplayer.Name, MMID); _mmrep.Decline(seplayer.Name, MMID.ToString()); ALL_DECLINED = true; } Thread.Sleep(500); _time = _time.Add(TimeSpan.FromSeconds(0.5)); Done += 1.428571429; Done += 1.428571429; } }