saul / demofile

Node.js library for parsing Counter-Strike: Global Offensive demo files
https://demofile.dev
MIT License
483 stars 53 forks source link

Some demos missing `round_announce_match_start` #354

Closed dbalders closed 2 years ago

dbalders commented 2 years ago

Research

Description

Hey Saul, I've been noticing a number of demos this year where no gameEvents are being called. No flashbangs, smokes, end of round, etc.

Here's an example demo where both maps nothing is called (tried to drop a demo below but it wouldn't accept it): https://www.hltv.org/matches/2354299/alternate-attax-vs-spirit-pinnacle-winter-series-2-regionals

Code working for other demos, but have seen dozens that this is happening to and isn't happening on demos from ~6 months ago. If you want or need a larger list of demos with the problem I can provide more. Thanks for the help.

Code to reproduce

No response

Affected demos

No response

dbalders commented 2 years ago

Wait, might have just realized its because the demo isn't calling round_announce_match_start, so none of my other stuff is catching. Is this the wrong way to get the start of the match? Has worked for a while with no issues.

saul commented 2 years ago

Those demos are definitely unusual - the demo seems to start when roundsPlayed = 1 (it should start at 0). This is likely why the round_announce_match_start event is missing - it was probably fired before the demo started recording. See below for an example of logging roundsPlayed:

demoFile.gameEvents.on("round_start", e => {
  console.log(
    `Round #${demoFile.entities.gameRules.roundsPlayed} (phase: ${demoFile.entities.gameRules.phase})`
  );
});
Expand to see output for alternate-attax-vs-spirit-m1-nuke.dem...
Round #1 (phase: first)
Round #2 (phase: first)
Round #3 (phase: first)
Round #4 (phase: first)
Round #5 (phase: first)
Round #6 (phase: first)
Round #7 (phase: first)
Round #8 (phase: first)
Round #9 (phase: first)
Round #10 (phase: first)
Round #11 (phase: first)
Round #12 (phase: first)
Round #13 (phase: first)
Round #14 (phase: first)
Round #15 (phase: second)
Round #16 (phase: second)
Round #17 (phase: second)
Round #18 (phase: second)
Round #19 (phase: second)
Round #20 (phase: second)
Round #21 (phase: second)
Round #22 (phase: second)
Round #23 (phase: second)
Round #24 (phase: second)
Round #25 (phase: second)
Finished.

With other demos I checked, the demo starts at roundsPlayed = 0. Out of interest why are you waiting for round_announce_match_start before you attach your events? I think your code could be more robust if you:

This way your code will correctly handle a demo recording that starts after round_announce_match_start has been fired.

dbalders commented 2 years ago

I had/have it like that currently because I was getting a lot of issues with players not existing or players being on the wrong team, etc. But, that might be smart to just try and capture immediately and then reset if the match start is called. Thanks.