ai: Use Disney's AIStart.py (broken)
This commit is contained in:
parent
f76bf08268
commit
f3ecc30c3d
|
|
@ -1,64 +1,93 @@
|
|||
from panda3d.core import *
|
||||
import builtins
|
||||
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description='Open Toontown - AI Server')
|
||||
parser.add_argument('--base-channel', help='The base channel that the server will use.')
|
||||
parser.add_argument('--max-channels', help='The number of channels that the server will be able to use.')
|
||||
parser.add_argument('--stateserver', help='The control channel of this AI\'s designated State Server.')
|
||||
parser.add_argument('--district-name', help='The name of the district on this AI server.')
|
||||
parser.add_argument('--messagedirector-ip',
|
||||
help='The IP address of the Message Director that this AI will connect to.')
|
||||
parser.add_argument('--eventlogger-ip', help='The IP address of the OTP Event Logger that this AI will log to.')
|
||||
parser.add_argument('config', nargs='*', default=['etc/Configrc.prc'],
|
||||
help='PRC file(s) that will be loaded on this AI instance.')
|
||||
args = parser.parse_args()
|
||||
|
||||
for prc in args.config:
|
||||
loadPrcFile(prc)
|
||||
|
||||
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.messagedirector_ip:
|
||||
localConfig += 'air-connect %s\n' % args.messagedirector_ip
|
||||
if args.eventlogger_ip:
|
||||
localConfig += 'eventlog-host %s\n' % args.eventlogger_ip
|
||||
|
||||
loadPrcFileData('AI Args Config', localConfig)
|
||||
|
||||
class game:
|
||||
name = 'toontown'
|
||||
process = 'server'
|
||||
name = "toontown"
|
||||
process = "ai"
|
||||
builtins.game = game()
|
||||
|
||||
builtins.game = game
|
||||
# NOTE: this file is not used in production. See AIServiceStart.py
|
||||
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
|
||||
print("Initializing...")
|
||||
|
||||
from otp.ai.AIBaseGlobal import *
|
||||
from toontown.ai.ToontownAIRepository import ToontownAIRepository
|
||||
from toontown.toonbase import TTLocalizer
|
||||
from . import ToontownAIRepository
|
||||
from direct.showbase import PythonUtil
|
||||
|
||||
simbase.air = ToontownAIRepository(ConfigVariableInt('air-base-channel', 401000000).value, ConfigVariableInt('air-stateserver', 4002).value, ConfigVariableString('district-name', TTLocalizer.AIStartDefaultDistrict).value)
|
||||
# Clear the default model extension for AI developers, so they'll know
|
||||
# when they screw up and omit it.
|
||||
from pandac.PandaModules import loadPrcFileData
|
||||
loadPrcFileData("AIStart.py", "default-model-extension")
|
||||
|
||||
host = ConfigVariableString('air-connect', '127.0.0.1:7199').value
|
||||
port = 7199
|
||||
if ':' in host:
|
||||
host, port = host.split(':', 1)
|
||||
port = int(port)
|
||||
simbase.mdip = simbase.config.GetString("msg-director-ip", "localhost")
|
||||
|
||||
simbase.air.connect(host, port)
|
||||
# Now the AI connects directly to the state server instead of the msg director
|
||||
simbase.mdport = simbase.config.GetInt("msg-director-port", 6666)
|
||||
|
||||
simbase.esip = simbase.config.GetString("event-server-ip", "localhost")
|
||||
simbase.esport = simbase.config.GetInt("event-server-port", 4343)
|
||||
|
||||
|
||||
districtType = 0
|
||||
serverId = simbase.config.GetInt("district-ssid", 20100000)
|
||||
|
||||
for i in range(1, 20+1):
|
||||
# always set up for i==1, then take the first district above 1 (if any)
|
||||
if i==1 or os.getenv("want_district_%s" % i):
|
||||
if i==1:
|
||||
postfix = ''
|
||||
else:
|
||||
postfix = '-%s' % i
|
||||
districtNumber = simbase.config.GetInt(
|
||||
"district-id%s"%postfix,
|
||||
200000000 + i*1000000)
|
||||
districtName = simbase.config.GetString(
|
||||
"district-name%s"%postfix,
|
||||
"%sville" % {1: 'Silly',
|
||||
2: 'Second',
|
||||
3: 'Third',
|
||||
4: 'Fourth',
|
||||
5: 'Fifth',
|
||||
6: 'Sixth',
|
||||
7: 'Seventh',
|
||||
8: 'Eighth',
|
||||
9: 'Ninth', }.get(i, str(i))
|
||||
)
|
||||
districtMinChannel = simbase.config.GetInt(
|
||||
"district-min-channel%s"%postfix,
|
||||
200100000 + i*1000000)
|
||||
districtMaxChannel = simbase.config.GetInt(
|
||||
"district-max-channel%s"%postfix,
|
||||
200149999 + i*1000000)
|
||||
if i != 1:
|
||||
break
|
||||
|
||||
print("-"*30, "creating toontown district %s" % districtNumber, "-"*30)
|
||||
|
||||
simbase.air = ToontownAIRepository.ToontownAIRepository(
|
||||
simbase.mdip,
|
||||
simbase.mdport,
|
||||
simbase.esip,
|
||||
simbase.esport,
|
||||
None,
|
||||
districtNumber,
|
||||
districtName,
|
||||
districtType,
|
||||
serverId,
|
||||
districtMinChannel,
|
||||
districtMaxChannel)
|
||||
|
||||
# How we let the world know we are not running a service
|
||||
simbase.aiService = 0
|
||||
|
||||
try:
|
||||
simbase.air.fsm.request("districtReset")
|
||||
run()
|
||||
except SystemExit:
|
||||
raise
|
||||
except Exception:
|
||||
from otp.otpbase import PythonUtil
|
||||
print(PythonUtil.describeException())
|
||||
except:
|
||||
info = PythonUtil.describeException()
|
||||
simbase.air.writeServerEvent('ai-exception', districtNumber, info)
|
||||
raise
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from enum import IntEnum
|
||||
|
||||
DefaultDbName = 'tt_code_redemption'
|
||||
RedeemErrors = IntEnum('RedeemErrors', ('Success', 'CodeDoesntExist', 'CodeIsInactive', 'CodeAlreadyRedeemed', 'AwardCouldntBeGiven', 'TooManyAttempts', 'SystemUnavailable'))
|
||||
RedeemErrors = IntEnum('RedeemErrors', ('Success', 'CodeDoesntExist', 'CodeIsInactive', 'CodeAlreadyRedeemed', 'AwardCouldntBeGiven', 'TooManyAttempts', 'SystemUnavailable'), start=0)
|
||||
RedeemErrorStrings = {RedeemErrors.Success: 'Success',
|
||||
RedeemErrors.CodeDoesntExist: 'Invalid code',
|
||||
RedeemErrors.CodeIsInactive: 'Code is inactive',
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.showbase.PythonUtil import list2dict, Enum
|
||||
from toontown.pets import PetTricks
|
||||
import types
|
||||
from enum import IntEnum
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('PetObserve')
|
||||
|
||||
def getEventName(zoneId):
|
||||
|
|
@ -16,8 +15,8 @@ def send(zoneIds, petObserve):
|
|||
messenger.send(getEventName(zoneId), [petObserve])
|
||||
|
||||
|
||||
Phrases = Enum('HI, BYE, YES, NO, SOOTHE, PRAISE, CRITICISM, HAPPY,SAD, ANGRY, HURRY, QUESTION, FRIENDLY, LETS_PLAY,COME, FOLLOW_ME, STAY, NEED_LAFF, NEED_GAGS, NEED_JB,GO_AWAY, DO_TRICK,')
|
||||
Actions = Enum('FEED, SCRATCH,ATTENDED_START, ATTENDED_STOP,ATTENDING_START, ATTENDING_STOP,CHANGE_ZONE, LOGOUT,GARDEN')
|
||||
Phrases = IntEnum('Phrases', ('HI', 'BYE', 'YES', 'NO', 'SOOTHE', 'PRAISE', 'CRITICISM', 'HAPPY', 'SAD', 'ANGRY', 'HURRY', 'QUESTION', 'FRIENDLY', 'LETS_PLAY', 'COME', 'FOLLOW_ME', 'STAY', 'NEED_LAFF', 'NEED_GAGS', 'NEED_JB', 'GO_AWAY', 'DO_TRICK'), start=0)
|
||||
Actions = IntEnum('Actions', ('FEED', 'SCRATCH', 'ATTENDED_START', 'ATTENDED_STOP', 'ATTENDING_START', 'ATTENDING_STOP', 'CHANGE_ZONE', 'LOGOUT', 'GARDEN'), start=0)
|
||||
|
||||
class PetObserve:
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from enum import IntEnum
|
||||
|
||||
GiveAwardErrors = IntEnum('GiveAwardErrors', ('Success', 'WrongGender', 'NotGiftable', 'FullMailbox', 'FullAwardMailbox', 'AlreadyInMailbox', 'AlreadyInGiftQueue', 'AlreadyInOrderedQueue', 'AlreadyInCloset', 'AlreadyBeingWorn', 'AlreadyInAwardMailbox', 'AlreadyInThirtyMinuteQueue', 'AlreadyInMyPhrases', 'AlreadyKnowDoodleTraining', 'AlreadyRented', 'GenericAlreadyHaveError', 'UnknownError', 'UnknownToon', 'NonToon'))
|
||||
GiveAwardErrors = IntEnum('GiveAwardErrors', ('Success', 'WrongGender', 'NotGiftable', 'FullMailbox', 'FullAwardMailbox', 'AlreadyInMailbox', 'AlreadyInGiftQueue', 'AlreadyInOrderedQueue', 'AlreadyInCloset', 'AlreadyBeingWorn', 'AlreadyInAwardMailbox', 'AlreadyInThirtyMinuteQueue', 'AlreadyInMyPhrases', 'AlreadyKnowDoodleTraining', 'AlreadyRented', 'GenericAlreadyHaveError', 'UnknownError', 'UnknownToon', 'NonToon'), start=0)
|
||||
GiveAwardErrorStrings = {GiveAwardErrors.Success: 'success',
|
||||
GiveAwardErrors.WrongGender: 'wrong gender',
|
||||
GiveAwardErrors.NotGiftable: 'item is not giftable',
|
||||
|
|
|
|||
Loading…
Reference in New Issue