Skip to content
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

Even more refactor #411

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from
Draft

Even more refactor #411

wants to merge 35 commits into from

Conversation

Mr-Auto
Copy link
Contributor

@Mr-Auto Mr-Auto commented Jan 9, 2025

Looking for way to reduce lua_vm.cpp size. Maybe also rpc.cpp and other things that feel usefull

Continuation of #407

… save/load save state saving/loading from/to slot 5 which is not guaranteed to be the main after online session
…move `read_prng` and some `get_frame_count` from `State`, remove `get_frame_count` from rpc
…s`, `set_pause`, `get_offset` from the `State`
…o `remove_liquid_oob`, move `API::init` to the end of state.cpp
…d` to `StateMemory::get_entity`, move the rest of the function to the `API` namespace
@@ -472,13 +468,13 @@ void UI::update_floor_at(float x, float y, LAYER l)
if (uid == -1)
return;
auto ent = get_entity_ptr(uid);
if ((ent->type->search_flags & 0x100) == 0 || !test_flag(ent->flags, 3))
if (!(ent->type->search_flags & ENTITY_MASK::FLOOR) || !test_flag(ent->flags, 3))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this fine, or should i be using != ENTITY_MASK::X wherever possible?


if (rec_mode == RECURSIVE_MODE::EXCLUSIVE)
{
if (mask.has_value() && (acutal_mask(mask.value()) & ent->type->search_flags) != 0)
if (mask.has_value() && !!(actual_mask(mask.value()) & ent->type->search_flags))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach !! is very debatable online, so I'm just highlighting it beforehand.
The only alternative I think is using function for it

…on definitions to the `deprecated_lua.cpp`, move some simple function definitions from rpc to entity and state lua
…set_drop_chance`, remove some more functions from rpc, move update_state function to state
@Mr-Auto
Copy link
Contributor Author

Mr-Auto commented Jan 12, 2025

With this, files are more or less around 1k lines
exceptions:

  • level_api - mostly due to the community chances and tilecodes adding around 500 lines
  • search - for obvious reasons
  • string_hashes - for obvious reasons
  • lua_backend - due to all the events, i think @SereneRuby12 is working template for this?
  • lua_vm - is still almost 2k, thou 500 lines just for the ON enum and it's comments (without all the comments the file is just 1400 lines now)
  • entity_monsters_lua - it's just so many sub-classes to expose, feels weird to split it
  • gui_lua - about 200 lines of Deprecated functions, plus a lot of stuff in general
  • level_lua - mostly CustomTheme stuff - should probably move to separate file
  • info_dump - don't care, thou mostly listing values from one enum
  • ui.cpp - begs for refactor
  • don't really care about python scripts or other files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant