// // Prepare to send. // Update p2p transport groups and rcvrs list in some msgs // Returns channel. // int 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; for(i=0;i<GetTalkList()->GetNumMembers(); i++) { v->Receivers()->AddReceiverPlayerID(GetTalkList()->GetMember(i)->GetPlayerID()); } 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;i<rl->GetNumReceivers();i++) { int idx=fTransport.FindMember(rl->GetReceiverPlayerID(i)); hsAssert(idx!=-1, "error finding transport mbr"); plNetTransportMember* tm = fTransport.GetMember(idx); if (tm->IsPeerToPeer()) fTransport.SubscribeToChannelGrp(tm, kNetChanListenListUpdate); } } } else if( plNetMsgGameMessageDirected::ConvertNoRef( msg ) ) { channel = kNetChanDirectedMsg; } return channel; }
// // show lists of members, listenList, and talkList // void plNetClientMgr::IShowLists() { plNetLinkingMgr * lm = plNetLinkingMgr::GetInstance(); plDebugText &txt = plDebugText::Instance(); int y,x,i; const int yOff=10, xOff=300, startY=70, startX=10; char str[256]; // My player info x=startX; 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", GetFlagsBit(kSendingVoice) ? "V" : " ", GetFlagsBit(kSendingActions) ? "A" : " ", GetPlayerName().c_str(), GetPlayerID(), 0, IsPeerToPeer(), GetJoinOrder(), 0, pos.fX, pos.fY, pos.fZ); txt.DrawString(x,y,str,255,255,255,255); SetFlagsBit(kSendingVoice, 0); SetFlagsBit(kSendingActions, 0); y+=yOff; sprintf(str, " Server=%s ILIAS=%d", "foo", IsLoadingInitialAgeState()); txt.DrawString(x,y,str,255,255,255,255); // MEMBERS y+=yOff; int baseY=y; txt.DrawString(x,y," Members",255,255,255,255,plDebugText::kStyleBold); y+=yOff; plNetTransportMember** members=nil; fTransport.GetMemberListDistSorted(members); for(i=0;i<fTransport.GetNumMembers();i++) { plNetTransportMember* mbr=members[i]; hsAssert(mbr, "ShowLists: nil member?"); if (mbr->IsServer()) continue; player = (mbr->GetAvatarKey() ? plSceneObject::ConvertNoRef(mbr->GetAvatarKey()->ObjectIsLoaded()) : nil); sprintf(str, "%s%s %s p2p=%d 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; mbr->SetTransportFlags(mbr->GetTransportFlags() & ~(plNetTransportMember::kSendingVoice|plNetTransportMember::kSendingActions)); } delete [] members; // LISTENLIST x+=xOff; y=baseY; txt.DrawString(x,y,"ListenList",255,255,255,255,plDebugText::kStyleBold); y+=yOff; for(i=0;i<GetListenList()->GetNumMembers();i++) { sprintf(str, "name=%s", GetListenList()->GetMember(i)->AsString().c_str()); txt.DrawString(x,y,str); y+=yOff; } // TALKLIST x+=xOff; y=baseY; txt.DrawString(x,y,"TalkList",255,255,255,255,plDebugText::kStyleBold); y+=yOff; for(i=0;i<GetTalkList()->GetNumMembers();i++) { sprintf(str, "name=%s", GetTalkList()->GetMember(i)->AsString().c_str()); txt.DrawString(x,y,str); y+=yOff; } }