public void ParseStringTable(IBitStream reader, string tableName, DemoParser parser) { var numStrings = (int)reader.ReadInt(16); if (tableName == "modelprecache") { parser.modelprecache.Clear(); } for (var i = 0; i < numStrings; i++) { var stringName = reader.ReadString(); if (stringName.Length >= 100) { throw new Exception("Roy said I should throw this."); } if (reader.ReadBit()) { var userDataSize = (int)reader.ReadInt(16); var data = reader.ReadBytes(userDataSize); if (tableName == "userinfo") { var info = PlayerInfo.ParseFrom(new BinaryReader(new MemoryStream(data))); parser.RawPlayers[int.Parse(stringName)] = info; } else if (tableName == "instancebaseline") { var classid = int.Parse(stringName); //wtf volvo? parser.instanceBaseline[classid] = data; } else if (tableName == "modelprecache") { parser.modelprecache.Add(stringName); } } } // Client side stuff if (reader.ReadBit()) { var numstrings = (int)reader.ReadInt(16); for (var i = 0; i < numstrings; i++) { reader.ReadString(); // stringname if (reader.ReadBit()) { var userDataSize = (int)reader.ReadInt(16); reader.ReadBytes(userDataSize); } } } }
public IBlockEvent DeSerialize(IBitStream stream) { var clientInfo = new ClientInfoEvent(); var userNameLength = stream.ReadBits(0x10); if (userNameLength > 0) { clientInfo.Username = stream.ReadString(userNameLength); } var v1 = stream.ReadBits(32); var v2 = stream.ReadBits(1); var v3 = stream.ReadBits(31); var v4 = stream.ReadBits(0x10); if (v4 > 0) { clientInfo.Username = stream.ReadString(v4); } var v5 = stream.ReadBits(0x10); if (v5 > 0) { clientInfo.SomeString = stream.ReadString(v5); } var v6 = stream.ReadBits(1); return(clientInfo); }
public string ReadString() { var a = A.ReadString(); var b = B.ReadString(); Verify(a, b); return(a); }
public void ParseStringTable(IBitStream reader, string tableName, DemoParser parser) { int numStrings = (int)reader.ReadInt(16); if (tableName == "modelprecache") { parser.modelprecache.Clear (); } for (int i = 0; i < numStrings; i++) { string stringName = reader.ReadString(); if (stringName.Length >= 100) throw new Exception("Roy said I should throw this."); if (reader.ReadBit()) { int userDataSize = (int)reader.ReadInt(16); byte[] data = reader.ReadBytes(userDataSize); if (tableName == "userinfo") { PlayerInfo info = PlayerInfo.ParseFrom(new BinaryReader(new MemoryStream(data))); parser.RawPlayers[int.Parse(stringName)] = info; } else if (tableName == "instancebaseline") { int classid = int.Parse(stringName); //wtf volvo? parser.instanceBaseline[classid] = data; } else if (tableName == "modelprecache") { parser.modelprecache.Add (stringName); } } } // Client side stuff if ( reader.ReadBit() ) { int numstrings = (int)reader.ReadInt(16); for ( int i = 0 ; i < numstrings; i++ ) { reader.ReadString(); // stringname if ( reader.ReadBit() ) { int userDataSize = ( int )reader.ReadInt(16); reader.ReadBytes( userDataSize ); } else { } } } }
private void ParseStringTable(IBitStream reader, string tableName, DemoParser parser) { int numStrings = (int)reader.ReadInt(16); for (int i = 0; i < numStrings; i++) { string stringName = reader.ReadString(); if (stringName.Length >= 100) { throw new Exception("Roy said I should throw this."); } if (reader.ReadBit()) { int userDataSize = (int)reader.ReadInt(16); byte[] data = reader.ReadBytes(userDataSize); switch (tableName) { case "userinfo": PlayerInfo info = PlayerInfo.ParseFrom(new BinaryReader(new MemoryStream(data))); UpdatePlayer(info, parser); break; case "instancebaseline": // TODO implement //int classid = int.Parse(stringName); //parser.instanceBaseline[classid] = data; break; } } } // Client side stuff if (reader.ReadBit()) { int numstrings = (int)reader.ReadInt(16); for (int i = 0; i < numstrings; i++) { reader.ReadString(); // stringname if (reader.ReadBit()) { int userDataSize = ( int )reader.ReadInt(16); reader.ReadBytes(userDataSize); } else { } } } }
public IBlockEvent DeSerialize(IBitStream stream) { var mapListEvent = new MapListEvent(); var mapCount = stream.ReadBits(16); while (mapCount > 0) { var map = new Map(); map.MaxPlayers = stream.ReadBits(16); var mapNameLen = stream.ReadBits(16); map.MapName = stream.ReadString(mapNameLen); var gameModeLen = stream.ReadBits(16); map.GameMode = stream.ReadString(gameModeLen); mapListEvent.Maps.Add(map); mapCount--; } return(mapListEvent); }
public void ParsePacket(IBitStream reader, DemoParser parser) { int numTables = reader.ReadByte(); for (int i = 0; i < numTables; i++) { string tableName = reader.ReadString(); ParseStringTable(reader, tableName, parser); } }
public IGameEvent DeSerialize(IBitStream stream) { var challengeEvent = new ChallengeEvent(); challengeEvent.Challenge = stream.ReadBytes(10); //actual challenge? var modNameLength = stream.ReadBits(8); //modname length challengeEvent.ModName = stream.ReadString(modNameLength); //actual modname return(challengeEvent); }
public void ParsePacket(IBitStream reader, DemoParser parser) { int numTables = reader.ReadByte(); for (int i = 0; i < numTables; i++) { string tableName = reader.ReadString(); ParseStringTable(reader, tableName, parser); } }
public IBlockEvent DeSerialize(IBitStream stream) { var mapInfoEvent = new MapInfoEvent(); var gameModeLen = stream.ReadBits(0x10); mapInfoEvent.GameMode = stream.ReadString(gameModeLen); var pathLen = stream.ReadBits(0x10); mapInfoEvent.MapPath = stream.ReadString(pathLen); var levelNameLen = stream.ReadBits(0x10); mapInfoEvent.MapName = stream.ReadString(levelNameLen); var v4 = stream.ReadBits(1); mapInfoEvent.MaxPlayers = stream.ReadBits(31); mapInfoEvent.CommanderEnabled = stream.ReadBits(1); var v7 = stream.ReadBits(1); mapInfoEvent.ChallengeOrdinal = stream.ReadBits(31); var v9 = stream.ReadBits(1); var v10 = stream.ReadBits(1); return(mapInfoEvent); }
public IGameEvent DeSerialize(IBitStream stream) { var createPlayerEvent = new CreatePlayerEvent(); createPlayerEvent.PlayerTeam = stream.ReadBits(3); createPlayerEvent.SpawnGroup = stream.ReadBits(4); var v3 = stream.ReadBits(1); createPlayerEvent.PlayerId = stream.ReadBits(8); //id given by gameserver, not actual gamespy id createPlayerEvent.PlayerIndex = stream.ReadBits(0x10); //another server id? This one does not start at 0 var v6 = stream.ReadBits(0x10); //always 0 createPlayerEvent.IsAI = stream.ReadBool(); createPlayerEvent.PlayerName = stream.ReadString(32).Replace("\0", ""); return(createPlayerEvent); }
public static string ReadString(this IBitStream bs) { return(bs.ReadString(Int32.MaxValue)); }
public static void Apply(CreateStringTable table, IBitStream reader, DemoParser parser) { if (table.Name == "modelprecache") { while (parser.modelprecache.Count < table.MaxEntries) { parser.modelprecache.Add(null); } } if (reader.ReadBit()) { throw new NotImplementedException("Encoded with dictionaries, unable to decode"); } int nTemp = table.MaxEntries; int nEntryBits = 0; while ((nTemp >>= 1) != 0) { ++nEntryBits; } List <string> history = new List <string>(); int lastEntry = -1; for (int i = 0; i < table.NumEntries; i++) { int entryIndex = lastEntry + 1; // d in the entity-index if (!reader.ReadBit()) { entryIndex = (int)reader.ReadInt(nEntryBits); } lastEntry = entryIndex; // Read the name of the string into entry. string entry = ""; if (entryIndex < 0 || entryIndex >= table.MaxEntries) { throw new InvalidDataException("bogus string index"); } if (reader.ReadBit()) { bool substringcheck = reader.ReadBit(); if (substringcheck) { int index = (int)reader.ReadInt(5); int bytestocopy = (int)reader.ReadInt(5); entry = history[index].Substring(0, bytestocopy); entry += reader.ReadString(1024); } else { entry = reader.ReadString(1024); } } if (entry == null) { entry = ""; } if (history.Count > 31) { history.RemoveAt(0); } history.Add(entry); // Read in the user data. byte[] userdata = new byte[0]; if (reader.ReadBit()) { if (table.UserDataFixedSize) { userdata = reader.ReadBits(table.UserDataSizeBits); } else { int bytesToRead = (int)reader.ReadInt(14); userdata = reader.ReadBytes(bytesToRead); } } if (userdata.Length == 0) { continue; } if (table.Name == "userinfo") { // Now we'll parse the players out of it. BinaryReader playerReader = new BinaryReader(new MemoryStream(userdata)); PlayerInfo info = PlayerInfo.ParseFrom(playerReader); parser.RawPlayers[entryIndex] = info; } else if (table.Name == "instancebaseline") { int classid = int.Parse(entry); //wtf volvo? parser.instanceBaseline[classid] = userdata; } else if (table.Name == "modelprecache") { parser.modelprecache[entryIndex] = entry; } } parser.stringTables.Add(table); }
public IBlockEvent DeSerialize(IBitStream stream) { var serverInfo = new ServerInfoEvent(); uint gameNameLength = stream.ReadBits(0x10); serverInfo.GameName = stream.ReadString(gameNameLength); uint v10 = 0; uint v11 = stream.ReadBits(0x10); var description = ""; do { uint descriptionPartLength = stream.ReadBits(0x10); if (descriptionPartLength != 0) { description += stream.ReadString(descriptionPartLength); } v10++; }while (v11 > v10); serverInfo.GameDescription = description; var v12 = stream.ReadBits(1); //20//some value that is always 1 serverInfo.Unknown1 = stream.ReadBits(1); //21 serverInfo.AllowNoseCam = stream.ReadBits(1); //22 serverInfo.HitIndicator = stream.ReadBits(1); //23 serverInfo.TeamKillPunishByDefault = stream.ReadBits(1); //24 serverInfo.AllowFreeCam = stream.ReadBits(1); //25 serverInfo.AllowExternalViews = stream.ReadBits(1); //26 serverInfo.Unknown2 = stream.ReadBits(32); //7 serverInfo.Unknown3 = stream.ReadBits(0x10); //16 serverInfo.Unknown4 = stream.ReadBits(0x10); //17 var v22 = stream.ReadBits(1); serverInfo.Unknown5 = stream.ReadBits(31); //9 serverInfo.GameSpyPort = stream.ReadBits(0x10); //26 var v25 = stream.ReadBits(1); serverInfo.RadioSpamInterval = stream.ReadBits(31);//10 var v27 = stream.ReadBits(1); serverInfo.RadioMaxSpamFlagCount = stream.ReadBits(31);//11 var v29 = stream.ReadBits(1); serverInfo.RadioBlockedDurationTime = stream.ReadBits(31); //12 var v31 = stream.ReadBits(1); //54 serverInfo.VotingEnabled = stream.ReadBits(1); //55 serverInfo.Unknown6 = stream.ReadBits(0x10); //28 serverInfo.FriendlyFireWithMines = stream.ReadBits(1); //58 serverInfo.TeamVoteOnly = stream.ReadBits(1); //59 serverInfo.NoVehicles = stream.ReadBits(1); //60 serverInfo.Unknown7 = stream.ReadBits(1); //61 var v38 = stream.ReadBits(1); serverInfo.RoundsPerMap = stream.ReadBits(31);//16 var v40 = stream.ReadBits(1); serverInfo.SpawnTime = stream.ReadBits(31);//17 var v42 = stream.ReadBits(1); serverInfo.TimeLimit = stream.ReadBits(31);//18 var v44 = stream.ReadBits(1); serverInfo.TicketRatio = stream.ReadBits(31);//19 var v46 = stream.ReadBits(1); serverInfo.TeamRatioPercent = stream.ReadBits(31); //20 serverInfo.AutoBalanceTeam = stream.ReadBits(1); //84 serverInfo.UseGlobalUnlocks = stream.ReadBits(1); //85 var v50 = stream.ReadBits(1); serverInfo.CoopBotRatio = stream.ReadBits(31);//22 var v52 = stream.ReadBits(1); serverInfo.CoopBotCount = stream.ReadBits(31);//23 var v54 = stream.ReadBits(1); serverInfo.CoopBotDifficulty = stream.ReadBits(31);//24 return(serverInfo); }
public static void Apply(CreateStringTable table, IBitStream reader, DemoParser parser) { if (table.Name == "modelprecache") { while (parser.modelprecache.Count < table.MaxEntries) { parser.modelprecache.Add(null); } } if (reader.ReadBit()) throw new NotImplementedException("Encoded with dictionaries, unable to decode"); int nTemp = table.MaxEntries; int nEntryBits = 0; while ((nTemp >>= 1) != 0) ++nEntryBits; List<string> history = new List<string>(); int lastEntry = -1; for (int i = 0; i < table.NumEntries; i++) { int entryIndex = lastEntry + 1; // d in the entity-index if (!reader.ReadBit()) { entryIndex = (int)reader.ReadInt(nEntryBits); } lastEntry = entryIndex; // Read the name of the string into entry. string entry = ""; if (entryIndex < 0 || entryIndex >= table.MaxEntries) { throw new InvalidDataException("bogus string index"); } if (reader.ReadBit()) { bool substringcheck = reader.ReadBit(); if (substringcheck) { int index = (int)reader.ReadInt(5); int bytestocopy = (int)reader.ReadInt(5); entry = history[index].Substring(0, bytestocopy); entry += reader.ReadString(1024); } else { entry = reader.ReadString(1024); } } if (entry == null) entry = ""; if (history.Count > 31) history.RemoveAt(0); history.Add(entry); // Read in the user data. byte[] userdata = new byte[0]; if (reader.ReadBit()) { if (table.UserDataFixedSize) { userdata = reader.ReadBits(table.UserDataSizeBits); } else { int bytesToRead = (int)reader.ReadInt(14); userdata = reader.ReadBytes(bytesToRead); } } if (userdata.Length == 0) break; if (table.Name == "userinfo") { // Now we'll parse the players out of it. BinaryReader playerReader = new BinaryReader(new MemoryStream(userdata)); PlayerInfo info = PlayerInfo.ParseFrom(playerReader); parser.RawPlayers[entryIndex] = info; } else if (table.Name == "instancebaseline") { int classid = int.Parse(entry); //wtf volvo? parser.instanceBaseline[classid] = userdata; } else if (table.Name == "modelprecache") { parser.modelprecache[entryIndex] = entry; } } parser.stringTables.Add(table); }
public void ParseStringTableMessage(CSVCMsg_CreateStringTable table, DemoParser parser) { using (IBitStream reader = BitStreamUtil.Create(table.string_data)) { if (reader.ReadBit()) { throw new NotImplementedException("Encoded with dictionaries, unable to decode"); } int nTemp = table.max_entries; int nEntryBits = 0; while ((nTemp >>= 1) != 0) { ++nEntryBits; } List <string> history = new List <string>(); int lastEntry = -1; for (int i = 0; i < table.num_entries; i++) { int entryIndex = lastEntry + 1; // read in the entity-index if (!reader.ReadBit()) { entryIndex = (int)reader.ReadInt(nEntryBits); } lastEntry = entryIndex; // Read the name of the string into entry. string entry = ""; if (entryIndex < 0 || entryIndex >= table.max_entries) { throw new InvalidDataException("bogus string index"); } if (reader.ReadBit()) { bool substringcheck = reader.ReadBit(); if (substringcheck) { int index = (int)reader.ReadInt(5); int bytestocopy = (int)reader.ReadInt(5); entry = history[index].Substring(0, bytestocopy); entry += reader.ReadString(1024); } else { entry = reader.ReadString(1024); } } if (entry == null) { entry = ""; } if (history.Count > 31) { history.RemoveAt(0); } // Read in the user data. byte[] userdata = new byte[0]; if (reader.ReadBit()) { if (table.user_data_fixed_size) { userdata = reader.ReadBits(table.user_data_size_bits); } else { int bytesToRead = (int)reader.ReadInt(14); userdata = reader.ReadBytes(bytesToRead); } } if (userdata.Length == 0) { break; } // Now we'll parse the players out of it. BinaryReader playerReader = new BinaryReader(new MemoryStream(userdata)); PlayerInfo info = PlayerInfo.ParseFrom(playerReader); UpdatePlayer(info, parser); } } }