Move away from SDL_Delay for gui-related delays,
so --nogui runs at full speed (doing AI testing)
This commit is contained in:
parent
9de2ea3f9c
commit
8b69833317
18 changed files with 51 additions and 38 deletions
|
@ -325,7 +325,7 @@ void show_about(display &disp, std::string campaign)
|
|||
update_rect(map_rect);
|
||||
close.set_dirty(true);
|
||||
disp.flip();
|
||||
SDL_Delay(20);
|
||||
disp.delay(20);
|
||||
|
||||
} while(!close.pressed() && (last_escape || !key[SDLK_ESCAPE]));
|
||||
|
||||
|
|
|
@ -165,8 +165,7 @@ std::string recruit_unit(const gamemap& map, int side,
|
|||
disp->invalidate(recruit_location);
|
||||
disp->draw();
|
||||
events::pump();
|
||||
if(!disp->turbo()) SDL_Delay(10);
|
||||
|
||||
disp->non_turbo_delay();
|
||||
}
|
||||
un->second.set_standing(*disp,recruit_location);
|
||||
}
|
||||
|
@ -1471,7 +1470,7 @@ void calculate_healing(display& disp, const gamemap& map,
|
|||
finished &= (!healing);
|
||||
disp.draw();
|
||||
events::pump();
|
||||
SDL_Delay(10);
|
||||
disp.delay(10);
|
||||
} while (!finished);
|
||||
|
||||
i->second.set_standing(disp,i->first);
|
||||
|
|
|
@ -137,7 +137,7 @@ bool animate_unit_advancement(const game_data& info,unit_map& units, gamemap::lo
|
|||
gui.invalidate(loc);
|
||||
gui.draw();
|
||||
events::pump();
|
||||
if(!gui.turbo()) SDL_Delay(10);
|
||||
gui.non_turbo_delay();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ bool animate_unit_advancement(const game_data& info,unit_map& units, gamemap::lo
|
|||
gui.invalidate(loc);
|
||||
gui.draw();
|
||||
events::pump();
|
||||
if(!gui.turbo()) SDL_Delay(10);
|
||||
gui.non_turbo_delay();
|
||||
}
|
||||
u->second.set_standing(gui,u->first);
|
||||
gui.invalidate(loc);
|
||||
|
|
|
@ -894,7 +894,7 @@ void display::draw(bool update,bool force)
|
|||
|
||||
//force a wait for 10 ms every frame.
|
||||
//TODO: review whether this is the correct thing to do
|
||||
SDL_Delay(maximum<int>(10,wait_time));
|
||||
delay(maximum<int>(10,wait_time));
|
||||
|
||||
if(update) {
|
||||
lastDraw_ = SDL_GetTicks();
|
||||
|
@ -2159,7 +2159,7 @@ bool display::turbo() const
|
|||
res = !res;
|
||||
}
|
||||
|
||||
return res;
|
||||
return res || screen_.faked();
|
||||
}
|
||||
|
||||
void display::set_turbo(bool turbo)
|
||||
|
@ -2167,6 +2167,19 @@ void display::set_turbo(bool turbo)
|
|||
turbo_ = turbo;
|
||||
}
|
||||
|
||||
//Delay routines: use these not SDL_Delay (for --nogui).
|
||||
void display::non_turbo_delay() const
|
||||
{
|
||||
if (!turbo())
|
||||
delay(10);
|
||||
}
|
||||
|
||||
void display::delay(unsigned int milliseconds) const
|
||||
{
|
||||
if (!screen_.faked())
|
||||
SDL_Delay(milliseconds);
|
||||
}
|
||||
|
||||
void display::set_grid(bool grid)
|
||||
{
|
||||
grid_ = grid;
|
||||
|
|
|
@ -296,6 +296,10 @@ public:
|
|||
bool turbo() const;
|
||||
void set_turbo(bool turbo);
|
||||
|
||||
//Delay routines: use these not SDL_Delay (for --nogui).
|
||||
void non_turbo_delay() const;
|
||||
void delay(unsigned int milliseconds) const;
|
||||
|
||||
//function which determines whether a grid should be overlayed on the
|
||||
//game board to more clearly show where hexes are.
|
||||
void set_grid(bool grid);
|
||||
|
|
|
@ -89,7 +89,7 @@ int show_file_chooser_dialog(display &disp, std::string &filename,
|
|||
}
|
||||
}
|
||||
disp.flip();
|
||||
SDL_Delay(10);
|
||||
disp.delay(10);
|
||||
}
|
||||
}
|
||||
} //end namespace dialogs
|
||||
|
|
|
@ -462,7 +462,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
wassert(state_of_game != NULL);
|
||||
delay_string = utils::interpolate_variables_into_string(delay_string, *state_of_game);
|
||||
const int delay_time = atoi(delay_string.c_str());
|
||||
::SDL_Delay(delay_time);
|
||||
screen->delay(delay_time);
|
||||
}
|
||||
|
||||
else if(cmd == "scroll") {
|
||||
|
@ -1128,8 +1128,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
screen->invalidate(loc);
|
||||
screen->draw();
|
||||
events::pump();
|
||||
if(!screen->turbo()) SDL_Delay(10);
|
||||
|
||||
screen->non_turbo_delay();
|
||||
}
|
||||
un->second.set_standing(*screen,un->first);
|
||||
}
|
||||
|
@ -1730,8 +1729,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
screen->invalidate(u->first);
|
||||
screen->draw();
|
||||
events::pump();
|
||||
if(!screen->turbo()) SDL_Delay(10);
|
||||
|
||||
screen->non_turbo_delay();
|
||||
}
|
||||
u->second.set_standing(*screen,u->first);
|
||||
screen->invalidate(u->first);
|
||||
|
|
|
@ -80,7 +80,7 @@ effect::effect(int xpos, int ypos, const std::string& img, ORIENTATION orientati
|
|||
|
||||
if(!images_.animation_finished()) {
|
||||
images_.update_current_frame();
|
||||
SDL_Delay(20);
|
||||
disp->delay(20);
|
||||
}
|
||||
|
||||
current_image_ = "";
|
||||
|
|
|
@ -2788,7 +2788,7 @@ void show_help(display &disp, const section &toplevel_sec, const std::string sho
|
|||
}
|
||||
}
|
||||
disp.flip();
|
||||
SDL_Delay(10);
|
||||
disp.delay(10);
|
||||
}
|
||||
}
|
||||
catch (parse_error e) {
|
||||
|
|
|
@ -215,7 +215,7 @@ bool show_intro_part(display &disp, const config& part,
|
|||
return false;
|
||||
}
|
||||
|
||||
SDL_Delay(delay/50);
|
||||
disp.delay(delay/50);
|
||||
|
||||
events::pump();
|
||||
events::raise_process_event();
|
||||
|
@ -314,7 +314,7 @@ bool show_intro_part(display &disp, const config& part,
|
|||
disp.flip();
|
||||
|
||||
if(!skip || itor == utils::utf8_iterator::end(story))
|
||||
SDL_Delay(20);
|
||||
disp.delay(20);
|
||||
}
|
||||
|
||||
draw_solid_tinted_rectangle(0,0,video.getx()-1,video.gety()-1,0,0,0,1.0,
|
||||
|
@ -347,8 +347,8 @@ void the_end(display &disp)
|
|||
|
||||
SDL_FillRect(video.getSurface(),&area,0);
|
||||
|
||||
SDL_Delay(10);
|
||||
disp.delay(10);
|
||||
}
|
||||
|
||||
SDL_Delay(4000);
|
||||
disp.delay(4000);
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ void default_map_generator::user_config(display& disp)
|
|||
update_rect(xpos,ypos,width,height);
|
||||
|
||||
disp.update_display();
|
||||
SDL_Delay(10);
|
||||
disp.delay(10);
|
||||
events::pump();
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ void run_lobby_loop(display& disp, mp::ui& ui)
|
|||
ui.process_network();
|
||||
|
||||
disp.flip();
|
||||
SDL_Delay(20);
|
||||
disp.delay(20);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -494,7 +494,7 @@ void playsingle_controller::play_ai_turn(){
|
|||
gui_->invalidate_game_status();
|
||||
gui_->invalidate_all();
|
||||
gui_->draw();
|
||||
SDL_Delay(500);
|
||||
gui_->delay(500);
|
||||
}
|
||||
|
||||
void playsingle_controller::handle_generic_event(const std::string& name){
|
||||
|
|
|
@ -824,7 +824,7 @@ void show_hotkeys_dialog (display & disp, config *save_config)
|
|||
};
|
||||
SDL_PollEvent(&event);
|
||||
disp.flip();
|
||||
SDL_Delay(10);
|
||||
disp.delay(10);
|
||||
} while (event.type!=SDL_KEYUP);
|
||||
restorer.restore();
|
||||
disp.update_display();
|
||||
|
@ -858,7 +858,7 @@ void show_hotkeys_dialog (display & disp, config *save_config)
|
|||
|
||||
disp.update_display();
|
||||
|
||||
SDL_Delay(10);
|
||||
disp.delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -823,7 +823,7 @@ int show_dialog(display& disp, surface image,
|
|||
}
|
||||
|
||||
disp.flip();
|
||||
SDL_Delay(10);
|
||||
disp.delay(10);
|
||||
|
||||
if(action != NULL) {
|
||||
const int act = action->do_action();
|
||||
|
|
|
@ -83,7 +83,7 @@ bool fade_logo(display& screen, int xpos, int ypos)
|
|||
|
||||
screen.update_display();
|
||||
|
||||
SDL_Delay(10);
|
||||
screen.delay(10);
|
||||
|
||||
events::pump();
|
||||
if(screen.video().modeChanged()) {
|
||||
|
@ -335,7 +335,7 @@ TITLE_RESULT show_title(display& screen, config& tips_of_day, int* ntip)
|
|||
return TITLE_CONTINUE;
|
||||
}
|
||||
|
||||
SDL_Delay(20);
|
||||
screen.delay(20);
|
||||
}
|
||||
|
||||
return QUIT_GAME;
|
||||
|
|
|
@ -49,8 +49,7 @@ void teleport_unit_between(display& disp, const gamemap::location& a, const game
|
|||
disp.place_temporary_unit(u, a);
|
||||
disp.draw();
|
||||
events::pump();
|
||||
if(!disp.turbo()) SDL_Delay(10);
|
||||
|
||||
disp.non_turbo_delay();
|
||||
}
|
||||
}
|
||||
if (!disp.fogged(b.x, b.y)) { // teleport
|
||||
|
@ -61,7 +60,7 @@ void teleport_unit_between(display& disp, const gamemap::location& a, const game
|
|||
disp.place_temporary_unit(u, b);
|
||||
disp.draw();
|
||||
events::pump();
|
||||
if(!disp.turbo()) SDL_Delay(10);
|
||||
disp.non_turbo_delay();
|
||||
}
|
||||
}
|
||||
u.set_standing(disp,b);
|
||||
|
@ -100,7 +99,7 @@ void move_unit_between(display& disp, const gamemap& map, const gamemap::locatio
|
|||
u.set_offset(pos);
|
||||
disp.draw();
|
||||
events::pump();
|
||||
if(!disp.turbo()) SDL_Delay(10);
|
||||
disp.non_turbo_delay();
|
||||
|
||||
mvt_time = SDL_GetTicks() -start_time;
|
||||
}
|
||||
|
@ -182,7 +181,7 @@ void unit_die(display& disp,const gamemap::location& loc, unit& u, const attack_
|
|||
disp.invalidate(loc);
|
||||
disp.draw();
|
||||
events::pump();
|
||||
if(!disp.turbo()) SDL_Delay(10);
|
||||
disp.non_turbo_delay();
|
||||
}
|
||||
u.set_standing(disp,loc);
|
||||
disp.update_display();
|
||||
|
@ -241,7 +240,7 @@ bool unit_attack_ranged(display& disp, unit_map& units,
|
|||
if(leader_loc.valid()) disp.invalidate(leader_loc);
|
||||
disp.draw();
|
||||
events::pump();
|
||||
if(!disp.turbo()) SDL_Delay(10);
|
||||
disp.non_turbo_delay();
|
||||
}
|
||||
|
||||
|
||||
|
@ -329,7 +328,7 @@ bool unit_attack_ranged(display& disp, unit_map& units,
|
|||
}
|
||||
disp.draw();
|
||||
events::pump();
|
||||
if(!disp.turbo()) SDL_Delay(10);
|
||||
disp.non_turbo_delay();
|
||||
animation_time = defender.get_animation()->get_animation_time();
|
||||
}
|
||||
halo::remove(missile_halo);
|
||||
|
@ -436,7 +435,7 @@ bool unit_attack(display& disp, unit_map& units,
|
|||
if(leader_loc.valid()) disp.invalidate(leader_loc);
|
||||
disp.draw();
|
||||
events::pump();
|
||||
if(!disp.turbo()) SDL_Delay(10);
|
||||
disp.non_turbo_delay();
|
||||
|
||||
animation_time = attacker.get_animation()->get_animation_time();
|
||||
}
|
||||
|
@ -457,7 +456,7 @@ bool unit_attack(display& disp, unit_map& units,
|
|||
if(leader_loc.valid()) disp.invalidate(leader_loc);
|
||||
disp.draw();
|
||||
events::pump();
|
||||
if(!disp.turbo()) SDL_Delay(10);
|
||||
disp.non_turbo_delay();
|
||||
|
||||
animation_time = attacker.get_animation()->get_animation_time();
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ class CVideo {
|
|||
int getBpp();
|
||||
|
||||
void make_fake();
|
||||
bool faked() { return fake_screen; }
|
||||
bool faked() const { return fake_screen; }
|
||||
|
||||
//functions to set and clear 'help strings'. A 'help string' is like a tooltip, but it appears
|
||||
//at the bottom of the screen, so as to not be intrusive. Setting a help string sets what
|
||||
|
|
Loading…
Add table
Reference in a new issue