Index: src/globals.cpp =================================================================== --- src/globals.cpp (revision 3509) +++ src/globals.cpp (working copy) @@ -45,8 +45,7 @@ bool show_input_debug_screen = false; bool render_preview = false; -int min_frame_skip = 1; -int max_frame_skip = 5; +int frame_skip = 0; std::string controller_file; Index: src/globals.hpp =================================================================== --- src/globals.hpp (revision 3509) +++ src/globals.hpp (working copy) @@ -66,8 +66,8 @@ extern std::string default_language; ///< The default language, which is used when the env var LANG is not set extern unsigned int pingus_debug_flags; ///< Set some bits in this thing to get debug infos -extern int min_frame_skip; -extern int max_frame_skip; +extern int frame_skip; ///< if non-zero then the game loop skips rendering every + ///< frame_skip iteration enum { PINGUS_DEBUG_ACTIONS = (1 << 0), PINGUS_DEBUG_SOUND = (1 << 1), Index: src/screen/screen_manager.cpp =================================================================== --- src/screen/screen_manager.cpp (revision 3509) +++ src/screen/screen_manager.cpp (working copy) @@ -66,6 +66,8 @@ DeltaManager delta_manager; DeltaManager frame_timer; + int frame_num = 0; // invariant: this frame number mod frame_skip (one-based) + // Main loop for the menu // and incidentally this is also the main loop for the whole game while (!screens.empty()) @@ -75,14 +77,21 @@ // start the frame timer frame_timer.set(); + // update the invariant + if (frame_skip > 0) { + frame_num %= frame_skip; + frame_num++; + } + // previous frame took more than one second - if (time_delta > 1.0) - { + /** if (time_delta > 1.0) + { if (maintainer_mode) std::cout << "ScreenManager: detected large delta (" << time_delta << "), ignoring and doing frameskip" << std::endl; continue; // skip this frame } + **/ // update the input input_manager.update(time_delta); @@ -94,6 +103,7 @@ last_screen = get_current_screen(); // Most likely the screen will get changed in this update call + // after this call the world will be updated to catch up with the current time get_current_screen()->update (delta); if (cursor) @@ -132,13 +142,15 @@ // skip draw if the screen changed to avoid glitches if (last_screen == get_current_screen() || fast_mode) { - if (get_current_screen()->draw(*display_gc)) + if (get_current_screen()->draw(*display_gc) && (frame_num != frame_skip || !(frame_skip > 0))) { + // only render the frame if we are not skipping any frames or if this is not the frame to skip display_gc->render(Display::get_screen(), Rect(Vector2i(0,0), Size(Display::get_width(), Display::get_height()))); Display::flip_display(); display_gc->clear(); - } + } //else + // frame_num == frame_skip && frame_skip > 0 } else { Index: src/pingus_options.hpp =================================================================== --- src/pingus_options.hpp (revision 3509) +++ src/pingus_options.hpp (working copy) @@ -89,8 +89,7 @@ Value maintainer_mode; Value debug; - Value min_frame_skip; - Value max_frame_skip; + Value frame_skip; Value speed; Value desiredfps; Value tile_size; Index: src/pingus_main.cpp =================================================================== --- src/pingus_main.cpp (revision 3509) +++ src/pingus_main.cpp (working copy) @@ -233,11 +233,8 @@ if (options.debug.is_set()) pingus_debug_flags = options.debug.get(); - if (options.min_frame_skip.is_set()) - min_frame_skip = options.min_frame_skip.get(); - - if (options.max_frame_skip.is_set()) - max_frame_skip = options.max_frame_skip.get(); + if (options.frame_skip.is_set()) + frame_skip = options.frame_skip.get(); if (options.speed.is_set()) game_speed = options.speed.get(); @@ -322,12 +319,8 @@ _("Enable the output of debugging info, possible " "OPTIONs are tiles, gametime, actions, sound, resources, gui, " "input, pathmgr")); - argp.add_option(354, "min-frame-skip", "N", - _("Skip at least N frames, larger values speed the game up")); - argp.add_option(355, "max-frame-skip", "N", - _("Skip at most N frames")); - argp.add_option(357, "frame-skip", "N", - _("Set both min and max frameskip to N")); + argp.add_option(356, "frame-skip", "N", + _("Skip rendering every Nth frame")); argp.add_option('t', "speed", "SPEED", _("Set the game speed (0=fastest, >0=slower)")); argp.add_option('k', "fps", "FPS", @@ -520,17 +513,8 @@ pingus_debug_flags = cmd_options.debug.get(); break; - case 354: - cmd_options.min_frame_skip.set(StringUtil::to(argp.get_argument())); - break; - - case 355: // max_frame_skip - cmd_options.max_frame_skip.set(StringUtil::to(argp.get_argument())); - break; - - case 357: // frame_skip - cmd_options.max_frame_skip.set(StringUtil::to(argp.get_argument())); - cmd_options.min_frame_skip.set(StringUtil::to(argp.get_argument())); + case 356: // frame_skip + cmd_options.frame_skip.set(StringUtil::to(argp.get_argument())); break; case 360: Index: src/game_session.cpp =================================================================== --- src/game_session.cpp (revision 3512) +++ src/game_session.cpp (working copy) @@ -139,6 +139,7 @@ int update_time = game_speed; //left_over_time = 0; + /** if (0){ int i; for (i = 0; @@ -152,6 +153,7 @@ ++number_of_updates; } } + */ // update the world (and the objects in it) in constant steps to account // for the time the previous frame took