kernel: separate host objects from regular handle range
Burnout Paradise statically expects certain thread handle values based on how many objects it knows it is allocating ahead of time. From this, it calculates an ID by subtracting the thread handle from a base handle of what it expects the first such thread to be assigned. The value is statically declared in the executable and is not determined automatically. The host objects in the handle range made these thread handles higher than what the game expects. Removing these, and allowing 0xF8000000 to be assigned, allows the thread handles to fit perfectly in the range the game expects. It is not clear what handle range the host objects should be taking. For now though, they're 0-based rather than 0xF8000000-based.
This commit is contained in:
@@ -49,10 +49,10 @@ class ObjectTable {
|
||||
X_STATUS RestoreHandle(X_HANDLE handle, XObject* object);
|
||||
template <typename T>
|
||||
object_ref<T> LookupObject(X_HANDLE handle, bool already_locked = false) {
|
||||
auto object = LookupObject(handle, already_locked);
|
||||
if (T::kObjectType == XObject::Type::Socket) {
|
||||
object = LookupObject((handle | 0xF8000000), false);
|
||||
handle |= XObject::kHandleBase;
|
||||
}
|
||||
auto object = LookupObject(handle, already_locked);
|
||||
if (object) {
|
||||
assert_true(object->type() == T::kObjectType);
|
||||
}
|
||||
@@ -95,16 +95,20 @@ class ObjectTable {
|
||||
std::vector<object_ref<XObject>>* results);
|
||||
|
||||
X_HANDLE TranslateHandle(X_HANDLE handle);
|
||||
static constexpr uint32_t GetHandleSlot(X_HANDLE handle) {
|
||||
return (handle - XObject::kHandleBase) >> 2;
|
||||
static constexpr uint32_t GetHandleSlot(X_HANDLE handle, bool host) {
|
||||
if (!host) handle -= XObject::kHandleBase;
|
||||
return handle >> 2;
|
||||
}
|
||||
X_STATUS FindFreeSlot(uint32_t* out_slot);
|
||||
bool Resize(uint32_t new_capacity);
|
||||
X_STATUS FindFreeSlot(uint32_t* out_slot, bool host);
|
||||
bool Resize(uint32_t new_capacity, bool host);
|
||||
|
||||
xe::global_critical_region global_critical_region_;
|
||||
uint32_t table_capacity_ = 0;
|
||||
uint32_t host_table_capacity_ = 0;
|
||||
ObjectTableEntry* table_ = nullptr;
|
||||
ObjectTableEntry* host_table_ = nullptr;
|
||||
uint32_t last_free_entry_ = 0;
|
||||
uint32_t last_free_host_entry_ = 0;
|
||||
std::unordered_map<string_key_case, X_HANDLE> name_table_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user