LiveSplit / asr

Helper crate to write auto splitters for LiveSplit One's auto splitting runtime.
https://livesplit.org/asr/asr
Apache License 2.0
10 stars 10 forks source link

Porting DeepPointer over from classic LiveSplit #64

Closed Jujstme closed 11 months ago

Jujstme commented 11 months ago

Despite the runtime already allows pointer path resolution with process.read_pointer_path32() and process.read_pointer_path64(), sometimes it's more convenient and provides more freedom when pointer paths are defined inside a custom function, then stored in a struct and dereferenced when needed inside the autosplitter logic.

This provides an essentially equal implementation of DeepPointer from OG LiveSplit, allowing for easier retrieval of memory addresses or values via the defined deref_offsets() or deref::<T>() functions.

CryZe commented 11 months ago

What's the reason for allowing a higher capacity than the path's actual length?

Jujstme commented 11 months ago

It's a thing I discussed with Knauth when I was originally writing the function for Unity. I personally would see no reason, except maybe making a series of DeepPointers with the same capacity for code purposes (eg. iterating through them).

The capacity still needs to be provided anyway, so either this or forcing it to be the same length of the path is, for me, fine.

Jujstme commented 11 months ago

There is actually a sound reason to have a capacity instead of a length, for example when a pointer path has different lengths according to the game version (it's a very rare occurrence but it does happen sometimes).