Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Logging Debug-Mode in Factorio

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions
View previous topic :: View next topic  
Author Message
Sanga
How do I cheat?
Reputation: 0

Joined: 06 Jun 2019
Posts: 3

PostPosted: Sun May 24, 2020 4:39 am    Post subject: Logging Debug-Mode in Factorio Reply with quote

Hello Cheat-Engine Community,

right now I despair of a problem I tried to solve so many times that I stopped counting ...

Hopefully someone will be able to help me with a solution but first I'll try to explain what I want to do and how far I got until this day.
I have almost no background in the field of informatics what might explain if I use wrong terms in the following section.

My goal is to log data from a game named "Factorio" which is shown in the Debug-Mode of this game (see - Debug-Mode.png - left side). Basically you yield information about what objects/processes in the game consume which calculation time (in ms) what helps you then to optimize your layouts. In the screenshot as example you see the "Game render"-time. It is separated in three numbers (ave / min / max) and encoded as string. By using "Unknown initial value - increased value - decreased value - etc." I was already able to identify linked values (normally in 4 bytes format) but never the value itself (here e. g. Game render: 0.239ms/0.200ms/1.987ms). I assume that it must be calculated as float or double but never found the exact value.

The memory viewer (see Working-Memory.png) indicates that the region of calculation of the string in the working memory changes extreme fast (dynamically?) and I was not able to track its source down by using "What accesses/writes to this address" but this is maybe because I also try something impossible?

Right now I am using quite a workaround whose result can be seen in Log-Data.png.
As I mentioned earlier I tracked down some linked values which need an Off-Set to fit to the values seen in the Debug-Mode of this game and are static? now because I found a pointer to each one. Cheat-Engine then logs these values for me and I insert them into Excel (one day Origin).

What answers I hope to find out with my post are :

- What kind of value I am really looking for?
- Is it even possible to track this kind of values?
- Do you have a smart solution which I miss because of a lack of knowledge in the field of informatics?

Greetings,
Sanga ^_^



Log-Data.png
 Description:
 Filesize:  61.1 KB
 Viewed:  2539 Time(s)

Log-Data.png



Working-Memory.png
 Description:
 Filesize:  296.02 KB
 Viewed:  2539 Time(s)

Working-Memory.png



Debug-Mode.png
 Description:
 Filesize:  279.08 KB
 Viewed:  2539 Time(s)

Debug-Mode.png


Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4696

PostPosted: Sun May 24, 2020 10:31 am    Post subject: Reply with quote

A lot of those values are probably temporaries materialized from arithmetic expressions involving other values, and/or they're stored on the stack and thrown away quickly. e.g. something like this pseudocode:
Code:
local start = current_time()
game_render()
local duration = current_time() - start
logData("Game render:", duration / 1000)

The start and duration variables are stored on the stack and only exist within the function. When the function exits, those variables' lifetimes end, and they'll get overwritten shortly thereafter by some other function. Scanning for values in CE probably won't find these.
The actual value you want to find comes from the expression "duration / 1000". This materializes a temporary that has a similar transient lifetime as local variables stored on the stack. They aren't stored anywhere in particular for any substantial length of time and can't be found by scans (generally).

I don't think there's any easy way of doing what you want to do. A "correct" way would be to hook a game's function that's involved in the logging process, but that could delve into basic reverse engineering and isn't for beginners. Whatever workaround you're using is probably the best method you're going to get.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Sanga
How do I cheat?
Reputation: 0

Joined: 06 Jun 2019
Posts: 3

PostPosted: Mon May 25, 2020 1:18 pm    Post subject: Thanks for the information Reply with quote

Thx ParkourPenguin for your explanations.

As far as I understood the mechanics of Factorio the game is updated 60 times per second. So this means the stack which yields my value (computing time) is updated every 1/60 s ?

The workaround basically uses a linked value with a fix address which also increases while the shown computing time rises. I tracked it down by e. g. using a specific unit (Logistic Bots) to just increase the computing time needed for managing the logistic network. But I have no clue why this specific 4-byte-value is linked to it. Then you just need to use the right offset to get ms-values instead of 4 bytes
.... quite frustrating and costly but it works. Thanks again because now I can stop to try it again and again Very Happy
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4696

PostPosted: Mon May 25, 2020 2:22 pm    Post subject: Reply with quote

Sanga wrote:
So this means the stack which yields my value (computing time) is updated every 1/60 s ?
I wouldn't say stacks "yield" values- it's just a temporary storage space for values that weren't important enough to have memory allocated for them elsewhere.
I wouldn't use the word "updated" either. Again, the stack is for temporary storage. The vast majority of values only live in the stack for microseconds or nanoseconds.
The function might get run about every 1/60th of a second, but it doesn't "update" values in the stack. It puts new values there, runs some other code, and when the function returns, those values are abandoned to die. Some other function will come in and overwrite them with something else. Values aren't being "updated" - they're constantly created and destroyed.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites