Rebounding back to the menu and loading a new map from zero state works. The way I'm having to clear out the actors seems wrong. Instead of memset/ClearProperty I should be able to call akgl_heap_release_actor but I can't.
This commit is contained in:
@@ -60,13 +60,26 @@ char dirnamebuf[1024];
|
||||
akerr_ErrorContext AKERR_NOIGNORE *akgltest_set_gamemode_menu(akgl_Actor *appstate, SDL_Event *event)
|
||||
{
|
||||
akgl_Actor *menupointer = SDL_GetPointerProperty(AKGL_REGISTRY_ACTOR, "menupointer", NULL);
|
||||
akgl_Actor *player = SDL_GetPointerProperty(AKGL_REGISTRY_ACTOR, "player", NULL);
|
||||
PREPARE_ERROR(e);
|
||||
PASS(e, akgl_tilemap_release(&gamemap));
|
||||
FAIL_ZERO_RETURN(e, player, AKERR_NULLPOINTER, "missing actor");
|
||||
FAIL_ZERO_RETURN(e, menupointer, AKERR_NULLPOINTER, "missing actor");
|
||||
AKGL_BITMASK_DEL(game.state.flags, AKGLTEST_STATE_WAITFORINPUT);
|
||||
AKGL_BITMASK_ADD(game.state.flags, AKGLTEST_STATE_MAPMENU);
|
||||
AKGL_BITMASK_DEL(game.state.flags, AKGLTEST_STATE_RUNNING);
|
||||
// Reset all the actors back to empty (except the player and menupointer)
|
||||
for ( int i = 0 ; i < AKGL_MAX_HEAP_ACTOR; i++ ) {
|
||||
if ( &HEAP_ACTOR[i] != player && &HEAP_ACTOR[i] != menupointer ) {
|
||||
SDL_ClearProperty(AKGL_REGISTRY_ACTOR, (char *)&HEAP_ACTOR[i].name);
|
||||
memset(&HEAP_ACTOR[i], 0x00, sizeof(akgl_Actor));
|
||||
} else {
|
||||
SDL_Log("Preserving menupointer and actor (%p)", &HEAP_ACTOR[i]);
|
||||
}
|
||||
}
|
||||
GAME_ControlMaps[AKGLTEST_CONTROLMAP_INGAMEACTOR].target = NULL;
|
||||
GAME_ControlMaps[AKGLTEST_CONTROLMAP_MENU].target = menupointer;
|
||||
menupointer->visible = true;
|
||||
AKGL_BITMASK_ADD(game.state.flags, AKGLTEST_STATE_MAPMENU);
|
||||
SUCCEED_RETURN(e);
|
||||
}
|
||||
|
||||
@@ -265,7 +278,7 @@ akerr_ErrorContext AKERR_NOIGNORE *akgltest_controller_bind_universal(char *acto
|
||||
// Quit
|
||||
control.key = SDLK_ESCAPE;
|
||||
control.event_on = SDL_EVENT_KEY_DOWN;
|
||||
control.handler_on = &quit_game;
|
||||
control.handler_on = &akgltest_set_gamemode_menu;
|
||||
PASS(e, akgl_controller_pushmap(mapid, &control));
|
||||
|
||||
// Toggle the music
|
||||
|
||||
Reference in New Issue
Block a user