Skip to content

Commit

Permalink
Merge branch 'master' into csharp-api
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed May 13, 2024
2 parents fd25f34 + e447a20 commit 8427d94
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/reframework/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#endif

#define REFRAMEWORK_PLUGIN_VERSION_MAJOR 1
#define REFRAMEWORK_PLUGIN_VERSION_MINOR 9
#define REFRAMEWORK_PLUGIN_VERSION_MINOR 10
#define REFRAMEWORK_PLUGIN_VERSION_PATCH 0

#define REFRAMEWORK_RENDERER_D3D11 0
Expand Down Expand Up @@ -254,6 +254,8 @@ typedef struct {

void* (*get_init_data)(REFrameworkFieldHandle);
void* (*get_data_raw)(REFrameworkFieldHandle, void* obj, bool is_value_type);

unsigned int (*get_index)(REFrameworkFieldHandle);
} REFrameworkTDBField;

typedef struct {
Expand Down
5 changes: 5 additions & 0 deletions include/reframework/API.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,11 @@ class API {
return fn(*this, obj, is_value_type);
}

uint32_t get_index() const {
static const auto fn = API::s_instance->sdk()->field->get_index;
return fn(*this);
}

template <typename T> T& get_data(void* object = nullptr, bool is_value_type = false) const { return *(T*)get_data_raw(object, is_value_type); }
};

Expand Down
6 changes: 6 additions & 0 deletions shared/sdk/RETypeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ void* REField::get_data_raw(void* object, bool is_value_type) const {

return nullptr;
}

uint32_t sdk::REField::get_index() const {
auto tdb = RETypeDB::get();

return (uint32_t)(((uintptr_t)this - (uintptr_t)tdb->fields) / sizeof(sdk::REField));
}
} // namespace sdk

// methods
Expand Down
1 change: 1 addition & 0 deletions shared/sdk/RETypeDB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,7 @@ struct REField : public sdk::REField_ {
bool is_literal() const;

void* get_data_raw(void* object = nullptr, bool is_value_type = false) const;
uint32_t get_index() const;

template <typename T> T& get_data(void* object = nullptr, bool is_value_type = false) const { return *(T*)get_data_raw(object); }
};
Expand Down
2 changes: 2 additions & 0 deletions src/mods/PluginLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ REFrameworkTDBField g_tdb_field_data {

[](REFrameworkFieldHandle field) { return REFIELD(field)->get_init_data(); },
[](REFrameworkFieldHandle field, void* obj, bool is_value_type) { return REFIELD(field)->get_data_raw(obj, is_value_type); },

[](REFrameworkFieldHandle field) { return REFIELD(field)->get_index(); },
};

REFrameworkTDBProperty g_tdb_property_data {
Expand Down

0 comments on commit 8427d94

Please sign in to comment.