Curation round 13: grid entities, more enemies, Caves, boss helpers and five bosses, chests and costumes, curses and alt stages, the Lua API
This commit is contained in:
1 parent
f8ce24fc6c
commit
8ae02a8422
160 files changed
+16231
-1689
No files matched your search
+11
-14
@@ -1,4 +1,5 @@
|
||||
#include "lua_engine.h"
|
||||
#include "lua_api.h"
|
||||
#include "classes.h"
|
||||
#include "data.h"
|
||||
#include "game.h"
|
||||
@@ -11,16 +12,6 @@
|
||||
#include <fstream>
|
||||
#include <numeric>
|
||||
|
||||
// classes.h declares the original's Lua imports, and its luaL_newstate differs from Lua's only in its return type.
|
||||
// Lua's is renamed away here, as Init opens the state the way the original's reserved heap did.
|
||||
#define luaL_newstate lua_newstate_auxiliary
|
||||
extern "C"
|
||||
{
|
||||
#include "lauxlib.h"
|
||||
#include "lua.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
#undef luaL_newstate
|
||||
|
||||
constexpr const char* ENUMS_SCRIPT = "scripts/enums.lua";
|
||||
constexpr const char* MAIN_SCRIPT = "scripts/main.lua";
|
||||
@@ -33,13 +24,13 @@ constexpr const char* PATH_SEPARATORS = "/\\";
|
||||
constexpr const char* RUN_CALLBACK = "_RunCallback";
|
||||
constexpr const char* UNLOAD_MOD = "_UnloadMod";
|
||||
|
||||
constexpr uint64_t NS_PER_MS = 1000000;
|
||||
constexpr int API_VERSION_NONE = -1;
|
||||
constexpr int API_VERSION_CURRENT = 1;
|
||||
constexpr int GC_COOLDOWN_FRAMES = 600;
|
||||
constexpr int GC_SHRINK_DIVISOR = 100;
|
||||
constexpr int GC_SHRINK_MIN = 10;
|
||||
constexpr int GC_STEP_MAX = 10000;
|
||||
constexpr uint64_t NS_PER_MS = 1000000;
|
||||
constexpr uint32_t MASK_SALT = 0xdeadbeef;
|
||||
constexpr int MASK_SHIFTS[] = {4, 5, 11};
|
||||
|
||||
@@ -153,7 +144,7 @@ static void mod_unload(LuaEngine& engine, LuaMod& mod)
|
||||
// 008604c0 Opens a state with the pointer mask hashed from the time, the sandboxed libraries or, in debug mode, every
|
||||
// library with require searching resources/scripts/, then runs enums.lua and main.lua, as RunBundledScript did
|
||||
// (0086e5e0), and takes their _RunCallback and _UnloadMod. The state always opens as on the reserved heap, with the
|
||||
// C heap in its place, since --luaheapsize is ignored. RegisterAPI is not called until it is reconstructed.
|
||||
// C heap in its place, since --luaheapsize is ignored.
|
||||
void LuaEngine::Init(LuaMode luaMode)
|
||||
{
|
||||
pointerMask = pointer_mask_make((uint32_t)(GetTimeNs() / NS_PER_MS));
|
||||
@@ -176,16 +167,22 @@ void LuaEngine::Init(LuaMode luaMode)
|
||||
}
|
||||
mode = luaMode;
|
||||
|
||||
log_printf(LOG_WARN, "**The mod API is not reconstructed yet, so scripts run without the Isaac table\n");
|
||||
RegisterAPI();
|
||||
RunScript(resource_path(ENUMS_SCRIPT));
|
||||
RunScript(resource_path(MAIN_SCRIPT));
|
||||
runCallbackRef = global_take(state, RUN_CALLBACK);
|
||||
unloadModRef = global_take(state, UNLOAD_MOD);
|
||||
}
|
||||
|
||||
// 00866960 Registers the mod API: the classes, then the namespaces and the global functions, which replace the
|
||||
// SFXManager and MusicManager classes with the functions returning them.
|
||||
void LuaEngine::RegisterAPI()
|
||||
{
|
||||
reconstruction_missing("LuaEngine::RegisterAPI 00866960");
|
||||
for (auto registerPart : {lua_api_vector_register, lua_api_color_register, lua_api_rng_register,
|
||||
lua_api_bit_set128_register, lua_api_sprite_register, lua_api_entity_register,
|
||||
lua_api_entities_register, lua_api_entity_player_register, lua_api_game_register,
|
||||
lua_api_room_register, lua_api_item_config_register, lua_api_isaac_register})
|
||||
registerPart(state);
|
||||
}
|
||||
|
||||
// 0086e520 Unloads every registered mod, releases the engine's references and closes the state.
|
||||
|
||||
Reference in new issue
Block a user