mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
distributed: Replace the OTP protocol format with Astron's
Again, all this does is affect the 4-years-disused OTP system, leaving the CMU system entirely untouched. This changes the packet formatting in several of distributed's helper classes.
This commit is contained in:
parent
167c6dcafa
commit
f76b8a6ad8
@ -514,15 +514,9 @@ receive_update_broadcast_required_owner(PyObject *distobj,
|
|||||||
for (int i = 0; i < num_fields && !PyErr_Occurred(); ++i) {
|
for (int i = 0; i < num_fields && !PyErr_Occurred(); ++i) {
|
||||||
DCField *field = get_inherited_field(i);
|
DCField *field = get_inherited_field(i);
|
||||||
if (field->as_molecular_field() == (DCMolecularField *)NULL &&
|
if (field->as_molecular_field() == (DCMolecularField *)NULL &&
|
||||||
field->is_required()) {
|
field->is_required() && (field->is_ownrecv() || field->is_broadcast())) {
|
||||||
packer.begin_unpack(field);
|
packer.begin_unpack(field);
|
||||||
if (field->is_ownrecv()) {
|
field->receive_update(packer, distobj);
|
||||||
field->receive_update(packer, distobj);
|
|
||||||
} else {
|
|
||||||
// It's not an ownrecv field; skip over it. It's difficult to filter
|
|
||||||
// this on the server, ask Roger for the reason.
|
|
||||||
packer.unpack_skip();
|
|
||||||
}
|
|
||||||
if (!packer.end_unpack()) {
|
if (!packer.end_unpack()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -951,14 +945,12 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id,
|
|||||||
packer.raw_pack_uint16(STATESERVER_CREATE_OBJECT_WITH_REQUIRED);
|
packer.raw_pack_uint16(STATESERVER_CREATE_OBJECT_WITH_REQUIRED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
packer.raw_pack_uint32(do_id);
|
||||||
// Parent is a bit overloaded; this parent is not about inheritance, this
|
// Parent is a bit overloaded; this parent is not about inheritance, this
|
||||||
// one is about the visibility container parent, i.e. the zone parent:
|
// one is about the visibility container parent, i.e. the zone parent:
|
||||||
if (parent_id) {
|
packer.raw_pack_uint32(parent_id);
|
||||||
packer.raw_pack_uint32(parent_id);
|
|
||||||
}
|
|
||||||
packer.raw_pack_uint32(zone_id);
|
packer.raw_pack_uint32(zone_id);
|
||||||
packer.raw_pack_uint16(_number);
|
packer.raw_pack_uint16(_number);
|
||||||
packer.raw_pack_uint32(do_id);
|
|
||||||
|
|
||||||
// Specify all of the required fields.
|
// Specify all of the required fields.
|
||||||
int num_fields = get_num_inherited_fields();
|
int num_fields = get_num_inherited_fields();
|
||||||
@ -1009,77 +1001,6 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id,
|
|||||||
return Datagram(packer.get_data(), packer.get_length());
|
return Datagram(packer.get_data(), packer.get_length());
|
||||||
}
|
}
|
||||||
#endif // HAVE_PYTHON
|
#endif // HAVE_PYTHON
|
||||||
#ifdef HAVE_PYTHON
|
|
||||||
/**
|
|
||||||
* Generates a datagram containing the message necessary to create a new
|
|
||||||
* database distributed object from the AI.
|
|
||||||
*
|
|
||||||
* First Pass is to only include required values (with Defaults).
|
|
||||||
*/
|
|
||||||
Datagram DCClass::
|
|
||||||
ai_database_generate_context(
|
|
||||||
unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id,
|
|
||||||
CHANNEL_TYPE owner_channel,
|
|
||||||
CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const
|
|
||||||
{
|
|
||||||
DCPacker packer;
|
|
||||||
packer.raw_pack_uint8(1);
|
|
||||||
packer.RAW_PACK_CHANNEL(database_server_id);
|
|
||||||
packer.RAW_PACK_CHANNEL(from_channel_id);
|
|
||||||
// packer.raw_pack_uint8('A');
|
|
||||||
packer.raw_pack_uint16(STATESERVER_OBJECT_ENTER_WITH_REQUIRED_CONTEXT);
|
|
||||||
packer.raw_pack_uint32(parent_id);
|
|
||||||
packer.raw_pack_uint32(zone_id);
|
|
||||||
packer.RAW_PACK_CHANNEL(owner_channel);
|
|
||||||
packer.raw_pack_uint16(_number); // DCD class ID
|
|
||||||
packer.raw_pack_uint32(context_id);
|
|
||||||
|
|
||||||
// Specify all of the required fields.
|
|
||||||
int num_fields = get_num_inherited_fields();
|
|
||||||
for (int i = 0; i < num_fields; ++i) {
|
|
||||||
DCField *field = get_inherited_field(i);
|
|
||||||
if (field->is_required() && field->as_molecular_field() == NULL) {
|
|
||||||
packer.begin_pack(field);
|
|
||||||
packer.pack_default_value();
|
|
||||||
packer.end_pack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Datagram(packer.get_data(), packer.get_length());
|
|
||||||
}
|
|
||||||
#endif // HAVE_PYTHON
|
|
||||||
|
|
||||||
#ifdef HAVE_PYTHON
|
|
||||||
Datagram DCClass::
|
|
||||||
ai_database_generate_context_old(
|
|
||||||
unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id,
|
|
||||||
CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const
|
|
||||||
{
|
|
||||||
DCPacker packer;
|
|
||||||
packer.raw_pack_uint8(1);
|
|
||||||
packer.RAW_PACK_CHANNEL(database_server_id);
|
|
||||||
packer.RAW_PACK_CHANNEL(from_channel_id);
|
|
||||||
// packer.raw_pack_uint8('A');
|
|
||||||
packer.raw_pack_uint16(STATESERVER_OBJECT_ENTER_WITH_REQUIRED_CONTEXT);
|
|
||||||
packer.raw_pack_uint32(parent_id);
|
|
||||||
packer.raw_pack_uint32(zone_id);
|
|
||||||
packer.raw_pack_uint16(_number); // DCD class ID
|
|
||||||
packer.raw_pack_uint32(context_id);
|
|
||||||
|
|
||||||
// Specify all of the required fields.
|
|
||||||
int num_fields = get_num_inherited_fields();
|
|
||||||
for (int i = 0; i < num_fields; ++i) {
|
|
||||||
DCField *field = get_inherited_field(i);
|
|
||||||
if (field->is_required() && field->as_molecular_field() == NULL) {
|
|
||||||
packer.begin_pack(field);
|
|
||||||
packer.pack_default_value();
|
|
||||||
packer.end_pack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Datagram(packer.get_data(), packer.get_length());
|
|
||||||
}
|
|
||||||
#endif // HAVE_PYTHON
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a string representation of this instance to <out>.
|
* Write a string representation of this instance to <out>.
|
||||||
|
@ -117,11 +117,6 @@ PUBLISHED:
|
|||||||
Datagram client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id,
|
Datagram client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id,
|
||||||
ZONEID_TYPE zone_id, PyObject *optional_fields) const;
|
ZONEID_TYPE zone_id, PyObject *optional_fields) const;
|
||||||
|
|
||||||
Datagram ai_database_generate_context(unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id, CHANNEL_TYPE owner_channel,
|
|
||||||
CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const;
|
|
||||||
Datagram ai_database_generate_context_old(unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id,
|
|
||||||
CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -146,8 +146,6 @@ class DistributedObjectAI(DistributedObjectBase):
|
|||||||
barrier.cleanup()
|
barrier.cleanup()
|
||||||
self.__barriers = {}
|
self.__barriers = {}
|
||||||
|
|
||||||
self.air.stopTrackRequestDeletedDO(self)
|
|
||||||
|
|
||||||
# DCR: I've re-enabled this block of code so that Toontown's
|
# DCR: I've re-enabled this block of code so that Toontown's
|
||||||
# AI won't leak channels.
|
# AI won't leak channels.
|
||||||
# Let me know if it causes trouble.
|
# Let me know if it causes trouble.
|
||||||
@ -155,10 +153,9 @@ class DistributedObjectAI(DistributedObjectBase):
|
|||||||
### block until a solution is thought out of how to prevent
|
### block until a solution is thought out of how to prevent
|
||||||
### this delete message or to handle this message better
|
### this delete message or to handle this message better
|
||||||
# TODO: do we still need this check?
|
# TODO: do we still need this check?
|
||||||
if not hasattr(self, "doNotDeallocateChannel"):
|
if not getattr(self, "doNotDeallocateChannel", False):
|
||||||
if self.air and not hasattr(self.air, "doNotDeallocateChannel"):
|
if self.air:
|
||||||
if self.air.minChannel <= self.doId <= self.air.maxChannel:
|
self.air.deallocateChannel(self.doId)
|
||||||
self.air.deallocateChannel(self.doId)
|
|
||||||
self.air = None
|
self.air = None
|
||||||
|
|
||||||
self.parentId = None
|
self.parentId = None
|
||||||
@ -200,9 +197,6 @@ class DistributedObjectAI(DistributedObjectBase):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def addInterest(self, zoneId, note="", event=None):
|
|
||||||
self.air.addInterest(self.doId, zoneId, note, event)
|
|
||||||
|
|
||||||
def b_setLocation(self, parentId, zoneId):
|
def b_setLocation(self, parentId, zoneId):
|
||||||
self.d_setLocation(parentId, zoneId)
|
self.d_setLocation(parentId, zoneId)
|
||||||
self.setLocation(parentId, zoneId)
|
self.setLocation(parentId, zoneId)
|
||||||
@ -274,9 +268,6 @@ class DistributedObjectAI(DistributedObjectBase):
|
|||||||
|
|
||||||
dclass.receiveUpdateOther(self, di)
|
dclass.receiveUpdateOther(self, di)
|
||||||
|
|
||||||
def sendSetZone(self, zoneId):
|
|
||||||
self.air.sendSetZone(self, zoneId)
|
|
||||||
|
|
||||||
def startMessageBundle(self, name):
|
def startMessageBundle(self, name):
|
||||||
self.air.startMessageBundle(name)
|
self.air.startMessageBundle(name)
|
||||||
def sendMessageBundle(self):
|
def sendMessageBundle(self):
|
||||||
@ -349,10 +340,10 @@ class DistributedObjectAI(DistributedObjectBase):
|
|||||||
self.air.sendUpdate(self, fieldName, args)
|
self.air.sendUpdate(self, fieldName, args)
|
||||||
|
|
||||||
def GetPuppetConnectionChannel(self, doId):
|
def GetPuppetConnectionChannel(self, doId):
|
||||||
return doId + (1 << 32)
|
return doId + (1001L << 32)
|
||||||
|
|
||||||
def GetAccountConnectionChannel(self, doId):
|
def GetAccountConnectionChannel(self, doId):
|
||||||
return doId + (3 << 32)
|
return doId + (1003L << 32)
|
||||||
|
|
||||||
def GetAccountIDFromChannelCode(self, channel):
|
def GetAccountIDFromChannelCode(self, channel):
|
||||||
return channel >> 32
|
return channel >> 32
|
||||||
@ -482,7 +473,6 @@ class DistributedObjectAI(DistributedObjectBase):
|
|||||||
(self.__class__, doId))
|
(self.__class__, doId))
|
||||||
return
|
return
|
||||||
self.air.requestDelete(self)
|
self.air.requestDelete(self)
|
||||||
self.air.startTrackRequestDeletedDO(self)
|
|
||||||
self._DOAI_requestedDelete = True
|
self._DOAI_requestedDelete = True
|
||||||
|
|
||||||
def taskName(self, taskString):
|
def taskName(self, taskString):
|
||||||
@ -581,3 +571,5 @@ class DistributedObjectAI(DistributedObjectBase):
|
|||||||
""" This is a no-op on the AI. """
|
""" This is a no-op on the AI. """
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def setAI(self, aiChannel):
|
||||||
|
self.air.setAI(self.doId, aiChannel)
|
||||||
|
@ -270,10 +270,10 @@ class DistributedObjectUD(DistributedObjectBase):
|
|||||||
self.air.sendUpdate(self, fieldName, args)
|
self.air.sendUpdate(self, fieldName, args)
|
||||||
|
|
||||||
def GetPuppetConnectionChannel(self, doId):
|
def GetPuppetConnectionChannel(self, doId):
|
||||||
return doId + (1 << 32)
|
return doId + (1001L << 32)
|
||||||
|
|
||||||
def GetAccountConnectionChannel(self, doId):
|
def GetAccountConnectionChannel(self, doId):
|
||||||
return doId + (3 << 32)
|
return doId + (1003L << 32)
|
||||||
|
|
||||||
def GetAccountIDFromChannelCode(self, channel):
|
def GetAccountIDFromChannelCode(self, channel):
|
||||||
return channel >> 32
|
return channel >> 32
|
||||||
|
@ -111,7 +111,7 @@ class DoInterestManager(DirectObject.DirectObject):
|
|||||||
self._allInterestsCompleteCallbacks = []
|
self._allInterestsCompleteCallbacks = []
|
||||||
|
|
||||||
def __verbose(self):
|
def __verbose(self):
|
||||||
return self.InterestDebug or self.getVerbose()
|
return self.InterestDebug.getValue() or self.getVerbose()
|
||||||
|
|
||||||
def _getAnonymousEvent(self, desc):
|
def _getAnonymousEvent(self, desc):
|
||||||
return 'anonymous-%s-%s' % (desc, DoInterestManager._SerialGen.next())
|
return 'anonymous-%s-%s' % (desc, DoInterestManager._SerialGen.next())
|
||||||
@ -504,18 +504,23 @@ class DoInterestManager(DirectObject.DirectObject):
|
|||||||
'trying to set interest to invalid parent: %s' % parentId)
|
'trying to set interest to invalid parent: %s' % parentId)
|
||||||
datagram = PyDatagram()
|
datagram = PyDatagram()
|
||||||
# Add message type
|
# Add message type
|
||||||
datagram.addUint16(CLIENT_ADD_INTEREST)
|
|
||||||
datagram.addUint16(handle)
|
|
||||||
datagram.addUint32(contextId)
|
|
||||||
datagram.addUint32(parentId)
|
|
||||||
if isinstance(zoneIdList, list):
|
if isinstance(zoneIdList, list):
|
||||||
vzl = list(zoneIdList)
|
vzl = list(zoneIdList)
|
||||||
vzl.sort()
|
vzl.sort()
|
||||||
uniqueElements(vzl)
|
uniqueElements(vzl)
|
||||||
|
datagram.addUint16(CLIENT_ADD_INTEREST_MULTIPLE)
|
||||||
|
datagram.addUint32(contextId)
|
||||||
|
datagram.addUint16(handle)
|
||||||
|
datagram.addUint32(parentId)
|
||||||
|
datagram.addUint16(len(vzl))
|
||||||
for zone in vzl:
|
for zone in vzl:
|
||||||
datagram.addUint32(zone)
|
datagram.addUint32(zone)
|
||||||
else:
|
else:
|
||||||
datagram.addUint32(zoneIdList)
|
datagram.addUint16(CLIENT_ADD_INTEREST)
|
||||||
|
datagram.addUint32(contextId)
|
||||||
|
datagram.addUint16(handle)
|
||||||
|
datagram.addUint32(parentId)
|
||||||
|
datagram.addUint32(zoneIdList)
|
||||||
self.send(datagram)
|
self.send(datagram)
|
||||||
|
|
||||||
def _sendRemoveInterest(self, handle, contextId):
|
def _sendRemoveInterest(self, handle, contextId):
|
||||||
@ -530,9 +535,8 @@ class DoInterestManager(DirectObject.DirectObject):
|
|||||||
datagram = PyDatagram()
|
datagram = PyDatagram()
|
||||||
# Add message type
|
# Add message type
|
||||||
datagram.addUint16(CLIENT_REMOVE_INTEREST)
|
datagram.addUint16(CLIENT_REMOVE_INTEREST)
|
||||||
|
datagram.addUint32(contextId)
|
||||||
datagram.addUint16(handle)
|
datagram.addUint16(handle)
|
||||||
if contextId != 0:
|
|
||||||
datagram.addUint32(contextId)
|
|
||||||
self.send(datagram)
|
self.send(datagram)
|
||||||
if __debug__:
|
if __debug__:
|
||||||
state = DoInterestManager._interests[handle]
|
state = DoInterestManager._interests[handle]
|
||||||
@ -583,8 +587,8 @@ class DoInterestManager(DirectObject.DirectObject):
|
|||||||
This handles the interest done messages and may dispatch an event
|
This handles the interest done messages and may dispatch an event
|
||||||
"""
|
"""
|
||||||
assert DoInterestManager.notify.debugCall()
|
assert DoInterestManager.notify.debugCall()
|
||||||
handle = di.getUint16()
|
|
||||||
contextId = di.getUint32()
|
contextId = di.getUint32()
|
||||||
|
handle = di.getUint16()
|
||||||
if self.__verbose():
|
if self.__verbose():
|
||||||
print('CR::INTEREST.interestDone(handle=%s)' % handle)
|
print('CR::INTEREST.interestDone(handle=%s)' % handle)
|
||||||
DoInterestManager.notify.debug(
|
DoInterestManager.notify.debug(
|
||||||
|
@ -7,7 +7,7 @@ from panda3d.core import Datagram
|
|||||||
from panda3d.direct import *
|
from panda3d.direct import *
|
||||||
# Import the type numbers
|
# Import the type numbers
|
||||||
|
|
||||||
#from otp.ai.AIMsgTypes import *
|
from direct.distributed.MsgTypes import *
|
||||||
|
|
||||||
class PyDatagram(Datagram):
|
class PyDatagram(Datagram):
|
||||||
|
|
||||||
@ -47,13 +47,10 @@ class PyDatagram(Datagram):
|
|||||||
self.addUint16(code)
|
self.addUint16(code)
|
||||||
|
|
||||||
|
|
||||||
# def addServerControlHeader(self, code):
|
def addServerControlHeader(self, code):
|
||||||
# self.addInt8(1)
|
self.addInt8(1)
|
||||||
# self.addChannel(CONTROL_MESSAGE)
|
self.addChannel(CONTROL_CHANNEL)
|
||||||
# self.addUint16(code)
|
self.addUint16(code)
|
||||||
# def addOldServerControlHeader(self, code):
|
|
||||||
# self.addChannel(CONTROL_MESSAGE)
|
|
||||||
# self.addUint16(code)
|
|
||||||
|
|
||||||
def putArg(self, arg, subatomicType, divisor=1):
|
def putArg(self, arg, subatomicType, divisor=1):
|
||||||
if (divisor == 1):
|
if (divisor == 1):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user