made an option to set the number of fps that should be shown,
...not all code honours this yet the default is 50 fps changed the draw delay logic it now determines when the next draw should take place, this avoids adding a delay when the code is already lagging. That problem occurs with scrolling and animations. The engine now stays much closer to the desired fps, provided that the system it runs on is fast enough.
This commit is contained in:
parent
77a1e5b48f
commit
a32f36041e
8 changed files with 61 additions and 10 deletions
|
@ -1,3 +1,9 @@
|
|||
Version 1.3.1+svn:
|
||||
* graphics
|
||||
* added the --max-fps command line switch
|
||||
* changed the drawing logic so it no longer delays when the drawing is
|
||||
lagging
|
||||
|
||||
Version 1.3.1:
|
||||
* Campaignd
|
||||
* first argument is number of threads to use, defaults to 5
|
||||
|
|
|
@ -81,6 +81,10 @@ only warnings and errors, and
|
|||
.B --log-error
|
||||
just errors.
|
||||
.TP
|
||||
.BR --max-fps
|
||||
the number of frames per second the game can show, the value should be between
|
||||
the 1 and 1000, the default is 50.
|
||||
.TP
|
||||
.B --multiplayer
|
||||
runs a multiplayer game. There are additional options that can be used
|
||||
together with
|
||||
|
|
|
@ -2,7 +2,11 @@ This is meant to be a concise list of player-visible changes (very minor changes
|
|||
may be omitted). For a complete list of changes, see the main changelog:
|
||||
http://svn.gna.org/viewcvs/*checkout*/wesnoth/trunk/changelog
|
||||
|
||||
Version 1.3-svn:
|
||||
Version 1.3.1+svn:
|
||||
* Graphics
|
||||
* Added the --max-fps command line switch.
|
||||
|
||||
Version 1.3.1:
|
||||
* Campaigns
|
||||
* Eastern Invasion:
|
||||
* Drowned Plains: the dragon now starts on grassland.
|
||||
|
|
|
@ -83,7 +83,7 @@ display::display(unit_map& units, CVideo& video, const gamemap& map,
|
|||
temp_unit_(NULL),
|
||||
minimap_(NULL), redrawMinimap_(false),
|
||||
status_(status),
|
||||
teams_(t), lastDraw_(0),
|
||||
teams_(t), nextDraw_(0),
|
||||
invalidateAll_(true), invalidateUnit_(true),
|
||||
invalidateGameStatus_(true), panelsDrawn_(false),
|
||||
currentTeam_(0), activeTeam_(0),
|
||||
|
@ -897,22 +897,26 @@ void display::draw(bool update,bool force)
|
|||
|
||||
prune_chat_messages();
|
||||
|
||||
const int time_between_draws = 10;
|
||||
static const int time_between_draws = preferences::draw_delay();
|
||||
const int current_time = SDL_GetTicks();
|
||||
const int wait_time = lastDraw_ + time_between_draws - current_time;
|
||||
const int wait_time = nextDraw_ - current_time;
|
||||
|
||||
if(update) {
|
||||
if(force || changed) {
|
||||
if(!force && wait_time > 0) {
|
||||
// if it's not time yet to draw add a small delay due to the recent
|
||||
// optimizations we're now able to DOS the CPU if there's not much
|
||||
// invalidated, this still needs to be reworked after 1.3.1 has
|
||||
// been released -- Mordante
|
||||
// if it's not time yet to draw delay until it is
|
||||
SDL_Delay(wait_time);
|
||||
}
|
||||
update_display();
|
||||
}
|
||||
lastDraw_ = SDL_GetTicks();
|
||||
// set the theortical next draw time
|
||||
nextDraw_ += time_between_draws;
|
||||
|
||||
// if the next draw already should have been finished we'll enter an
|
||||
// update frenzy, so make sure that the too late value doesn't keep
|
||||
// growing. Note if force is used too often we can also get the
|
||||
// opposite effect.
|
||||
nextDraw_ = maximum<int>(nextDraw_, SDL_GetTicks());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -478,7 +478,9 @@ private:
|
|||
|
||||
const std::vector<team>& teams_;
|
||||
|
||||
int lastDraw_;
|
||||
// holds the tick count for when the next drawing event is scheduled
|
||||
// drawing shouldn't occur before this time
|
||||
int nextDraw_;
|
||||
|
||||
void invalidate_route();
|
||||
|
||||
|
|
16
src/game.cpp
16
src/game.cpp
|
@ -170,6 +170,20 @@ game_controller::game_controller(int argc, char** argv)
|
|||
preferences::set_show_fps(true);
|
||||
} else if(val == "--nocache") {
|
||||
use_caching_ = false;
|
||||
} else if(val == "--max-fps") {
|
||||
if(arg_+1 != argc_) {
|
||||
++arg_;
|
||||
int fps = lexical_cast_default<int>(argv_[arg_], 50);
|
||||
fps = minimum<int>(fps, 1000);
|
||||
fps = maximum<int>(fps, 1);
|
||||
fps = 1000 / fps;
|
||||
// increase the delay to avoid going above the maximum
|
||||
if(1000 % fps != 0) {
|
||||
++fps;
|
||||
}
|
||||
preferences::set_draw_delay(fps);
|
||||
std::cerr << preferences::draw_delay() << "\n";
|
||||
}
|
||||
} else if(val == "--validcache") {
|
||||
force_valid_cache_ = true;
|
||||
} else if(val == "--resolution" || val == "-r") {
|
||||
|
@ -1638,6 +1652,8 @@ int play_game(int argc, char** argv)
|
|||
<< " --nocache disables caching of game data.\n"
|
||||
<< " --validcache assume that cache is valid (dangerous)\n"
|
||||
<< " --nosound runs the game without sounds and music.\n"
|
||||
<< " --max-fps the maximum fps the game tries to run at the value\n"
|
||||
<< " should be between the 1 and 1000, the default is 50.\n"
|
||||
<< " --path prints the name of the game data directory and exits.\n"
|
||||
<< " -r, --resolution XxY sets the screen resolution. Example: -r 800x600\n"
|
||||
<< " -t, --test runs the game in a small test scenario.\n"
|
||||
|
|
|
@ -48,6 +48,8 @@ bool unit_genders = true;
|
|||
|
||||
bool fps = false;
|
||||
|
||||
int draw_delay_ = 20;
|
||||
|
||||
bool lobby_minimaps = true;
|
||||
|
||||
std::set<std::string> encountered_units_set;
|
||||
|
@ -958,6 +960,16 @@ void set_show_fps(bool value)
|
|||
fps = value;
|
||||
}
|
||||
|
||||
int draw_delay()
|
||||
{
|
||||
return draw_delay_;
|
||||
}
|
||||
|
||||
void set_draw_delay(int value)
|
||||
{
|
||||
draw_delay_ = value;
|
||||
}
|
||||
|
||||
bool upload_log()
|
||||
{
|
||||
return prefs["upload_log"] == "yes";
|
||||
|
|
|
@ -205,6 +205,9 @@ namespace preferences {
|
|||
bool show_haloes();
|
||||
void set_show_haloes(bool value);
|
||||
|
||||
int draw_delay();
|
||||
void set_draw_delay(int value);
|
||||
|
||||
bool show_fps();
|
||||
void set_show_fps(bool value);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue