* Save the map to a file. * param filename the filename to save the map to. * @return True when help was displayed or the file attempted to be saved. */
| 418 | * @return True when help was displayed or the file attempted to be saved. |
| 419 | */ |
| 420 | static bool ConSave(std::span<std::string_view> argv) |
| 421 | { |
| 422 | if (argv.empty()) { |
| 423 | IConsolePrint(CC_HELP, "Save the current game. Usage: 'save <filename>'."); |
| 424 | return true; |
| 425 | } |
| 426 | |
| 427 | if (argv.size() == 2) { |
| 428 | std::string filename = fmt::format("{}.sav", argv[1]); |
| 429 | IConsolePrint(CC_DEFAULT, "Saving map..."); |
| 430 | |
| 431 | if (SaveOrLoad(filename, SLO_SAVE, DFT_GAME_FILE, SAVE_DIR) != SL_OK) { |
| 432 | IConsolePrint(CC_ERROR, "Saving map failed."); |
| 433 | } else { |
| 434 | IConsolePrint(CC_INFO, "Map successfully saved to '{}'.", filename); |
| 435 | } |
| 436 | return true; |
| 437 | } |
| 438 | |
| 439 | return false; |
| 440 | } |
| 441 | |
| 442 | /** |
| 443 | * Explicitly save the configuration. |
nothing calls this directly
no test coverage detected