minor fixes to the MP clock

This commit is contained in:
Jérémy Rosen 2005-12-17 08:24:45 +00:00
parent c5283c0dfc
commit bc50e763b8
3 changed files with 47 additions and 27 deletions

View file

@ -614,8 +614,14 @@ height=600
[change]
id=status-position
rect="+15,=,+145,+16"
rect="+3,=,+115,+16"
[/change]
[change]
id=observers
rect="+6,=-1,+16,+16"
[/change]
[/partialresolution]
[partialresolution]

View file

@ -43,7 +43,7 @@ create::create(display& disp, const config &cfg, chat& c, config& gamelist) :
maps_menu_(disp.video(), std::vector<std::string>()),
turns_slider_(disp.video()),
turns_label_(disp.video(), "", font::SIZE_SMALL, font::LOBBY_COLOUR),
countdown_game_(disp.video(), _("Enable time limit"), gui::button::TYPE_CHECK),
countdown_game_(disp.video(), _("Time limit"), gui::button::TYPE_CHECK),
countdown_init_time_slider_(disp.video()),
countdown_init_time_label_(disp.video(), "", font::SIZE_SMALL, font::LOBBY_COLOUR),
countdown_turn_bonus_slider_(disp.video()),
@ -100,7 +100,7 @@ create::create(display& disp, const config &cfg, chat& c, config& gamelist) :
turns_slider_.set_help_string(_("The maximum number of turns the game can last"));
countdown_game_.set_check(preferences::countdown());
countdown_game_.set_help_string(_("Enables ingame user time limits"));
countdown_game_.set_help_string(_("Enables user time limit"));
countdown_init_time_slider_.set_min(0);
countdown_init_time_slider_.set_max(7200);
@ -108,7 +108,7 @@ create::create(display& disp, const config &cfg, chat& c, config& gamelist) :
countdown_init_time_slider_.set_value(preferences::countdown_init_time());
countdown_init_time_slider_.set_help_string(_("Initial time available for user at the begining of the match"));
countdown_turn_bonus_slider_.set_min(0);
countdown_turn_bonus_slider_.set_min(10);
countdown_turn_bonus_slider_.set_max(1000);
countdown_turn_bonus_slider_.set_increment(10);
countdown_turn_bonus_slider_.set_value(preferences::countdown_turn_bonus());
@ -263,12 +263,12 @@ void create::process_event()
const int mp_countdown_init_time_val = countdown_init_time_slider_.value();
buf.str("");
buf << _("Initial Time: ") << mp_countdown_init_time_val << " seconds";
buf << _("Initial Time: ") << mp_countdown_init_time_val;
countdown_init_time_label_.set_text(buf.str());
const int mp_countdown_turn_bonus_val = countdown_turn_bonus_slider_.value();
buf.str("");
buf << _("Turn time bonus: ") << mp_countdown_turn_bonus_val << " seconds";
buf << _("Turn time: ") << mp_countdown_turn_bonus_val;
countdown_turn_bonus_label_.set_text(buf.str());
//Villages can produce between 1 and 10 gold a turn
@ -549,8 +549,8 @@ void create::layout_children(const SDL_Rect& rect)
xp_modifier_slider_.set_location(xpos, ypos);
ypos += xp_modifier_slider_.height() + border_size;
countdown_game_.set_location(xpos, ypos);
ypos += countdown_game_.height() + border_size;
use_map_settings_.set_location(xpos, ypos);
ypos += use_map_settings_.height() + border_size;
countdown_init_time_label_.set_location(xpos, ypos);
countdown_turn_bonus_label_.set_location(xpos + (ca.w - xpos)/2 + 5 , ypos);
@ -561,17 +561,16 @@ void create::layout_children(const SDL_Rect& rect)
countdown_turn_bonus_slider_.set_location(xpos + (ca.w - xpos)/2 + 5, ypos);
ypos += countdown_init_time_slider_.height() + border_size;
countdown_game_.set_location(xpos, ypos);
// ypos += countdown_game_.height() + border_size;
use_map_settings_.set_location(xpos, ypos);
ypos += use_map_settings_.height() + border_size;
fog_game_.set_location(xpos, ypos);
fog_game_.set_location(xpos + (ca.w - xpos)/2 + 5, ypos);
ypos += fog_game_.height() + border_size;
shroud_game_.set_location(xpos, ypos);
ypos += shroud_game_.height() + border_size;
// ypos += shroud_game_.height() + border_size;
observers_game_.set_location(xpos, ypos);
observers_game_.set_location(xpos + (ca.w - xpos)/2 + 5, ypos);
ypos += observers_game_.height() + border_size;
vision_combo_.set_location(xpos, ypos);

View file

@ -144,18 +144,33 @@ void play_turn(const game_data& gameinfo, game_state& state_of_game,
if (teams[team_num -1].countdown_time() > 0 && ( level["mp_countdown"] == "yes" ) ){
SDL_Delay(1);
const int ticks = SDL_GetTicks();
teams[team_num -1].set_countdown_time(teams[team_num -1].countdown_time()-maximum<int>(1,(ticks - cur_ticks)));
cur_ticks = ticks;
if ( teams[team_num -1].countdown_time() <= beep_warning_time){
beep_warning_time=beep_warning_time - 1000;
sound::play_sound("bell.wav");
}
if ( teams[team_num -1].countdown_time() <= 0){
teams[team_num -1].set_countdown_time(teams[team_num -1].countdown_time() + 1000 * lexical_cast_default<int>(level["mp_countdown_turn_bonus"],0));
recorder.add_countdown_update(teams[team_num -1].countdown_time(),team_num);
recorder.end_turn();
turn_data.send_data();
throw end_turn_exception();
int new_time = teams[team_num -1].countdown_time()-maximum<int>(1,(ticks - cur_ticks));
if (new_time > 0 ){
teams[team_num -1].set_countdown_time(teams[team_num -1].countdown_time()-maximum<int>(1,(ticks - cur_ticks)));
cur_ticks = ticks;
if ( teams[team_num -1].countdown_time() <= beep_warning_time){
beep_warning_time=beep_warning_time - 1000;
sound::play_sound("bell.wav");
}
} else {
// Clock time ended
// If no turn bonus -> defeat
if ( lexical_cast_default<int>(level["mp_countdown_turn_bonus"],0) == 0){
// Not possible to end level in MP with throw end_level_exception(DEFEAT);
// because remote players only notice network disconnection
// Current solution end remaining turns automatically
teams[team_num -1].set_countdown_time(10);
recorder.add_countdown_update(teams[team_num -1].countdown_time(),team_num);
recorder.end_turn();
turn_data.send_data();
throw end_turn_exception();
} else {
teams[team_num -1].set_countdown_time(1000 * lexical_cast_default<int>(level["mp_countdown_turn_bonus"],0));
recorder.add_countdown_update(teams[team_num -1].countdown_time(),team_num);
recorder.end_turn();
turn_data.send_data();
throw end_turn_exception();
}
}
}
@ -167,7 +182,7 @@ void play_turn(const game_data& gameinfo, game_state& state_of_game,
}
if ( level["mp_countdown"] == "yes" ){
teams[team_num -1].set_countdown_time(teams[team_num -1].countdown_time() + 1000 * lexical_cast_default<int>(level["mp_countdown_turn_bonus"],0));
recorder.add_countdown_update(teams[team_num -1].countdown_time(),team_num);
recorder.add_countdown_update(teams[team_num -1].countdown_time(),team_num);
}
//send one more time to make sure network is up-to-date.