Skip to content

Commit

Permalink
Snowberry: Dedicated server run under Terminal
Browse files Browse the repository at this point in the history
Dedicated mode requires a text-based terminal.
  • Loading branch information
skyjake committed Dec 20, 2011
1 parent c493632 commit 27356c4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -10,3 +10,4 @@ macx_release_build
*.changes
server-runtime
client-runtime
Zcustom.conf
25 changes: 22 additions & 3 deletions snowberry/plugins/launcher.py
Expand Up @@ -2,7 +2,7 @@
# $Id$
# Snowberry: Extensible Launcher for the Doomsday Engine
#
# Copyright (C) 2004, 2005
# Copyright (C) 2004, 2011
# Jaakko Keränen <jaakko.keranen@iki.fi>
#
# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -216,10 +216,24 @@ def startGame(profile):
# Execute the command line.
if host.isWindows():
spawnFunc = os.spawnv
elif host.isMac() and '-dedicated' in options:
# On the Mac, we'll tell Terminal to run it.
osaFile = os.path.join(paths.getUserPath(paths.RUNTIME), 'Launch.scpt')
scpt = file(osaFile, 'w')
print >> scpt, 'tell application "Terminal"'
print >> scpt, ' activate'
def q1p(s): return '\\\"' + s + '\\\"'
def q2p(s): return '\\\\\\\"' + s + '\\\\\\\"'
curDir = os.getcwd()
print >> scpt, " do script \"cd %s; %s @%s\"" % \
(q1p(curDir), engineBin.replace(' ', '\\\\ '), q2p(responseFile))
print >> scpt, 'end tell'
scpt.close()
spawnFunc = spawnWithTerminal
else:
spawnFunc = os.spawnvp
spawnFunc(os.P_NOWAIT, engineBin,
[engineBin, '@' + paths.quote(responseFile)])

spawnFunc(os.P_NOWAIT, engineBin, [engineBin, '@' + paths.quote(responseFile)])

# Shut down if the configuration settings say so.
value = profile.getValue('quit-on-launch')
Expand All @@ -228,6 +242,11 @@ def startGame(profile):
events.sendAfter(events.Command('quit'))


def spawnWithTerminal(wait, bin, arguments):
os.spawnvp(wait, 'osascript', ['osascript',
os.path.join(paths.getUserPath(paths.RUNTIME), 'Launch.scpt')])


def generateOptions(profile):
"""Generate a text string of all the command line options used
when launching a game.
Expand Down

0 comments on commit 27356c4

Please sign in to comment.