Skip to content

Commit

Permalink
Refactor engine flags
Browse files Browse the repository at this point in the history
* Make inline and add more accessors
* Fix comments
* Remove FIXME about number of pictures in 2k3 legacy (confirmed)
* Change IsRPG2k3Legacy() to mean < 1.0.5
  • Loading branch information
mateofio committed Dec 4, 2019
1 parent 2454376 commit d817cde
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 55 deletions.
12 changes: 6 additions & 6 deletions src/filefinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,18 +601,18 @@ void FileFinder::InitRtpPaths(bool no_rtp, bool no_rtp_warnings) {
read_rtp_registry("ASCII", product, "RuntimePackagePath");
read_rtp_registry("KADOKAWA", product, "RuntimePackagePath");
}
else if (Player::IsRPG2k3Legacy()) {
else if (Player::IsRPG2k3E()) {
// Prefer Kadokawa RTP over Enterbrain for new RPG2k3
read_rtp_registry("KADOKAWA", product, "RuntimePackagePath");
read_rtp_registry("Enterbrain", product, "RUNTIMEPACKAGEPATH");
}
else if (Player::IsRPG2k3()) {
// Original 2003 RTP installer registry key is upper case
// and Wine registry is case insensitive but new 2k3v1.10 installer is not
// Prefer Enterbrain RTP over Kadokawa for old RPG2k3 (search order)
read_rtp_registry("Enterbrain", product, "RUNTIMEPACKAGEPATH");
read_rtp_registry("KADOKAWA", product, "RuntimePackagePath");
}
else if (Player::IsRPG2k3E()) {
// Prefer Kadokawa RTP over Enterbrain for new RPG2k3
read_rtp_registry("KADOKAWA", product, "RuntimePackagePath");
read_rtp_registry("Enterbrain", product, "RUNTIMEPACKAGEPATH");
}

// Our RTP is for all engines
read_rtp_registry("EasyRPG", "RTP", "path");
Expand Down
1 change: 0 additions & 1 deletion src/game_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ static int GetDefaultNumberOfPictures() {
return 50;
}
if (Player::IsRPG2k3()) {
// FIXME: Needs confirmation with 2k3 RPG_RT <= 1.0.4
return 40;
}
return 20;
Expand Down
30 changes: 1 addition & 29 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ void Player::CreateGameObjects() {
}
}
}
Output::Debug("Engine configured as: 2k=%d 2k3=%d 2k3Legacy=%d MajorUpdated=%d Eng=%d", Player::IsRPG2k(), Player::IsRPG2k3(), Player::IsRPG2k3Legacy(), Player::IsMajorUpdatedVersion(), Player::IsEnglish());
Output::Debug("Engine configured as: 2k=%d 2k3=%d MajorUpdated=%d Eng=%d", Player::IsRPG2k(), Player::IsRPG2k3(), Player::IsMajorUpdatedVersion(), Player::IsEnglish());

FileFinder::InitRtpPaths(no_rtp_flag, no_rtp_warning_flag);

Expand Down Expand Up @@ -1135,34 +1135,6 @@ startup directory does not contain a valid game (and the game browser loads)
Alex, EV0001 and the EasyRPG authors wish you a lot of fun!)" << std::endl;
}

bool Player::IsRPG2k() {
return (engine & EngineRpg2k) == EngineRpg2k;
}

bool Player::IsRPG2k3Legacy() {
return (engine == EngineRpg2k3 || engine == (EngineRpg2k3 | EngineMajorUpdated));
}

bool Player::IsRPG2k3() {
return (engine & EngineRpg2k3) == EngineRpg2k3;
}

bool Player::IsMajorUpdatedVersion() {
return (engine & EngineMajorUpdated) == EngineMajorUpdated;
}

bool Player::IsRPG2k3E() {
return (IsRPG2k3() && IsEnglish());
}

bool Player::IsRPG2kE() {
return (IsRPG2k() && IsEnglish());
}

bool Player::IsEnglish() {
return (engine & EngineEnglish) == EngineEnglish;
}

bool Player::IsCP932() {
return (encoding == "ibm-943_P15A-2003" || encoding == "932");
}
Expand Down
84 changes: 65 additions & 19 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,37 +148,39 @@ namespace Player {
*/
std::string GetEncoding();

/**
* @return Whether engine is RPG2k
*/
/** @return If engine is any version of RPG2k */
bool IsRPG2k();

/**
* @return If engine is RPG2k3 v1.09a or older
*/
bool IsRPG2k3Legacy();

/**
* @return If engine is RPG2k3
*/
/** @return If engine is any version of RPG2k3 */
bool IsRPG2k3();

/**
* @return If engine is RPG2k v1.50 or newer, or RPG2k3 v1.05 or newer
*/
bool IsMajorUpdatedVersion();
/** @return If engine is RPG2k <= 1.10 */
bool IsRPG2kLegacy();

/**
* @return If engine is the official English RM2k3 release (v1.10) or newer.
*/
bool IsRPG2k3E();
/** @return If engine is RPG2k3 <= v1.04 */
bool IsRPG2k3Legacy();

/** @return If engine is RPG2k >= 1.50 and RPG2k <= 1.52 */
bool IsRPG2kUpdated();

/** @return If engine is RPG2k3 >= 1.05 and RPG2k3 <= 1.09a */
bool IsRPG2k3Updated();

/**
* @return If engine is the official English RM2k release v.1.61 or newer.
* False if engine is RM2k3, Japanese, unofficial or v.1.60.
*/
bool IsRPG2kE();

/** @return If engine is the official English RM2k3 release (v1.10) or newer. */
bool IsRPG2k3E();

/** @return If engine is RPG2kLegacy() or RPG2k3Legacy() */
bool IsLegacy();

/** @return If engine is RPG2kUpdated() or RPG2k3Updated() */
bool IsMajorUpdatedVersion();

/**
* @return If engine is the official English release (and not RM2k v.1.60,
* which is hard to detect).
Expand Down Expand Up @@ -328,4 +330,48 @@ namespace Player {
#endif
}

inline bool Player::IsRPG2k() {
return (engine & EngineRpg2k) == EngineRpg2k;
}

inline bool Player::IsRPG2k3() {
return (engine & EngineRpg2k3) == EngineRpg2k3;
}

inline bool Player::IsRPG2kLegacy() {
return engine == EngineRpg2k;
}

inline bool Player::IsRPG2k3Legacy() {
return engine == EngineRpg2k3;
}

inline bool Player::IsLegacy() {
return IsRPG2kLegacy() || IsRPG2k3Legacy();
}

inline bool Player::IsMajorUpdatedVersion() {
return (engine & EngineMajorUpdated) == EngineMajorUpdated;
}

inline bool Player::IsEnglish() {
return (engine & EngineEnglish) == EngineEnglish;
}

inline bool Player::IsRPG2kUpdated() {
return (IsRPG2k() && IsMajorUpdatedVersion());
}

inline bool Player::IsRPG2k3Updated() {
return (IsRPG2k3() && IsMajorUpdatedVersion());
}

inline bool Player::IsRPG2kE() {
return (IsRPG2k() && IsEnglish());
}

inline bool Player::IsRPG2k3E() {
return (IsRPG2k3() && IsEnglish());
}

#endif

0 comments on commit d817cde

Please sign in to comment.