Skip to content

Commit

Permalink
TDB: Use name pool bitmask to work around unknown games
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jan 25, 2024
1 parent 70910c7 commit bc6455b
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions shared/sdk/RETypeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,18 @@ sdk::RETypeDefinition* REField::get_type() const {
const char* REField::get_name() const {
auto tdb = RETypeDB::get();

static uint32_t bitmask = [tdb]() -> uint32_t {
uint32_t out{1};
while (out < tdb->numStringPool) {
out <<= 1;
}

return out - 1;
}();

#if TDB_VER >= 69
auto& impl = (*tdb->fieldsImpl)[this->impl_id];
const auto name_offset = impl.name_offset;
const auto name_offset = impl.name_offset & bitmask;
#else
const auto name_offset = this->name_offset;
#endif
Expand Down Expand Up @@ -375,9 +384,18 @@ sdk::RETypeDefinition* REMethodDefinition::get_return_type() const {
const char* REMethodDefinition::get_name() const {
auto tdb = RETypeDB::get();

static uint32_t bitmask = [tdb]() -> uint32_t {
uint32_t out{1};
while (out < tdb->numStringPool) {
out <<= 1;
}

return out - 1;
}();

#if TDB_VER >= 69
auto& impl = (*tdb->methodsImpl)[this->impl_id];
const auto name_offset = impl.name_offset;
const auto name_offset = impl.name_offset & bitmask;
#else
const auto name_offset = this->name_offset;
#endif
Expand Down

0 comments on commit bc6455b

Please sign in to comment.