mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-27 13:15:26 +00:00
Refactoring step.
Expose the play_controller object in play_campaign.cpp; we're going to need it to implement linger mode.
This commit is contained in:
parent
5c511b7a11
commit
a91a35231d
@ -34,6 +34,7 @@
|
||||
#include "wassert.hpp"
|
||||
|
||||
#define LOG_G LOG_STREAM(info, general)
|
||||
#define LOG_NG LOG_STREAM(info, engine)
|
||||
|
||||
namespace {
|
||||
|
||||
@ -278,16 +279,27 @@ LEVEL_RESULT play_game(display& disp, game_state& gamestate, const config& game_
|
||||
|
||||
gamestate.completion = "running";
|
||||
|
||||
const int ticks = SDL_GetTicks();
|
||||
const int num_turns = atoi((*scenario)["turns"].c_str());
|
||||
playsingle_controller *pcontroller;
|
||||
|
||||
LOG_NG << "creating objects... " << (SDL_GetTicks() - ticks) << "\n";
|
||||
switch (io_type){
|
||||
case IO_NONE:
|
||||
res = playsingle_scenario(units_data,game_config,scenario,video,gamestate,story,log, skip_replay);
|
||||
pcontroller = new playsingle_controller(*scenario,units_data,gamestate,ticks,num_turns,game_config,video,skip_replay);
|
||||
LOG_NG << "created objects... " << (SDL_GetTicks() - pcontroller->get_ticks()) << "\n";
|
||||
res = pcontroller->play_scenario(story, log, skip_replay);
|
||||
break;
|
||||
case IO_SERVER:
|
||||
case IO_CLIENT:
|
||||
res = playmp_scenario(units_data,game_config,scenario,video,gamestate,story,log, skip_replay);
|
||||
pcontroller = new playmp_controller(*scenario,units_data,gamestate,ticks,num_turns,game_config,video,skip_replay);
|
||||
LOG_NG << "created objects... " << (SDL_GetTicks() - pcontroller->get_ticks()) << "\n";
|
||||
res = reinterpret_cast<playmp_controller *>(pcontroller)->play_scenario(story, log, skip_replay);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// tell all clients that the campaign won't continue
|
||||
// why isn't this done on VICTORY as well?
|
||||
if(io_type==IO_SERVER && (res==QUIT || res==DEFEAT)) {
|
||||
|
@ -23,16 +23,6 @@
|
||||
|
||||
unsigned int playmp_controller::replay_last_turn_ = 0;
|
||||
|
||||
LEVEL_RESULT playmp_scenario(const game_data& gameinfo, const config& game_config,
|
||||
config const* level, CVideo& video, game_state& state_of_game,
|
||||
const config::child_list& story, upload_log& log, bool skip_replay)
|
||||
{
|
||||
const int ticks = SDL_GetTicks();
|
||||
const int num_turns = atoi((*level)["turns"].c_str());
|
||||
playmp_controller playcontroller(*level, gameinfo, state_of_game, ticks, num_turns, game_config, video, skip_replay);
|
||||
return playcontroller.play_scenario(story, log, skip_replay);
|
||||
}
|
||||
|
||||
playmp_controller::playmp_controller(const config& level, const game_data& gameinfo, game_state& state_of_game,
|
||||
const int ticks, const int num_turns, const config& game_config, CVideo& video,
|
||||
bool skip_replay)
|
||||
|
@ -60,9 +60,4 @@ private:
|
||||
static unsigned int replay_last_turn_;
|
||||
};
|
||||
|
||||
|
||||
LEVEL_RESULT playmp_scenario(const game_data& gameinfo, const config& terrain_config,
|
||||
config const* level, CVideo& video, game_state& state_of_game,
|
||||
const config::child_list& story, upload_log& log, bool skip_replay);
|
||||
|
||||
#endif
|
||||
|
@ -24,19 +24,6 @@
|
||||
|
||||
#define LOG_NG LOG_STREAM(info, engine)
|
||||
|
||||
LEVEL_RESULT playsingle_scenario(const game_data& gameinfo, const config& game_config,
|
||||
const config* level, CVideo& video, game_state& state_of_game,
|
||||
const std::vector<config*>& story, upload_log& log, bool skip_replay)
|
||||
{
|
||||
const int ticks = SDL_GetTicks();
|
||||
const int num_turns = atoi((*level)["turns"].c_str());
|
||||
LOG_NG << "creating objects... " << (SDL_GetTicks() - ticks) << "\n";
|
||||
playsingle_controller playcontroller(*level, gameinfo, state_of_game, ticks, num_turns, game_config, video, skip_replay);
|
||||
LOG_NG << "created objects... " << (SDL_GetTicks() - playcontroller.get_ticks()) << "\n";
|
||||
|
||||
return playcontroller.play_scenario(story, log, skip_replay);
|
||||
}
|
||||
|
||||
playsingle_controller::playsingle_controller(const config& level, const game_data& gameinfo, game_state& state_of_game,
|
||||
const int ticks, const int num_turns, const config& game_config, CVideo& video,
|
||||
bool skip_replay)
|
||||
|
@ -74,9 +74,4 @@ protected:
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
LEVEL_RESULT playsingle_scenario(const game_data& gameinfo, const config& terrain_config,
|
||||
const config* level, CVideo& video, game_state& state_of_game,
|
||||
const std::vector<config*>& story, upload_log& loo, bool skip_replay);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user