Skip to content

Commit

Permalink
Refactor some logic in init_dirs
Browse files Browse the repository at this point in the history
Eliminates the one remaining warning in there and simplifies the logic a
bit.

The overall procedure seems to work like this:
 1. Check if Oblivion.ini exists in Oblivion's directory.
 2. If the file exists, check if bUseMyGamesDirectory exists and retrieve its value.
 3. If Oblivion.ini exists and the bUseMyGamesDirectory option is present and it's set to 0, set the saveBase and mods dirs relative to the Oblivion directory.
 4. If any of the above are false, keep the saveBase and mods dirs at their default values.

This also seems to be Oblivion-specific - STEP calls
bUseMyGamesDirectory 'unused' for Skyrim, but I'd have to ask e.g.
Nukem for further information on this.
  • Loading branch information
Infernio committed Apr 26, 2019
1 parent cb32315 commit 3a50c3b
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions Mopy/bash/initialization.py
Expand Up @@ -151,23 +151,19 @@ def init_dirs(bashIni_, personal, localAppData, game_info):
# actually matter.
# Utumno: not sure how/if this applies to other games
data_oblivion_ini = dirs['app'].join(game_info.iniFiles[0])
use_data_dir = False
game_ini_path = dirs['saveBase'].join(game_info.iniFiles[0])
dirs['mods'] = dirs['app'].join(u'Data')
if data_oblivion_ini.exists():
oblivionIni = ConfigParser()
oblivionIni.read(data_oblivion_ini.s)
# is bUseMyGamesDirectory set to 0?
use_data_dir = get_ini_option(oblivionIni,
u'bUseMyGamesDirectory') == u'0'
if use_data_dir:
game_ini_path = data_oblivion_ini
# Set the save game folder to the Oblivion directory
dirs['saveBase'] = dirs['app']
# Set the data folder to sLocalMasterPath
dirs['mods'] = dirs['app'].join(get_ini_option(oblivionIni,
u'SLocalMasterPath') or u'Data')
else:
game_ini_path = dirs['saveBase'].join(game_info.iniFiles[0])
dirs['mods'] = dirs['app'].join(u'Data')
if get_ini_option(oblivionIni, u'bUseMyGamesDirectory') == u'0':
game_ini_path = data_oblivion_ini
# Set the save game folder to the Oblivion directory
dirs['saveBase'] = dirs['app']
# Set the data folder to sLocalMasterPath
dirs['mods'] = dirs['app'].join(get_ini_option(oblivionIni,
u'SLocalMasterPath') or u'Data')
# these are relative to the mods path so they must be set here
dirs['patches'] = dirs['mods'].join(u'Bash Patches')
dirs['tweaks'] = dirs['mods'].join(u'INI Tweaks')
Expand Down

0 comments on commit 3a50c3b

Please sign in to comment.