savegame reorganization: implemented savegame_config for team.

moved savegame_config to its own file to resolve dependency issues
between team.hpp and gamestatus.hpp
This commit is contained in:
Eugen Jiresch 2009-06-02 15:40:50 +00:00
parent 35587bcb0c
commit 2f27a42389
4 changed files with 40 additions and 9 deletions

View file

@ -31,14 +31,6 @@ class gamestatus; //needed to declare get_player_info (until game_state and game
class scoped_wml_variable;
/* interface for building a config from savegame related objects */
class savegame_config
{
public:
virtual ~savegame_config() {};
virtual config toConfig() = 0;
};
struct wml_menu_item
{
wml_menu_item(const std::string& id, const config* cfg=NULL);

28
src/savegame_config.hpp Normal file
View file

@ -0,0 +1,28 @@
/*
Copyright (C) 2009 by Eugen Jiresch
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 version 2
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 SAVEGAME_CONFIG_HPP_INCLUDED
#define SAVEGAME_CONFIG_HPP_INCLUDED
/* interface for building a config from savegame related objects */
//FIXME: move to gamestate.hpp once dependencies between team and game_state are sorted
class config;
class savegame_config
{
public:
virtual ~savegame_config() {};
virtual config toConfig() = 0;
};
#endif

View file

@ -967,6 +967,14 @@ void team::log_recruitable(){
LOG_NG << "Added all recruitable units\n";
}
config team::toConfig()
{
config cfg;
config& result = cfg.add_child("side");
write(result);
return result;
}
namespace player_teams {
int village_owner(const map_location& loc)
{

View file

@ -19,6 +19,7 @@
#include "game_config.hpp"
#include "map_location.hpp"
#include "viewpoint.hpp"
#include "savegame_config.hpp"
class gamemap;
struct time_of_day;
@ -33,7 +34,7 @@ struct time_of_day;
* This class stores all the data for a single 'side' (in game nomenclature).
* E.g., there is only one leader unit per team.
*/
class team : public viewpoint
class team : public viewpoint, public savegame_config
{
class shroud_map {
public:
@ -312,6 +313,8 @@ public:
/** clear the shroud, fog, and enemies cache for all teams*/
static void clear_caches();
config toConfig();
private:
//Make these public if you need them, but look at knows_about_team(...) first.
bool share_maps() const { return info_.share_maps; }