mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
Yeet save/load_world_state stuff as it wasn't used anyway.
This commit is contained in:
parent
031083e75f
commit
134584dcf2
3 changed files with 4 additions and 51 deletions
|
@ -44,8 +44,8 @@ unsafe impl Send for Grabbed {}
|
||||||
|
|
||||||
pub(crate) struct GrabbedGlobals {
|
pub(crate) struct GrabbedGlobals {
|
||||||
// These 3 actually point to a pointer.
|
// These 3 actually point to a pointer.
|
||||||
pub(crate) game_global: *mut usize,
|
pub(crate) _game_global: *mut usize,
|
||||||
pub(crate) world_state_entity: *mut usize,
|
pub(crate) _world_state_entity: *mut usize,
|
||||||
pub(crate) entity_manager: *const *mut EntityManager,
|
pub(crate) entity_manager: *const *mut EntityManager,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +93,8 @@ pub(crate) fn grab_addrs(lua: LuaState) {
|
||||||
GRABBED
|
GRABBED
|
||||||
.set(Grabbed {
|
.set(Grabbed {
|
||||||
globals: GrabbedGlobals {
|
globals: GrabbedGlobals {
|
||||||
game_global,
|
_game_global: game_global,
|
||||||
world_state_entity,
|
_world_state_entity: world_state_entity,
|
||||||
entity_manager,
|
entity_manager,
|
||||||
},
|
},
|
||||||
fns: GrabbedFns { get_entity },
|
fns: GrabbedFns { get_entity },
|
||||||
|
|
|
@ -30,15 +30,9 @@ thread_local! {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SavedWorldState {
|
|
||||||
game_global: usize,
|
|
||||||
world_state_entity: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct ExtState {
|
struct ExtState {
|
||||||
particle_world_state: Option<ParticleWorldState>,
|
particle_world_state: Option<ParticleWorldState>,
|
||||||
saved_world_state: Option<SavedWorldState>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_particle_world_state(lua: LuaState) -> c_int {
|
fn init_particle_world_state(lua: LuaState) -> c_int {
|
||||||
|
@ -76,40 +70,6 @@ fn encode_area(lua: LuaState) -> c_int {
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn save_world_state() {
|
|
||||||
let game_global = grabbed_globals().game_global.read();
|
|
||||||
let world_state_entity = grabbed_globals().world_state_entity.read();
|
|
||||||
STATE.with(|state| {
|
|
||||||
let mut state = state.borrow_mut();
|
|
||||||
state.saved_world_state = Some(SavedWorldState {
|
|
||||||
game_global,
|
|
||||||
world_state_entity,
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe fn load_world_state() {
|
|
||||||
println!("Loading world state");
|
|
||||||
STATE.with(|state| {
|
|
||||||
let state = state.borrow_mut();
|
|
||||||
let saved_ws = state.saved_world_state.as_ref().unwrap();
|
|
||||||
grabbed_globals().game_global.write(saved_ws.game_global);
|
|
||||||
grabbed_globals()
|
|
||||||
.world_state_entity
|
|
||||||
.write(saved_ws.world_state_entity);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe extern "C" fn save_world_state_lua(_lua: *mut lua_State) -> i32 {
|
|
||||||
save_world_state();
|
|
||||||
0
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe extern "C" fn load_world_state_lua(_lua: *mut lua_State) -> i32 {
|
|
||||||
load_world_state();
|
|
||||||
0
|
|
||||||
}
|
|
||||||
|
|
||||||
fn make_ephemerial(lua: LuaState) -> c_int {
|
fn make_ephemerial(lua: LuaState) -> c_int {
|
||||||
unsafe {
|
unsafe {
|
||||||
let entity_id = lua.to_integer(1) as u32;
|
let entity_id = lua.to_integer(1) as u32;
|
||||||
|
@ -150,10 +110,6 @@ pub unsafe extern "C" fn luaopen_ewext0(lua: *mut lua_State) -> c_int {
|
||||||
|
|
||||||
add_lua_fn!(init_particle_world_state);
|
add_lua_fn!(init_particle_world_state);
|
||||||
add_lua_fn!(encode_area);
|
add_lua_fn!(encode_area);
|
||||||
LUA.lua_pushcclosure(lua, Some(load_world_state_lua), 0);
|
|
||||||
LUA.lua_setfield(lua, -2, c"load_world_state".as_ptr());
|
|
||||||
LUA.lua_pushcclosure(lua, Some(save_world_state_lua), 0);
|
|
||||||
LUA.lua_setfield(lua, -2, c"save_world_state".as_ptr());
|
|
||||||
add_lua_fn!(make_ephemerial);
|
add_lua_fn!(make_ephemerial);
|
||||||
add_lua_fn!(on_world_initialized);
|
add_lua_fn!(on_world_initialized);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ local module = {}
|
||||||
function module.on_world_initialized()
|
function module.on_world_initialized()
|
||||||
initial_world_state_entity = GameGetWorldStateEntity()
|
initial_world_state_entity = GameGetWorldStateEntity()
|
||||||
ewext.on_world_initialized()
|
ewext.on_world_initialized()
|
||||||
ewext.save_world_state()
|
|
||||||
local grid_world = world_ffi.get_grid_world()
|
local grid_world = world_ffi.get_grid_world()
|
||||||
local chunk_map = grid_world.vtable.get_chunk_map(grid_world)
|
local chunk_map = grid_world.vtable.get_chunk_map(grid_world)
|
||||||
grid_world = tonumber(ffi.cast("intptr_t", grid_world))
|
grid_world = tonumber(ffi.cast("intptr_t", grid_world))
|
||||||
|
@ -38,8 +37,6 @@ end
|
||||||
|
|
||||||
function module.on_world_update()
|
function module.on_world_update()
|
||||||
if GameGetWorldStateEntity() ~= initial_world_state_entity then
|
if GameGetWorldStateEntity() ~= initial_world_state_entity then
|
||||||
-- -- EntityKill(GameGetWorldStateEntity())
|
|
||||||
-- ewext.load_world_state()
|
|
||||||
oh_another_world_state(GameGetWorldStateEntity())
|
oh_another_world_state(GameGetWorldStateEntity())
|
||||||
initial_world_state_entity = GameGetWorldStateEntity()
|
initial_world_state_entity = GameGetWorldStateEntity()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue