MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ConLoad

Function ConLoad

src/console_cmds.cpp:459–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457}
458
459static bool ConLoad(std::span<std::string_view> argv)
460{
461 if (argv.empty()) {
462 IConsolePrint(CC_HELP, "Load a game by name or index. Usage: 'load <file | number>'.");
463 return true;
464 }
465
466 if (argv.size() != 2) return false;
467
468 std::string_view file = argv[1];
469 _console_file_list_savegame.ValidateFileList();
470 const FiosItem *item = _console_file_list_savegame.FindItem(file);
471 if (item != nullptr) {
472 if (item->type.abstract == FT_SAVEGAME) {
473 _switch_mode = SM_LOAD_GAME;
474 _file_to_saveload.Set(*item);
475 } else {
476 IConsolePrint(CC_ERROR, "'{}' is not a savegame.", file);
477 }
478 } else {
479 IConsolePrint(CC_ERROR, "'{}' cannot be found.", file);
480 }
481
482 return true;
483}
484
485static bool ConLoadScenario(std::span<std::string_view> argv)
486{

Callers

nothing calls this directly

Calls 6

ValidateFileListMethod · 0.80
FindItemMethod · 0.80
IConsolePrintFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected