More work on OTP support

This commit is contained in:
Open Toontown 2022-01-01 20:56:58 -05:00
parent 9015c58e81
commit ab97006ebb
2 changed files with 51 additions and 55 deletions

View File

@ -3,6 +3,8 @@ by the CMU ServerRepository/ClientRepository code in this directory.
It replaces the MsgTypes module, which is not used by the CMU
implementation. """
from panda3d.core import ConfigVariableBool
from direct.showbase.PythonUtil import invertDictLossless
MsgName2Id = {
@ -18,10 +20,13 @@ MsgName2Id = {
'OBJECT_SET_ZONE_CMU' : 9010,
'CLIENT_HEARTBEAT_CMU' : 9011,
'CLIENT_OBJECT_UPDATE_FIELD_TARGETED_CMU' : 9011,
'CLIENT_OBJECT_UPDATE_FIELD' : 120, # Matches MsgTypes.CLIENT_OBJECT_SET_FIELD
}
if ConfigVariableBool('astron-support', True):
MsgName2Id['CLIENT_OBJECT_UPDATE_FIELD'] = 120 # Matches MsgTypes.CLIENT_OBJECT_SET_FIELD
else:
MsgName2Id['CLIENT_OBJECT_UPDATE_FIELD'] = 24 # Matches MsgTypes.CLIENT_OBJECT_UPDATE_FIELD
# create id->name table for debugging
MsgId2Names = invertDictLossless(MsgName2Id)

View File

@ -303,61 +303,43 @@ check_datagram() {
return true;
}
// FIXME: This is despicable...
// There must be a better way of doing
// this...
if (astron_support) { // Astron
switch (_msg_type) {
unsigned int client_update_msg;
unsigned int stateserver_update_msg;
if (astron_support)
{
client_update_msg = CLIENT_OBJECT_SET_FIELD;
stateserver_update_msg = STATESERVER_OBJECT_SET_FIELD;
}
else
{
client_update_msg = CLIENT_OBJECT_UPDATE_FIELD;
stateserver_update_msg = STATESERVER_OBJECT_UPDATE_FIELD;
}
switch (_msg_type) {
#ifdef HAVE_PYTHON
case CLIENT_OBJECT_SET_FIELD:
case STATESERVER_OBJECT_SET_FIELD:
if (_handle_c_updates) {
if (_has_owner_view) {
if (!handle_update_field_owner()) {
return false;
}
} else {
if (!handle_update_field()) {
return false;
}
case client_update_msg:
case stateserver_update_msg:
if (_handle_c_updates) {
if (_has_owner_view) {
if (!handle_update_field_owner()) {
return false;
}
} else {
// Let the caller (Python) deal with this update.
return true;
}
break;
#endif // HAVE_PYTHON
default:
// Some unknown message; let the caller deal with it.
return true;
}
} else { // OTP
switch (_msg_type) {
#ifdef HAVE_PYTHON
case CLIENT_OBJECT_UPDATE_FIELD:
case STATESERVER_OBJECT_UPDATE_FIELD:
if (_handle_c_updates) {
if (_has_owner_view) {
if (!handle_update_field_owner()) {
return false;
}
} else {
if (!handle_update_field()) {
return false;
}
if (!handle_update_field()) {
return false;
}
} else {
// Let the caller (Python) deal with this update.
return true;
}
break;
#endif // HAVE_PYTHON
default:
// Some unknown message; let the caller deal with it.
} else {
// Let the caller (Python) deal with this update.
return true;
}
break;
#endif // HAVE_PYTHON
default:
// Some unknown message; let the caller deal with it.
return true;
}
}
@ -522,7 +504,10 @@ send_message_bundle(unsigned int channel, unsigned int sender_channel) {
dg.add_int8(1);
dg.add_uint64(channel);
dg.add_uint64(sender_channel);
//dg.add_uint16(STATESERVER_BOUNCE_MESSAGE);
if (!astron_support)
{
dg.add_uint16(STATESERVER_BOUNCE_MESSAGE);
}
// add each bundled message
BundledMsgVector::const_iterator bmi;
for (bmi = _bundle_msgs.begin(); bmi != _bundle_msgs.end(); bmi++) {
@ -930,17 +915,23 @@ describe_message(std::ostream &out, const string &prefix,
packer.RAW_UNPACK_CHANNEL(); // msg_sender
msg_type = packer.raw_unpack_uint16();
if (astron_support) {
if (astron_support)
{
is_update = (msg_type == STATESERVER_OBJECT_SET_FIELD);
} else {
}
else
{
is_update = (msg_type == STATESERVER_OBJECT_UPDATE_FIELD);
}
} else {
msg_type = packer.raw_unpack_uint16();
if (astron_support) {
if (astron_support)
{
is_update = (msg_type == CLIENT_OBJECT_SET_FIELD);
} else {
}
else
{
is_update = (msg_type == CLIENT_OBJECT_UPDATE_FIELD);
}
}