From 07f696855d3b2a854541b16197e0fa762cffcaf0 Mon Sep 17 00:00:00 2001 From: Dregu Date: Sat, 14 Oct 2023 12:19:13 +0300 Subject: [PATCH] make it not stupid --- src/game_api/spawn_api.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/game_api/spawn_api.cpp b/src/game_api/spawn_api.cpp index 1d59f3666..14a06ec71 100644 --- a/src/game_api/spawn_api.cpp +++ b/src/game_api/spawn_api.cpp @@ -685,15 +685,12 @@ int32_t spawn_player(int8_t player_slot, std::optional x, std::optionalnext_entity_uid; using spawn_player_fun = void(Items*, uint8_t ps); static auto spawn_player = (spawn_player_fun*)get_address("spawn_player"); - auto layer_off = (size_t)State::get().ptr() + 0x1300; // move the back layer to front layer offset if spawning in back layer if (layer.has_value() && layer.value() == LAYER::BACK) - { - auto layer1_ptr = memory_read(layer_off + 8); - write_mem_recoverable("spawn_player_layer", layer_off, layer1_ptr, true); - } + std::swap(State::get().ptr()->layers[0], State::get().ptr()->layers[1]); spawn_player(get_state_ptr()->items, player_slot - 1); - recover_mem("spawn_player_layer"); + if (layer.has_value() && layer.value() == LAYER::BACK) + std::swap(State::get().ptr()->layers[0], State::get().ptr()->layers[1]); state->level_gen->spawn_x = old_x; state->level_gen->spawn_y = old_y; return uid;