Skip to content

Commit

Permalink
fix crash when destroying layer with players
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu committed Oct 14, 2023
1 parent d375795 commit 1a100fd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/game_api/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2152,6 +2152,12 @@ void destroy_layer(uint8_t layer)
}
if (offset != 0)
{
auto state = State::get().ptr();
for (auto i = 0; i < MAX_PLAYERS; ++i)
{
if (state->items->players[i] && state->items->players[i]->layer == layer)
state->items->players[i] = nullptr;
}
auto* layer_ptr = State::get().layer(layer);
typedef void destroy_func(Layer*);
static destroy_func* df = (destroy_func*)(offset);
Expand Down

0 comments on commit 1a100fd

Please sign in to comment.