Skip to content

Commit

Permalink
Enhanced Unity version detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Kimjio committed Jun 19, 2023
1 parent ff75f94 commit 665bc27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
5 changes: 2 additions & 3 deletions module/src/main/cpp/game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

#include <string>

#define Unity2019 "2019.4.21f1"
#define Unity2019Twn "2019.4.19f1"
#define Unity2020 "2020.3.24f1"
#define Unity2019 "2019.4."s
#define Unity2020 "2020.3."s

using namespace std;

Expand Down
16 changes: 8 additions & 8 deletions module/src/main/cpp/il2cpp_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2160,16 +2160,16 @@ void CanvasScaler_set_referenceResolution_hook(Il2CppObject *thisObj, Vector2_t
void *SetResolution_orig = nullptr;

void SetResolution_hook(int w, int h, bool fullscreen, bool forceUpdate) {
if (!resolutionIsSet || GetUnityVersion() == Unity2020) {
if (!resolutionIsSet || GetUnityVersion().starts_with(Unity2020)) {
if (sceneManager ||
(GetUnityVersion() == Unity2019 || GetUnityVersion() == Unity2019Twn) && w < h) {
(GetUnityVersion().starts_with(Unity2019)) && w < h) {
resolutionIsSet = true;
}
reinterpret_cast<decltype(SetResolution_hook) * > (SetResolution_orig)(w, h, fullscreen,
forceUpdate);
if (g_force_landscape) {
if ((GetUnityVersion() == Unity2019 || GetUnityVersion() == Unity2019Twn) ||
(w < h && GetUnityVersion() == Unity2020)) {
if ((GetUnityVersion().starts_with(Unity2019)) ||
(w < h && GetUnityVersion().starts_with(Unity2020))) {
reinterpret_cast<decltype(set_resolution_hook) * > (set_resolution_orig)(h, w,
fullscreen);
}
Expand Down Expand Up @@ -3791,7 +3791,7 @@ void hookMethods() {
"_CreateOrmByQueryResultWithCharacterId", 2);

auto CriAtomExPlayer_criAtomExPlayer_Stop_addr =
GetUnityVersion() == Unity2020 ? il2cpp_symbols::get_method_pointer(
GetUnityVersion().starts_with(Unity2020) ? il2cpp_symbols::get_method_pointer(
"CriMw.CriWare.Runtime.dll", "CriWare", "CriAtomExPlayer",
"criAtomExPlayer_Stop", 1)
: il2cpp_symbols::get_method_pointer(
Expand Down Expand Up @@ -4059,7 +4059,7 @@ void hookMethods() {
"FixedUpdate", 0);

auto CriMana_Player_SetFile_addr =
GetUnityVersion() == Unity2020 ? il2cpp_symbols::get_method_pointer(
GetUnityVersion().starts_with(Unity2020) ? il2cpp_symbols::get_method_pointer(
"CriMw.CriWare.Runtime.dll", "CriWare.CriMana", "Player", "SetFile", 3)
: il2cpp_symbols::get_method_pointer(
"Cute.Cri.Assembly.dll", "CriMana", "Player", "SetFile", 3);
Expand Down Expand Up @@ -4259,7 +4259,7 @@ void hookMethods() {

ADD_HOOK(GameSystem_FixedUpdate)

/*if (GetUnityVersion() == Unity2020) {
/*if (GetUnityVersion().starts_with(Unity2020)) {
ADD_HOOK(DialogCommon_Close)
}*/

Expand All @@ -4277,7 +4277,7 @@ void hookMethods() {

ADD_HOOK(SafetyNet_OnError)

if (GetUnityVersion() == Unity2020) {
if (GetUnityVersion().starts_with(Unity2020)) {
ADD_HOOK(NowLoading_Show2)
if (g_hide_now_loading) {
ADD_HOOK(NowLoading_Hide2)
Expand Down

0 comments on commit 665bc27

Please sign in to comment.