The end of multiplayer "quick replay" is now determined...

...from the current turn of the selected game on entering it as
observer. If that turn is reached, quick replay is turned off and
normal gameplay continues.
This commit is contained in:
Jörg Hinrichs 2006-07-03 18:52:20 +00:00
parent 19bbbafc46
commit 2a8b65d0d1
5 changed files with 21 additions and 7 deletions

View file

@ -46,6 +46,5 @@ void start_server(display& disp, const config& game_config, game_data& data,
void start_client(display& disp, const config& game_config, game_data& data,
const std::string host);
extern bool skip_mp_replay;
}
#endif

View file

@ -21,6 +21,7 @@
#include "wml_separators.hpp"
#include "game_config.hpp"
#include "gettext.hpp"
#include "playmp_controller.hpp"
#include "show_dialog.hpp"
#include "sound.hpp"
@ -466,8 +467,7 @@ lobby::lobby(display& disp, const config& cfg, chat& c, config& gamelist) :
game_preferences_(disp.video(), _("Preferences")),
quit_game_(disp.video(), _("Quit")),
sorter_(gamelist),
games_menu_(disp.video(),cfg.child("multiplayer_hashes")),
current_game_(0)
games_menu_(disp.video(),cfg.child("multiplayer_hashes"))
{
skip_replay_.set_check(preferences::skip_mp_replay());
skip_replay_.set_help_string(_("Skip quickly to the active turn when observing"));
@ -552,6 +552,12 @@ void lobby::process_event()
network::send_data(response);
if(observe) {
const std::string& str_current_turn = game_cfg["turn"];
int index = str_current_turn.find_first_of('/');
if (index > -1){
const std::string strTest = str_current_turn.substr(0, index);
playmp_controller::set_replay_last_turn(lexical_cast<unsigned int>(strTest));
}
set_result(OBSERVE);
} else {
set_result(JOIN);

View file

@ -123,7 +123,6 @@ private:
lobby_sorter sorter_;
gamebrowser games_menu_;
int current_game_;
std::map<std::string,std::string> minimaps_;
};

View file

@ -20,6 +20,8 @@
#define LOG_NG LOG_STREAM(info, engine)
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)
@ -39,6 +41,10 @@ playmp_controller::playmp_controller(const config& level, const game_data& gamei
turn_data_ = NULL;
}
void playmp_controller::set_replay_last_turn(unsigned int turn){
replay_last_turn_ = turn;
}
void playmp_controller::clear_labels(){
menu_handler_.clear_labels();
}
@ -212,6 +218,9 @@ bool playmp_controller::play_network_turn(){
if(result == turn_info::PROCESS_RESTART_TURN) {
return true;
} else if(result == turn_info::PROCESS_END_TURN) {
if (skip_replay_ && replay_last_turn_ <= status_.turn()){
skip_replay_ = false;
}
break;
}
}
@ -221,9 +230,6 @@ bool playmp_controller::play_network_turn(){
}
}
else{
skip_replay_ = false;
}
play_slice();
turn_data.send_data();

View file

@ -27,6 +27,9 @@ public:
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);
static unsigned int replay_last_turn() { return replay_last_turn_; }
static void set_replay_last_turn(unsigned int turn);
protected:
virtual void handle_generic_event(const std::string& name);
@ -46,6 +49,7 @@ protected:
int beep_warning_time_;
private:
void process_oos(const std::string& err_msg);
static unsigned int replay_last_turn_;
};