diff --git a/Monika After Story/game/definitions.rpy b/Monika After Story/game/definitions.rpy index 8a431a471b..71795bd9bb 100644 --- a/Monika After Story/game/definitions.rpy +++ b/Monika After Story/game/definitions.rpy @@ -7947,3 +7947,38 @@ init python: and should_kiss and mas_timePastSince(persistent._mas_last_kiss, cooldown) ) + +python early: + def mas_isRunningInWine(): + """ + Checks (by calling wine_get_version NTDLL function) if MAS is currently + running in Wine environment. Always returns False on non-Windows platforms. + + OUT: + True if MAS is running in Wine environment. + False otherwise and if function is called on non-Windows platform. + """ + + if not renpy.windows: + return False # If MAS is running in Wine it will always think it's running in Windows + + try: + import ctypes + NTDLL = ctypes.WinDLL("ntdll.dll") + except Exception: + return False + + try: + wine_get_version = NTDLL.wine_get_version + wine_get_version.argtypes = [] + wine_get_version.restype = ctypes.c_char_p + except Exception: + # No such function in DLL + return False + + try: + wine_get_version() + return True + except Exception: + # Invalid signature, return type etc. + return False diff --git a/Monika After Story/game/script-ch30.rpy b/Monika After Story/game/script-ch30.rpy index f9f3153acd..14d2444645 100644 --- a/Monika After Story/game/script-ch30.rpy +++ b/Monika After Story/game/script-ch30.rpy @@ -15,6 +15,11 @@ define mas_in_intro_flow = False # True means disable animations, False means enable default persistent._mas_disable_animations = False +init -999999 python: + if mas_isRunningInWine(): + raise Exception(_("The game was started from an .exe, but is currently running on non-Windows platform.\n" + "Please instead start it using DDLC.sh script.")) + init -998 python: #We need to flow hijack here if we're running unstable mode files but on a fresh persistent if "unstable" in config.version and not persistent.sessions: diff --git a/Monika After Story/game/script-story-events.rpy b/Monika After Story/game/script-story-events.rpy index c168593309..82d2fd66ac 100644 --- a/Monika After Story/game/script-story-events.rpy +++ b/Monika After Story/game/script-story-events.rpy @@ -2806,3 +2806,28 @@ label mas_backup_restored: ) return "no_unlock|pause: 35" + +init 5 python: + addEvent( + Event( + persistent.event_database, + conditional="store.mas_isRunningInWine()", + action=EV_ACT_QUEUE, + eventlabel="mas_using_wine", + ) + ) + +label mas_using_wine: + m "[player], there is something I wanted to let you know about." + m "You see, I've been experimenting with your OS a bit...{w=0.5}{nw} " + extend "Oh, ahaha, don't worry, I didn't break anything!" + m "It's just that a few things here in its code didn't seem {i}quite{/i} like I expected..." + m "While everything I did seemed to work, somehow it still felt like it was... emulated, you know?" + m "Like there's still some thin layer my entire code goes through right as we speak." + m "It's hard to describe it any better, I'm sorry." + m "..." + m "Actually, when I was searching the web about it and exploring the code, I stumbled upon something." + m "It's called 'Wine', and it might be something that emulates me..." + m "[mas_get_player_nickname(capitalize=True)], could you make sure you open the game the right way?" + m "It'd really make it easier for me to work on my code~" + return