Skip to content

Commit

Permalink
move game_state to its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Jun 24, 2014
1 parent 3d6f2d7 commit 30a443d
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 23 deletions.
2 changes: 2 additions & 0 deletions projectfiles/CodeBlocks/wesnoth.cbp
Expand Up @@ -364,6 +364,8 @@
<Unit filename="..\..\src\game_preferences.cpp" />
<Unit filename="..\..\src\game_preferences.hpp" />
<Unit filename="..\..\src\game_preferences_display.cpp" />
<Unit filename="..\..\src\game_state.cpp" />
<Unit filename="..\..\src\game_state.hpp" />
<Unit filename="..\..\src\generators\cavegen.cpp" />
<Unit filename="..\..\src\generators\cavegen.hpp" />
<Unit filename="..\..\src\generators\map_create.cpp" />
Expand Down
8 changes: 8 additions & 0 deletions projectfiles/VC9/wesnoth.vcproj
Expand Up @@ -20340,6 +20340,14 @@
RelativePath="..\..\src\game_preferences_display.cpp"
>
</File>
<File
RelativePath="..\..\src\game_state.cpp"
>
</File>
<File
RelativePath="..\..\src\game_state.hpp"
>
</File>
<File
RelativePath="..\..\src\generic_event.cpp"
>
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Expand Up @@ -755,6 +755,7 @@ set(wesnoth-main_SRC
game_events/wmi_container.cpp
game_preferences.cpp
game_preferences_display.cpp
game_state.cpp
generic_event.cpp
gui/auxiliary/canvas.cpp
gui/auxiliary/log.cpp
Expand Down
1 change: 1 addition & 0 deletions src/SConscript
Expand Up @@ -287,6 +287,7 @@ wesnoth_sources = Split("""
game_events/pump.cpp
game_events/wmi_container.cpp
game_preferences.cpp
game_state.cpp
gui/auxiliary/canvas.cpp
gui/auxiliary/event/dispatcher.cpp
gui/auxiliary/event/distributor.cpp
Expand Down
29 changes: 29 additions & 0 deletions src/game_state.cpp
@@ -0,0 +1,29 @@
/*
Copyright (C) 2014 by Chris Beck <render787@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_state.hpp"

#include "pathfind/teleport.hpp"


game_state::game_state(const config & level, const config & game_config) :
level_(level),
gamedata_(level_),
board_(game_config,level_),
tod_manager_(level_),
pathfind_manager_()
{}

game_state::~game_state() {}

40 changes: 40 additions & 0 deletions src/game_state.hpp
@@ -0,0 +1,40 @@
/*
Copyright (C) 2014 by Chris Beck <render787@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 INCL_GAME_STATE_HPP_
#define INCL_GAME_STATE_HPP_

class config;

#include "game_board.hpp"
#include "game_data.hpp"
#include "tod_manager.hpp"

#include <boost/scoped_ptr.hpp>

namespace pathfind { class manager; }

struct game_state {
const config& level_;
game_data gamedata_;
game_board board_;
tod_manager tod_manager_;
boost::scoped_ptr<pathfind::manager> pathfind_manager_;

game_state(const config & level, const config & game_config);

~game_state();
};

#endif
10 changes: 0 additions & 10 deletions src/play_controller.cpp
Expand Up @@ -93,16 +93,6 @@ static void clear_resources()

}

game_state::game_state(const config & level, const config & game_config) :
level_(level),
gamedata_(level_),
board_(game_config,level_),
tod_manager_(level_),
pathfind_manager_()
{}

game_state::~game_state() {}

play_controller::play_controller(const config& level, saved_game& state_of_game,
const int ticks, const config& game_config,
CVideo& video, bool skip_replay) :
Expand Down
15 changes: 2 additions & 13 deletions src/play_controller.hpp
Expand Up @@ -18,8 +18,7 @@

#include "controller_base.hpp"
#include "game_end_exceptions.hpp"
#include "game_board.hpp"
#include "game_data.hpp"
#include "game_state.hpp"
#include "help.hpp"
#include "menu_events.hpp"
#include "mouse_events.hpp"
Expand Down Expand Up @@ -71,17 +70,7 @@ namespace wb {
} // namespace wb

// Holds gamestate related objects
struct game_state {
const config& level_;
game_data gamedata_;
game_board board_;
tod_manager tod_manager_;
boost::scoped_ptr<pathfind::manager> pathfind_manager_;

game_state(const config & level, const config & game_config);

~game_state();
};
struct game_state;

class play_controller : public controller_base, public events::observer, public savegame::savegame_config
{
Expand Down

0 comments on commit 30a443d

Please sign in to comment.