Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AntiLag measures #3194

Merged
merged 4 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 38 additions & 19 deletions resources/unix/easyrpg-player.6.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,36 @@ NOTE: For games that only use ASCII (English games) use '1252'.
Disable support for the Runtime Package (RTP). Will lead to checkerboard
graphics and silent music/sound effects in games depending on the RTP.

*--patch* _PATCH_A_ [_PATCH_B_ _..._]::
Instead of autodetecting patches used by this game, force emulation of certain
patches.
- 'common-this' - Support for __This Event__ in common events
- 'dynrpg' - DynRPG patch by Cherry
- 'key-patch' - Key Patch by Ineluki
- 'maniac' - Maniac Patch by BingShan
- 'pic-unlock' - Pictures are not blocked by messages
- 'rpg2k3-cmds' - Support RPG Maker 2003 event commands in all engines
*--patch-anti-lag-switch*:: _SWITCH_
Disables event page refreshing when the switch 'SWITCH' is set to 'ON'.

*--patch-common-this*::
Enable usage of __This Event__ in common events in any version of the engine.
By default, this behaviour is only enabled for RPG Maker 2003 v1.12.

*--patch-dynrpg*::
Enable limited support for the DynRPG patch from Cherry. The patches are not
loaded from DLL files, but re-implemented by the engine.

*--patch-key-patch*::
Enable support for the Key Patch by Ineluki.

*--patch-maniac*::
Enable support for the Maniac Patch by BingShan.

*--patch-pic-unlock*::
Picture movement is not interrupted by messages in any version of the engine.
By default, this behaviour is only enabled for RPG Maker 2003 v1.12.

*--patch-rpg2k3-cmds*::
Support all RPG Maker 2003 event commands in any version of the engine.

*--no-patch*::
Disable all engine patches.

NOTE: Providing any patch option disables the patch autodetection of the engine.
To disable a single patch, prefix any of the patch options with **--no-**.

*--project-path* _PATH_::
Instead of using the working directory, the game in 'PATH' is used.

Expand All @@ -111,8 +128,7 @@ NOTE: For games that only use ASCII (English games) use '1252'.
Instead of storing save files in the game directory they are stored in
'PATH'. The directory must exist.

NOTE: When using the game browser all games will share the same save
directory!
NOTE: When using the game browser all games will share the same save directory!

*--seed* _SEED_::
Seeds the random number generator.
Expand Down Expand Up @@ -282,25 +298,28 @@ Options in section 'Game':
*Engine*=_ENGINE_::
Same as *--engine*.

Options in section 'Patch' (see also *--patch*):
Options in section 'Patch' (see also options starting with *--patch*):

*AntiLagSwitch*=_SWITCH_::
Same as *--patch-anti-lag-switch* 'SWITCH'.

*CommonThisEvent*=_1_::
Same as *--patch common-this*.
Same as *--patch-common-this*.

*DynRPG*=_1_::
Same as *--patch dynrpg*.
Same as *--patch-dynrpg*.

*KeyPatch*=_1_::
Same as *--patch key-patch*.
Same as *--patch-key-patch*.

*Maniac*=_1_::
Same as *--patch maniac*.
Same as *--patch-maniac*.

*PicUnlock*=_1_::
Same as *--patch pic-unlock*.
Same as *--patch-pic-unlock*.

*RPG2k3Commands*=_1_::
Same as *--patch rpg2k3-commands*.
Same as *--patch-rpg2k3-commands*.

NOTE: Providing any patch option disables the patch autodetection of the engine.

Expand Down Expand Up @@ -344,7 +363,7 @@ Options in section 'RPG_RT':

Set a custom screen height.

NOTE: These resolution options invented by the Maniac Patch but they are
NOTE: These resolution options were invented by the Maniac Patch but they are
processed even when the patch is disabled. Using a custom resolution disables
*--game-resolution*.

Expand Down
20 changes: 19 additions & 1 deletion src/cmdline_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ class CmdlineArg {
return ptr[i + 1];
}

/**
* Use this with boolean arguments of structure --option and --no-option
* to decide if the --no- prefix was used or not.
*
* @return Whether the command line argument does not start with --no-
*/
bool ArgIsOn() const {
return !ArgIsOff();
}

/**
* @see ArgIsOn
* @return Whether the command line argument starts with --no-
*/
bool ArgIsOff() const {
return Arg().substr(0, 5) == "--no-";
}

/**
* Gets an argument value to an integer
*
Expand All @@ -89,7 +107,7 @@ class CmdlineArg {
/** Commandline parser class which is used to search through command line arguments. */
class CmdlineParser {
public:
/**
/**
* Construct with given arguments
*
* @param arguments main() argv as vector of strings
Expand Down
32 changes: 8 additions & 24 deletions src/game_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,8 @@ void Game_Config::LoadFromArgs(CmdlineParser& cp) {
long li_value = 0;
std::string str_value;

if (cp.ParseNext(arg, 0, "--vsync")) {
video.vsync.Set(true);
continue;
}
if (cp.ParseNext(arg, 0, "--no-vsync")) {
video.vsync.Set(false);
if (cp.ParseNext(arg, 0, {"--vsync", "--no-vsync"})) {
video.vsync.Set(arg.ArgIsOn());
continue;
}
if (cp.ParseNext(arg, 1, "--fps-limit")) {
Expand All @@ -261,20 +257,12 @@ void Game_Config::LoadFromArgs(CmdlineParser& cp) {
video.fps_limit.Set(0);
continue;
}
if (cp.ParseNext(arg, 0, "--show-fps")) {
video.show_fps.Set(true);
continue;
}
if (cp.ParseNext(arg, 0, "--no-show-fps")) {
video.show_fps.Set(false);
if (cp.ParseNext(arg, 0, {"--show-fps", "--no-show-fps"})) {
video.show_fps.Set(arg.ArgIsOn());
continue;
}
if (cp.ParseNext(arg, 0, "--fps-render-window")) {
video.fps_render_window.Set(true);
continue;
}
if (cp.ParseNext(arg, 0, "--no-fps-render-window")) {
video.fps_render_window.Set(false);
if (cp.ParseNext(arg, 0, {"--fps-render-window", "--no-fps-render-window"})) {
video.fps_render_window.Set(arg.ArgIsOn());
continue;
}
if (cp.ParseNext(arg, 0, "--window")) {
Expand All @@ -291,12 +279,8 @@ void Game_Config::LoadFromArgs(CmdlineParser& cp) {
}
continue;
}
if (cp.ParseNext(arg, 0, "--stretch")) {
video.stretch.Set(true);
continue;
}
if (cp.ParseNext(arg, 0, "--no-stretch")) {
video.stretch.Set(false);
if (cp.ParseNext(arg, 0, {"--stretch", "--no-stretch"})) {
video.stretch.Set(arg.ArgIsOn());
continue;
}
if (cp.ParseNext(arg, 1, "--scaling")) {
Expand Down
58 changes: 52 additions & 6 deletions src/game_config_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ void Game_ConfigGame::LoadFromArgs(CmdlineParser& cp) {

while (!cp.Done()) {
CmdlineArg arg;
if (cp.ParseNext(arg, 0, "--new-game")) {
new_game.Set(true);
continue;
}
if (cp.ParseNext(arg, 0, "--no-new-game")) {
new_game.Set(false);
long li_value = 0;

if (cp.ParseNext(arg, 0, {"--new-game", "--no-new-game"})) {
new_game.Set(arg.ArgIsOn());
continue;
}
if (cp.ParseNext(arg, 1, "--engine")) {
Expand All @@ -87,10 +85,54 @@ void Game_ConfigGame::LoadFromArgs(CmdlineParser& cp) {
patch_common_this_event.Lock(false);
patch_key_patch.Lock(false);
patch_rpg2k3_commands.Lock(false);
patch_anti_lag_switch.Lock(false);
patch_override = true;
continue;
}
if (cp.ParseNext(arg, 0, {"--patch-dynrpg", "--no-patch-dynrpg"})) {
patch_dynrpg.Set(arg.ArgIsOn());
patch_override = true;
continue;
}
if (cp.ParseNext(arg, 0, {"--patch-maniac", "--no-patch-maniac"})) {
patch_maniac.Set(arg.ArgIsOn());
patch_override = true;
continue;
}
if (cp.ParseNext(arg, 0, {"--patch-common-this", "--no-patch-common-this"})) {
patch_common_this_event.Set(arg.ArgIsOn());
patch_override = true;
continue;
}
if (cp.ParseNext(arg, 0, {"--patch-pic-unlock", "--no-patch-pic-unlock"})) {
patch_unlock_pics.Set(arg.ArgIsOn());
patch_override = true;
continue;
}
if (cp.ParseNext(arg, 0, {"--patch-key-patch", "--no-patch-key-patch"})) {
patch_key_patch.Set(arg.ArgIsOn());
patch_override = true;
continue;
}
if (cp.ParseNext(arg, 0, {"--patch-rpg2k3-cmds", "--patch-rpg2k3-commands", "--no-patch-rpg2k3-cmds", "--no-patch-rpg2k3-commands"})) {
patch_rpg2k3_commands.Set(arg.ArgIsOn());
patch_override = true;
continue;
}
if (cp.ParseNext(arg, 1, "--patch-antilag-switch")) {
if (arg.ParseValue(0, li_value)) {
patch_anti_lag_switch.Set(li_value);
patch_override = true;
}
continue;
}
if (cp.ParseNext(arg, 0, "--no-patch-antilag-switch")) {
patch_anti_lag_switch.Set(0);
patch_override = true;
continue;
}
if (cp.ParseNext(arg, 6, "--patch")) {
// For backwards compatibility only
for (int i = 0; i < arg.NumValues(); ++i) {
const auto& v = arg.Value(i);
if (v == "dynrpg") {
Expand Down Expand Up @@ -151,4 +193,8 @@ void Game_ConfigGame::LoadFromStream(Filesystem_Stream::InputStream& is) {
if (patch_rpg2k3_commands.FromIni(ini)) {
patch_override = true;
}

if (patch_anti_lag_switch.FromIni(ini)) {
patch_override = true;
}
}
1 change: 1 addition & 0 deletions src/game_config_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct Game_ConfigGame {
BoolConfigParam patch_unlock_pics{ "Unlock Pictures", "Allow picture commands while a message is shown", "Patch", "PicUnlock", false };
BoolConfigParam patch_key_patch{ "Ineluki Key Patch", "Support \"Ineluki Key Patch\"", "Patch", "KeyPatch", false };
BoolConfigParam patch_rpg2k3_commands{ "RPG2k3 Event Commands", "Enable support for RPG2k3 event commands", "Patch", "RPG2k3Commands", false };
ConfigParam<int> patch_anti_lag_switch{ "Anti-Lag Switch", "Disable event page refreshes when switch is set", "Patch", "AntiLagSwitch", 0 };

// Command line only
BoolConfigParam patch_support{ "Support patches", "When OFF all patch support is disabled", "", "", true };
Expand Down
Loading