Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to find the initial tick that corresponds to the game start? #53

Open
Whoeza opened this issue Dec 4, 2022 · 7 comments
Open

How to find the initial tick that corresponds to the game start? #53

Whoeza opened this issue Dec 4, 2022 · 7 comments
Labels

Comments

@Whoeza
Copy link
Contributor

Whoeza commented Dec 4, 2022

Hi! I wanted to learn to convert timestamp and timestamp_raw into clock time. Is there a fixed offset that can be used to translate those two values into clock time? Or is there an event in the replay that refers to the switch from strategy time to match start?

@spheenik
Copy link
Member

spheenik commented Dec 4, 2022

Read this comment (and the whole thread):

skadistats/clarity#106 (comment)

@Whoeza
Copy link
Contributor Author

Whoeza commented Dec 4, 2022

Thank you for the link. I have read it, but I'm confused, I'll try to describe why. I made a dump with the clarity example "dump" and I found that timestamp seems to be the variable that tracks the time. Now from your link I found that there's another time to take into account, which is paused time, which might be what timestamp_raw is.
But apart from that, I read in the thread that they are talking about and using another variable, rather than timestamp, and that is m_fGameTime, or m_flGameStartTime, etc.
When I Ctrl+F these strings in the replay dump, I find one occurrence of each, inside a binary(?) blob that I haven't understood what and why is there in the dump. There are many binary(?) blobs in the dump, and they have "string_data" or "data" in their name, then their contents have backslashes and numbers like \00\02\032 etc., and my Ctrl+F research found those m_fGameTime variables in the middle of one of those. Which might explain my confusion to you, I hope.

So, to summarize, I thought I could use timestamp and timestamp_raw in a dump file to calculate clock time and sync game events that way. Is it possible? Is it the wrong approach? What am I doing if I do it that way?
And what is the difference with using m_fGameTime, which occurs once in the whole dump? And if one must use m_fGameTime, how can one use it if it occurs once? My impression is that you can "access" m_fGameTime when you know how to write a parser that uses the Annotations events system, but it's an hypothesis at this point, as I haven't tried that in practice.

As an example, take the combatlog parser from clarity-examples. It kind of does it, because it syncs timestamps and actions, and would need to convert the times into clock times, like the thread you posted shows how it is possible to do it.
I thought I could read the dump file and be able to recreate a combatlog since it included a dump of everything from the replay. Should I learn from combatlog, and integrate it with the link you posted, to answer my questions and confusion?
Is there a difference between reading the dump and using the Annotations system to write a new events parser?

Thanks. o/

@spheenik
Copy link
Member

spheenik commented Dec 4, 2022

First of all, dumping the replay is raw data, you shouldn't use it.
The game works by providing a set of "networked entities", entities being heroes, creeps, buildings, but also some for stat data.
What you see in analyzer is the entities data.

Clarity provides access to entities through a processor (Entities.class), and several Annotations (for example @OnEntityUpdated), where you can get a callback if a property for an entity changes.

This example code (skadistats/clarity#106 (comment)) shows you how to get access to the CDOTAGamerulesProxy entity, and read poperties from them.

Here is an example that uses entities in another way: https://github.com/skadistats/clarity-examples/blob/master/src/main/java/skadistats/clarity/examples/dumpmana/Main.java

It dumps current mana and max mana for all heroes.

@Whoeza
Copy link
Contributor Author

Whoeza commented Dec 4, 2022

I'll see what I can do with these two. Thank you. I will post something here when I can get it to work.

@Whoeza
Copy link
Contributor Author

Whoeza commented Dec 4, 2022

spheenik, I don't understand...
The person in skadistats/clarity#106 used this string

CDOTAGamerulesProxy

from which to retrieve these properties

m_pGameRules.m_fGameTime
m_pGameRules.m_flPreGameStartTime
m_pGameRules.m_flGameStartTime
m_pGameRules.m_flStateTransitionTime

and you used these strings and properties

CDOTA_Unit_Hero
m_flMana
m_flMaxMana

to retrieve mana and max mana.. I have searched those strings in Protobufs and in clarity, but I have not found them.

Are mana and game time networked entities? Or the networked entities are "CDOTA_Unit_Hero..." and "CDOTAGamerulesProxy"?
I have understood that once you have retrieved these two "CDOTA_xxx" objects, they have the properties that you want to extract, but I don't see a list of these in the repository (unless my search was in the wrong scope... I searched everywhere in clarity and in all Protobuf files from GameTracker-Dota2)

One more thing I noticed: you used @OnEntityCreated when you declared the method that dumps the mana information, but the person in skadistats/clarity#106 has not used any event in the snippet they provided. Does it mean that time is not to be retrieved with events, or was the snippet incomplete and time is retrieved like any other thing?

I'm getting clarity a little bit more after some time, but I still have confusion.

Cheers!

@Whoeza
Copy link
Contributor Author

Whoeza commented Dec 14, 2022

Hi spheenik, I think I begin to understand a bit better what I'm looking at/for.
The strings such as "m_flMana" can be found in the Game tracking repository; and they appear to be connected with the Model folder in clarity. After a little exploration with IDEA, I noticed that I always ended my research in a .class java file, sometimes made of tens of thousands of lines. If my understanding is correct, those .class files are generated with the protobuf compiler for Java, and I assume(I have not read that far) that clarity reads the protobuf messages through the methods that Google's protobuf automatically generated for extraction of data from serialised protobuf data. When I need to extract the mana, for example, then I have to look for the most accurate string to use (e.g. 'm_flMana'), start a listener on the most accurate event (in the example for dumping mana it was something like OnCreateEntity and OnUpdateEntity), and in the event object that I receive from the event subsystem, extract the fieldpath for mana by its name saved in the string aforementioned. Does it sound correct to you so far? I have not tried it yet, but I will on the next occasion.
Sorry to bother you with such noob questions.
Cheers!

@spheenik
Copy link
Member

spheenik commented Jan 14, 2023

"m_FlMana" is a property of an entity.

I invite you to use clarity analyzer to inspect the plethora of entities and their properties.

I concise example on how to get to specific entities and their properties by yourself is the dumpmana example.

Hope that clears it up. Good luck on your journey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants