Merge branch 'beta-wip' into estates

This commit is contained in:
Harvir 2014-08-03 03:52:27 +01:00
commit 1a8fa69a2a
14 changed files with 169 additions and 27 deletions

View file

@ -25,6 +25,7 @@ vfs-mount resources/phase_10 /phase_10
vfs-mount resources/phase_11 /phase_11
vfs-mount resources/phase_12 /phase_12
vfs-mount resources/phase_13 /phase_13
vfs-mount resources/server /server
model-path /
default-model-extension .bam
@ -52,7 +53,7 @@ want-parties #f
want-gardening #t
# This is a temporary 'fix' for DistributedSmoothNodes... probably not the permanent solution to our problem, but it works for now.
smooth-lag 0.4
want-keep-alive #f
want-keep-alive #t
# Developer Modifications
@ -65,10 +66,11 @@ want-toontorial #f
# Chat stuff
want-whitelist #f
want-blacklist-sequence #f
force-avatar-understandable #t
force-player-understandable #t
# Holidays and Events
force-holiday-decorations 6
want-arg-manager #t
want-arg-manager #f

View file

@ -12,6 +12,7 @@ preload-avatars #t
texture-anisotropic-degree 16
language LANGUAGE_HERE
# Resources settings
model-path /
model-cache-models #f
@ -31,13 +32,22 @@ vfs-mount phase_12.mf /
vfs-mount phase_13.mf /
default-model-extension .bam
# Now that we've loaded the phase files, tell panda to trust the TTRCA
ssl-certificates phase_3/etc/TTRCA.crt
ssl-certificates /phase_3/etc/TTRCA.crt
#<dev>
ssl-certificates /phase_3/etc/TTRDev.crt
want-dev-certificate-trust #t
#</dev>
server-force-ssl #t
# This is the shared secret for CSMUD login
# ##### NB! Update deployment/server.prc too! #####
csmud-secret Yv1JrpTUdkX6M86h44Z9q4AUaQYdFnectDgl2I5HOQf8CBh7LUZWpzKB9FBD
# DC files are NOT configured.
# They're wrapped up into the code automatically.
@ -50,12 +60,12 @@ want-news-page #f
want-gardening #f
# This is a temporary 'fix' for DistributedSmoothNodes... probably not the permanent solution to our problem, but it works for now.
smooth-lag 0.4
want-keep-alive #f
want-keep-alive #t
# Holidays and Events
force-holiday-decorations 6
want-arg-manager #t
want-arg-manager #f
# Chat

View file

@ -1,7 +1,7 @@
{
"__fyi__": "If you use anything other than the first 7 characters of the git hash, you just broke everything",
"astron": "b467639",
"panda3d": "d048f43",
"panda3d": "185f908",
"version-prefix": "ttr-beta-",
"server-resources": ["dna", "xml", "txt", "dat", "bam"]
}

View file

@ -6,10 +6,12 @@
want-dev #f
want-cheesy-expirations #t
# Shared secret for CSMUD
# ##### NB! Update config/public_client.prc too! #####
csmud-secret Yv1JrpTUdkX6M86h44Z9q4AUaQYdFnectDgl2I5HOQf8CBh7LUZWpzKB9FBD
# Beta Modifications
# Temporary modifications for unimplemented features go here.
want-bbhq #f
@ -18,6 +20,13 @@ want-parties #f
want-accessories #f
want-golf #f
want-gardening #f
want-keep-alive #f
want-keep-alive #t
# Chat stuff
blacklist-sequence-url https://s3.amazonaws.com/cdn.toontownrewritten.com/misc/tsequence.dat
want-whitelist #t
want-blacklist-sequence #t
# Holidays and Events

View file

@ -2,6 +2,7 @@ from direct.directnotify import DirectNotifyGlobal
from direct.distributed.DistributedObjectGlobalUD import DistributedObjectGlobalUD
# TODO: OTP should not depend on Toontown... Hrrm.
from toontown.chat.TTWhiteList import TTWhiteList
from toontown.chat.TTSequenceList import TTSequenceList
from otp.distributed import OtpDoGlobals
class ChatAgentUD(DistributedObjectGlobalUD):
@ -9,8 +10,12 @@ class ChatAgentUD(DistributedObjectGlobalUD):
def announceGenerate(self):
DistributedObjectGlobalUD.announceGenerate(self)
self.whiteList = TTWhiteList()
self.wantBlacklistSequence = config.GetBool('want-blacklist-sequence', True)
self.wantWhitelist = config.GetBool('want-whitelist', True)
if self.wantWhitelist:
self.whiteList = TTWhiteList()
if self.wantBlacklistSequence:
self.sequenceList = TTSequenceList()
self.chatMode2channel = {
1 : OtpDoGlobals.OTP_MOD_CHANNEL,
2 : OtpDoGlobals.OTP_ADMIN_CHANNEL,
@ -29,8 +34,10 @@ class ChatAgentUD(DistributedObjectGlobalUD):
issue='Account sent chat without an avatar', message=message)
return
cleanMessage, modifications = self.cleanWhitelist(message)
if self.wantWhitelist:
cleanMessage, modifications = self.cleanWhitelist(message)
else:
cleanMessage, modifications = message, []
self.air.writeServerEvent('chat-said', avId=sender, chatMode=chatMode, msg=message, cleanMsg=cleanMessage)
# TODO: The above is probably a little too ugly for my taste... Maybe AIR
@ -58,7 +65,6 @@ class ChatAgentUD(DistributedObjectGlobalUD):
return
cleanMessage, modifications = self.cleanWhitelist(message)
# Maybe a better "cleaner" way of doing this, but it works
self.air.writeServerEvent('whisper-said', avId=sender, reciever=receiverAvId, msg=message, cleanMsg=cleanMessage)
DistributedAvatar = self.air.dclassesByName['DistributedAvatarUD']
@ -87,15 +93,18 @@ class ChatAgentUD(DistributedObjectGlobalUD):
modifications = []
words = message.split(' ')
offset = 0
WantWhitelist = self.air.config.GetBool('want-whitelist', True)
for word in words:
if word and not self.whiteList.isWord(word) and WantWhitelist:
if word and not self.whiteList.isWord(word):
modifications.append((offset, offset+len(word)-1))
offset += len(word) + 1
cleanMessage = message
if self.wantBlacklistSequence:
modifications += self.cleanSequences(cleanMessage)
for modStart, modStop in modifications:
cleanMessage = cleanMessage[:modStart] + '*'*(modStop-modStart+1) + cleanMessage[modStop+1:]
# Traverse through modification list and replace the characters of non-whitelisted words and/or blacklisted sequences with asterisks.
cleanMessage = cleanMessage[:modStart] + '*' * (modStop - modStart + 1) + cleanMessage[modStop + 1:]
return (cleanMessage, modifications)
@ -103,3 +112,25 @@ class ChatAgentUD(DistributedObjectGlobalUD):
def cleanBlacklist(self, message):
# We don't have a black list so we just return the full message
return message
# Check for black-listed word sequences and scrub accordingly.
def cleanSequences(self, message):
modifications = []
offset = 0
words = message.split()
for wordit in xrange(len(words)):
word = words[wordit].lower()
seqlist = self.sequenceList.getList(word)
if len(seqlist) > 0:
for seqit in xrange(len(seqlist)):
sequence = seqlist[seqit]
splitseq = sequence.split()
if len(words) - (wordit + 1) >= len(splitseq):
cmplist = words[wordit + 1:]
del cmplist[len(splitseq):]
cmplist = [word.lower() for word in cmplist]
if cmp(cmplist, splitseq) == 0:
modifications.append((offset, offset + len(word) + len(sequence) - 1))
offset += len(word) + 1
return modifications

13
otp/chat/SequenceList.py Normal file
View file

@ -0,0 +1,13 @@
class SequenceList:
def __init__(self, wordlist):
self.list = {}
for line in wordlist.split('\r\n'):
split = line.split(':')
self.list[split[0].lower()] = [word.rstrip('\r\n').lower() for word in split[1].split(',')]
def getList(self, word):
if word in self.list:
return self.list[word]
else:
return []

View file

@ -488,6 +488,15 @@ class OTPClientRepository(ClientRepositoryBase):
self.connectingBox.show()
self.renderFrame()
self.handler = self.handleConnecting
# TTR SSL Hack
# Because Panda has weird requirements that a certificate be associated with a URLSpec,
# we take the URLSpec in serverList and trust our certs for that URLSpec
if self.checkHttp():
for server in self.serverList:
self.http.addPreapprovedServerCertificateFilename(server, Filename('/phase_3/etc/TTRCA.crt'))
if base.config.GetBool('want-dev-certificate-trust', 0):
self.http.addPreapprovedServerCertificateFilename(server, Filename('/phase_3/etc/TTRDev.crt'))
self.connect(self.serverList, successCallback=self._sendHello, failureCallback=self.failedToConnect)
def _sendHello(self):

View file

@ -569,7 +569,7 @@ SuitBrushOffs = {'f': ["I'm late for a meeting."],
"You're in no position to meet with me.",
'Talk to my assistant.']}
SuitFaceoffTaunts = {'b': ['Would you like to make a donation?',
"This may make you sore loser.",
"This may make you a sore loser.",
"I'm going to leave you high and dry.",
'I\'m "Positive" this will go well.',
'"O" don\'t be so "Negative".',

@ -1 +1 @@
Subproject commit 74f4c40fe74041265835cf9766bdb928624f0b97
Subproject commit e85706bc15d8a18445e319cd9fb07bb804552b19

View file

@ -67,6 +67,8 @@ class ClientBuilder(object):
self.modules = {}
self.path_overrides = {}
self.config_file = os.path.join(self.directory, 'config/public_client.prc')
self.mf = ModuleFinder(sys.path+[self.directory])
from panda3d.direct import DCFile
self.dcf = DCFile()
@ -114,7 +116,7 @@ class ClientBuilder(object):
# Next we need config files...
configData = []
with open(os.path.join(self.directory, 'config/public_client.prc')) as f:
with open(self.config_file) as f:
fd = f.read()
fd = fd.replace('SERVER_VERSION_HERE', self.version)
fd = fd.replace('LANGUAGE_HERE', self.language)

View file

@ -0,0 +1,36 @@
from pandac.PandaModules import *
from otp.chat.SequenceList import SequenceList
from direct.directnotify import DirectNotifyGlobal
class TTSequenceList(SequenceList):
def __init__(self):
self.notify = DirectNotifyGlobal.directNotify.newCategory('TTSequenceList')
sequenceListURL = config.GetString('blacklist-sequence-url', '')
if sequenceListURL == '':
self.notify.warning('No Sequence BL URL specified! Continuing with local sequence.')
SequenceList.__init__(self, self.loadSquencesLocally())
else:
SequenceList.__init__(self, self.downloadSequences(sequenceListURL))
def downloadSequences(self, url):
fs = Ramfile()
http = HTTPClient.getGlobalPtr()
self.ch = http.makeChannel(True)
self.ch.getHeader(DocumentSpec(url))
doc = self.ch.getDocumentSpec()
self.ch.getDocument(doc)
self.ch.downloadToRam(fs)
return fs.getData()
def loadSquencesLocally(self):
vfs = VirtualFileSystem.getGlobalPtr()
filename = Filename('tsequence.dat')
searchPath = DSearchPath()
searchPath.appendDirectory(Filename('/server'))
found = vfs.resolveFilename(filename, searchPath)
if not found:
self.notify.warning("Couldn't find blacklist sequence data file!")
return
data = vfs.readFile(filename, 1)
return data

View file

@ -2,12 +2,11 @@ import os
import datetime
from pandac.PandaModules import *
from direct.directnotify import DirectNotifyGlobal
from direct.distributed import DistributedObject
from direct.showbase import AppRunnerGlobal
from otp.chat.WhiteList import WhiteList
from toontown.toonbase import TTLocalizer
class TTWhiteList(WhiteList, DistributedObject.DistributedObject):
class TTWhiteList(WhiteList):
RedownloadTaskName = 'RedownloadWhitelistTask'
WhitelistBaseDir = config.GetString('whitelist-base-dir', '')
WhitelistStageDir = config.GetString('whitelist-stage-dir', 'whitelist')

View file

@ -545,7 +545,7 @@ class Place(StateData.StateData, FriendsListManager.FriendsListManager):
door = base.cr.doId2do.get(requestStatus['doorDoId'])
if door is None:
# We're about to die anyway because door is None, so raise a StandardError with more information
raise StandardError("Place's door is None! Place: %s, requestStatus: %s" % (str(self.__class__)), str(requestStatus))
raise StandardError("Place's door is None! Place: %s, requestStatus: %s" % (str(self.__class__), str(requestStatus)))
door.readyToExit()
base.localAvatar.obscureMoveFurnitureButton(1)
base.localAvatar.startQuestMap()

View file

@ -229,6 +229,9 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
self.magicWordTeleportRequests = []
self.webAccountId = 0
self.hasQuests = False
# KeepAlive
self.keepAliveTask = None
return
def generate(self):
@ -265,7 +268,7 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
if self.isPlayerControlled():
# Begin checking if clients are still alive
if config.GetBool('want-keep-alive', True):
taskMgr.doMethodLater(config.GetInt('keep-alive-timeout-delay', 300), self.__noKeepAlive, self.uniqueName('KeepAliveTimeout'), extraArgs=[])
self.keepAliveTask = taskMgr.doMethodLater(config.GetInt('keep-alive-timeout-delay', 300), self.__noKeepAlive, self.uniqueName('KeepAliveTimeout'))
if self.getAdminAccess() < 500:
# Ensure they have the correct laff.
@ -347,7 +350,13 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
taskMgr.remove(taskName)
taskName = 'next-bothDelivery-%s' % self.doId
taskMgr.remove(taskName)
# Cleanup KeepAlive stuff
taskMgr.remove(self.uniqueName('KeepAliveTimeout'))
if self.keepAliveTask:
self.keepAliveTask.remove()
self.keepAliveTask = None
self.stopToonUp()
del self.dna
if self.inventory:
@ -370,7 +379,12 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
self.experience = None
taskName = self.uniqueName('next-catalog')
taskMgr.remove(taskName)
# Cleanup KeepAlive stuff
taskMgr.remove(self.uniqueName('KeepAliveTimeout'))
if self.keepAliveTask:
self.keepAliveTask.remove()
self.keepAliveTask = None
return
def ban(self, comment):
@ -380,6 +394,15 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
def disconnect(self):
self.requestDelete()
self.notify.debug("Disconnecting %s (%d)." % (self.getName(), self.getDoId()))
# Cleanup KeepAlive stuff
taskMgr.remove(self.uniqueName('KeepAliveTimeout'))
if self.keepAliveTask:
self.notify.debug("Removing keepAliveTask for %s (%d)." % (self.getName(), self.getDoId()))
self.keepAliveTask.remove()
self.keepAliveTask = None
def patchDelete(self):
del self.dna
if self.inventory:
@ -4593,10 +4616,17 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
def keepAlive(self):
# We received the Keep Alive response
self.notify.debug("Received keep alive response %s (%d)." % (self.getName(), self.getDoId()))
taskMgr.remove(self.uniqueName('KeepAliveTimeout'))
taskMgr.doMethodLater(config.GetInt('keep-alive-timeout-delay', 300), self.__noKeepAlive, self.uniqueName('KeepAliveTimeout'), extraArgs=[])
def __noKeepAlive(self):
# Kill the current running task, if we have one
taskMgr.remove(self.uniqueName('KeepAliveTimeout'))
if self.keepAliveTask:
self.keepAliveTask.remove()
self.keepAliveTask = None
# Fire up the check again
self.keepAliveTask = taskMgr.doMethodLater(config.GetInt('keep-alive-timeout-delay', 300), self.__noKeepAlive, self.uniqueName('KeepAliveTimeout'))
def __noKeepAlive(self, task):
# Log everything just so we have a record of it
self.notify.debug("No keep alive response %s (%d)." % (self.getName(), self.getDoId()))
self.air.writeServerEvent("keep-alive", avId=self.getDoId(), message="Avatar failed to respond to Keep Alive.")
@ -4608,8 +4638,9 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
dg.addString('Link renegotiation timed out.')
self.air.send(dg)
# RIP
self.requestDelete()
# Kill it, kill it with fire!
self.notify.debug("Killing %s (%d)." % (self.getName(), self.getDoId()))
self.disconnect()
def d_setLastSeen(self, timestamp):
self.sendUpdate('setLastSeen', [int(timestamp)])