mirror of
https://github.com/open-goal/jak-project
synced 2026-05-23 06:54:31 -04:00
[decompiler] new features + fixes, + other jak2 fixes (#2796)
Fixes empty boxed arrays of strings breaking some decomp (`ctywide-speech` and `race-info`). Adds `decomp-as` tag to decompiler types so that the static data decompiler can use macros like `meters` and `seconds` on fields that aren't of type `meters` or `time-frame`. Adds `override` tag to decompiler types which overrides the type of field with that name. The type must be a child type of the original field's type (or the same type, but why would you do this?). Fixes the camera being offset for `drillmtn` after loading `palout` once. This is a huge refactor sadly.
This commit is contained in:
@@ -914,8 +914,25 @@ bool LinkedObjectFile::is_string(int seg, int byte_idx) const {
|
||||
if (type_tag_ptr < 0 || size_t(type_tag_ptr) >= words_by_seg.at(seg).size() * 4) {
|
||||
return false;
|
||||
}
|
||||
auto& type_word = words_by_seg.at(seg).at(type_tag_ptr / 4);
|
||||
return type_word.kind() == LinkedWord::TYPE_PTR && type_word.symbol_name() == "string";
|
||||
int type_word_idx = type_tag_ptr / 4;
|
||||
auto& type_word = words_by_seg.at(seg).at(type_word_idx);
|
||||
if (type_word.kind() == LinkedWord::TYPE_PTR && type_word.symbol_name() == "string") {
|
||||
// could be a string basic
|
||||
// check if we're not right after a zero-length string array.
|
||||
if (type_word_idx >= 3) {
|
||||
auto& arr_type_word = words_by_seg.at(seg).at(type_word_idx - 3);
|
||||
auto& arr_len_word = words_by_seg.at(seg).at(type_word_idx - 2);
|
||||
auto& arr_alen_word = words_by_seg.at(seg).at(type_word_idx - 1);
|
||||
if (arr_type_word.kind() == LinkedWord::TYPE_PTR && arr_type_word.symbol_name() == "array" &&
|
||||
arr_len_word.kind() == LinkedWord::PLAIN_DATA && arr_len_word.data == 0 &&
|
||||
arr_alen_word.kind() == LinkedWord::PLAIN_DATA && arr_alen_word.data == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// seems good.
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user