Skip to content

Commit

Permalink
Disable loading puzzle solutions on Android
Browse files Browse the repository at this point in the history
Causes inexplicable crashes with something to do with the Android confirm dialog.
  • Loading branch information
rollerozxa committed Jun 15, 2024
1 parent 4066de5 commit 1c506dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/src/game.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5917,20 +5917,25 @@ game::handle_input_playing(tms::event *ev, int action)
} else {
if (this->state.success && this->state.pkg != 0) {
if (this->state.is_main_puzzle) {
// XXX: causes segfaults on android

char filename[1024];
uint32_t next = this->state.pkg->get_next_level(W->level.local_id);
snprintf(filename, 1023, "%s/7.%d.psol", pkgman::get_level_path(LEVEL_LOCAL), next);

tms_infof("does %s exist?", filename);

open_play_data *opd = new open_play_data(LEVEL_LOCAL, next, this->state.pkg, false, 1);

#ifndef TMS_BACKEND_ANDROID
tms_infof("does %s exist?", filename);
if (file_exists(filename)) {
tms_infof("yep! send ui confirm thing");
ui::confirm("Do you want to load your last saved solution?",
"Yes", principia_action(ACTION_OPEN_MAIN_PUZZLE_SOLUTION, opd),
"No", principia_action(ACTION_CREATE_MAIN_PUZZLE_SOLUTION, opd),
"Back", ACTION_BACK);
} else {
} else
#endif
{
tms_infof("file %s does not exist!", filename);
P.add_action(ACTION_CREATE_MAIN_PUZZLE_SOLUTION, opd);
}
Expand Down
6 changes: 5 additions & 1 deletion src/src/menu_pkg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ menu_pkg::handle_input(tms::event *ev, int action)
bool test_playing = false;
G->screen_back = this;
if (this->pkg.type == LEVEL_MAIN && this->pkg.id == 7) {
// XXX: causes segfaults on android
#ifndef TMS_BACKEND_ANDROID
char filename[1024];
snprintf(filename, 1023, "%s/7.%d.psol", pkgman::get_level_path(LEVEL_LOCAL), level_id);

Expand All @@ -482,7 +484,9 @@ menu_pkg::handle_input(tms::event *ev, int action)
"Yes", principia_action(ACTION_OPEN_MAIN_PUZZLE_SOLUTION, opd),
"No", principia_action(ACTION_CREATE_MAIN_PUZZLE_SOLUTION, opd),
"Cancel", principia_action(ACTION_IGNORE, 0));
} else {
} else
#endif
{
P.add_action(ACTION_CREATE_MAIN_PUZZLE_SOLUTION, new open_play_data(LEVEL_LOCAL, level_id, &pkg, false, 1));
}

Expand Down

0 comments on commit 1c506dd

Please sign in to comment.