Skip to content

Commit 38687ff

Browse files
InfernioSharlikran
authored andcommitted
Rework exe-based game detection logic
Prerequisite for Enderal, otherwise launching with '-o' will break. The core root of the problem is that: 1. GameInfo.exe was used for two separate tasks (game detection and specifying which exe to use when launching the game). 2. It was not flexible enough - only top-level files could be used for game detection this way. NB: This was not a problem YET, but could certainly become one in the future. To solve this problem, the obvious solution is to explicitly split GameInfo.exe into two separate variables for the two tasks. This commit does just that, splitting it into launch_exe and game_detect_file. This also allowed making game_detect_file more flexible, by turning it into a list that will be Path.join()-ed with the path given by the -o parameter. Currently, only Skyrim and Enderal need a non-standard game_detect_file, because they both ship TESV.exe.
1 parent 50f523d commit 38687ff

13 files changed

Lines changed: 30 additions & 15 deletions

File tree

Mopy/bash/basher/app_buttons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def Execute(self):
249249
exeObse = bass.dirs['app'].join(bush.game.se.exe)
250250
exeLaa = bass.dirs['app'].join(bush.game.laa.exe)
251251
if BashStatusBar.laaButton.button_state and \
252-
self.exePath.tail == bush.game.exe:
252+
self.exePath.tail == bush.game.launch_exe:
253253
# Should use the LAA Launcher
254254
exePath = exeLaa
255255
args = [exePath.s]

Mopy/bash/basher/gui_fomod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(self, parent_window, installer, page_size, pos):
6262

6363
fomod_file = installer.fomod_file().s
6464
data_path = bass.dirs["mods"]
65-
ver = env.get_file_version(bass.dirs["app"].join(bush.game.exe).s)
65+
ver = env.get_file_version(bass.dirs["app"].join(bush.game.launch_exe).s)
6666
game_ver = u".".join([unicode(i) for i in ver])
6767

6868
self.parser = FomodInstaller(fomod_file, self.files_list, data_path, game_ver)

Mopy/bash/basher/links.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def _init_tool_buttons(): # tooldirs must have been initialized
7373
BashStatusBar.buttons.append(AutoQuit_Button(uid=u'AutoQuit'))
7474
BashStatusBar.buttons.append( # Game
7575
Game_Button(
76-
exePathArgs=bass.dirs['app'].join(bush.game.exe),
76+
exePathArgs=bass.dirs['app'].join(bush.game.launch_exe),
7777
images=imageList(u'%s%%s.png' % bush.game.fsName.lower()),
7878
tip=u' '.join((_(u"Launch"),bush.game.displayName)),
7979
obseTip=u' '.join((_(u"Launch"),bush.game.displayName,u'%(version)s')),

Mopy/bash/belt.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,8 @@ def opExp(self, l, r): return l ** r
10771077

10781078
# Functions...
10791079
def fnCompareGameVersion(self, obWant):
1080-
ret = self._TestVersion(self._TestVersion_Want(obWant), bass.dirs['app'].join(bush.game.exe))
1080+
ret = self._TestVersion(self._TestVersion_Want(obWant),
1081+
bass.dirs['app'].join(bush.game.launch_exe))
10811082
return ret[0]
10821083
def fnCompareSEVersion(self, seWant):
10831084
if bush.game.se.se_abbrev != u'':
@@ -1557,7 +1558,8 @@ def kwdRequireVersions(self, game, se=u'None', ge=u'None', wbWant=u'0.0'):
15571558
if not wbWant: wbWant = u'0.0'
15581559
wbHave = bass.AppVersion
15591560

1560-
ret = self._TestVersion(gameWant, bass.dirs['app'].join(bush.game.exe))
1561+
ret = self._TestVersion(gameWant,
1562+
bass.dirs['app'].join(bush.game.launch_exe))
15611563
bGameOk = ret[0] >= 0
15621564
gameHave = ret[1]
15631565
if bush.game.se.se_abbrev != u'':

Mopy/bash/bush.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def _detectGames(cli_path=u'', bash_ini_=None):
147147
# iterate installPaths in insert order ('cmd', 'ini', 'upMopy')
148148
for test_path, foundMsg, errorMsg in installPaths.itervalues():
149149
for name, info in _allGames.items():
150-
if test_path.join(info.exe).exists():
150+
if test_path.join(*info.game_detect_file).exists():
151151
# Must be this game
152152
deprint(foundMsg % {'gamename': name}, test_path)
153153
foundGames_[name] = test_path

Mopy/bash/env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_registry_path(subkey, entry, exe):
6969
def get_registry_game_path(submod):
7070
"""Check registry supplied game paths for the game.exe."""
7171
subkey, entry = submod.regInstallKeys
72-
return get_registry_path(subkey, entry, submod.exe)
72+
return get_registry_path(subkey, entry, submod.launch_exe)
7373

7474
try: # Python27\Lib\site-packages\win32comext\shell
7575
from win32com.shell import shell, shellcon

Mopy/bash/game/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,14 @@ class GameInfo(object):
3939
altName = u'' ## Example: u'Wrye Smash'
4040
# Name of game's default ini file.
4141
defaultIniFile = u''
42-
# Exe to look for to see if this is the right game
43-
exe = u'' ## Example: u'TESV.exe'
42+
# Path to a file to look for to see if this is the right game. Given as a
43+
# list of strings that will be joined with the -o parameter. Must be unique
44+
# among all games. As a rule of thumb, use the file you specified in
45+
# launch_exe, unless that file is shared by multiple games, in which case
46+
# you MUST find unique files - see Skyrim and Enderal, which share TESV.exe
47+
game_detect_file = []
48+
# The exe to use when launching the game (without xSE present)
49+
launch_exe = u'' ## Example: u'TESV.exe'
4450
# The main plugin Wrye Bash should look for
4551
masterFiles = []
4652
# INI files that should show up in the INI Edits tab

Mopy/bash/game/fallout3/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class Fallout3GameInfo(GameInfo):
3333
fsName = u'Fallout3'
3434
altName = u'Wrye Flash'
3535
defaultIniFile = u'Fallout_default.ini'
36-
exe = u'Fallout3.exe'
36+
game_detect_file = [u'Fallout3.exe']
37+
launch_exe = u'Fallout3.exe'
3738
masterFiles = [u'Fallout3.esm']
3839
iniFiles = [u'Fallout.ini', u'FalloutPrefs.ini']
3940
pklfile = ur'bash\db\Fallout3_ids.pkl'

Mopy/bash/game/fallout4/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class Fallout4GameInfo(GameInfo):
3333
fsName = u'Fallout4'
3434
altName = u'Wrye Flash'
3535
defaultIniFile = u'Fallout4_default.ini'
36-
exe = u'Fallout4.exe'
36+
game_detect_file = [u'Fallout4.exe']
37+
launch_exe = u'Fallout4.exe'
3738
masterFiles = [u'Fallout4.esm']
3839
iniFiles = [u'Fallout4.ini', u'Fallout4Prefs.ini', u'Fallout4Custom.ini', ]
3940
pklfile = ur'bash\db\Fallout4_ids.pkl'

Mopy/bash/game/falloutnv/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class FalloutNVGameInfo(GameInfo):
3333
fsName = u'FalloutNV'
3434
altName = u'Wrye Flash NV'
3535
defaultIniFile = u'Fallout_default.ini'
36-
exe = u'FalloutNV.exe'
36+
game_detect_file = [u'FalloutNV.exe']
37+
launch_exe = u'FalloutNV.exe'
3738
masterFiles = [u'FalloutNV.esm']
3839
iniFiles = [u'Fallout.ini', u'FalloutPrefs.ini']
3940
pklfile = ur'bash\db\FalloutNV_ids.pkl'

0 commit comments

Comments
 (0)