skadistats / clarity

Comically fast Dota 2, CSGO, CS2 and Deadlock replay parser written in Java.
BSD 3-Clause "New" or "Revised" License
657 stars 120 forks source link

CS2 - Read file header info #322

Open ndorigatti opened 1 week ago

ndorigatti commented 1 week ago

Hello, I'm opening a new issue related to CS2 replays. I take as reference the issue #321 where i've put the replay file.

Taking as a reference the project https://github.com/LaihoE/demoparser I'm trying to get the header of this file in the same way is possible in the python project.

As a reference, in python is just:

header = parser.parse_header()
  print("** Map is: " + header["map_name"])
  print("** GUID is:" + header["demo_version_guid"])
  print("****** Last Tick Parsed ******")

I tryed to do in clarity the following:

     @OnMessage
    public void onMessage(Context ctx, GeneratedMessage message) {
        if (isHeader(message)) {
            logger.debug(message.toString());
            final Demo.CDemoFileHeader headers = (Demo.CDemoFileHeader) message;
            logger.info("********");
            logger.info("map name: {}", headers.getMapName());
            logger.info("Guid: {}", headers.getDemoVersionGuid());
            logger.info("Server start tick: {}", headers.getServerStartTick());
        }
//        log.info("{}", event.toString());
    }

And it works, but this way is an event "listener", is it possible to retrieve it programmatically on need? Given Demo.CDemoFileInfo info = Clarity.infoForFile(demofile);

the infoForFile does not retrieve it and i can't find any other way...

spheenik commented 3 days ago

@OnMessage(Demo.CDemoFilerHeader.class) does the trick.

spheenik commented 3 days ago

Regarding file info: It's not in there. It's a Dota-thing.