chat: Replace DistributedChatManager in the DC file with ChatAgent. Route chat messages through it instead.
This commit is contained in:
parent
50071028f7
commit
8efe836673
10 changed files with 54 additions and 268 deletions
|
@ -16,6 +16,10 @@ uberdogs:
|
|||
id: 4665
|
||||
anonymous: true
|
||||
|
||||
- class: ChatAgent
|
||||
id: 4681
|
||||
anonymous: false
|
||||
|
||||
- class: FriendManager
|
||||
id: 4501
|
||||
anonymous: false
|
||||
|
|
|
@ -21,7 +21,7 @@ from otp.distributed import DistributedTestObject/AI
|
|||
from otp.snapshot import SnapshotDispatcher/AI/UD
|
||||
from otp.snapshot import SnapshotRenderer/AI/UD
|
||||
from otp.uberdog import OtpAvatarManager/AI/UD
|
||||
from otp.uberdog import DistributedChatManager/AI/UD
|
||||
from otp.chat import ChatAgent/UD
|
||||
from otp.uberdog import SpeedchatRelay/UD
|
||||
from otp.distributed import CentralLogger/AI/UD
|
||||
from otp.web import SettingsMgr/AI/UD
|
||||
|
@ -268,34 +268,9 @@ dclass OtpAvatarManager : DistributedObject {
|
|||
shareAvatarResponse(uint32, uint32, uint8);
|
||||
};
|
||||
|
||||
dclass DistributedChatManager : DistributedObject {
|
||||
online();
|
||||
dclass ChatAgent : DistributedObject {
|
||||
adminChat(uint32, string);
|
||||
setAvatarLocation(uint32, uint32, uint32);
|
||||
setAvatarCrew(uint32, uint32);
|
||||
setAvatarGuild(uint32, uint32);
|
||||
chatParentId(uint32) airecv clsend;
|
||||
chatZoneId(uint32) airecv clsend;
|
||||
chatFace(uint32) airecv clsend;
|
||||
chatEmote(uint16) airecv clsend;
|
||||
chatEmoteTarget(uint32) airecv clsend;
|
||||
chatIndex(uint16) airecv clsend;
|
||||
chatString(string(0-256)) airecv clsend;
|
||||
chatToAvatarIndex : chatZoneId, chatIndex;
|
||||
chatParentZoneFaceEmoteWithTargetIndex : chatParentId, chatZoneId, chatFace, chatEmote, chatEmoteTarget, chatIndex;
|
||||
chatToAvatarString : chatZoneId, chatString;
|
||||
chatParentZoneFaceEmoteWithTargetString : chatParentId, chatZoneId, chatFace, chatEmote, chatEmoteTarget, chatString;
|
||||
speedChatTo(uint16) airecv clsend;
|
||||
speedChatFrom(uint32, uint16);
|
||||
speedChatCustomTo(uint16) airecv clsend;
|
||||
speedChatCustomFrom(uint32, uint16);
|
||||
whisperSCTo(uint32, uint16) airecv clsend;
|
||||
whisperSCFrom(uint32, uint16);
|
||||
whisperSCCustomTo(uint32, uint16) airecv clsend;
|
||||
whisperSCCustomFrom(uint32, uint16);
|
||||
whisperSCEmoteTo(uint32, uint16) airecv clsend;
|
||||
whisperSCEmoteFrom(uint32, uint16);
|
||||
whisperIgnored(uint32);
|
||||
chatMessage(string(0-256)) clsend;
|
||||
};
|
||||
|
||||
dclass FriendManager : DistributedObject {
|
||||
|
|
22
otp/chat/ChatAgent.py
Normal file
22
otp/chat/ChatAgent.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from direct.distributed.DistributedObjectGlobal import DistributedObjectGlobal
|
||||
from pandac.PandaModules import *
|
||||
from otp.otpbase import OTPGlobals
|
||||
|
||||
class ChatAgent(DistributedObjectGlobal):
|
||||
def __init__(self, cr):
|
||||
DistributedObjectGlobal.__init__(self, cr)
|
||||
self.notify.warning('ChatAgent going online')
|
||||
|
||||
def delete(self):
|
||||
self.ignoreAll()
|
||||
self.notify.warning('ChatAgent going offline')
|
||||
self.cr.chatManager = None
|
||||
DistributedObjectGlobal.delete(self)
|
||||
return
|
||||
|
||||
def adminChat(self, aboutId, message):
|
||||
self.notify.warning('Admin Chat(%s): %s' % (aboutId, message))
|
||||
messenger.send('adminChat', [aboutId, message])
|
||||
|
||||
def sendChatMessage(self, message):
|
||||
self.sendUpdate('chatMessage', [message])
|
20
otp/chat/ChatAgentUD.py
Normal file
20
otp/chat/ChatAgentUD.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.distributed.DistributedObjectGlobalUD import DistributedObjectGlobalUD
|
||||
|
||||
class ChatAgentUD(DistributedObjectGlobalUD):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("ChatAgentUD")
|
||||
|
||||
def chatMessage(self, message):
|
||||
sender = self.air.getAvatarIdFromSender()
|
||||
if sender == 0:
|
||||
self.air.writeServerEvent('suspicious', self.air.getAccountIdFromSender(),
|
||||
'Account sent chat without an avatar', message)
|
||||
return
|
||||
|
||||
# TODO: The above is probably a little too ugly for my taste... Maybe AIR
|
||||
# should be given an API for sending updates for unknown objects?
|
||||
DistributedAvatar = self.air.dclassesByName['DistributedAvatarUD']
|
||||
dg = DistributedAvatar.aiFormatUpdate('setTalk', sender, sender,
|
||||
self.air.ourChannel,
|
||||
[0, 0, '', message, [], 0])
|
||||
self.air.send(dg)
|
|
@ -619,12 +619,7 @@ class TalkAssistant(DirectObject.DirectObject):
|
|||
chatFlags = CFSpeech | CFTimeout
|
||||
if self.isThought(message):
|
||||
chatFlags = CFThought
|
||||
base.localAvatar.sendUpdate('setTalk', [0,
|
||||
0,
|
||||
'',
|
||||
message,
|
||||
[],
|
||||
0])
|
||||
base.cr.chatAgent.sendChatMessage(message)
|
||||
messenger.send('chatUpdate', [message, chatFlags])
|
||||
return error
|
||||
|
||||
|
|
|
@ -442,6 +442,7 @@ class OTPClientRepository(ClientRepositoryBase):
|
|||
self.wantSwitchboardHacks = base.config.GetBool('want-switchboard-hacks', 0)
|
||||
|
||||
self.centralLogger = self.generateGlobalObject(OtpDoGlobals.OTP_DO_ID_CENTRAL_LOGGER, 'CentralLogger')
|
||||
self.chatAgent = self.generateGlobalObject(OtpDoGlobals.OTP_DO_ID_CHAT_MANAGER, 'ChatAgent')
|
||||
self.csm = None # To be set by subclass.
|
||||
|
||||
def startLeakDetector(self):
|
||||
|
|
|
@ -1,84 +0,0 @@
|
|||
from direct.distributed.DistributedObject import DistributedObject
|
||||
from direct.distributed.DistributedObjectGlobal import DistributedObjectGlobal
|
||||
from pandac.PandaModules import *
|
||||
from otp.otpbase import OTPGlobals
|
||||
|
||||
class DistributedChatManager(DistributedObjectGlobal):
|
||||
|
||||
def __init__(self, cr):
|
||||
DistributedObjectGlobal.__init__(self, cr)
|
||||
self.notify.warning('ChatManager going online')
|
||||
|
||||
def delete(self):
|
||||
self.ignoreAll()
|
||||
self.notify.warning('ChatManager going offline')
|
||||
self.cr.chatManager = None
|
||||
DistributedObjectGlobal.delete(self)
|
||||
return
|
||||
|
||||
def online(self):
|
||||
pass
|
||||
|
||||
def adminChat(self, aboutId, message):
|
||||
self.notify.warning('Admin Chat(%s): %s' % (aboutId, message))
|
||||
messenger.send('adminChat', [aboutId, message])
|
||||
|
||||
def sendChatTo(self, message, chatFlags):
|
||||
self.sendUpdate('chatTo', [message, chatFlags])
|
||||
|
||||
def chatFrom(self, fromId, message, chatFlags):
|
||||
pass
|
||||
|
||||
def sendSpeedChatTo(self, msgIndex):
|
||||
self.sendUpdate('speedChatTo', [msgIndex])
|
||||
|
||||
def speedChatFrom(self, fromId, msgIndex):
|
||||
pass
|
||||
|
||||
def sendSpeedChatCustomTo(self, msgIndex):
|
||||
self.sendUpdate('speedChatCustomTo', [msgIndex])
|
||||
|
||||
def speedChatCustomFrom(self, fromId, msgIndex):
|
||||
pass
|
||||
|
||||
def sendWhisperTo(self, toId, message):
|
||||
self.sendUpdate('whisperTo', [toId, message])
|
||||
|
||||
def whisperFrom(self, fromId, message):
|
||||
if base.cr.wantSwitchboardHacks:
|
||||
print 'received whisper on avatar: %s' % message
|
||||
whisper = WhisperPopup(message, OTPGlobals.getInterfaceFont(), WhisperPopup.WTNormal)
|
||||
whisper.manage(base.marginManager)
|
||||
|
||||
def sendWhisperSCTo(self, toId, msgIndex):
|
||||
self.sendUpdate('whisperSCTo', [toId, msgIndex])
|
||||
|
||||
def whisperSCFrom(self, fromId, msgIndex):
|
||||
pass
|
||||
|
||||
def sendWhisperSCCustomTo(self, toId, msgIndex):
|
||||
self.sendUpdate('whisperSCCustomTo', [toId, msgIndex])
|
||||
|
||||
def whisperSCCustomFrom(self, fromId, msgIndex):
|
||||
pass
|
||||
|
||||
def sendWhisperSCEmoteTo(self, toId, emoteId):
|
||||
self.sendUpdate('whisperSCEmoteTo', [toId, emoteId])
|
||||
|
||||
def whisperSCEmoteFrom(self, fromId, emoteId):
|
||||
pass
|
||||
|
||||
def whisperIgnored(self, fromId):
|
||||
pass
|
||||
|
||||
def sendCrewChatTo(self, message):
|
||||
self.sendUpdate('crewChatTo', [message])
|
||||
|
||||
def crewChatFrom(self, fromId, message):
|
||||
pass
|
||||
|
||||
def sendGuildChatTo(self, message):
|
||||
self.sendUpdate('guildChatTo', [message])
|
||||
|
||||
def guildChatFrom(self, fromId, message):
|
||||
pass
|
|
@ -1,75 +0,0 @@
|
|||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
||||
|
||||
class DistributedChatManagerAI(DistributedObjectAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedChatManagerAI")
|
||||
|
||||
def online(self):
|
||||
pass
|
||||
|
||||
def adminChat(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def setAvatarLocation(self, todo0, todo1, todo2):
|
||||
pass
|
||||
|
||||
def setAvatarCrew(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def setAvatarGuild(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def chatParentId(self, todo0):
|
||||
pass
|
||||
|
||||
def chatZoneId(self, todo0):
|
||||
pass
|
||||
|
||||
def chatFace(self, todo0):
|
||||
pass
|
||||
|
||||
def chatEmote(self, todo0):
|
||||
pass
|
||||
|
||||
def chatEmoteTarget(self, todo0):
|
||||
pass
|
||||
|
||||
def chatIndex(self, todo0):
|
||||
pass
|
||||
|
||||
def chatString(self, todo0):
|
||||
pass
|
||||
|
||||
def speedChatTo(self, todo0):
|
||||
pass
|
||||
|
||||
def speedChatFrom(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def speedChatCustomTo(self, todo0):
|
||||
pass
|
||||
|
||||
def speedChatCustomFrom(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def whisperSCTo(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def whisperSCFrom(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def whisperSCCustomTo(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def whisperSCCustomFrom(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def whisperSCEmoteTo(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def whisperSCEmoteFrom(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def whisperIgnored(self, todo0):
|
||||
pass
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.distributed.DistributedObjectUD import DistributedObjectUD
|
||||
|
||||
class DistributedChatManagerUD(DistributedObjectUD):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedChatManagerUD")
|
||||
|
||||
def online(self):
|
||||
pass
|
||||
|
||||
def adminChat(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def setAvatarLocation(self, todo0, todo1, todo2):
|
||||
pass
|
||||
|
||||
def setAvatarCrew(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def setAvatarGuild(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def chatParentId(self, todo0):
|
||||
pass
|
||||
|
||||
def chatZoneId(self, todo0):
|
||||
pass
|
||||
|
||||
def chatFace(self, todo0):
|
||||
pass
|
||||
|
||||
def chatEmote(self, todo0):
|
||||
pass
|
||||
|
||||
def chatEmoteTarget(self, todo0):
|
||||
pass
|
||||
|
||||
def chatIndex(self, todo0):
|
||||
pass
|
||||
|
||||
def chatString(self, todo0):
|
||||
pass
|
||||
|
||||
def speedChatTo(self, todo0):
|
||||
pass
|
||||
|
||||
def speedChatFrom(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def speedChatCustomTo(self, todo0):
|
||||
pass
|
||||
|
||||
def speedChatCustomFrom(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def whisperSCTo(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def whisperSCFrom(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def whisperSCCustomTo(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def whisperSCCustomFrom(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def whisperSCEmoteTo(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def whisperSCEmoteFrom(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def whisperIgnored(self, todo0):
|
||||
pass
|
||||
|
|
@ -21,3 +21,6 @@ class ToontownUberRepository(ToontownInternalRepository):
|
|||
|
||||
self.csm = simbase.air.generateGlobalObject(OTP_DO_ID_CLIENT_SERVICES_MANAGER,
|
||||
'ClientServicesManager')
|
||||
|
||||
self.chatAgent = simbase.air.generateGlobalObject(OTP_DO_ID_CHAT_MANAGER,
|
||||
'ChatAgent')
|
||||
|
|
Loading…
Reference in a new issue