| 507 | public: |
| 508 | CCC_ALifeSave(LPCSTR N) : IConsole_Command(N) { bEmptyArgsHandled = true; }; |
| 509 | virtual void Execute(LPCSTR args) |
| 510 | { |
| 511 | if (!g_actor || !Actor()->g_Alive()) |
| 512 | { |
| 513 | Msg("cannot make saved game because actor is dead :("); |
| 514 | return; |
| 515 | } |
| 516 | |
| 517 | string_path S, S1; |
| 518 | S[0] = 0; |
| 519 | //. sscanf (args ,"%s",S); |
| 520 | strcpy_s(S, args); |
| 521 | |
| 522 | #ifdef DEBUG |
| 523 | CTimer timer; |
| 524 | timer.Start(); |
| 525 | #endif |
| 526 | if (!xr_strlen(S)) |
| 527 | { |
| 528 | strconcat(sizeof(S), S, Core.UserName, "_", "quicksave"); |
| 529 | NET_Packet net_packet; |
| 530 | net_packet.w_begin(M_SAVE_GAME); |
| 531 | net_packet.w_stringZ(S); |
| 532 | net_packet.w_u8(0); |
| 533 | Level().Send(net_packet, net_flags(TRUE)); |
| 534 | } |
| 535 | else |
| 536 | { |
| 537 | if (!valid_file_name(S)) |
| 538 | { |
| 539 | Msg("invalid file name"); |
| 540 | return; |
| 541 | } |
| 542 | |
| 543 | NET_Packet net_packet; |
| 544 | net_packet.w_begin(M_SAVE_GAME); |
| 545 | net_packet.w_stringZ(S); |
| 546 | net_packet.w_u8(1); |
| 547 | Level().Send(net_packet, net_flags(TRUE)); |
| 548 | } |
| 549 | #ifdef DEBUG |
| 550 | Msg("Game save overhead : %f milliseconds", timer.GetElapsed_sec() * 1000.f); |
| 551 | #endif |
| 552 | SDrawStaticStruct* _s = HUD().GetUI()->UIGame()->AddCustomStatic("game_saved", true); |
| 553 | _s->m_endTime = Device.fTimeGlobal + 3.0f; // 3sec |
| 554 | string_path save_name; |
| 555 | strconcat(sizeof(save_name), save_name, *CStringTable().translate("st_game_saved"), ": ", S); |
| 556 | _s->wnd()->SetText(save_name); |
| 557 | |
| 558 | strcat_s(S, ".dds"); |
| 559 | FS.update_path(S1, "$game_saves$", S); |
| 560 | |
| 561 | #ifdef DEBUG |
| 562 | timer.Start(); |
| 563 | #endif |
| 564 | MainMenu()->Screenshot(IRender_interface::SM_FOR_GAMESAVE, S1); |
| 565 | |
| 566 | #ifdef DEBUG |
nothing calls this directly
no test coverage detected