bool load_game (const char *filename) { rb->memset (&header, 0, sizeof (header)); if (rb->strlen (filename) + 1 > SAVE_FILE_LENGTH) { DEBUGF ("file name too long\n"); return false; } if (!rb->file_exists (filename)) { DEBUGF ("file doesn't exist!\n"); return false; } pre_game_setup (); rb->strcpy (save_file, filename); #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost (true); #endif rb->splash (0, "Loading..."); bool parse_failed = false; if (!parse_sgf (save_file)) { rb->splash (3 * HZ, "Unable to parse SGF file. Will overwrite."); parse_failed = true; } game_dirty = false; autosave_dirty = false; #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost (false); #endif if (header.handicap >= 2) { current_player = WHITE; } post_game_setup_sgf (); if (!parse_failed) { draw_screen_display(); if (rb->strcmp(filename, DEFAULT_SAVE)) { metadata_summary(); } } return true; }
static void do_gameinfo_menu (void) { MENUITEM_STRINGLIST (gameinfo_menu, "Game Info", NULL, "Basic Info", "Time Limit", "Overtime", "Result", "Handicap", "Komi", "Ruleset", "Black Player", "Black Rank", "Black Team", "White Player", "White Rank", "White Team", "Date", "Event", "Place", "Round", "Done"); /* IMPORTANT: * * if you edit this string list, make sure you keep * menu_selection_to_prop function in line with it!! (see the bottom * of this file). */ int new_ruleset = 0; char *gameinfo_string; int gameinfo_string_size; bool done = false; int selection = 0; while (!done) { selection = rb->do_menu (&gameinfo_menu, &selection, NULL, false); switch (selection) { case GINFO_OVERTIME: case GINFO_RESULT: case GINFO_BLACK_PLAYER: case GINFO_BLACK_RANK: case GINFO_BLACK_TEAM: case GINFO_WHITE_PLAYER: case GINFO_WHITE_RANK: case GINFO_WHITE_TEAM: case GINFO_DATE: case GINFO_EVENT: case GINFO_PLACE: case GINFO_ROUND: if (!get_header_string_and_size (&header, menu_selection_to_prop (selection), &gameinfo_string, &gameinfo_string_size)) { rb->splash (3 * HZ, "Couldn't get header string"); break; } rb->kbd_input (gameinfo_string, gameinfo_string_size); sanitize_string (gameinfo_string); set_game_modified(); break; /* these need special handling in some way, so they are separate */ case GINFO_BASIC_INFO: metadata_summary(); break; case GINFO_TIME_LIMIT: rb->set_int ("Time Limit", "", UNIT_INT, &header.time_limit, NULL, 60, 0, 24 * 60 * 60, &time_formatter); set_game_modified(); break; case GINFO_HANDICAP: rb->splashf (0, "%d stones. Start a new game to set handicap", header.handicap); rb->action_userabort(TIMEOUT_BLOCK); break; case GINFO_KOMI: rb->set_int ("Komi", "moku", UNIT_INT, &header.komi, NULL, 1, -300, 300, &komi_formatter); set_game_modified(); break; case GINFO_RULESET: new_ruleset = 0; rb->set_int ("Ruleset", "", UNIT_INT, &new_ruleset, NULL, 1, 0, NUM_RULESETS - 1, &ruleset_formatter); rb->strcpy (header.ruleset, ruleset_names[new_ruleset]); set_game_modified(); break; case GINFO_DONE: case GO_TO_ROOT: case GO_TO_PREVIOUS: case MENU_ATTACHED_USB: default: done = true; break; }; } }