Skip to content

Commit

Permalink
Snowberry: Launching doomsday-server
Browse files Browse the repository at this point in the history
The server needs to be launched with the doomsday-server executable,
and it needs to use a different runtime folder than the client (as it
lacks many subsystems and thus would fail to retain client-only cvars
etc.).

Also bumped Snowberry version to 1.6.
  • Loading branch information
skyjake committed Jan 17, 2013
1 parent c076987 commit 9df2bbc
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
1 change: 1 addition & 0 deletions snowberry/conf/doomsday.conf
Expand Up @@ -13,6 +13,7 @@ configure system (
#
configure doomsday (
binary: ..\Bin\Doomsday.exe
server-binary: ..\Bin\Doomsday-Server.exe
base: ..
)

Expand Down
1 change: 1 addition & 0 deletions snowberry/conf/osx-doomsday.conf
Expand Up @@ -13,6 +13,7 @@ configure system (
#
configure doomsday (
binary: ../Doomsday.app/Contents/MacOS/Doomsday
server-binary: ../Doomsday.app/Contents/Resources/doomsday-server
base: ../Doomsday.app/Contents/Resources
)

Expand Down
2 changes: 1 addition & 1 deletion snowberry/conf/snowberry.conf
Expand Up @@ -4,5 +4,5 @@

configure snowberry (
title: Doomsday Engine Frontend
version: 1.5
version: 1.6
)
1 change: 1 addition & 0 deletions snowberry/conf/x-doomsday.conf
Expand Up @@ -13,6 +13,7 @@ configure system (
#
configure doomsday (
binary: doomsday
server-binary: doomsday-server
)


Expand Down
3 changes: 2 additions & 1 deletion snowberry/paths.py
Expand Up @@ -64,6 +64,7 @@ def isHomeless():
PROFILES = 'profiles'
GRAPHICS = 'graphics'
RUNTIME = 'runtime'
SERVER_RUNTIME = 'server-runtime'

# List of custom addons directories.
addonPaths = []
Expand Down Expand Up @@ -152,7 +153,7 @@ def _checkSnowberryHome():

# Create the rest of the user directories if they don't exist yet.
for p in [ADDONS, MANIFESTS, UNINSTALLED, CONF, LANG, PLUGINS, PROFILES,
GRAPHICS, RUNTIME]:
GRAPHICS, RUNTIME, SERVER_RUNTIME]:
_createDir(getUserPath(p))


Expand Down
35 changes: 20 additions & 15 deletions snowberry/plugins/launcher.py
Expand Up @@ -198,25 +198,33 @@ def startGame(profile):
"""
setLaunchMessage(language.translate('launch-message'))

# Broadcast a notification about the launch of a game.
options = generateOptions(profile)
if options == None:
return

# Locate the paths and binaries. Most of these are configured in
# the .conf files.
engineBin = st.getSystemString('doomsday-binary')
isServer = '-dedicated' in options
if isServer:
idx = options.index('-dedicated')
options = options[:idx] + options[idx+10:]
engineBin = st.getSystemString('doomsday-server-binary')
userPath = paths.getUserPath(paths.SERVER_RUNTIME)
else:
engineBin = st.getSystemString('doomsday-binary')
userPath = paths.getUserPath(paths.RUNTIME)

options = generateOptions(profile)
if options == None:
return
options += '-userdir ' + paths.quote(userPath)

# Put the response file in the user's runtime directory.
responseFile = os.path.join(paths.getUserPath(paths.RUNTIME), 'Options.rsp')
responseFile = os.path.join(userPath, 'Options.rsp')

file(responseFile, 'w').write(options + "\n")

# Execute the command line.
if host.isWindows():
if '-dedicated' in options:
batFile = os.path.join(paths.getUserPath(paths.RUNTIME), 'launch.bat')
if isServer:
batFile = os.path.join(userPath, 'launch.bat')
bat = file(batFile, 'wt')
print >> bat, '@ECHO OFF'
print >> bat, 'ECHO Launching Doomsday...'
Expand All @@ -228,9 +236,9 @@ def startGame(profile):
spawnFunc = spawnWithTerminal
else:
spawnFunc = os.spawnv
elif host.isMac() and '-dedicated' in options:
elif host.isMac() and isServer:
# On the Mac, we'll tell Terminal to run it.
osaFile = os.path.join(paths.getUserPath(paths.RUNTIME), 'Launch.scpt')
osaFile = os.path.join(userPath, 'Launch.scpt')
scpt = file(osaFile, 'w')
print >> scpt, 'tell application "Terminal"'
print >> scpt, ' activate'
Expand All @@ -243,8 +251,8 @@ def q2p(s): return '\\\\\\\"' + s + '\\\\\\\"'
scpt.close()
engineBin = osaFile
spawnFunc = spawnWithTerminal
elif host.isUnix() and '-dedicated' in options:
shFile = os.path.join(paths.getUserPath(paths.RUNTIME), 'launch.sh')
elif host.isUnix() and isServer:
shFile = os.path.join(userPath, 'launch.sh')
sh = file(shFile, 'w')
print >> sh, '#!/bin/sh'
print >> sh, "cd %s" % (paths.quote(os.getcwd()))
Expand Down Expand Up @@ -307,9 +315,6 @@ def generateOptions(profile):
basePath = os.path.abspath(st.getSystemString('doomsday-base'))
cmdLine.append('-basedir ' + paths.quote(basePath))

userPath = paths.getUserPath(paths.RUNTIME)
cmdLine.append('-userdir ' + paths.quote(userPath))

# Determine the components used by the profile.
for compId in profile.getComponents():
# Append the component's options to the command line as-is.
Expand Down

0 comments on commit 9df2bbc

Please sign in to comment.