saul / demofile-net

Blazing fast cross-platform demo parser library for Counter-Strike 2, written in C#.
MIT License
76 stars 7 forks source link

Some Demos broken after new cs2 update "Missing CSoundEventPathCornerEntity" #65

Closed xGuysOG closed 1 month ago

xGuysOG commented 1 month ago

Research

Description

Hi, it seems we have another error with parsing after the new cs2 update, its an error that dosnt happen often occoured in 4 out of 40 demos.

error is: CSoundEventPathCornerEntity

from another project i have a stack trace too: Logs: 27/05/2024 - 21.08.34 - Error at HandleAbove25Demos System.Exception: Attempted to create unknown entity: CSoundEventPathCornerEntity at DemoFile.DemoParser.<>c__DisplayClass115_0.b__1(EntityContext context) at DemoFile.DemoParser.OnPacketEntities(CSVCMsg_PacketEntities msg) at DemoFile.PacketEvents.ParseNetMessage(Int32 msgType, ReadOnlySpan1 buf) at DemoFile.DemoParser.OnDemoPacket(CDemoPacket msg) at DemoFile.DemoEvents.ReadDemoCommandCore[T](Action1 callback, MessageParser1 parser, ReadOnlySpan1 buffer, Boolean isCompressed) at DemoFile.DemoEvents.ReadDemoCommand(EDemoCommands msgType, ReadOnlySpan1 buffer, Boolean isCompressed) at DemoFile.DemoParser.MoveNextCoreAsync(EDemoCommands msgType, Boolean isCompressed, Int32 size, CancellationToken cancellationToken) at DemoFile.DemoParser.ReadAllAsync(Stream stream, CancellationToken cancellationToken) at PowerLigaStats.DemoParsing.DemoHandler.ProcessCS2DemoRewrite(String demoFilePath, Int32 season, String division, DateTime dateTime, Boolean playoff) in C:\Users\Patri\Documents\Kode\Full-stack\PowerLigaStats\PowerLigaStats\DemoParsing\DemoHandler.cs:line 915 at PowerLigaStats.DemoParsing.DemoHandler.ProcessCS2DemoRewrite(String demoFilePath, Int32 season, String division, DateTime dateTime, Boolean playoff) in C:\Users\Patri\Documents\Kode\Full-stack\PowerLigaStats\PowerLigaStats\DemoParsing\DemoHandler.cs:line 1046 at PowerLigaStats.DemoParsing.DemoHandler.ProcessDemoFileAbove24(String demoFilePath, Int32 season, String division, DateTime dateTime, Boolean playoff) in C:\Users\Patri\Documents\Kode\Full-stack\PowerLigaStats\PowerLigaStats\DemoParsing\DemoHandler.cs:line 57 at PowerLigaStats.DemoParsing.DemoManager.HandleDemosByDivision(Int32 season, String division, List1 allResults) in C:\Users\Patri\Documents\Kode\Full-stack\PowerLigaStats\PowerLigaStats\DemoParsing\DemoManager.cs:line 271 at PowerLigaStats.DemoParsing.DemoManager.Start(Int32 season) in C:\Users\Patri\Documents\Kode\Full-stack\PowerLigaStats\PowerLigaStats\DemoParsing\DemoManager.cs:line 720

Code to reproduce

public static class Program
{
    //public static string flashNoWork = "C:\\Users\\xguys\\Desktop\\Flash issues\\crystal_vulture.dem";
    public static string flashWork = "C:\\Users\\xguys\\Desktop\\Demos To test\\661577c94c197423489bd882_0_1716836561580.dem";

    public static async Task Main(string[] args)
    {
        try
        {
            Stopwatch stopwatch3 = new Stopwatch();
            stopwatch3.Start();
            MemoryStream _fileStream;
            byte[] _demoBytes;
            //_demoBytes = File.ReadAllBytes(demoFilePath);
            _demoBytes = await File.ReadAllBytesAsync(flashWork);
            _fileStream = new MemoryStream(_demoBytes);

            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            var demo = new DemoParser();

            demo.Source1GameEvents.BombExploded += e =>
            {
                Console.WriteLine("Bomb exploded");
            };

            demo.Source1GameEvents.PlayerBlind += e =>
            {
                Console.WriteLine("Player blind");

            };

            demo.Source1GameEvents.TrPlayerFlashbanged += e =>
            {
                Console.WriteLine("Player flashbanged");
            };

            //demo.Source1GameEvents.FlashbangDetonate += e =>
            //{
            //    Console.WriteLine("Flashbang detonate");
            //};

            demo.Source1GameEvents.RoundStart += e =>
            {

                if (!demo.GameRules.HasMatchStarted)
                {
                    //PowerLigaManager.Log("ROund end called but we have an issue, it seems match was not started yet");
                    return;
                }
                Console.WriteLine("Round start called at round ct:" + demo.TeamCounterTerrorist.Score + " and t:" + demo.TeamTerrorist.Score);
                Debug.WriteLine("Round start called at round ct:" + demo.TeamCounterTerrorist.Score + " and t:" + demo.TeamTerrorist.Score);
            };

            demo.Source1GameEvents.CsWinPanelMatch += e =>
            {
                Console.WriteLine("WIn match has ended");
            };
            await demo.ReadAllAsync(_fileStream);
            stopwatch3.Stop();

            stopwatch.Stop();
            Console.WriteLine("Time elapsed after file data: {0}", stopwatch.Elapsed);
            Console.WriteLine("Time elapsed: {0}", stopwatch3.Elapsed);
            Console.WriteLine("\nFinished!");
        } catch (Exception e)
        { 
            Console.WriteLine("Exception: " + e.Message.ToString());
        }

        Console.ReadKey();
    }

Affected demos

https://drive.google.com/file/d/1ks0sX_5EVK-Cy7BT66bpXorhmJUrVAqp/view?usp=sharing

saul commented 1 month ago

Thanks for reporting. The fix will be released as v0.15.1