From 8d40ca8be68725c11dcaadbc95cb20084bd93649 Mon Sep 17 00:00:00 2001 From: Quietust Date: Sat, 1 Apr 2023 12:37:36 -0600 Subject: [PATCH 1/3] Add "faststart" plugin to make DF start faster In particular, it makes the game's "Loading..." screen animate as quickly as possible, shortening it from around 10 seconds to slightly more than 1 second. A conditional build setting makes it skip the animation as well, making it slightly faster yet. Ideally, this should become part of the Tweak plugin, but we're not building that right now. --- docs/changelog.txt | 1 + docs/plugins/faststart.rst | 18 ++++++++++ plugins/CMakeLists.txt | 1 + plugins/faststart.cpp | 69 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 docs/plugins/faststart.rst create mode 100644 plugins/faststart.cpp diff --git a/docs/changelog.txt b/docs/changelog.txt index 4be3e6a64..59c0dc2b1 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -34,6 +34,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: # Future ## New Plugins +- `faststart`: speeds up the "Loading..." screen so the Main Menu appears sooner ## Fixes - `hotkeys`: hotkey hints on menu popup will no longer get their last character cut off by the scrollbar diff --git a/docs/plugins/faststart.rst b/docs/plugins/faststart.rst new file mode 100644 index 000000000..3dc734183 --- /dev/null +++ b/docs/plugins/faststart.rst @@ -0,0 +1,18 @@ +faststart +========= + +.. dfhack-tool:: + :summary: Makes the main menu appear sooner. + :tags: interface + :no-command: + +This plugin accelerates the initial "Loading..." screen that appears when the +game first starts, so you don't have to wait as long before the Main Menu +appears and you can start playing. + +Usage +----- + +:: + + enable faststart diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index dc7fa9276..53d0296c7 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -112,6 +112,7 @@ dfhack_plugin(dig-now dig-now.cpp LINK_LIBRARIES lua) #dfhack_plugin(embark-tools embark-tools.cpp) dfhack_plugin(eventful eventful.cpp LINK_LIBRARIES lua) dfhack_plugin(fastdwarf fastdwarf.cpp) +dfhack_plugin(faststart faststart.cpp) dfhack_plugin(filltraffic filltraffic.cpp) #dfhack_plugin(fix-unit-occupancy fix-unit-occupancy.cpp) #dfhack_plugin(fixveins fixveins.cpp) diff --git a/plugins/faststart.cpp b/plugins/faststart.cpp new file mode 100644 index 000000000..d885726c0 --- /dev/null +++ b/plugins/faststart.cpp @@ -0,0 +1,69 @@ +// Fast Startup tweak + +#include "Core.h" +#include +#include +#include +#include +#include + +#include "df/viewscreen_initial_prepst.h" +#include + +using namespace DFHack; +using namespace df::enums; +using std::vector; + +// Uncomment this to make the Loading screen as fast as possible +// This has the side effect of removing the dwarf face animation +// (and briefly making the game become unresponsive) + +//#define REALLY_FAST + +DFHACK_PLUGIN("faststart"); +DFHACK_PLUGIN_IS_ENABLED(is_enabled); + +struct prep_hook : df::viewscreen_initial_prepst +{ + typedef df::viewscreen_initial_prepst interpose_base; + + DEFINE_VMETHOD_INTERPOSE(void, logic, ()) + { +#ifdef REALLY_FAST + while (breakdown_level != interface_breakdown_types::STOPSCREEN) + { + render_count++; + INTERPOSE_NEXT(logic)(); + } +#else + render_count = 4; + INTERPOSE_NEXT(logic)(); +#endif + } +}; + +IMPLEMENT_VMETHOD_INTERPOSE(prep_hook, logic); + +DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) +{ + if (enable != is_enabled) + { + if (!INTERPOSE_HOOK(prep_hook, logic).apply(enable)) + return CR_FAILURE; + + is_enabled = enable; + } + + return CR_OK; +} + +DFhackCExport command_result plugin_init ( color_ostream &out, vector &commands) +{ + return CR_OK; +} + +DFhackCExport command_result plugin_shutdown ( color_ostream &out ) +{ + INTERPOSE_HOOK(prep_hook, logic).remove(); + return CR_OK; +} From 93962df3de15db1193438b520c52ef2af00aa93d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 7 Apr 2023 01:57:11 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- plugins/faststart.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/faststart.cpp b/plugins/faststart.cpp index d885726c0..de014801c 100644 --- a/plugins/faststart.cpp +++ b/plugins/faststart.cpp @@ -18,7 +18,7 @@ using std::vector; // This has the side effect of removing the dwarf face animation // (and briefly making the game become unresponsive) -//#define REALLY_FAST +//#define REALLY_FAST DFHACK_PLUGIN("faststart"); DFHACK_PLUGIN_IS_ENABLED(is_enabled); From 75bdc8904c920a5542c0ee2d28a67339f9b44c19 Mon Sep 17 00:00:00 2001 From: Myk Date: Thu, 6 Apr 2023 18:59:57 -0700 Subject: [PATCH 3/3] add dfhack tag to faststart --- docs/plugins/faststart.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/plugins/faststart.rst b/docs/plugins/faststart.rst index 3dc734183..b39269e01 100644 --- a/docs/plugins/faststart.rst +++ b/docs/plugins/faststart.rst @@ -3,7 +3,7 @@ faststart .. dfhack-tool:: :summary: Makes the main menu appear sooner. - :tags: interface + :tags: dfhack interface :no-command: This plugin accelerates the initial "Loading..." screen that appears when the