more complete transaction handling for persistent variables.
This commit is contained in:
parent
e4567a3793
commit
eca9d94e2b
4 changed files with 12 additions and 6 deletions
|
@ -25,17 +25,17 @@ class persist_manager {
|
|||
bool in_transaction_;
|
||||
context_map contexts_;
|
||||
public:
|
||||
bool start_transaction();
|
||||
bool end_transaction();
|
||||
bool cancel_transaction();
|
||||
|
||||
persist_manager() : in_transaction_(false),contexts_() {}
|
||||
virtual ~persist_manager() {
|
||||
cancel_transaction();
|
||||
for (context_map::iterator i = contexts_.begin(); i != contexts_.end(); i++)
|
||||
delete (i->second);
|
||||
}
|
||||
persist_context &get_context(const std::string &ns);
|
||||
|
||||
//TODO - Transactions
|
||||
bool start_transaction();
|
||||
bool end_transaction();
|
||||
bool cancel_transaction();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -138,7 +138,6 @@ play_controller::play_controller(const config& level, game_state& state_of_game,
|
|||
|
||||
play_controller::~play_controller()
|
||||
{
|
||||
persist_.end_transaction();
|
||||
clear_resources();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,12 +26,14 @@
|
|||
#include "gui/dialogs/transient_message.hpp"
|
||||
#include "playcampaign.hpp"
|
||||
#include "map_create.hpp"
|
||||
#include "persist_manager.hpp"
|
||||
#include "playmp_controller.hpp"
|
||||
#include "replay_controller.hpp"
|
||||
#include "log.hpp"
|
||||
#include "map_exception.hpp"
|
||||
#include "dialogs.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "savegame.hpp"
|
||||
#include "sound.hpp"
|
||||
#include "wml_exception.hpp"
|
||||
|
@ -129,6 +131,8 @@ static LEVEL_RESULT playsingle_scenario(const config& game_config,
|
|||
end_level = playcontroller.get_end_level_data();
|
||||
|
||||
if (res == DEFEAT) {
|
||||
if (resources::persist != NULL)
|
||||
resources::persist->end_transaction();
|
||||
gui2::show_transient_message(disp.video(),
|
||||
_("Defeat"),
|
||||
_("You have been defeated!")
|
||||
|
@ -167,6 +171,8 @@ static LEVEL_RESULT playmp_scenario(const config& game_config,
|
|||
io_type = IO_SERVER;
|
||||
|
||||
if (res == DEFEAT) {
|
||||
if (resources::persist != NULL)
|
||||
resources::persist->end_transaction();
|
||||
gui2::show_transient_message(disp.video(),
|
||||
_("Defeat"),
|
||||
_("You have been defeated!")
|
||||
|
|
|
@ -929,6 +929,7 @@ void playsingle_controller::store_gold(bool obs)
|
|||
if (obs) {
|
||||
title = _("Scenario Report");
|
||||
} else {
|
||||
persist_.end_transaction();
|
||||
title = _("Victory");
|
||||
report << "<b>" << _("You have emerged victorious!") << "</b>\n\n";
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue