Skip to content

Commit

Permalink
uglier hack that works better
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu committed Oct 14, 2023
1 parent a9c1f3e commit 20eeb43
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/game_api/spawn_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,10 +685,13 @@ int32_t spawn_player(int8_t player_slot, std::optional<float> x, std::optional<f
auto uid = (int32_t)state->next_entity_uid;
using spawn_player_fun = void(Items*, uint8_t ps);
static auto spawn_player = (spawn_player_fun*)get_address("spawn_player");
// lazy? maybe. it's where it gets the state+0x1300 layer0 pointer
auto layer_off = get_address("spawn_player") + 0x3ea;
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)
write_mem_recoverable("spawn_player_layer", layer_off, 0x1308, true);
{
auto layer1_ptr = memory_read<size_t>(layer_off + 8);
write_mem_recoverable("spawn_player_layer", layer_off, layer1_ptr, true);
}
spawn_player(get_state_ptr()->items, player_slot - 1);
recover_mem("spawn_player_layer");
state->level_gen->spawn_x = old_x;
Expand Down

0 comments on commit 20eeb43

Please sign in to comment.