racing: it loads and crashes

This commit is contained in:
John Cote 2020-01-02 22:02:07 -05:00
parent 00f5bfc3a4
commit 9e742f51c4
7 changed files with 50 additions and 31 deletions

View file

@ -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)

View file

@ -1,6 +1,8 @@
import builtins
import sys
import math
import random
import time
__all__ = ['enumerate', 'nonRepeatingRandomList', 'describeException', 'pdir', 'choice', 'cmp', 'lerp', 'triglerp']

View file

@ -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:

View file

@ -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:

View file

@ -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'):

View file

@ -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

View file

@ -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)