Author: zaroth
Date: Mon May 23 19:52:30 2011
New Revision: 49637

URL: http://svn.gna.org/viewcvs/wesnoth?rev=49637&view=rev
Log:
Added a new game_instance class, which is supposed to hold state of game
in the new campaign system.

Added:
    trunk/src/game_instance.cpp
    trunk/src/game_instance.hpp
Modified:
    trunk/src/CMakeLists.txt
    trunk/src/SConscript
    trunk/src/game.cpp

Modified: trunk/src/CMakeLists.txt
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/CMakeLists.txt?rev=49637&r1=49636&r2=49637&view=diff
==============================================================================
--- trunk/src/CMakeLists.txt (original)
+++ trunk/src/CMakeLists.txt Mon May 23 19:52:30 2011
@@ -361,6 +361,7 @@
        game_display.cpp
        game_errors.cpp
        game_events.cpp
+       game_instance.cpp
        game_preferences.cpp
        game_preferences_display.cpp
        gamestatus.cpp

Modified: trunk/src/SConscript
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/SConscript?rev=49637&r1=49636&r2=49637&view=diff
==============================================================================
--- trunk/src/SConscript (original)
+++ trunk/src/SConscript Mon May 23 19:52:30 2011
@@ -223,6 +223,7 @@
     game_display.cpp
     game_errors.cpp
     game_events.cpp
+    game_instance.cpp
     game_preferences.cpp
     gamestatus.cpp
     gui/auxiliary/canvas.cpp

Modified: trunk/src/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=49637&r1=49636&r2=49637&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Mon May 23 19:52:30 2011
@@ -27,6 +27,7 @@
 #include "dialogs.hpp"
 #include "foreach.hpp"
 #include "game_display.hpp"
+#include "game_instance.hpp"
 #include "game_preferences.hpp"
 #include "builder.hpp"
 #include "filesystem.hpp"
@@ -224,6 +225,8 @@
 
        util::scoped_ptr<game_display> disp_;
 
+       /// Stateful class taking over scenario-switching capabilities from the 
current game_controller and playsingle_controller. Currently only available 
when --new-syntax command line option is enabled.
+       game_instance game_instance_;
        game_state state_;
 
        std::string multiplayer_server_;
@@ -260,6 +263,7 @@
        game_config_(),
        old_defines_map_(),
        disp_(NULL),
+       game_instance_(),
        state_(),
        multiplayer_server_(),
        jump_to_multiplayer_(false),
@@ -1062,6 +1066,11 @@
 
 bool game_controller::new_campaign()
 {
+       if (game_config::new_syntax)
+       {
+               game_instance_ = game_instance();
+               return false;
+       }
        state_ = game_state();
        state_.classification().campaign_type = "scenario";
 
@@ -1069,7 +1078,6 @@
        std::vector<config> campaigns(ci.first, ci.second);
        mark_completed_campaigns(campaigns);
        std::sort(campaigns.begin(),campaigns.end(),less_campaigns_rank);
-
 
        if(campaigns.begin() == campaigns.end()) {
          gui2::show_error_message(disp().video(),
@@ -2176,7 +2184,7 @@
        }
 
        //ensure recorder has an actually random seed instead of what it got 
during
-       //static initialization (befire any srand() call)
+       //static initialization (before any srand() call)
        recorder.set_seed(rand());
 
        game_controller game(argc,argv);
@@ -2327,7 +2335,6 @@
                                res = gui2::ttitle_screen::NOTHING;
                                continue;
                        }
-
                        should_reload = game_controller::NO_RELOAD_DATA;
                } else if(res == gui2::ttitle_screen::TUTORIAL) {
                        game.set_tutorial();

Added: trunk/src/game_instance.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_instance.cpp?rev=49637&view=auto
==============================================================================
--- trunk/src/game_instance.cpp (added)
+++ trunk/src/game_instance.cpp Mon May 23 19:52:30 2011
@@ -1,0 +1,26 @@
+/* $Id$ */
+/*
+   Copyright (C) 2011 by Lukasz Dobrogowski <[email protected]>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY.
+
+   See the COPYING file for more details.
+*/
+
+#include "game_instance.hpp"
+
+#include "log.hpp"
+
+#define LOG_GENERAL LOG_STREAM(info, lg::general)
+#define WRN_GENERAL LOG_STREAM(warn, lg::general)
+#define DBG_GENERAL LOG_STREAM(debug, lg::general)
+
+game_instance::game_instance()
+{
+}

Added: trunk/src/game_instance.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_instance.hpp?rev=49637&view=auto
==============================================================================
--- trunk/src/game_instance.hpp (added)
+++ trunk/src/game_instance.hpp Mon May 23 19:52:30 2011
@@ -1,0 +1,24 @@
+/* $Id$ */
+/*
+   Copyright (C) 2011 by Lukasz Dobrogowski <[email protected]>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY.
+
+   See the COPYING file for more details.
+*/
+#ifndef GAME_INSTANCE_H_INCLUDED
+#define GAME_INSTANCE_H_INCLUDED
+
+class game_instance
+{
+public:
+       game_instance();
+};
+
+#endif


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

Reply via email to