-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StateMemory and State structs changes #379
base: main
Are you sure you want to change the base?
Conversation
@@ -31,8 +31,7 @@ Entity* Layer::spawn_entity(ENT_TYPE id, float x, float y, bool screen, float vx | |||
} | |||
else if (screen) | |||
{ | |||
auto& state = State::get(); | |||
std::tie(x, y) = state.click_position(x, y); | |||
std::tie(x, y) = StateMemory::click_position(x, y); | |||
min_speed_check = 0.04f; | |||
if (snap && abs(vx) + abs(vy) <= min_speed_check) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove the screen
param?
if i recall, it's only used by the UI, so we could move this feature to the ui_util
auto* state_ptr = State::get().ptr_local(); | ||
auto* state_ptr = State::ptr_local(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're changing every getter, can we get rid of the _local
part?
I think there should always be just ptr()
and ptr_main()
(since the second one is the specific one used rarely)
But I'm open for discussion if someone have better idea/reasons to keep the naming
@@ -0,0 +1,24 @@ | |||
#include "savedata.hpp" | |||
struct ModAPI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If everything is static, it begs the question what this struct is even for?
@@ -6,15 +6,12 @@ | |||
|
|||
PRNG& PRNG::get_main() | |||
{ | |||
const auto& state = State::get(); | |||
static PRNG* prng = (PRNG*)((size_t)state.ptr_main() - 0xb0); | |||
static PRNG* prng = &State::get_main()->prng; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now confusing.
State::get_main()->prng
gets the prng
State::ptr()
gets the ptr to ... something
By the code itself I would assume it's State itself, but that's not the case
if (!functions_hooked) | ||
{ | ||
auto memory = Memory::get(); | ||
auto addr_damage = memory.at_exe(get_virtual_function_address(VTABLE_OFFSET::CHAR_ANA_SPELUNKY, 48)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you didn't write this code, but wondering why this is done via Detour probably better to do it via hook_vtable
?
@@ -260,7 +258,7 @@ std::vector<Player*> get_players(StateMemory* state) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should probably be just member of StateMemory
auto& state = State::get(); | ||
state.set_camera_position(cx, cy); | ||
StateMemory* state = State::ptr(); | ||
state->set_camera_position(cx, cy); | ||
} | ||
|
||
void warp(uint8_t world, uint8_t level, uint8_t theme) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of those simple functions that just get StateMemory and return some value from it or based on it, should probably be just member functions of the StateMemory. Then in lua_vm
just make lambda.
Would you mind if i try and make my own version of this PR ? |
Maybe it would be even better if you're the one that makes this PR tbh |
Some StateMemory and State changes, discussion started in #369 (comment)