Added a new game_instance class,

...which is supposed to hold state of game in the new campaign system.
This commit is contained in:
Lukasz Dobrogowski 2011-05-23 17:52:30 +00:00
parent 80bec3a048
commit 0204508df7
5 changed files with 62 additions and 3 deletions

View file

@ -361,6 +361,7 @@ set(wesnoth-main_SRC
game_display.cpp
game_errors.cpp
game_events.cpp
game_instance.cpp
game_preferences.cpp
game_preferences_display.cpp
gamestatus.cpp

View file

@ -223,6 +223,7 @@ wesnoth_sources = Split("""
game_display.cpp
game_errors.cpp
game_events.cpp
game_instance.cpp
game_preferences.cpp
gamestatus.cpp
gui/auxiliary/canvas.cpp

View file

@ -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 @@ private:
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_controller::game_controller(int argc, char** argv) :
game_config_(),
old_defines_map_(),
disp_(NULL),
game_instance_(),
state_(),
multiplayer_server_(),
jump_to_multiplayer_(false),
@ -1062,6 +1066,11 @@ void game_controller::mark_completed_campaigns(std::vector<config> &campaigns)
bool game_controller::new_campaign()
{
if (game_config::new_syntax)
{
game_instance_ = game_instance();
return false;
}
state_ = game_state();
state_.classification().campaign_type = "scenario";
@ -1070,7 +1079,6 @@ bool game_controller::new_campaign()
mark_completed_campaigns(campaigns);
std::sort(campaigns.begin(),campaigns.end(),less_campaigns_rank);
if(campaigns.begin() == campaigns.end()) {
gui2::show_error_message(disp().video(),
_("No campaigns are available.\n"));
@ -2176,7 +2184,7 @@ static int do_gameloop(int argc, char** argv)
}
//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 @@ static int do_gameloop(int argc, char** argv)
res = gui2::ttitle_screen::NOTHING;
continue;
}
should_reload = game_controller::NO_RELOAD_DATA;
} else if(res == gui2::ttitle_screen::TUTORIAL) {
game.set_tutorial();

26
src/game_instance.cpp Normal file
View file

@ -0,0 +1,26 @@
/* $Id$ */
/*
Copyright (C) 2011 by Lukasz Dobrogowski <lukasz.dobrogowski@gmail.com>
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()
{
}

24
src/game_instance.hpp Normal file
View file

@ -0,0 +1,24 @@
/* $Id$ */
/*
Copyright (C) 2011 by Lukasz Dobrogowski <lukasz.dobrogowski@gmail.com>
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