Skip to content

Commit

Permalink
Add EasyRPG Patch Flag and lock some extensions behind it.
Browse files Browse the repository at this point in the history
Is mostly for features that can break games by accident.

Currently behind it is:

- Our custom event commands
- Large charset
- 32 bit image support. Reporting 32 bit images is useful because this prevents that games tested with EasyRPG do not run in RPG_RT by accident.
  • Loading branch information
Ghabry committed Apr 15, 2024
1 parent 0f6f8fb commit 14ad93e
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 6 deletions.
3 changes: 3 additions & 0 deletions resources/unix/easyrpg-player.6.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ NOTE: For games that only use ASCII (English games) use '1252'.
Enable limited support for the DynRPG patch from Cherry. The patches are not
loaded from DLL files, but re-implemented by the engine.

*--patch-easyrpg*::
Enable EasyRPG extensions such as support for 32 bit images and large charsets.

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

Expand Down
5 changes: 5 additions & 0 deletions src/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ namespace {
bmp = Bitmap::Create(std::move(is), transparent, flags);
if (!bmp) {
Output::Warning("Invalid image: {}/{}", s.directory, filename);
} else {
if (bmp->GetOriginalBpp() > 8 && !Player::HasEasyRpgExtensions()) {
Output::Warning("Image {}/{} has a bit depth of {} that is not supported by RPG_RT. Enable EasyRPG Extensions or Maniac Patch to load such images.", s.directory, filename, bmp->GetOriginalBpp());
bmp.reset();
}
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/game_config_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ void Game_ConfigGame::LoadFromArgs(CmdlineParser& cp) {
patch_override = true;
continue;
}
if (cp.ParseNext(arg, 0, {"--patch-easyrpg", "--no-patch-easyrpg"})) {
patch_easyrpg.Set(arg.ArgIsOn());
patch_override = true;
continue;
}
if (cp.ParseNext(arg, 0, {"--patch-dynrpg", "--no-patch-dynrpg"})) {
patch_dynrpg.Set(arg.ArgIsOn());
patch_override = true;
Expand Down Expand Up @@ -170,6 +175,10 @@ void Game_ConfigGame::LoadFromStream(Filesystem_Stream::InputStream& is) {
engine_str.FromIni(ini);
fake_resolution.FromIni(ini);

if (patch_easyrpg.FromIni(ini)) {
patch_override = true;
}

if (patch_dynrpg.FromIni(ini)) {
patch_override = true;
}
Expand Down
1 change: 1 addition & 0 deletions src/game_config_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct Game_ConfigGame {
BoolConfigParam new_game{ "Start new game", "Skips the title screen and starts a new game directly", "Game", "NewGame", false };
StringConfigParam engine_str{ "Engine", "", "Game", "Engine", std::string() };
BoolConfigParam fake_resolution{ "Fake Metrics", "Makes games run on higher resolutions (with some success)", "Game", "FakeResolution", false };
BoolConfigParam patch_easyrpg{ "EasyRPG", "EasyRPG Engine Extensions", "Patch", "EasyRPG", false };
BoolConfigParam patch_dynrpg{ "DynRPG", "", "Patch", "DynRPG", false };
BoolConfigParam patch_maniac{ "Maniac Patch", "", "Patch", "Maniac", false };
BoolConfigParam patch_common_this_event{ "Common This Event", "Support \"This Event\" in Common Events", "Patch", "CommonThisEvent", false };
Expand Down
4 changes: 4 additions & 0 deletions src/game_interpreter_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,10 @@ bool Game_Interpreter_Map::CommandToggleAtbMode(lcf::rpg::EventCommand const& /*
}

bool Game_Interpreter_Map::CommandEasyRpgTriggerEventAt(lcf::rpg::EventCommand const& com) {
if (!Player::HasEasyRpgExtensions()) {
return true;
}

int x = ValueOrVariable(com.parameters[0], com.parameters[1]);
int y = ValueOrVariable(com.parameters[2], com.parameters[3]);

Expand Down
2 changes: 1 addition & 1 deletion src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,7 @@ Engine options:
--patch-common-this Enable usage of "This Event" in common events in any
version of the engine.
--patch-dynrpg Enable support of DynRPG patch by Cherry (very limited).
--patch-easyrpg Enable EasyRPG extensions.
--patch-key-patch Enable Key Patch by Ineluki.
--patch-maniac Enable Maniac Patch by BingShan.
--patch-pic-unlock Picture movement is not interrupted by messages in any
Expand Down Expand Up @@ -1549,4 +1550,3 @@ std::string Player::GetEngineVersion() {
if (EngineVersion() > 0) return std::to_string(EngineVersion());
return std::string();
}

9 changes: 9 additions & 0 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ namespace Player {
*/
bool IsPatchKeyPatch();

/**
* @return True when EasyRpg extensions are on
*/
bool HasEasyRpgExtensions();

/**
* @return Running engine version. 2000 for RPG2k and 2003 for RPG2k3
*/
Expand Down Expand Up @@ -480,4 +485,8 @@ inline bool Player::IsPatchKeyPatch() {
return game_config.patch_key_patch.Get();
}

inline bool Player::HasEasyRpgExtensions() {
return game_config.patch_easyrpg.Get();
}

#endif
15 changes: 10 additions & 5 deletions src/sprite_character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "cache.h"
#include "game_map.h"
#include "bitmap.h"
#include "output.h"

Sprite_Character::Sprite_Character(Game_Character* character, CloneType type) :
character(character),
Expand Down Expand Up @@ -124,16 +125,20 @@ void Sprite_Character::ChipsetUpdated() {

Rect Sprite_Character::GetCharacterRect(StringView name, int index, const Rect bitmap_rect) {
Rect rect;
rect.width = 24 * (TILE_SIZE / 16) * 3;
rect.height = 32 * (TILE_SIZE / 16) * 4;

// Allow large 4x2 spriteset of 3x4 sprites
// when the character name starts with a $ sign.
// This is not exactly the VX Ace way because
// VX Ace uses a single 1x1 spriteset of 3x4 sprites.
if (!name.empty() && name.front() == '$') {
rect.width = bitmap_rect.width * (TILE_SIZE / 16) / 4;
rect.height = bitmap_rect.height * (TILE_SIZE / 16) / 2;
} else {
rect.width = 24 * (TILE_SIZE / 16) * 3;;
rect.height = 32 * (TILE_SIZE / 16) * 4;
if (!Player::HasEasyRpgExtensions()) {
Output::Debug("Ignoring large charset {}. EasyRPG Extension not enabled.");
} else {
rect.width = bitmap_rect.width * (TILE_SIZE / 16) / 4;
rect.height = bitmap_rect.height * (TILE_SIZE / 16) / 2;
}
}
rect.x = (index % 4) * rect.width;
rect.y = (index / 4) * rect.height;
Expand Down

0 comments on commit 14ad93e

Please sign in to comment.