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

Implement Wine detection #10284

Draft
wants to merge 5 commits into
base: content
Choose a base branch
from
Draft
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
35 changes: 35 additions & 0 deletions Monika After Story/game/definitions.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions Monika After Story/game/script-ch30.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
25 changes: 25 additions & 0 deletions Monika After Story/game/script-story-events.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -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