URL:
  <http://gna.org/patch/?3125>

                 Summary: save_index refactoring
                 Project: Battle for Wesnoth
            Submitted by: zamotivator
            Submitted on: Wed 08 Feb 2012 07:17:39 PM GMT
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

Refactoring of save_index.


New class savegame::save_index_class with instance save_index_manager:
Methods:
        * data() - old save_index::load() - load save_index from disk if doesn't
loaded yet
        * data(const std::string& name) - get (or create if not available) 
summary
from save_index (from data())
        * write_save_index() - write current save_index to disk
        * rebuild(const std::string& name, const time_t& modified) - re-load 
summary
from savefile, update summary, write updated index to disk
        * rebuild(const std::string& name) - rebuild where modified == file
modification time
        * set_modified(const std::string& name) - remember modified time of file
        * get(const std::string& name) - check data(name)["mod_time"] - if 
different
from remembered by "set_modified" - rebuild


Class savegame::save_info changed
        *  time_t and std::string members now private. You should use method
for access to it
        * summary() method for transparent access to summary
(save_index_manager.get(name()) - see save_index_manager.get description
above)
      


Class savegame::manager removed. All statis function moved to savegame
namespace.



Function "savegame::extract_summary_data_from_save" removed, because it
word-by-word equalient to "extract_summary_from_config". I just call "rebuild"
for save_info in "finish_save_game". My purpose was avoid copy-paste.

Other changes:
        * I removed summaries from src/dialogs.cpp. Now you can transparent 
access by
save_info::summary()
        * I removed all copy-paste like (use summary() instead of this):
--------------------------------------------------
        std::string dummy;
        const config &summary = *summaries_[index_];
        if (summary["label"].empty())
        {
                try {
                        savegame::manager::load_summary((*info_)[index_].name, 
*summaries_[index_],
&dummy);
                } catch(game::load_game_failed&) {
                        (*summaries_[index_])["corrupt"] = true;
                }
        }
--------------------------------------------------
        * added class filename_filter - predicate for erase (used in 
get_saves_list)
        * added class create_save_info - builder for save_info. In general you 
can't
create save_info right now (and this is unecessary). If you need this in
feature - just move declaration of class create_save_info to header.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Wed 08 Feb 2012 07:17:39 PM GMT  Name: save_refactoring.patch  Size:
34kB   By: zamotivator

<http://gna.org/patch/download.php?file_id=15039>

    _______________________________________________________

Reply to this item at:

  <http://gna.org/patch/?3125>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs

Reply via email to