Poodletooth-iLand/toontown/ai/ServiceStart.py

77 lines
2.7 KiB
Python
Raw Normal View History

2015-03-03 16:10:12 -06:00
import __builtin__
__builtin__.process = 'ai'
# Temporary hack patch:
__builtin__.__dict__.update(__import__('pandac.PandaModules', fromlist=['*']).__dict__)
from direct.extensions_native import HTTPChannel_extensions
2015-05-29 05:03:48 -05:00
import sys, os
sys.path.append(
os.path.abspath(
os.path.join(
os.path.dirname(__file__),
"../../dependencies"
)
)
)
2015-03-03 16:10:12 -06:00
import argparse
2015-07-17 13:01:50 -05:00
import gc
# Panda3D 1.10.0 is 63.
gc.disable()
2015-03-03 16:10:12 -06:00
parser = argparse.ArgumentParser()
parser.add_argument('--base-channel', help='The base channel that the server may use.')
parser.add_argument('--max-channels', help='The number of channels the server may use.')
parser.add_argument('--stateserver', help="The control channel of this AI's designated State Server.")
parser.add_argument('--district-name', help="What this AI Server's district will be named.")
parser.add_argument('--astron-ip', help="The IP address of the Astron Message Director to connect to.")
parser.add_argument('--eventlogger-ip', help="The IP address of the Astron Event Logger to log to.")
2015-05-29 05:03:48 -05:00
parser.add_argument('config', nargs='*', default=['dependencies/config/general.prc', 'dependencies/config/release/dev.prc'], help="PRC file(s) to load.")
2015-03-03 16:10:12 -06:00
args = parser.parse_args()
for prc in args.config:
loadPrcFile(prc)
2015-06-05 00:05:01 -05:00
2015-05-31 15:08:46 -05:00
if os.path.isfile('dependencies/config/local.prc'):
loadPrcFile('dependencies/config/local.prc')
2015-03-03 16:10:12 -06:00
localconfig = ''
if args.base_channel: localconfig += 'air-base-channel %s\n' % args.base_channel
if args.max_channels: localconfig += 'air-channel-allocation %s\n' % args.max_channels
if args.stateserver: localconfig += 'air-stateserver %s\n' % args.stateserver
if args.district_name: localconfig += 'district-name %s\n' % args.district_name
if args.astron_ip: localconfig += 'air-connect %s\n' % args.astron_ip
if args.eventlogger_ip: localconfig += 'eventlog-host %s\n' % args.eventlogger_ip
loadPrcFileData('Command-line', localconfig)
from otp.ai.AIBaseGlobal import *
from toontown.ai.ToontownAIRepository import ToontownAIRepository
simbase.air = ToontownAIRepository(config.GetInt('air-base-channel', 401000000),
config.GetInt('air-stateserver', 4002),
config.GetString('district-name', 'Devhaven'))
host = config.GetString('air-connect', '127.0.0.1')
port = 7100
if ':' in host:
host, port = host.split(':', 1)
port = int(port)
simbase.air.connect(host, port)
2015-08-22 17:33:08 -05:00
gc.enable()
2015-03-03 16:10:12 -06:00
try:
run()
except SystemExit:
raise
except Exception:
info = describeException()
2015-04-02 07:23:24 -05:00
simbase.air.writeServerEvent('ai-exception', avId=simbase.air.getAvatarIdFromSender(), accId=simbase.air.getAccountIdFromSender(), exception=info)
2015-03-03 16:10:12 -06:00
raise