diff --git a/Sources/Plasma/Apps/plClient/plClient.cpp b/Sources/Plasma/Apps/plClient/plClient.cpp index 2eb8c1f1f7..5c8af209ba 100644 --- a/Sources/Plasma/Apps/plClient/plClient.cpp +++ b/Sources/Plasma/Apps/plClient/plClient.cpp @@ -110,7 +110,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plNetClient/plLinkEffectsMgr.h" #include "plNetClient/plNetLinkingMgr.h" #include "plNetClient/plNetClientMgr.h" -#include "plNetCommon/plNetCommonConstants.h" #include "plNetGameLib/plNetGameLib.h" #include "plPipeline/plCaptureRender.h" #include "plPipeline/plDTProgressMgr.h" diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp index 8124ae1d6d..0ca661a9a6 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp @@ -5270,7 +5270,6 @@ PF_CONSOLE_CMD(Age, ResetPythonSDL, "", "Resets the Python Age SDL") constexpr uint32_t writeOptions = plSDL::kDirtyOnly | plSDL::kBroadcast | plSDL::kTimeStampOnRead; plNetMsgSDLState* netMsg = rec->PrepNetMsg(0.f, writeOptions); - netMsg->SetNetProtocol(kNetProtocolCli2Game); netMsg->ObjectInfo()->SetUoid(sdlMod->GetStateOwnerKey()->GetUoid()); netMsg->SetPlayerID(plNetClientApp::GetInstance()->GetPlayerID()); plNetClientApp::GetInstance()->SendMsg(netMsg); diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp index 3e94fb4bc5..6b886075b8 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp @@ -506,7 +506,6 @@ PF_CONSOLE_CMD( Net, // groupName // send net msg plNetMsgObjectUpdateFilter netMsg; - netMsg.SetNetProtocol(kNetProtocolCli2Game); netMsg.SetMaxUpdateFreq(freq); netMsg.ObjectListInfo()->AddObject(key); plNetClientMgr::GetInstance()->SendMsg(&netMsg); diff --git a/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoaderPaging.cpp b/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoaderPaging.cpp index c055cb3862..235eafbfdc 100644 --- a/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoaderPaging.cpp +++ b/Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoaderPaging.cpp @@ -97,7 +97,6 @@ void plAgeLoader::FinishedPagingInRoom(plKey* rmKey, int numRms) // Send a msg to the server indicating that we have this room paged in plNetMsgPagingRoom * pagingMsg = new plNetMsgPagingRoom; - pagingMsg->SetNetProtocol(kNetProtocolCli2Game); int i; for(i=0;iGetPlayerID()); if (plNetClientApp::GetInstance()->GetFlagsBit(plNetClientApp::kEchoVoice)) @@ -309,7 +308,6 @@ void plVoiceRecorder::Update(double time) if (packedLength) { plNetMsgVoice pMsg; - pMsg.SetNetProtocol(kNetProtocolCli2Game); pMsg.SetVoiceData(packet.get(), packedLength); pMsg.SetPlayerID(plNetClientApp::GetInstance()->GetPlayerID()); pMsg.SetFlag(encoder->GetVoiceFlag()); diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp index 14488ac125..e491b5573d 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp @@ -1556,7 +1556,6 @@ bool plArmatureMod::IEval(double time, float elapsed, uint32_t dirty) { // Send message to the server here. plNetMsgRelevanceRegions relRegionsNetMsg; - relRegionsNetMsg.SetNetProtocol(kNetProtocolCli2Game); relRegionsNetMsg.SetRegionsICareAbout(fRegionsICareAbout); relRegionsNetMsg.SetRegionsImIn(fRegionsImIn); plNetClientApp::GetInstance()->SendMsg(&relRegionsNetMsg); diff --git a/Sources/Plasma/PubUtilLib/plModifier/plLogicModifier.cpp b/Sources/Plasma/PubUtilLib/plModifier/plLogicModifier.cpp index 67dba7095c..a6dbb09f21 100644 --- a/Sources/Plasma/PubUtilLib/plModifier/plLogicModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plModifier/plLogicModifier.cpp @@ -240,7 +240,6 @@ void plLogicModifier::UpdateSharedState(bool triggered) const ss.SetServerMayDelete(!lock); plNetMsgTestAndSet ts; - ts.SetNetProtocol(kNetProtocolCli2Game); ts.CopySharedState(&ss); ts.ObjectInfo()->SetFromKey(GetKey()); ts.SetLockRequest(lock); // if triggering, lock state, else unlock state diff --git a/Sources/Plasma/PubUtilLib/plModifier/plSDLModifier.cpp b/Sources/Plasma/PubUtilLib/plModifier/plSDLModifier.cpp index ff671dd2c2..882580fe89 100644 --- a/Sources/Plasma/PubUtilLib/plModifier/plSDLModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plModifier/plSDLModifier.cpp @@ -102,7 +102,6 @@ void plSDLModifier::ISendNetMsg(plStateDataRecord*& state, const plKey& senderKe // send to server plNetMsgSDLState* msg = state->PrepNetMsg(0, writeOptions); - msg->SetNetProtocol(kNetProtocolCli2Game); msg->ObjectInfo()->SetUoid(senderKey->GetUoid()); if (sendFlags & plSynchedObject::kNewState) diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp index e5791f7ace..054bc39788 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp @@ -315,7 +315,6 @@ void plNCAgeJoiner::ExecNextOp () { // Request initial SDL state plNetMsgGameStateRequest gsmsg; - gsmsg.SetNetProtocol(kNetProtocolCli2Game); gsmsg.SetBit(plNetMessage::kInitialAgeStateRequest); nc->SendMsg(&gsmsg); diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientCommInterface.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientCommInterface.cpp index 56e9a68d6f..1712f2b0ed 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientCommInterface.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientCommInterface.cpp @@ -41,34 +41,19 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com *==LICENSE==*/ #include "plNetClientMgr.h" -#include "plNetLinkingMgr.h" - -#include "plgDispatch.h" -#include "hsTimer.h" - -#include "plNetClientRecorder/plNetClientRecorder.h" -#include "plNetMessage/plNetMessage.h" - // // Code for interfacing with plNetClientComm library, which in turn // handles most client-server communication // - -plNetMsgHandler::Status plNetClientCommMsgHandler::HandleMessage(plNetMessage* msg) -{ - plNetClientMgr* nc=plNetClientMgr::GetInstance(); - return nc->fMsgHandler.ReceiveMsg(msg); -} - void plNetClientMgr::IInitNetClientComm() { NetCommActivatePostInitErrorHandler(); NetCommActivateMsgDispatchers(); ASSERT(!GetFlagsBit(kNetClientCommInited)); - fNetClientComm.SetDefaultHandler(&fNetClientCommMsgHandler); + fNetClientComm.SetMsgHandler(&fMsgHandler); SetFlagsBit(kNetClientCommInited); } @@ -78,5 +63,6 @@ void plNetClientMgr::IInitNetClientComm() // void plNetClientMgr::IDeInitNetClientComm() { + fNetClientComm.SetMsgHandler(nullptr); SetFlagsBit(kNetClientCommInited, false); } diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp index 54603d5329..2d6057708d 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp @@ -115,7 +115,6 @@ plNetClientMgr::plNetClientMgr() SetFlagsBit(kAllowAuthTimeOut); // fPlayerVault.SetPlayerName("SinglePlayer"); // in a MP game, this will be replaced with a player name like 'Atrus' - fTransport.SetNumChannels(kNetNumChannels); } // @@ -326,21 +325,13 @@ void plNetClientMgr::Init() // // Prepare to send. -// Update p2p transport groups and rcvrs list in some msgs -// Returns channel. +// Update rcvrs list in some msgs // -int plNetClientMgr::IPrepMsg(plNetMessage* msg) +void plNetClientMgr::IPrepMsg(plNetMessage* msg) { - // pick channel, prepare msg - int channel=kNetChanDefault; plNetMsgVoice* v=plNetMsgVoice::ConvertNoRef(msg); if (v) { // VOICE MSG - channel=kNetChanVoice; - - // compute new transport group (from talkList) if necessary - GetTalkList()->UpdateTransportGroup(this); - // update receivers list in voice msg based on talk list v->Receivers()->Clear(); int i; @@ -352,31 +343,6 @@ int plNetClientMgr::IPrepMsg(plNetMessage* msg) if (msg->IsBitSet(plNetMessage::kEchoBackToSender)) v->Receivers()->AddReceiverPlayerID(GetPlayerID()); } - else if (plNetMsgListenListUpdate::ConvertNoRef(msg)) - { // LISTEN LIST UPDATE MSG - channel=kNetChanListenListUpdate; - - // update transport group from rcvrs list, add p2p mbrs to trasnport group - fTransport.ClearChannelGrp(kNetChanListenListUpdate); - if (IsPeerToPeer()) - { - plNetMsgReceiversListHelper* rl = plNetMsgReceiversListHelper::ConvertNoRef(msg); - hsAssert(rl, "error converting msg to rcvrs list?"); - int i; - for(i=0;iGetNumReceivers();i++) - { - plNetTransportMember* tm = fTransport.GetMemberByID(rl->GetReceiverPlayerID(i)); - hsAssert(tm, "error finding transport mbr"); - if (tm->IsPeerToPeer()) - fTransport.SubscribeToChannelGrp(tm, kNetChanListenListUpdate); - } - } - } - else if( plNetMsgGameMessageDirected::ConvertNoRef( msg ) ) - { - channel = kNetChanDirectedMsg; - } - return channel; } // @@ -1227,7 +1193,6 @@ bool plNetClientMgr::IHandlePlayerPageMsg(plPlayerPageMsg *playerMsg) // notify server - NOTE: he might not still be around to get this... plNetMsgPlayerPage npp (playerKey->GetUoid(), playerMsg->fUnload); - npp.SetNetProtocol(kNetProtocolCli2Game); SendMsg(&npp); } else if (int idx; IsRemotePlayerKey(playerKey, &idx)) @@ -1269,7 +1234,6 @@ bool plNetClientMgr::IHandlePlayerPageMsg(plPlayerPageMsg *playerMsg) // notify server plNetMsgPlayerPage npp (playerKey->GetUoid(), playerMsg->fUnload); - npp.SetNetProtocol(kNetProtocolCli2Game); SendMsg(&npp); } else diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h index 63ec58f560..e8cad46975 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h @@ -81,25 +81,11 @@ class plCCRPetitionMsg; class plNetMsgPagingRoom; -struct plNetClientCommMsgHandler : plNetClientComm::MsgHandler { - plNetMsgHandler::Status HandleMessage(plNetMessage* msg) override; -}; - class plNetClientMgr : public plNetClientApp { private: typedef std::vector plKeyVec; public: - - enum NetChannels - { - kNetChanDefault, - kNetChanVoice, - kNetChanListenListUpdate, - kNetChanDirectedMsg, - kNetNumChannels - }; - enum DirectedSendFlags { kInterAgeMsg = 0x1 @@ -211,7 +197,7 @@ class plNetClientMgr : public plNetClientApp bool IUpdateListenList(double secs); void IHandleNetVoiceListMsg(plNetVoiceListMsg* msg); bool IApplyNewListenList(std::vector& newListenList, bool forceSynch); - int IPrepMsg(plNetMessage* msg); + void IPrepMsg(plNetMessage* msg); void IPlayerChangeAge(bool exiting, int32_t spawnPt); void IAddCloneRoom(); @@ -289,9 +275,6 @@ class plNetClientMgr : public plNetClientApp plKey GetLocalPlayerKey() const override { return fLocalPlayerKey; } plSynchedObject* GetLocalPlayer(bool forceLoad=false) const override; - - bool IsPeerToPeer() const { return false; } - bool IsConnected() const { return true; } void IncNumInitialSDLStates(); void ResetNumInitialSDLStates() { fNumInitialSDLStates=0; } @@ -383,8 +366,7 @@ class plNetClientMgr : public plNetClientApp private: plNetClientComm fNetClientComm; - plNetClientCommMsgHandler fNetClientCommMsgHandler; - + void IInitNetClientComm(); void IDeInitNetClientComm(); void INetClientCommOpStarted(uint32_t context); @@ -395,7 +377,6 @@ class plNetClientMgr : public plNetClientApp friend class plNetDniInfoSource; friend class plNetTalkList; friend class plNetClientMsgHandler; - friend struct plNetClientCommMsgHandler; }; #endif // PL_NET_CLIENT_inc diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp index 5ec2b71933..e295d3a677 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrSend.cpp @@ -80,7 +80,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com void plNetClientMgr::ISendMembersListRequest() { plNetMsgMembersListReq msg; - msg.SetNetProtocol(kNetProtocolCli2Game); SendMsg(&msg); } @@ -91,7 +90,6 @@ void plNetClientMgr::ISendRoomsReset() { plNetMsgPagingRoom msg; msg.SetPageFlags(plNetMsgPagingRoom::kResetList); - msg.SetNetProtocol(kNetProtocolCli2Game); SendMsg(&msg); } @@ -377,7 +375,6 @@ void plNetClientMgr::ISendGameMessage(plMessage* msg) #endif netMsgWrap->SetPlayerID(GetPlayerID()); - netMsgWrap->SetNetProtocol(kNetProtocolCli2Game); SendMsg(netMsgWrap); if (plNetObjectDebugger::GetInstance()->IsDebugObject(msg->GetSender() ? msg->GetSender()->ObjectIsLoaded() : nullptr)) @@ -412,11 +409,11 @@ void plNetClientMgr::SendMsg(plNetMessage* msg) } msg->SetTimeSent(plUnifiedTime::GetCurrent()); - int channel = IPrepMsg(msg); + IPrepMsg(msg); // hsLogEntry( DebugMsg( " {} {}", msg->ClassName(), msg->AsStdString()) ); - fTransport.SendMsg(channel, msg); + fTransport.SendMsg(msg); // Debug if (plNetMsgVoice::ConvertNoRef(msg)) diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp index 7bac3edebd..4fe03169f9 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp @@ -74,11 +74,11 @@ void plNetClientMgr::IShowLists() y=startY; plSceneObject *player = plSceneObject::ConvertNoRef(GetLocalPlayer()); hsPoint3 pos = (player ? player->GetLocalToWorld() * hsPoint3(0, 0, 0) : hsPoint3(0, 0, 0)); - sprintf(str, "%s%s PlyrName=%s PlyrID=%d AcctID=%d P2P=%d Join#=%d Peers=%d %.1f,%.1f,%.1f", + sprintf(str, "%s%s PlyrName=%s PlyrID=%d Join#=%d %.1f,%.1f,%.1f", GetFlagsBit(kSendingVoice) ? "V" : " ", GetFlagsBit(kSendingActions) ? "A" : " ", - GetPlayerName().c_str(), GetPlayerID(), 0, - IsPeerToPeer(), GetJoinOrder(), 0, + GetPlayerName().c_str(), GetPlayerID(), + GetJoinOrder(), pos.fX, pos.fY, pos.fZ); txt.DrawString(x,y,str,255,255,255,255); SetFlagsBit(kSendingVoice, 0); @@ -101,11 +101,10 @@ void plNetClientMgr::IShowLists() if (mbr->IsServer()) continue; player = (mbr->GetAvatarKey() ? plSceneObject::ConvertNoRef(mbr->GetAvatarKey()->ObjectIsLoaded()) : nullptr); - sprintf(str, "%s%s %s p2p=%d dist=%.1f", + sprintf(str, "%s%s %s dist=%.1f", mbr->GetTransportFlags() & plNetTransportMember::kSendingVoice ? "V" : " ", mbr->GetTransportFlags() & plNetTransportMember::kSendingActions ? "A" : " ", mbr->AsString().c_str(), - mbr->IsPeerToPeer(), mbr->GetDistSq() != FLT_MAX ? sqrt(mbr->GetDistSq()) :-1.f); txt.DrawString(x,y,str); y+=yOff; diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrVoice.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrVoice.cpp index 40cd6d1965..88b1d7bf05 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrVoice.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrVoice.cpp @@ -106,7 +106,6 @@ bool plNetClientMgr::IApplyNewListenList(std::vector& newListenList, plNetMsgListenListUpdate llu; llu.SetPlayerID(GetPlayerID()); - llu.SetNetProtocol(kNetProtocolCli2Game); // // for each client in the old list, if not in the new list, send a ListenList remove msg @@ -275,11 +274,6 @@ bool plNetClientMgr::IUpdateListenList(double secs) // I can't listen to players that are more than 50 ft away if (distSq>plNetListenList::kMaxListenDistSq) continue; - // if we are p2p and member isn't, skip them. - if ( IsPeerToPeer() && !fTransport.GetMember(i)->IsPeerToPeer() ) - continue; - // otherwise, we aren't p2p so just update the listen list - // normally so it will update in the gui as distance changes. #else float distSq=1; #endif diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.cpp index b25df54314..87b38aa7af 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.cpp @@ -63,7 +63,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plMessage/plLoadCloneMsg.h" #include "plMessage/plMemberUpdateMsg.h" #include "plMessage/plNetOwnershipMsg.h" -#include "plNetMessage/plNetCommonMessage.h" #include "plNetMessage/plNetMessage.h" #include "plNetTransport/plNetTransportMember.h" #include "plSDL/plSDL.h" @@ -87,18 +86,6 @@ plNetClientMgr * plNetClientMsgHandler::IGetNetClientMgr() return plNetClientMgr::ConvertNoRef(GetNetApp()); } -int plNetClientMsgHandler::PeekMsg(plNetMessage * netMsg) -{ - plNetClientMgr * nc = IGetNetClientMgr(); - int cnt = -1; - if (netMsg->GetNetCoreMsg()) // && !netMsg->Peeked()) // not needed - { - cnt = netMsg->PeekBuffer(netMsg->GetNetCoreMsg()->GetData(), netMsg->GetNetCoreMsg()->GetLen()); - hsAssert(cnt,"0 length message"); - } - return cnt; -} - void plNetClientMsgHandler::IFillInTransportMember(const plNetMsgMemberInfoHelper* mbi, plNetTransportMember* mbr) { const plNetClientMgr* nc=IGetNetClientMgr(); @@ -117,7 +104,7 @@ void plNetClientMsgHandler::IFillInTransportMember(const plNetMsgMemberInfoHelpe mbr->SetAvatarKey(avKey); } -plNetMsgHandler::Status plNetClientMsgHandler::ReceiveMsg(plNetMessage *& netMsg) +plNetMsgHandler::Status plNetClientMsgHandler::ReceiveMsg(plNetMessage* netMsg) { #ifdef HS_DEBUGGING //plNetClientMgr::GetInstance()->DebugMsg(" {}", netMsg->ClassName()); @@ -160,11 +147,9 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgGroupOwner) { plNetClientMgr* nc = IGetNetClientMgr(); plNetMsgGroupOwner* m = plNetMsgGroupOwner::ConvertNoRef(netMsg); - PeekMsg(m); /* !!! THIS LOG MSG CRASHES THE CLIENT SOMETIMES! -eap - hsLogEntry( nc->DebugMsg(" {}, {}, sz={}", - m->ClassName(), m->AsStdString(), m->GetNetCoreMsgLen()) ); + hsLogEntry( nc->DebugMsg(" {}, {}", m->ClassName(), m->AsStdString())); */ /* @@ -200,11 +185,9 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgSDLState) { plNetClientMgr* nc = IGetNetClientMgr(); plNetMsgSDLState* m = plNetMsgSDLState::ConvertNoRef(netMsg); - PeekMsg(m); /* !!! THIS LOG MSG CRASHES THE CLIENT SOMETIMES! -eap - hsLogEntry( nc->DebugMsg(" {}, {}, sz={}", - m->ClassName(), m->AsStdString(), m->GetNetCoreMsgLen()) ); + hsLogEntry(nc->DebugMsg(" {}, {}, sz={}", m->ClassName(), m->AsStdString())); */ uint32_t rwFlags = 0; @@ -297,8 +280,6 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgGameMessage) plNetMsgGameMessage* m = plNetMsgGameMessage::ConvertNoRef(netMsg); if (m) { - PeekMsg(m); - plNetMsgLoadClone * lcMsg = plNetMsgLoadClone::ConvertNoRef( m ); if ( lcMsg ) { @@ -315,11 +296,10 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgGameMessage) if (gameMsg) { /* !!! THIS LOG MSG CRASHES THE CLIENT SOMETIMES!!! -eap - hsLogEntry( nc->DebugMsg(" {}, {}, sndr {} rcvr {} sz={}", + hsLogEntry( nc->DebugMsg(" {}, {}, sndr {} rcvr {}", m->ClassName(), m->AsStdString(), gameMsg->GetSender() ? gameMsg->GetSender()->GetName() : "?", - gameMsg->GetNumReceivers() ? gameMsg->GetReceiver(0)->GetName() : "?", - m->GetNetCoreMsgLen()) ); + gameMsg->GetNumReceivers() ? gameMsg->GetReceiver(0)->GetName() : "?")); */ if (lcMsg) @@ -386,11 +366,9 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgVoice) { plNetClientMgr* nc = IGetNetClientMgr(); plNetMsgVoice* m = plNetMsgVoice::ConvertNoRef(netMsg); - PeekMsg(m); /* !!! THIS LOG MSG CRASHES THE CLIENT SOMETIMES! -eap - hsLogEntry( nc->DebugMsg(" {}, {}, sz={}", - m->ClassName(), m->AsStdString(), m->GetNetCoreMsgLen()) ); + hsLogEntry(nc->DebugMsg(" {}, {}", m->ClassName(), m->AsStdString())); */ size_t bufLen = m->GetVoiceDataLen(); @@ -441,11 +419,9 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgMembersList) { plNetClientMgr* nc = IGetNetClientMgr(); plNetMsgMembersList* m = plNetMsgMembersList::ConvertNoRef(netMsg); - PeekMsg(m); /* !!! THIS LOG MSG CRASHES THE CLIENT SOMETIMES! -eap - hsLogEntry( nc->DebugMsg(" {}, {}, sz={}", - m->ClassName(), m->AsStdString(), m->GetNetCoreMsgLen()) ); + hsLogEntry(nc->DebugMsg(" {}, {}", m->ClassName(), m->AsStdString())); */ // remove existing members, except server @@ -463,7 +439,7 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgMembersList) { plNetTransportMember* mbr = new plNetTransportMember(nc); IFillInTransportMember(m->MemberListInfo()->GetMember(i), mbr); - hsLogEntry(nc->DebugMsg("\tAdding transport member, name={}, p2p={}, plrID={}\n", mbr->AsString(), mbr->IsPeerToPeer(), mbr->GetPlayerID())); + hsLogEntry(nc->DebugMsg("\tAdding transport member, name={}, plrID={}\n", mbr->AsString(), mbr->GetPlayerID())); hsSsize_t idx = nc->fTransport.AddMember(mbr); hsAssert(idx>=0, "Failed adding member?"); @@ -480,11 +456,9 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgMemberUpdate) { plNetClientMgr* nc = IGetNetClientMgr(); plNetMsgMemberUpdate* m = plNetMsgMemberUpdate::ConvertNoRef(netMsg); - PeekMsg(m); /* !!! THIS LOG MSG CRASHES THE CLIENT SOMETIMES! -eap - hsLogEntry( nc->DebugMsg(" {}, {}, sz={}", - m->ClassName(), m->AsStdString(), m->GetNetCoreMsgLen()) ); + hsLogEntry(nc->DebugMsg(" {}, {}", m->ClassName(), m->AsStdString())); */ if (m->AddingMember()) @@ -528,11 +502,9 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgListenListUpdate) { plNetClientMgr* nc = IGetNetClientMgr(); plNetMsgListenListUpdate* m = plNetMsgListenListUpdate::ConvertNoRef(netMsg); - PeekMsg(m); /* !!! THIS LOG MSG CRASHES THE CLIENT SOMETIMES! -eap - hsLogEntry( nc->DebugMsg(" {}, {}, sz={}", - m->ClassName(), m->AsStdString(), m->GetNetCoreMsgLen()) ); + hsLogEntry(nc->DebugMsg(" {}, {}", m->ClassName(), m->AsStdString())); */ plNetTransportMember* tm = nc->fTransport.GetMemberByID(m->GetPlayerID()); @@ -566,11 +538,9 @@ MSG_HANDLER_DEFN(plNetClientMsgHandler,plNetMsgInitialAgeStateSent) { plNetClientMgr * nc = IGetNetClientMgr(); plNetMsgInitialAgeStateSent* msg = plNetMsgInitialAgeStateSent::ConvertNoRef(netMsg); - PeekMsg(msg); /* !!! THIS LOG MSG CRASHES THE CLIENT SOMETIMES! -eap - hsLogEntry( nc->DebugMsg(" {}, {}, sz={}", - netMsg->ClassName(), netMsg->AsStdString(), netMsg->GetNetCoreMsgLen()) ); + hsLogEntry(nc->DebugMsg(" {}, {}", netMsg->ClassName(), netMsg->AsStdString())); */ nc->DebugMsg( "Initial age SDL count: {}", msg->GetNumInitialSDLStates( ) ); diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.h b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.h index 0bfcf52e56..9ecd01e451 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.h +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMsgHandler.h @@ -70,8 +70,7 @@ class plNetClientMsgHandler : public plNetMsgHandler plNetClientMsgHandler(plNetClientMgr * mgr); ~plNetClientMsgHandler(); - plNetMsgHandler::Status ReceiveMsg(plNetMessage *& netMsg) override; - int PeekMsg(plNetMessage * netMsg); // return msgsize on success. -1 on error. + plNetMsgHandler::Status ReceiveMsg(plNetMessage* netMsg) override; MSG_HANDLER_DECL(plNetMsgTerminated) MSG_HANDLER_DECL(plNetMsgGroupOwner) diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetVoiceList.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetVoiceList.cpp index b9b8713802..e8802a619c 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetVoiceList.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetVoiceList.cpp @@ -71,24 +71,6 @@ int plNetVoiceList::FindMember(plNetTransportMember* e) * ***/ -void plNetTalkList::UpdateTransportGroup(plNetClientMgr* nc) -{ - if (fFlags & kDirty) - { - nc->fTransport.ClearChannelGrp(plNetClientMgr::kNetChanVoice); - if (nc->IsPeerToPeer()) - { - int i; - for(i=0;iIsPeerToPeer()) - nc->fTransport.SubscribeToChannelGrp(GetMember(i), plNetClientMgr::kNetChanVoice); - } - } - fFlags &= ~kDirty; - } -} - void plNetTalkList::AddMember(plNetTransportMember* e) { if (FindMember(e)==-1) @@ -96,7 +78,6 @@ void plNetTalkList::AddMember(plNetTransportMember* e) plStatusLog::AddLineSF("voice.log", "Adding {} to talk list", e->AsString()); fMembers.push_back(e); } - fFlags |= kDirty; } void plNetTalkList::RemoveMember(plNetTransportMember* e) @@ -107,13 +88,6 @@ void plNetTalkList::RemoveMember(plNetTransportMember* e) plStatusLog::AddLineSF("voice.log", "Removing {} from talklist", e->AsString()); fMembers.erase(fMembers.begin()+idx); } - fFlags |= kDirty; -} - -void plNetTalkList::Clear() -{ - plNetVoiceList::Clear(); - fFlags |= kDirty; } diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetVoiceList.h b/Sources/Plasma/PubUtilLib/plNetClient/plNetVoiceList.h index a906a55bbe..4406e0c53e 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetVoiceList.h +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetVoiceList.h @@ -104,21 +104,9 @@ class plNetListenList : public plNetVoiceList // class plNetTalkList : public plNetVoiceList { -private: - enum - { - kDirty = 0x1 - }; - uint32_t fFlags; public: - plNetTalkList() : fFlags(0) {} - ~plNetTalkList() {} - - void UpdateTransportGroup(plNetClientMgr* nc); - void AddMember(plNetTransportMember* e) override; void RemoveMember(plNetTransportMember* e) override; - void Clear() override; }; #endif // plNetVoiceList_h diff --git a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp index e462c5f189..eab5846245 100644 --- a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp @@ -78,16 +78,6 @@ using namespace std::literals::string_view_literals; extern bool gDataServerLocal; -/***************************************************************************** -* -* Exported data -* -***/ - -const unsigned kNetCommAllMsgClasses = (unsigned)-1; -FNetCommMsgHandler * kNetCommAllMsgHandlers = (FNetCommMsgHandler*)-1; -const void * kNetCommAllUserStates = (void*)-1; - struct NetCommParam { void * param; plNetCommReplyMsg::EParamType type; @@ -131,30 +121,7 @@ static plUUID s_iniStartupAgeInstId; static unsigned s_iniStartupPlayerId = 0; static bool s_netError = false; - -struct NetCommMsgHandler : THashKeyVal { - HASHLINK(NetCommMsgHandler) link; - FNetCommMsgHandler * proc; - void * state; - - NetCommMsgHandler ( - unsigned msgId, - FNetCommMsgHandler * proc, - void * state - ) : THashKeyVal(msgId) - , proc(proc) - , state(state) - { } -}; - -static HASHTABLEDECL( - NetCommMsgHandler, - THashKeyVal, - link -) s_handlers; - -static NetCommMsgHandler s_defaultHandler(0, nullptr, nullptr); -static NetCommMsgHandler s_preHandler(0, nullptr, nullptr); +static plNetMsgHandler* s_msgHandler = nullptr; //============================================================================ @@ -220,7 +187,8 @@ static void INetBufferCallback ( return; } - if (!msg->PeekBuffer((const char *)buffer, bytes)) { + hsReadOnlyStream stream(bytes, buffer); + if (!msg->PeekBuffer(&stream)) { LogMsg(kLogError, "NetComm: plNetMessage %u failed to peek buffer", type); return; } @@ -739,14 +707,6 @@ void NetCommStartup () { void NetCommShutdown () { s_shutdown = true; - NetCommSetDefaultMsgHandler(nullptr, nullptr); - NetCommSetMsgPreHandler(nullptr, nullptr); - NetCommRemoveMsgHandler( - kNetCommAllMsgClasses, - kNetCommAllMsgHandlers, - kNetCommAllUserStates - ); - NetCliGameDisconnect(); NetCliAuthDisconnect(); if (!gDataServerLocal) @@ -872,127 +832,25 @@ void NetCommSendMsg ( ) { msg->SetPlayerID(NetCommGetPlayer()->playerInt); - unsigned msgSize = msg->GetPackSize(); - uint8_t * buf = (uint8_t *)malloc(msgSize); - msg->PokeBuffer((char *)buf, msgSize); - - switch (msg->GetNetProtocol()) { - case kNetProtocolCli2Auth: - NetCliAuthPropagateBuffer( - msg->ClassIndex(), - msgSize, - buf - ); - break; - - case kNetProtocolCli2Game: - NetCliGamePropagateBuffer( - msg->ClassIndex(), - msgSize, - buf - ); - break; - - DEFAULT_FATAL(msg->GetNetProtocol()); - } + hsRAMStream stream; + msg->PokeBuffer(&stream); - free(buf); + NetCliGamePropagateBuffer( + msg->ClassIndex(), + stream.GetEOF(), + static_cast(stream.GetData()) + ); } //============================================================================ void NetCommRecvMsg ( plNetMessage * msg ) { - for (;;) { - if (s_preHandler.proc && s_preHandler.proc(msg, s_preHandler.state) == plNetMsgHandler::Status::kConsumed) - break; - - unsigned msgClassIdx = msg->ClassIndex(); - NetCommMsgHandler * handler = s_handlers.Find(msgClassIdx); - - if (!handler && s_defaultHandler.proc) { - s_defaultHandler.proc(msg, s_defaultHandler.state); - break; - } - while (handler) { - if (handler->proc(msg, handler->state) == plNetMsgHandler::Status::kConsumed) - break; - handler = s_handlers.FindNext(msgClassIdx, handler); - } - break; - } -} - -//============================================================================ -void NetCommAddMsgHandlerForType ( - unsigned msgClassIdx, - FNetCommMsgHandler * proc, - void * state -) { - for (unsigned i = 0; i < plFactory::GetNumClasses(); ++i) { - if (plFactory::DerivesFrom(msgClassIdx, i)) - NetCommAddMsgHandlerForExactType(i, proc, state); - } -} - -//============================================================================ -void NetCommAddMsgHandlerForExactType ( - unsigned msgClassIdx, - FNetCommMsgHandler * proc, - void * state -) { - ASSERT(msgClassIdx != kNetCommAllMsgClasses); - ASSERT(proc && proc != kNetCommAllMsgHandlers); - ASSERT(!state || (state && state != kNetCommAllUserStates)); - - NetCommRemoveMsgHandler(msgClassIdx, proc, state); - NetCommMsgHandler * handler = new NetCommMsgHandler(msgClassIdx, proc, state); - - s_handlers.Add(handler); -} - -//============================================================================ -void NetCommRemoveMsgHandler ( - unsigned msgClassIdx, - FNetCommMsgHandler * proc, - const void * state -) { - NetCommMsgHandler * next, * handler = s_handlers.Head(); - for (; handler; handler = next) { - next = handler->link.Next(); - if (handler->GetValue() != msgClassIdx) - if (msgClassIdx != kNetCommAllMsgClasses) - continue; - if (handler->proc != proc) - if (proc != kNetCommAllMsgHandlers) - continue; - if (handler->state != state) - if (state != kNetCommAllUserStates) - continue; - - // We found a matching handler, delete it - delete handler; + if (s_msgHandler != nullptr) { + s_msgHandler->ReceiveMsg(msg); } } -//============================================================================ -void NetCommSetDefaultMsgHandler ( - FNetCommMsgHandler * proc, - void * state -) { - s_defaultHandler.proc = proc; - s_defaultHandler.state = state; -} - -//============================================================================ -void NetCommSetMsgPreHandler ( - FNetCommMsgHandler * proc, - void * state -) { - s_preHandler.proc = proc; - s_preHandler.state = state; -} - //============================================================================ void NetCommSetAccountUsernamePassword ( const ST::string& username, @@ -1159,68 +1017,6 @@ void NetCommSetAgePublic ( // --> no msg ); } -//============================================================================ -void NetCommCreatePublicAge (// --> plNetCommPublicAgeMsg - const char ageName[], - const plUUID& ageInstId, - void * param -) { -} - -//============================================================================ -void NetCommRemovePublicAge(// --> plNetCommPublicAgeMsg - const plUUID& ageInstId, - void * param -) { -} - -//============================================================================ -void NetCommRegisterOwnedAge ( - const NetCommAge & age, - const char ageInstDesc[], - unsigned playerInt, - void * param -) { -} - -//============================================================================ -void NetCommUnregisterOwnedAge ( - const char ageName[], - unsigned playerInt, - void * param -) { -} - -//============================================================================ -void NetCommRegisterVisitAge ( - const NetCommAge & age, - const char ageInstDesc[], - unsigned playerInt, - void * param -) { -} - -//============================================================================ -void NetCommUnregisterVisitAge ( - const plUUID& ageInstId, - unsigned playerInt, - void * param -) { -} - -//============================================================================ -void NetCommConnectPlayerVault ( - void * param -) { -} - -//============================================================================ -void NetCommConnectAgeVault ( - const plUUID& ageInstId, - void * param -) { -} - //============================================================================ void NetCommUpgradeVisitorToExplorer ( unsigned playerInt, @@ -1300,55 +1096,11 @@ void NetCommLogStackDump(const ST::string& stackDump) /***************************************************************************** * -* Msg handler interface - compatibility layer with legacy code +* Msg handler interface * ***/ - -//////////////////////////////////////////////////////////////////// - -// plNetClientComm ---------------------------------------------- -plNetClientComm::plNetClientComm() -{ -} - -// ~plNetClientComm ---------------------------------------------- -plNetClientComm::~plNetClientComm() -{ - NetCommSetMsgPreHandler(nullptr, nullptr); -} - -// AddMsgHandlerForType ---------------------------------------------- -void plNetClientComm::AddMsgHandlerForType( uint16_t msgClassIdx, MsgHandler* handler ) -{ - int i; - for( i = 0; i < plFactory::GetNumClasses(); i++ ) - { - if ( plFactory::DerivesFrom( msgClassIdx, i ) ) - AddMsgHandlerForExactType( i, handler ); - } -} - -// AddMsgHandlerForExactType ---------------------------------------------- -void plNetClientComm::AddMsgHandlerForExactType( uint16_t msgClassIdx, MsgHandler* handler ) +void plNetClientComm::SetMsgHandler(plNetMsgHandler* msgHandler) { - NetCommAddMsgHandlerForExactType(msgClassIdx, MsgHandler::StaticMsgHandler, handler); -} - -// RemoveMsgHandler ---------------------------------------------- -bool plNetClientComm::RemoveMsgHandler( MsgHandler* handler ) -{ - NetCommRemoveMsgHandler(kNetCommAllMsgClasses, kNetCommAllMsgHandlers, handler); - return true; -} - -// SetDefaultHandler ---------------------------------------------- -void plNetClientComm::SetDefaultHandler( MsgHandler* handler) { - NetCommSetDefaultMsgHandler(MsgHandler::StaticMsgHandler, handler); -} - -// MsgHandler::StaticMsgHandler ---------------------------------------------- -plNetMsgHandler::Status plNetClientComm::MsgHandler::StaticMsgHandler(plNetMessage* msg, void* userState) { - plNetClientComm::MsgHandler * handler = (plNetClientComm::MsgHandler *) userState; - return handler->HandleMessage(msg); + s_msgHandler = msgHandler; } diff --git a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h index b0d84113ba..3447cebfe8 100644 --- a/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h +++ b/Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h @@ -141,49 +141,6 @@ void NetCommActivatePostInitErrorHandler(); void NetCommActivateMsgDispatchers(); -/***************************************************************************** -* -* Net message handlers -* -***/ - -typedef plNetMsgHandler::Status (FNetCommMsgHandler)( - plNetMessage * msg, - void * userState -); - -// Adds a msg handler for a msg that is convertable to specified type. -void NetCommAddMsgHandlerForType ( - unsigned msgClassIdx, - FNetCommMsgHandler * handler, - void * userState -); -// Adds a msg handler for a specific msg type. -void NetCommAddMsgHandlerForExactType ( - unsigned msgClassIdx, - FNetCommMsgHandler * handler, - void * userState -); - -extern const unsigned kNetCommAllMsgClasses; -extern FNetCommMsgHandler * kNetCommAllMsgHandlers; -extern const void * kNetCommAllUserStates; - -void NetCommRemoveMsgHandler ( - unsigned msgClassIdx, - FNetCommMsgHandler * handler, - const void * userState -); - -void NetCommSetDefaultMsgHandler ( - FNetCommMsgHandler * handler, - void * userState -); -void NetCommSetMsgPreHandler ( - FNetCommMsgHandler * handler, - void * userState -); - /***************************************************************************** * * Network requests @@ -194,16 +151,6 @@ void NetCommSetMsgPreHandler ( void NetCommAuthenticate ( // --> plNetCommAuthMsg void * param ); -void NetCommGetFileList ( // --> plNetCommFileListMsg - const char16_t dir[], - const char16_t ext[], - void * param -); -void NetCommGetFile ( // --> plNetCommFileDownloadMsg - const char16_t filename[], - hsStream * writer, - void * param -); void NetCommLinkToAge ( // --> plNetCommLinkToAgeMsg const NetCommAge & age, void * param @@ -232,46 +179,6 @@ void NetCommSetAgePublic ( // --> no msg unsigned ageInfoId, bool makePublic ); -void NetCommCreatePublicAge (// --> plNetCommPublicAgeMsg - const char ageName[], - const plUUID& ageInstId, - void * param -); -void NetCommRemovePublicAge(// --> plNetCommPublicAgeMsg - const plUUID& ageInstId, - void * param -); -void NetCommRegisterOwnedAge ( - const NetCommAge & age, - const char ageInstDesc[], - unsigned playerInt, - void * param -); -void NetCommUnregisterOwnedAge ( - const char ageName[], - unsigned playerInt, - void * param -); -void NetCommRegisterVisitAge ( - const NetCommAge & age, - const char ageInstDesc[], - unsigned playerInt, - void * param -); -void NetCommUnregisterVisitAge ( - const plUUID& ageInstId, - unsigned playerInt, - void * param -); -void NetCommConnectPlayerVault ( - void * param -); -void NetCommDisconnectPlayerVault (); -void NetCommConnectAgeVault ( - const plUUID& ageInstId, - void * param -); -void NetCommDisconnectAgeVault (); void NetCommUpgradeVisitorToExplorer ( unsigned playerInt, void * param @@ -318,33 +225,7 @@ void NetCommLogStackDump(const ST::string& stackDump); class plNetClientComm { public: - // Message handler for unsolicited msgs or registered for specific msg types. - class MsgHandler - { - public: - static plNetMsgHandler::Status StaticMsgHandler(plNetMessage* msg, void* userState); - virtual plNetMsgHandler::Status HandleMessage(plNetMessage* msg) = 0; - }; - - //////////////////////////////////////////////////////////////// - - plNetClientComm(); - ~plNetClientComm(); - - //////////////////////////////////////////////////////////////// - - // Adds a msg handler for a msg that is convertable to specified type. - void AddMsgHandlerForType( uint16_t msgClassIdx, MsgHandler* handler ); - - // Adds a msg handler for a specific msg type. - void AddMsgHandlerForExactType( uint16_t msgClassIdx, MsgHandler* handler ); - - bool RemoveMsgHandler( MsgHandler* handler ); - - // Msgs not part of a task controlled by this - // object, and doesn't have a handler set for its type - // are sent to this handler (if set). - void SetDefaultHandler( MsgHandler* msgHandler ); + void SetMsgHandler(plNetMsgHandler* msgHandler); }; //////////////////////////////////////////////////////////////////// diff --git a/Sources/Plasma/PubUtilLib/plNetCommon/CMakeLists.txt b/Sources/Plasma/PubUtilLib/plNetCommon/CMakeLists.txt index 113d9699ea..650cfab1b4 100644 --- a/Sources/Plasma/PubUtilLib/plNetCommon/CMakeLists.txt +++ b/Sources/Plasma/PubUtilLib/plNetCommon/CMakeLists.txt @@ -12,7 +12,6 @@ set(plNetCommon_SOURCES set(plNetCommon_HEADERS plClientGuid.h plNetCommon.h - plNetCommonConstants.h plNetCommonCreatable.h plNetCommonHelpers.h plNetMember.h diff --git a/Sources/Plasma/PubUtilLib/plNetCommon/plNetCommonConstants.h b/Sources/Plasma/PubUtilLib/plNetCommon/plNetCommonConstants.h deleted file mode 100644 index 528ac1e596..0000000000 --- a/Sources/Plasma/PubUtilLib/plNetCommon/plNetCommonConstants.h +++ /dev/null @@ -1,49 +0,0 @@ -/*==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Additional permissions under GNU GPL version 3 section 7 - -If you modify this Program, or any covered work, by linking or -combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, -NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent -JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK -(or a modified version of those libraries), -containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, -PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG -JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the -licensors of this Program grant you additional -permission to convey the resulting work. Corresponding Source for a -non-source form of such a combination shall include the source code for -the parts of OpenSSL and IJG JPEG Library used as well as that of the covered -work. - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - -*==LICENSE==*/ -#ifndef plNetCommonConstants_h_inc -#define plNetCommonConstants_h_inc - - - -#endif // plNetCommonConstants_h_inc - - diff --git a/Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgHandler.h b/Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgHandler.h index 2ea5e3475a..4fe32a2dc7 100644 --- a/Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgHandler.h +++ b/Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgHandler.h @@ -60,9 +60,6 @@ class plNetMsgHandler { kError, kHandled, - // Return this value from your registered msg handler - // to stop further dispatching of incoming msg. - kConsumed, }; plNetMsgHandler() : fNetApp() { } @@ -71,7 +68,7 @@ class plNetMsgHandler void SetNetApp(plNetApp* na) { fNetApp=na; } plNetApp* GetNetApp() { return fNetApp; } - virtual Status ReceiveMsg(plNetMessage*& netMsg) = 0; + virtual Status ReceiveMsg(plNetMessage* netMsg) = 0; }; #define MSG_HANDLER(msgClassName) msgClassName##HandleMsg @@ -80,13 +77,13 @@ class plNetMsgHandler // Use to declare msg handler fxns in your MsgHandler .h class header // #define MSG_HANDLER_DECL(msgClassName) \ -virtual plNetMsgHandler::Status MSG_HANDLER(msgClassName)(plNetMessage*& netMsg); +virtual plNetMsgHandler::Status MSG_HANDLER(msgClassName)(plNetMessage* netMsg); // // Use to define msg handler fxns in your MsgHandler .cpp file // #define MSG_HANDLER_DEFN(handlerClassName, msgClassName) \ -plNetMsgHandler::Status handlerClassName::MSG_HANDLER(msgClassName)(plNetMessage*& netMsg) +plNetMsgHandler::Status handlerClassName::MSG_HANDLER(msgClassName)(plNetMessage* netMsg) // // Use in the switch statement in your ReceiveMsg function diff --git a/Sources/Plasma/PubUtilLib/plNetMessage/CMakeLists.txt b/Sources/Plasma/PubUtilLib/plNetMessage/CMakeLists.txt index 54b7ff85f0..84746c33b8 100644 --- a/Sources/Plasma/PubUtilLib/plNetMessage/CMakeLists.txt +++ b/Sources/Plasma/PubUtilLib/plNetMessage/CMakeLists.txt @@ -4,7 +4,6 @@ set(plNetMessage_SOURCES ) set(plNetMessage_HEADERS - plNetCommonMessage.h plNetMessage.h plNetMessageCreatable.h plNetMsgHelpers.h @@ -18,7 +17,6 @@ target_link_libraries( CoreLib pnFactory pnKeyedObject - pnNetBase pnNetCommon plNetCommon plUnifiedTime diff --git a/Sources/Plasma/PubUtilLib/plNetMessage/plNetCommonMessage.h b/Sources/Plasma/PubUtilLib/plNetMessage/plNetCommonMessage.h deleted file mode 100644 index 155bd229c5..0000000000 --- a/Sources/Plasma/PubUtilLib/plNetMessage/plNetCommonMessage.h +++ /dev/null @@ -1,99 +0,0 @@ -/*==LICENSE==* - -CyanWorlds.com Engine - MMOG client, server and tools -Copyright (C) 2011 Cyan Worlds, Inc. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Additional permissions under GNU GPL version 3 section 7 - -If you modify this Program, or any covered work, by linking or -combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, -NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent -JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK -(or a modified version of those libraries), -containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, -PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG -JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the -licensors of this Program grant you additional -permission to convey the resulting work. Corresponding Source for a -non-source form of such a combination shall include the source code for -the parts of OpenSSL and IJG JPEG Library used as well as that of the covered -work. - -You can contact Cyan Worlds, Inc. by email legal@cyan.com - or by snail mail at: - Cyan Worlds, Inc. - 14617 N Newport Hwy - Mead, WA 99021 - -*==LICENSE==*/ -#ifndef plNetCommonMessage_inc -#define plNetCommonMessage_inc - -#include "HeadSpin.h" -#include "hsRefCnt.h" - -// -// refcntable data -// -class plNetCommonMessageData : public hsRefCnt -{ -private: - char *fData; // sent -public: - plNetCommonMessageData(char* d) : fData(d) {} - ~plNetCommonMessageData() - { - hsAssert(RefCnt()==1, "illegal refcnt"); - delete [] fData; - } - - char* GetData() const { return fData; } -}; - -// -// basic msg payload w/ refcntable data -// -class plNetCommonMessage -{ - plNetCommonMessage(const plNetCommonMessage & other); -private: - plNetCommonMessageData* fMsgData; -protected: - uint32_t fLen; // sent -public: - plNetCommonMessage() : fLen(), fMsgData() { } - virtual ~plNetCommonMessage() { hsRefCnt_SafeUnRef(fMsgData); } - - // setters - void SetData(char *d) - { - plNetCommonMessageData* n = d ? new plNetCommonMessageData(d) : nullptr; - hsRefCnt_SafeAssign(fMsgData, n); - hsRefCnt_SafeUnRef(n); - } - void SetMsgData(plNetCommonMessageData* d) - { - hsRefCnt_SafeAssign(fMsgData, d); - } - void SetLen(uint32_t l) { fLen=l; } - - // getters - char* GetData() const { return fMsgData ? fMsgData->GetData() : nullptr; } - virtual uint32_t GetDataLen() { return fLen; } - uint32_t GetLen() const { return fLen; } - plNetCommonMessageData* GetMsgData() const { return fMsgData; } -}; -#endif // plNetCommonMessage_inc diff --git a/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.cpp b/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.cpp index 0870a1c787..639b1d556b 100644 --- a/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.cpp +++ b/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.cpp @@ -46,7 +46,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "hsResMgr.h" #include "hsStream.h" -#include "plNetCommonMessage.h" #include "plNetMsgVersion.h" #include "pnFactory/plFactory.h" @@ -115,99 +114,39 @@ void plNetMessage::InitReplyFieldsFrom(plNetMessage * msg) #endif } -// -// STATIC -// create and READ from lowlevel net buffer -// -plNetMessage* plNetMessage::CreateAndRead(const plNetCommonMessage* msg) -{ - // create - plNetMessage* pHdr = Create(msg); - if (!pHdr) - return nullptr; - - // read - pHdr->PeekBuffer(msg->GetData(), msg->GetLen(), 0, false); - return pHdr; -} - -// -// STATIC -// create from lowlevel net buffer -// -plNetMessage* plNetMessage::Create(const plNetCommonMessage* msg) -{ - if (msg) - { - ClassIndexType classIndex; - hsReadOnlyStream readStream(sizeof(classIndex), msg->GetData()); - readStream.ReadLE16(&classIndex); - if (!plFactory::IsValidClassIndex(classIndex)) - return nullptr; - plNetMessage* pnm = plNetMessage::ConvertNoRef(plFactory::Create(classIndex)); - if (pnm) - pnm->SetNetCoreMsg(msg); - else - { - char str[256]; - sprintf(str, "Factory create failed, class index=%d, garbage msg?", classIndex); - hsAssert(false, str); - } - return pnm; - } - return nullptr; -} - -int plNetMessage::PokeBuffer(char* bufIn, int bufLen, uint32_t peekOptions) +int plNetMessage::PokeBuffer(hsStream* s, uint32_t peekOptions) { fPeekStatus = 0; - - if (!bufIn) - return 0; - - if (! (peekOptions & kDontClearBuffer)) - memset(bufIn, 0, bufLen); - - ValidatePoke(); - hsWriteOnlyStream writeStream(bufLen, bufIn); + int ret; if (peekOptions & kBaseClassOnly) { - ret=plNetMessage::IPokeBuffer(&writeStream, peekOptions); + ret=plNetMessage::IPokeBuffer(s, peekOptions); } else { - ret=IPokeBuffer(&writeStream, peekOptions); + ret=IPokeBuffer(s, peekOptions); } return ret; } -int plNetMessage::PeekBuffer(const char* bufIn, int bufLen, uint32_t peekOptions, bool forcePeek) +int plNetMessage::PeekBuffer(hsStream* s, uint32_t peekOptions, bool forcePeek) { - if(!bufLen || bufLen < 1) - return 0; - uint32_t partialPeekOptions = (peekOptions & kPartialPeekMask); if (!forcePeek && (fPeekStatus & partialPeekOptions) ) return 0; // already peeked, fully or partially - - if (!bufIn) - return 0; - + // set peek status based on peekOptions fPeekStatus = partialPeekOptions ? partialPeekOptions : kFullyPeeked; - - hsReadOnlyStream readStream(bufLen, bufIn); + int ret; if (peekOptions & kBaseClassOnly) { - ret=plNetMessage::IPeekBuffer(&readStream, peekOptions); - plNetMessage::ValidatePeek(); + ret=plNetMessage::IPeekBuffer(s, peekOptions); } else { - ret=IPeekBuffer(&readStream, peekOptions); - ValidatePeek(); + ret=IPeekBuffer(s, peekOptions); } return ret; @@ -375,21 +314,6 @@ int plNetMessage::GetPackSize() return IPokeBuffer(&nullStream); } -uint32_t plNetMessage::GetNetCoreMsgLen() const -{ - return fNetCoreMsg ? fNetCoreMsg->GetLen() : 0; -} - -void plNetMessage::ValidatePeek() const -{ - -} - -void plNetMessage::ValidatePoke() const -{ - -} - ST::string plNetMessage::AsString() const { const char* delim = ""; diff --git a/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.h b/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.h index 79f0dc4ced..020454a87d 100644 --- a/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.h +++ b/Sources/Plasma/PubUtilLib/plNetMessage/plNetMessage.h @@ -45,7 +45,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "HeadSpin.h" #include "hsBitVector.h" -#include "pnNetBase/pnNetBase.h" #include "pnNetCommon/plNetGroup.h" #include "pnFactory/plCreatable.h" @@ -53,7 +52,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plNetCommon/plNetServerSessionInfo.h" #include "plNetCommon/plNetCommon.h" -#include "plNetCommon/plNetCommonConstants.h" #include "plNetCommon/plNetCommonHelpers.h" #include "plUnifiedTime/plClientUnifiedTime.h" @@ -65,9 +63,7 @@ class plUUID; // // Base class for application network messages. -// These become the data in a plNetCommonMessage when sent over the network. // -class plNetCommonMessage; class plKey; class plNetMessage : public plCreatable @@ -82,11 +78,9 @@ class plNetMessage : public plCreatable uint32_t fTransactionID; // set by originator, included in reply. Only written if kHasTransactionID flag set uint32_t fPlayerID; // set by originator. Only written if kHasPlayerID flag set plUUID fAcctUUID; // set by sender (app level). Only written if kHasAcctUUID flag set - const plNetCommonMessage* fNetCoreMsg; // not sent, set by the receiver uint32_t fPeekStatus; // not sent. set on PeekBuffer, cleared on PokeBuffer uint8_t fProtocolVerMajor; // conditionally sent uint8_t fProtocolVerMinor; // conditionally sent - ENetProtocol fNetProtocol; // the server this msg should be sent to. this value is not sent over wire. enum ContentFlags { @@ -181,20 +175,16 @@ class plNetMessage : public plCreatable // ctor plNetMessage() - : fTimeRecvd(), fBytesRead(), fNetCoreMsg(), fContext(), + : fTimeRecvd(), fBytesRead(), fContext(), fPeekStatus(), fTransactionID(), fPlayerID(kInvalidPlayerID), - fNetProtocol(), fProtocolVerMajor(), fProtocolVerMinor(), + fProtocolVerMajor(), fProtocolVerMinor(), fFlags(0) { } - static plNetMessage* CreateAndRead(const plNetCommonMessage*); - static plNetMessage* Create(const plNetCommonMessage*); - int PokeBuffer(char* buf, int bufLen, uint32_t peekOptions=0); // put msg in buffer - int PeekBuffer(const char* buf, int bufLen, uint32_t peekOptions=0, bool forcePeek=false); // get msg out of buffer + int PokeBuffer(hsStream* s, uint32_t peekOptions = 0); // put msg in stream + int PeekBuffer(hsStream* s, uint32_t peekOptions = 0, bool forcePeek = false); // get msg out of stream bool NeedsReliableSend() const { return IsBitSet(kNeedsReliableSend); } bool IsSystemMessage() const { return IsBitSet(kIsSystemMessage); } - virtual void ValidatePoke() const; - virtual void ValidatePeek() const; virtual bool NeedsBroadcast() const { return false; } // should game server broadcast this message to other clients? virtual int ValidationSchemeID() const { return 1; } @@ -204,8 +194,6 @@ class plNetMessage : public plCreatable bool GetHasTimeSent() const { return IsBitSet(kHasTimeSent); } double GetTimeReceived() const { return fTimeRecvd; } bool IsBitSet(int b) const { return (fFlags & b) != 0; } - const plNetCommonMessage* GetNetCoreMsg() const { return fNetCoreMsg; } - uint32_t GetNetCoreMsgLen() const; bool GetHasContext() const { return IsBitSet(kHasContext);} uint32_t GetContext() const { return fContext;} bool GetHasTransactionID() const { return IsBitSet(kHasTransactionID);} @@ -217,14 +205,12 @@ class plNetMessage : public plCreatable const plUUID * GetAcctUUID() const { return &fAcctUUID; } uint8_t GetVersionMajor() const { return fProtocolVerMajor; } uint8_t GetVersionMinor() const { return fProtocolVerMinor; } - ENetProtocol GetNetProtocol () const { return fNetProtocol; } // setters void SetTimeSent(const plUnifiedTime& t) { fTimeSent=t;SetHasTimeSent(true); } void SetHasTimeSent(bool value) { SetBit( kHasTimeSent, value ); } void SetTimeReceived(double t) { fTimeRecvd=t; } void SetBit(int b, bool on=true) { if (on) fFlags |= b; else fFlags &= ~b; } - void SetNetCoreMsg(const plNetCommonMessage* ncmsg) { fNetCoreMsg=ncmsg; } void SetHasContext(bool value) { SetBit(kHasContext,value);} void SetContext(uint32_t value) { fContext=value; SetHasContext(true);} void SetHasTransactionID(bool value) { SetBit(kHasTransactionID,value);} @@ -234,7 +220,6 @@ class plNetMessage : public plCreatable void SetHasAcctUUID( bool v ) { SetBit( kHasAcctUUID,v ); } void SetAcctUUID(const plUUID * v ) { fAcctUUID.CopyFrom(v); SetHasAcctUUID(true); } void SetVersion(uint8_t maj=kVerMajor, uint8_t min=kVerMinor) { SetBit(kHasVersion); fProtocolVerMajor=maj; fProtocolVerMinor=min; } - void SetNetProtocol (ENetProtocol v ) { fNetProtocol = v; } // init fContext, fTransactionID, etc. if needed. void InitReplyFieldsFrom(plNetMessage * msg); diff --git a/Sources/Plasma/PubUtilLib/plNetTransport/plNetTransport.cpp b/Sources/Plasma/PubUtilLib/plNetTransport/plNetTransport.cpp index 5ec4d91424..e78e68b966 100644 --- a/Sources/Plasma/PubUtilLib/plNetTransport/plNetTransport.cpp +++ b/Sources/Plasma/PubUtilLib/plNetTransport/plNetTransport.cpp @@ -75,17 +75,6 @@ hsSsize_t plNetTransport::AddMember(plNetTransportMember* mbr) return -1; } -void plNetTransport::IUnSubscribeToAllChannelGrps(plNetTransportMember* mbr) -{ - int i; - for( i=mbr->GetNumSubscriptions()-1; i>=0 ; i-- ) - { - int chan=mbr->GetSubscription(i); - bool ok=UnSubscribeToChannelGrp(mbr, chan); - hsAssert(ok, "can't find supposed subscription to remove"); - } // for -} - void plNetTransport::IRemoveMember(plNetTransportMember* mbr) { if (!mbr) @@ -97,9 +86,6 @@ void plNetTransport::IRemoveMember(plNetTransportMember* mbr) plNetClientMgr::GetInstance()->GetTalkList()->RemoveMember(mbr); plNetClientMgr::GetInstance()->GetListenList()->RemoveMember(mbr); - // remove member from subscription lists - IUnSubscribeToAllChannelGrps(mbr); - auto it = std::find(fMembers.cbegin(), fMembers.cend(), mbr); // remove member from master list @@ -153,50 +139,9 @@ hsSsize_t plNetTransport::FindMember(const plNetTransportMember* mbr) // -// add this member to the given channel grp -// -void plNetTransport::SubscribeToChannelGrp(plNetTransportMember* mbr, int channel) -{ -// hsAssert(FindMember(mbr) != -1, "must add member before subscribing to channel"); - if (mbr->AddSubscription(channel)) - { - hsAssert(channel=0 && chancbegin(), mList->cend(), mbr); - if (it != mList->cend()) - { - mList->erase(it); - bool ret=mbr->RemoveSubscription(chan); - hsAssert(ret, "error removing subscription"); - return true; - } - return false; -} - -// -// copy list of members channelGrp subscriptions +// Send Msg to the server. // -void plNetTransport::GetSubscriptions(plNetTransportMember* mbr, std::vector* channels) const -{ - mbr->CopySubscriptions(channels); -} - - -// -// Send Msg to all members in the given channelGrp. -// Here's where multicasting would be used. -// -void plNetTransport::SendMsg(int chan, plNetMessage* netMsg) const +void plNetTransport::SendMsg(plNetMessage* netMsg) const { NetCommSendMsg(netMsg); } @@ -207,7 +152,6 @@ void plNetTransport::ClearMembers() for (plNetTransportMember* mbr : fMembers) { hsAssert(mbr, "nil member?"); - IUnSubscribeToAllChannelGrps(mbr); delete mbr; } // for @@ -243,59 +187,21 @@ hsSsize_t plNetTransport::FindMember(const plKey& avKey) const return -1; } -// -// clear channel and unsubscribe all members to that channel -// -void plNetTransport::ClearChannelGrp(int channel) -{ - const MembersList* mList = &fChannelGroups[channel]; - for (plNetTransportMember* tm : *mList) - { - bool ok=tm->RemoveSubscription(channel); - hsAssert(ok, "error removing subscription"); - } - - fChannelGroups[channel].clear(); -} - void plNetTransport::DumpState() { plNetClientMgr* nc=plNetClientMgr::GetInstance(); hsLogEntry( nc->DebugMsg("-------------------\n") ); - hsLogEntry( nc->DebugMsg("Num Channels={}\n", fChannelGroups.size()) ); - - for (size_t i = 0; i < fChannelGroups.size(); i++) - { - MembersList* mList = &fChannelGroups[i]; - hsLogEntry( nc->DebugMsg("\tChannel {}, num mbrs={}\n", i, mList->size()) ); - for (plNetTransportMember* mbr : *mList) - { - hsLogEntry(nc->DebugMsg("\t\tMbr {}\n", mbr->AsString())); - } - } nc->DebugMsg("Num Mbrs={}\n", GetNumMembers()); for (size_t i = 0; i < GetNumMembers(); i++) { plNetTransportMember * mbr = GetMember(i); - hsLogEntry (nc->DebugMsg("\tMbr {}, name={}, plyrID={}, subs={}", - i,mbr->AsString(),mbr->GetPlayerID(),mbr->GetNumSubscriptions()) ); - int j; - for(j=0;jGetNumSubscriptions();j++) - { - hsLogEntry( nc->DebugMsg("\t\tSub {}, chan={}\n", j, mbr->GetSubscription(j)) ); - } + hsLogEntry(nc->DebugMsg("\tMbr {}, name={}, plyrID={}", i, mbr->AsString(), mbr->GetPlayerID())); } hsLogEntry( nc->DebugMsg("\n") ); } -void plNetTransport::SetNumChannels(int n) -{ - if (n>fChannelGroups.size()) - fChannelGroups.resize(n); -} - // // create a members list sorted by dist. // diff --git a/Sources/Plasma/PubUtilLib/plNetTransport/plNetTransport.h b/Sources/Plasma/PubUtilLib/plNetTransport/plNetTransport.h index c0e72f1b3a..e2089471ab 100644 --- a/Sources/Plasma/PubUtilLib/plNetTransport/plNetTransport.h +++ b/Sources/Plasma/PubUtilLib/plNetTransport/plNetTransport.h @@ -61,9 +61,7 @@ class plNetTransport private: typedef std::vector MembersList; MembersList fMembers; // master list of all members in the game, server is member[0] - std::vector fChannelGroups; // members grouped by channel - void IUnSubscribeToAllChannelGrps(plNetTransportMember* mbr); void IRemoveMember(plNetTransportMember* mbr); public: plNetTransport() {} @@ -86,14 +84,7 @@ class plNetTransport const std::vector& GetMemberList() const { return fMembers; } void ClearMembers(); - // channel group ops - void SubscribeToChannelGrp(plNetTransportMember* mbr, int channel); - bool UnSubscribeToChannelGrp(plNetTransportMember* mbr, int channel); - void GetSubscriptions(plNetTransportMember* mbr, std::vector* channels) const; - void ClearChannelGrp(int channel); - void SetNumChannels(int n); - - void SendMsg(int channel, plNetMessage* msg) const; + void SendMsg(plNetMessage* msg) const; }; #endif // plNetTransport_h diff --git a/Sources/Plasma/PubUtilLib/plNetTransport/plNetTransportMember.cpp b/Sources/Plasma/PubUtilLib/plNetTransport/plNetTransportMember.cpp index e13b9e375b..a92f329e72 100644 --- a/Sources/Plasma/PubUtilLib/plNetTransport/plNetTransportMember.cpp +++ b/Sources/Plasma/PubUtilLib/plNetTransport/plNetTransportMember.cpp @@ -42,39 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plNetTransportMember.h" -#include - -// -// add a channel subscription if it's not already there -// returns true if added -// -bool plNetTransportMember::AddSubscription(int chan) -{ - if (FindSubscription(chan)==-1) - { - fSubscriptions.push_back(chan); - return true; - } - return false; -} - -bool plNetTransportMember::RemoveSubscription(int chan) -{ - int idx=FindSubscription(chan); - if (idx>=0) - { - fSubscriptions.erase(fSubscriptions.begin()+idx); - return true; - } - return false; -} - -int plNetTransportMember::FindSubscription(int chan) -{ - std::vector::iterator it=std::find(fSubscriptions.begin(), fSubscriptions.end(), chan); - return (it==fSubscriptions.end()) ? -1 : (int)(it-fSubscriptions.begin()); -} - ST::string plNetTransportMember::AsString() const { if (IsServer()) diff --git a/Sources/Plasma/PubUtilLib/plNetTransport/plNetTransportMember.h b/Sources/Plasma/PubUtilLib/plNetTransport/plNetTransportMember.h index 13d608393d..dfa042dde4 100644 --- a/Sources/Plasma/PubUtilLib/plNetTransport/plNetTransportMember.h +++ b/Sources/Plasma/PubUtilLib/plNetTransport/plNetTransportMember.h @@ -47,12 +47,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnKeyedObject/plKey.h" #include -#include // // This represents a participant in the game, ie. another // remote user. -// It is a basic net member with a list of channels that it subscribes to. // class plKey; @@ -68,7 +66,6 @@ class plNetTransportMember : public plNetMember plKey fAvatarKey; ST::string fPlayerName; uint32_t fPlayerID; - std::vector fSubscriptions; // list of channelGrp subscriptions uint32_t fTransportFlags; float fDistSq; // from local player, temp uint8_t fCCRLevel; @@ -97,19 +94,9 @@ class plNetTransportMember : public plNetMember void SetIsServer(bool value) { (value)?SetFlags(GetFlags()|kIsServer):SetFlags(GetFlags()&~kIsServer);} bool IsServer() const { return (GetFlags()&kIsServer)?true:false;} - bool AddSubscription(int chan); - bool RemoveSubscription(int chan); // return true on success - int FindSubscription(int chan); // return index into subscription array or -1 - - int GetNumSubscriptions() { return fSubscriptions.size(); } - int GetSubscription(int i) { return fSubscriptions[i]; } - - void CopySubscriptions(std::vector* channels) { *channels = fSubscriptions; } - void SetTransportFlags(uint32_t f) { fTransportFlags=f; } uint32_t GetTransportFlags() const { return fTransportFlags; } - bool IsPeerToPeer() const { return hsCheckBits(fFlags, kRequestP2P); } ST::string AsString() const override; bool IsEqualTo(const plNetMember * other) const override {