Made the default_settings file itself detect GAME_DIR, leading to a lot less cookie cutter in the gamedir/server/conf/settings.py file. Refactored the detection algorithm also in the launcher.
This commit is contained in:
parent
9bf09365d2
commit
6782ff1333
4 changed files with 52 additions and 104 deletions
|
|
@ -1605,3 +1605,22 @@ class LimitedSizeOrderedDict(OrderedDict):
|
|||
def update(self, *args, **kwargs):
|
||||
super(LimitedSizeOrderedDict, self).update(*args, **kwargs)
|
||||
self._check_size()
|
||||
|
||||
def get_game_dir_path():
|
||||
"""
|
||||
This is called by settings_default in order to determine the path
|
||||
of the game directory.
|
||||
|
||||
Returns:
|
||||
path (str): Full OS path to the game dir
|
||||
|
||||
"""
|
||||
# current working directory, assumed to be somewhere inside gamedir.
|
||||
for i in range(10):
|
||||
gpath = os.getcwd()
|
||||
if "server" in os.listdir(gpath):
|
||||
if os.path.isfile(os.path.join("server", "conf", "settings.py")):
|
||||
return gpath
|
||||
else:
|
||||
os.chdir(os.pardir)
|
||||
raise RuntimeError("server/conf/settings.py not found: Must start from inside game dir.")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue