LiveSplit / LiveSplit/asr

(Feature Request) Unreal: Listing or iterating through all fields In a UObject

Open
#113 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
13
Forks
16
Avg merge
16d 9h
Merged PRs (30d)
15

Description

While working on the THPS 1+2/3+4 autosplitter, when starting to adopt UObject field names to find offsets (and more directly, #112), but found it difficult to actually figure out what I was looking for. It was useful to modify the asr crate to list all fields in a given UObject for me.

For example, to UObject, I added the following:
```
pub fn list_fields(&self, process: &Process, module: &Module) {
let name = self.get_fname::(process, module).unwrap().validate_utf8().unwrap().to_string();
crate::print_message(&format!("Fields for UObject {}:", name));

self.get_uclass(process, module)
.unwrap()
.list_fields(process, module);

crate::print_message(&format!(""));
}
```

and to UClass,
```
fn list_fields(
&self,
process: &Process,
module: &Module,
) {
for field in self.properties(process, module) {
let name = field.get_fname::(process, module).unwrap().validate_utf8().unwrap().to_string();
let offset = field.get_offset(process, module).unwrap();

crate::print_message(&format!("{}: offset {:#018x}", name, offset));
}
}
```

Obviously this solution isn't great as it relies upon alloc. I think the ideal solution is to expose the iterator and allow the user to do anything for each entry. I don't really have the time to iterate upon it right now to make a proper pull request so I'm making this issue to present the idea.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the UObject and UClass list_fields examples in the issue, then trace UClass::properties and the field name and offset accessors. Done means exposing iteration over a UObject's fields without requiring alloc, while allowing callers to perform their own action for each entry.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, unreal-engine
Domain
game-dev, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.