diff --git a/otp/distributed/OTPInternalRepository.py b/otp/distributed/OTPInternalRepository.py index 3dd121d..6b3fc93 100644 --- a/otp/distributed/OTPInternalRepository.py +++ b/otp/distributed/OTPInternalRepository.py @@ -1,5 +1,6 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.AstronInternalRepository import AstronInternalRepository +from direct.distributed.PyDatagram import * # TODO: Remove Astron dependence. @@ -24,3 +25,19 @@ class OTPInternalRepository(AstronInternalRepository): def sendSetZone(self, distObj, zoneId): distObj.setLocation(distObj.parentId, zoneId) self.sendSetLocation(distObj, distObj.parentId, zoneId) + + def setAllowClientSend(self, avId, distObj, fieldNameList=[]): + dg = PyDatagram() + dg.addServerHeader(distObj.GetPuppetConnectionChannel(avId), self.ourChannel, CLIENTAGENT_SET_FIELDS_SENDABLE) + fieldIds = [] + for fieldName in fieldNameList: + field = distObj.dclass.getFieldByName(fieldName) + if field: + fieldIds.append(field.getNumber()) + + dg.addUint32(distObj.getDoId()) + dg.addUint16(len(fieldIds)) + for fieldId in fieldIds: + dg.addUint16(fieldId) + + self.send(dg) diff --git a/otp/otpbase/PythonUtil.py b/otp/otpbase/PythonUtil.py index f943450..5438f92 100644 --- a/otp/otpbase/PythonUtil.py +++ b/otp/otpbase/PythonUtil.py @@ -1,6 +1,8 @@ import builtins import sys import math +import random +import time __all__ = ['enumerate', 'nonRepeatingRandomList', 'describeException', 'pdir', 'choice', 'cmp', 'lerp', 'triglerp'] diff --git a/toontown/effects/Drift.py b/toontown/effects/Drift.py index bd6a08d..262776f 100644 --- a/toontown/effects/Drift.py +++ b/toontown/effects/Drift.py @@ -1,7 +1,6 @@ from pandac.PandaModules import * from direct.particles import ParticleEffect from direct.directnotify import DirectNotifyGlobal -from direct.showbase import AppRunnerGlobal import os class Drift(NodePath): @@ -15,19 +14,14 @@ class Drift(NodePath): self.assign(parent.attachNewNode('drift')) self.effect = ParticleEffect.ParticleEffect() particleSearchPath = DSearchPath() - if AppRunnerGlobal.appRunner: - particleSearchPath.appendDirectory(Filename.expandFrom('$TT_3_5_ROOT/phase_3.5/etc')) - else: - basePath = os.path.expandvars('$TOONTOWN') or './toontown' - particleSearchPath.appendDirectory(Filename.fromOsSpecific(basePath + '/src/effects')) - particleSearchPath.appendDirectory(Filename('phase_3.5/etc')) - particleSearchPath.appendDirectory(Filename('phase_4/etc')) - particleSearchPath.appendDirectory(Filename('phase_5/etc')) - particleSearchPath.appendDirectory(Filename('phase_6/etc')) - particleSearchPath.appendDirectory(Filename('phase_7/etc')) - particleSearchPath.appendDirectory(Filename('phase_8/etc')) - particleSearchPath.appendDirectory(Filename('phase_9/etc')) - particleSearchPath.appendDirectory(Filename('.')) + if __debug__: + particleSearchPath.appendDirectory(Filename('resources/phase_3.5/etc')) + particleSearchPath.appendDirectory(Filename('resources/phase_4/etc')) + particleSearchPath.appendDirectory(Filename('resources/phase_5/etc')) + particleSearchPath.appendDirectory(Filename('resources/phase_6/etc')) + particleSearchPath.appendDirectory(Filename('resources/phase_7/etc')) + particleSearchPath.appendDirectory(Filename('resources/phase_8/etc')) + particleSearchPath.appendDirectory(Filename('resources/phase_9/etc')) pfile = Filename('drift.ptf') found = vfs.resolveFilename(pfile, particleSearchPath) if not found: diff --git a/toontown/effects/Sparks.py b/toontown/effects/Sparks.py index a7391ca..2b662db 100644 --- a/toontown/effects/Sparks.py +++ b/toontown/effects/Sparks.py @@ -1,7 +1,6 @@ from pandac.PandaModules import * from direct.particles import ParticleEffect from direct.directnotify import DirectNotifyGlobal -from direct.showbase import AppRunnerGlobal import os class Sparks(NodePath): @@ -15,19 +14,14 @@ class Sparks(NodePath): self.assign(parent.attachNewNode('sparks')) self.effect = ParticleEffect.ParticleEffect('Sparks') particleSearchPath = DSearchPath() - if AppRunnerGlobal.appRunner: - particleSearchPath.appendDirectory(Filename.expandFrom('$TT_3_5_ROOT/phase_3.5/etc')) - else: - basePath = os.path.expandvars('$TOONTOWN') or './toontown' - particleSearchPath.appendDirectory(Filename.fromOsSpecific(basePath + '/src/effects')) - particleSearchPath.appendDirectory(Filename('phase_3.5/etc')) - particleSearchPath.appendDirectory(Filename('phase_4/etc')) - particleSearchPath.appendDirectory(Filename('phase_5/etc')) - particleSearchPath.appendDirectory(Filename('phase_6/etc')) - particleSearchPath.appendDirectory(Filename('phase_7/etc')) - particleSearchPath.appendDirectory(Filename('phase_8/etc')) - particleSearchPath.appendDirectory(Filename('phase_9/etc')) - particleSearchPath.appendDirectory(Filename('.')) + if __debug__: + particleSearchPath.appendDirectory(Filename('resources/phase_3.5/etc')) + particleSearchPath.appendDirectory(Filename('resources/phase_4/etc')) + particleSearchPath.appendDirectory(Filename('resources/phase_5/etc')) + particleSearchPath.appendDirectory(Filename('resources/phase_6/etc')) + particleSearchPath.appendDirectory(Filename('resources/phase_7/etc')) + particleSearchPath.appendDirectory(Filename('resources/phase_8/etc')) + particleSearchPath.appendDirectory(Filename('resources/phase_9/etc')) pfile = Filename('sparks.ptf') found = vfs.resolveFilename(pfile, particleSearchPath) if not found: diff --git a/toontown/racing/DistributedRace.py b/toontown/racing/DistributedRace.py index d15ed74..d5bfc5b 100644 --- a/toontown/racing/DistributedRace.py +++ b/toontown/racing/DistributedRace.py @@ -1,4 +1,5 @@ from pandac.PandaModules import * +from libtoontown import * from direct.distributed.ClockDelta import * from direct.distributed import DistributedObject from direct.directnotify import DirectNotifyGlobal @@ -965,7 +966,7 @@ class DistributedRace(DistributedObject.DistributedObject): def precomputeSideStreets(self): farDist = base.camLens.getFar() + 300 farDistSquared = farDist * farDist - for i in range(self.barricadeSegments): + for i in range(int(self.barricadeSegments)): testPoint = Point3(0, 0, 0) self.curve.getPoint(i / self.barricadeSegments * (self.curve.getMaxT() - 1e-11), testPoint) for side in ('innersidest', 'outersidest'): diff --git a/toontown/racing/DistributedVehicle.py b/toontown/racing/DistributedVehicle.py index 076dcdd..72f0a23 100644 --- a/toontown/racing/DistributedVehicle.py +++ b/toontown/racing/DistributedVehicle.py @@ -1,4 +1,5 @@ from pandac.PandaModules import * +from libotp import * from direct.distributed.ClockDelta import * from direct.interval.IntervalGlobal import * from direct.gui.DirectGui import * @@ -904,7 +905,7 @@ class DistributedVehicle(DistributedSmoothNode.DistributedSmoothNode, Kart.Kart, driftMin = self.surfaceModifiers[self.groundType]['driftMin'] * 0.2 if self.skidding: driftMin = self.surfaceModifiers[self.groundType]['driftMin'] - for i in range(numFrames): + for i in range(int(numFrames)): self.physicsMgr.doPhysics(self.physicsDt) curVelocity = self.actorNode.getPhysicsObject().getVelocity() idealVelocity = curHeading * curSpeed diff --git a/toontown/racing/Racer.py b/toontown/racing/Racer.py index d2c734e..c2d1036 100644 --- a/toontown/racing/Racer.py +++ b/toontown/racing/Racer.py @@ -1,2 +1,12 @@ class Racer: - pass + + def __init__(self, race, air, avId, zoneId): + self.race = race + self.air = air + self.avId = avId + self.zoneId = zoneId + self.avatar = self.air.doId2do.get(self.avId) + self.avatar.takeOutKart(self.zoneId) + self.kart = self.avatar.kart + self.finished = False + self.exitEvent = self.air.getAvatarExitEvent(self.avId)