Merge branch 'beta-wip' into estates

Conflicts:
	resources
This commit is contained in:
Harvir 2014-08-10 05:17:55 +01:00
commit d1d87f0b8c
4 changed files with 94 additions and 30 deletions

View file

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

View file

@ -3,6 +3,8 @@ class SequenceList:
def __init__(self, wordlist):
self.list = {}
for line in wordlist.split('\r\n'):
if line is '':
continue
split = line.split(':')
self.list[split[0].lower()] = [word.rstrip('\r\n').lower() for word in split[1].split(',')]

View file

@ -1,10 +1,14 @@
from direct.showbase.ShowBase import ShowBase
from pandac.PandaModules import Camera, TPLow, VBase4, ColorWriteAttrib, Filename, getModelPath, NodePath, TexturePool
from pandac.PandaModules import Camera, TPLow, VBase4, ColorWriteAttrib, Filename, getModelPath, NodePath, TexturePool, Multifile
import OTPRender
import time
import math
import re
from otp.ai.MagicWordGlobal import *
import glob
from panda3d.core import VirtualFileSystem
import os
class OTPBase(ShowBase):
@ -304,26 +308,39 @@ def placer():
def explorer():
base.render.explore()
@magicWord(category=CATEGORY_GRAPHICAL, aliases=['syncTextures', 'reloadTex', 'synctex'])
def reloadTextures():
""" Artfart command to reload all of the textures. """
# TODO: A panel that says "Reloading textures... Please wait!"
# ...though it's not important since it's a staff command and
# only staff will see it.
import glob
# Stolen from ToontownStart.py
# Remount all phase files. This maybe might work? Idk. Lets see
# if Panda craps itself.
for file in glob.glob('resources/*.mf'):
mf = Multifile()
mf.openReadWrite(Filename(file))
names = mf.getSubfileNames()
for name in names:
ext = os.path.splitext(name)[1]
if ext not in ['.jpg', '.jpeg', '.ogg', '.rgb']:
mf.removeSubfile(name)
vfs.mount(mf, Filename('/'), 0)
# And finally reload everything!
for texture in TexturePool.findAllTextures():
@magicWord(category=CATEGORY_GRAPHICAL, aliases=['syncTextures', 'reloadTex', 'synctex', 'rt'], types=[str])
def reloadTextures(textureName=''):
"""
Artfart command to reload all of the textures.
TODO: A panel that says "Reloading textures... Please wait!"
...though it's not important since it's a staff command and
only staff will see it.
Stolen from ToontownStart.py
Remount all phase files. This maybe might work? Idk. Lets see
if Panda craps itself.
Place raw files in /resources/non-mf/phase_*/ and they will be
mounted without needing to multify!
"""
# Lock ...
vfs = VirtualFileSystem.getGlobalPtr()
for file in glob.glob('resources/non-mf/phase_*/'):
# Slightly hacky. We remove the trailing slash so we have a tail,
# and select the tail value from the returned tuple. Finally we
# prepend a slash for the mount point.
mount_point = '/' + str(os.path.split(file[:-1])[1])
vfs.mount(Filename(file), Filename(mount_point), 0)
# ... and load.
if textureName:
pool = TexturePool.findAllTextures('*'+textureName+'*')
else:
pool = TexturePool.findAllTextures()
for texture in pool:
texture.reload()
if textureName:
return "Reloaded all textures matching '%s'" % textureName
return "Reloaded all of the textures!"

View file

@ -17,10 +17,10 @@ class DistributedNPCTailorAI(DistributedNPCToonBaseAI):
self.customerDNA = None
self.customerId = None
self.jbCost = 150
if self.freeClothes:
self.useJellybeans = False
return
def getTailor(self):
@ -34,6 +34,34 @@ class DistributedNPCTailorAI(DistributedNPCToonBaseAI):
DistributedNPCToonBaseAI.delete(self)
return
def __verifyAvatarInMyZone(self, av):
return av.getLocation() == self.getLocation()
def __checkValidDNAChange(self, av, testDNA):
# verify they aren't trying to change anything other than their clothing.
# FML this took some time to write...
if testDNA.head != av.dna.head:
return False
if testDNA.torso != av.dna.torso:
# TODO: Check that they aren't changing torso size, but only skirt/shorts.
# Male toons can never change, but girls can change between skirt and shorts.
if av.dna.gender == 'm':
return False
if testDNA.legs != av.dna.legs:
return False
if testDNA.gender != av.dna.gender:
return False
if testDNA.armColor != av.dna.armColor:
return False
if testDNA.gloveColor != av.dna.gloveColor:
# wtf u little hackin' shit.
return False
if testDNA.legColor != av.dna.legColor:
return False
if testDNA.headColor != av.dna.headColor:
return False
return True
def avatarEnter(self):
avId = self.air.getAvatarIdFromSender()
if not self.air.doId2do.has_key(avId):
@ -43,27 +71,30 @@ class DistributedNPCTailorAI(DistributedNPCToonBaseAI):
self.freeAvatar(avId)
return
av = self.air.doId2do[avId]
if not self.__verifyAvatarInMyZone(av):
self.air.writeServerEvent('suspicious', avId=av.getDoId(), issue='Tried to avatarEnter without being in same location.')
return
self.customerDNA = ToonDNA.ToonDNA()
self.customerDNA.makeFromNetString(av.getDNAString())
self.customerId = avId
av.b_setDNAString(self.customerDNA.makeNetString())
self.acceptOnce(self.air.getAvatarExitEvent(avId), self.__handleUnexpectedExit, extraArgs=[avId])
if self.useJellybeans:
flag = NPCToons.PURCHASE_MOVIE_START_BROWSE_JBS
else:
flag = NPCToons.PURCHASE_MOVIE_START_BROWSE
if self.freeClothes:
flag = NPCToons.PURCHASE_MOVIE_START
elif self.air.questManager.hasTailorClothingTicket(av, self):
flag = NPCToons.PURCHASE_MOVIE_START
elif self.useJellybeans and self.hasEnoughJbs(av):
flag = NPCToons.PURCHASE_MOVIE_START
if self.housingEnabled and self.isClosetAlmostFull(av):
flag = NPCToons.PURCHASE_MOVIE_START_NOROOM
self.sendShoppingMovie(avId, flag)
DistributedNPCToonBaseAI.avatarEnter(self)
@ -72,7 +103,7 @@ class DistributedNPCTailorAI(DistributedNPCToonBaseAI):
if numClothes >= av.maxClothes - 1:
return 1
return 0
def hasEnoughJbs(self, av):
if av.getTotalMoney() >= self.jbCost:
return True
@ -130,12 +161,26 @@ class DistributedNPCTailorAI(DistributedNPCToonBaseAI):
self.air.writeServerEvent('suspicious', avId=avId, issue='DistributedNPCTailorAI.setDNA customer is %s' % self.customerId)
self.notify.warning('customerId: %s, but got setDNA for: %s' % (self.customerId, avId))
return
testDNA = ToonDNA.ToonDNA()
if not testDNA.isValidNetString(blob):
self.air.writeServerEvent('suspicious', avId=avId, issue='DistributedNPCTailorAI.setDNA: invalid dna: %s' % blob)
return
testDNA.makeFromNetString(blob)
if self.air.doId2do.has_key(avId):
av = self.air.doId2do[avId]
if not self.__verifyAvatarInMyZone(av):
self.air.writeServerEvent('suspicious', avId=av.getDoId(), issue='Tried to setDNA without being in same location.')
taskMgr.doMethodLater(0.1, self.sendTimeoutMovie, self.uniqueName('clearMovie'))
return
if not self.__checkValidDNAChange(av, testDNA):
self.air.writeServerEvent('suspicious', avId=av.getDoId(), issue='Avatar tried to modify parts of their DNA that isn\'t clothing!')
taskMgr.doMethodLater(0.1, self.sendTimeoutMovie, self.uniqueName('clearMovie'))
return
if finished == 2 and which > 0:
if self.freeClothes or self.air.questManager.removeClothingTicket(av, self) or av.takeMoney(self.jbCost, bUseBank = True):
av.b_setDNAString(blob)