Square789 / tf2_dem_py

TF2 demo parser for python, glued together using C.
MIT License
9 stars 0 forks source link

Using this for reading demos created from TF2 clients #9

Closed brandons209 closed 1 year ago

brandons209 commented 1 year ago

Hello, is it possible to modify the code to also read demo files from clients recording demos? Right now it only works with SourceTV generated demos as far as I can tell. If you can point me in the right direction I can take a crack at implementing this.

Square789 commented 1 year ago

I can parse through demos created simply by playing TF2 and running ds_record perfectly fine (this means client, i hope). It actually would be the inverse from my standpoint, I have no idea how to get SourceTV demos or how they could differ.

If you have a demo that is segfaulting or raising an error, i could try and take a look at it, if you're fine with sending it, that is. I hope however you're not expecting much, because, sorry to disappoint, this project is seriously lacking in general: events are not parsed alongside their tick and there is a lot of data that's being skipped, largely because there simply is a dwindling amount of information on its shape; This project is unfortunately not in my focus anymore for the forseeable future.

brandons209 commented 1 year ago

Hmm, from my understanding if this is a port of the demo parser for demos.tf then the code should be able to parse sourcetv demos, which it can for me. However, on my demos recorded using ds_record I get demo_parser.ParserError: Last message id: 48, File handle offset 998987 bytes. Errors: Unknown message id encountered. or a IO error. I'll attach the demo here if you want to take a look. I am building a program to parse the demo file in real time while playing and extract information like kills, damage, ubers, etc, similar to what logs.tf records. And since I am using python I am looking for a Python library to help with this. Archive.zip

Square789 commented 1 year ago

Thanks, found the problem (a missing return) and fixed it. I don't think i ever get multiple Print messages as i never really play on community servers, so this was somewhat helpful, thank you! (It kind of was the cause of this issue, so i'll go ahead and mark it as closed.)

What you're describing was my original intention for this project as well, but unfortunately i got kinda lost. I just don't know what should all be extracted and - bluntly - lost motivation with the intended "parent" project Demomgr after more successful competition popped up. All you can get at the moment is the header, chat and game events, without any timing information. And the worst thing is: game events are hardcoded by their id when i'm not even sure whether that's correct, or just pure dumb luck of the ids always being the same: https://github.com/Square789/tf2_dem_py/blob/76a6a8d2a22f3420f35dc3d49b30b8d9acd46f3c/tf2_dem_py/demo_parser/message/gameevents.c#L16-L23

Well, again, sorry. I don't think this project will be able to help you too much unless you spend weeks digging through the demo structure and making the improvements needed. If you want to parse information out of demos, probably best to use the already existing and actually working parser over at https://github.com/demostf/parser. It will be tedious to build a bridge between rust and python, but that should still be a lot less painful than getting this project into an acceptable shape.

brandons209 commented 1 year ago

Alright, thanks for coming back to this project after all this time. I'll take a look at demostf implementation.

I hope I can build a bridge between rust, never used it before. I might end up improving this repo with what ever fixes I need if I can't get the rust bridge working.