Feature Request: Console feedback on Successful Save #204

Closed
opened 2019-12-29 23:49:35 +00:00 by clort81 · 5 comments
clort81 commented 2019-12-29 23:49:35 +00:00 (Migrated from github.com)

Hitting the Save icon outdoors (linux, aarch64) I see savefile updated, but no console confirmation.

In game/boe.actions.cpp do_save, i added a message incase (saved) not true, but that yields no console text either.

        if(saved)
                add_string_to_buf("Save: Game saved");
        else
                add_string_to_buf("Save: Error saving game!");

Exploring this now.

Hitting the Save icon outdoors (linux, aarch64) I see savefile updated, but no console confirmation. In game/boe.actions.cpp do_save, i added a message incase (saved) not true, but that yields no console text either. ``` if(saved) add_string_to_buf("Save: Game saved"); else add_string_to_buf("Save: Error saving game!"); ``` Exploring this now.
retropipes commented 2019-12-30 00:26:45 +00:00 (Migrated from github.com)

Common culprits for this sort of thing: Writing to the wrong buffer; writing to the right buffer but on a thread that can't access it directly; writing to the right buffer on the right thread, but forgetting to check if it's full and gets cleared before your message ever shows up. Interested in this all the same.

Common culprits for this sort of thing: Writing to the wrong buffer; writing to the right buffer but on a thread that can't access it directly; writing to the right buffer on the right thread, but forgetting to check if it's full and gets cleared before your message ever shows up. Interested in this all the same.
clort81 commented 2019-12-30 03:04:53 +00:00 (Migrated from github.com)

added to game/boe.actions.cpp

                        case 5:
                                if(overall_mode == MODE_OUTDOORS) {
                                        fs::path file = univ.file;
                                        bool saved = false;
                                        if(!file.empty()) {
                                                univ.file = file;
                                                saved = save_party(univ.file, univ); // Clort FIXME add error check to save_party
                                        }
                                        if(saved)
                                                add_string_to_buf("Save: Game saved");
                                        else
                                                add_string_to_buf("Save: Error saving game!");
                                        need_redraw = true;
                                        current_switch = 6;
                                        break;
                                } else if(overall_mode == MODE_TOWN) {
                                        add_string_to_buf("Use: Select a space or item.");
                                        add_string_to_buf("  (Hit button again to cancel.)");
                                        need_reprint = true;
                                        overall_mode = MODE_USE_TOWN;
                                } else if(overall_mode == MODE_USE_TOWN) {
                                        overall_mode = MODE_TOWN;
                                        need_reprint = true;
                                        add_string_to_buf("  Cancelled.");
                                } else if(overall_mode == MODE_COMBAT) {
                                        need_reprint = true;
                                        need_redraw = true;
                                        pc_delayed = true;
                                }

                                break;

That is complete case 5: sorry I don't know how to do the github contributing to project yet.
I get console message for successful save now.

Unfortunately if i set savefile dir to unwriteable, savefile doesn't get created, but I still get "Game saved" because save_party() in fileio/fileio_party.cpp returns true no matter what.

some more reading shows we can catch an error after C++ open()

#include <iostream>
#include <fstream>
 
void log_message(const string& msg)
{
    std::ofstream out_file("data.log", 
             std::ios::out|std::ios::app|std::ios::ate);
    if (out_file.bad(  ))  
       // do something (what?) if we can't write
}

The actual open() is found in src/fileio/gzstream/gzstream.h

thanks wrldwzrd89! I hope i'm not wasting people's time!

added to game/boe.actions.cpp ``` case 5: if(overall_mode == MODE_OUTDOORS) { fs::path file = univ.file; bool saved = false; if(!file.empty()) { univ.file = file; saved = save_party(univ.file, univ); // Clort FIXME add error check to save_party } if(saved) add_string_to_buf("Save: Game saved"); else add_string_to_buf("Save: Error saving game!"); need_redraw = true; current_switch = 6; break; } else if(overall_mode == MODE_TOWN) { add_string_to_buf("Use: Select a space or item."); add_string_to_buf(" (Hit button again to cancel.)"); need_reprint = true; overall_mode = MODE_USE_TOWN; } else if(overall_mode == MODE_USE_TOWN) { overall_mode = MODE_TOWN; need_reprint = true; add_string_to_buf(" Cancelled."); } else if(overall_mode == MODE_COMBAT) { need_reprint = true; need_redraw = true; pc_delayed = true; } break; ``` That is complete case 5: sorry I don't know how to do the github contributing to project yet. I get console message for successful save now. Unfortunately if i set savefile dir to unwriteable, savefile doesn't get created, but I still get "Game saved" because save_party() in fileio/fileio_party.cpp returns true no matter what. some more reading shows we can catch an error after C++ open() ``` #include <iostream> #include <fstream> void log_message(const string& msg) { std::ofstream out_file("data.log", std::ios::out|std::ios::app|std::ios::ate); if (out_file.bad( )) // do something (what?) if we can't write } ``` The actual open() is found in src/fileio/gzstream/gzstream.h thanks wrldwzrd89! I hope i'm not wasting people's time!
CelticMinstrel commented 2019-12-30 06:13:03 +00:00 (Migrated from github.com)

Note that gzstream is an external library, so we shouldn't be changing it.

Probably the reason your first version didn't work was a missing need_reprint = true, as the in-game console won't be redrawn unless that is true.

Also, there already is notification on successful save, though not on error...

Note that `gzstream` is an external library, so we shouldn't be changing it. Probably the reason your first version didn't work was a missing `need_reprint = true`, as the in-game console won't be redrawn unless that is true. Also, there _already is_ notification on successful save, though not on error...
clort81 commented 2020-01-05 07:20:23 +00:00 (Migrated from github.com)

With current master git, i do not get a save game notification in game console.

With current master git, i do not get a save game notification in game console.
CelticMinstrel commented 2020-01-06 13:52:37 +00:00 (Migrated from github.com)

Hm, you're saving via the Save button while outdoors, right? I guess I can test that method, maybe there's something different about it…

Hm, you're saving via the Save button while outdoors, right? I guess I can test that method, maybe there's something different about it…
Sign in to join this conversation.
No description provided.