bool Auth2Certificate::UnpackHook(ReadBuffer &theData) { if(!AuthBase::UnpackHook(theData)) return false; unsigned short aDataCount = theData.ReadShort(); for(int i=0; i<aDataCount; i++) { unsigned short aTypeId = theData.ReadShort(); unsigned short aDataLen = theData.ReadShort(); int aPos = theData.pos(); switch(aTypeId) { case 0: // standard login data { mUserId = theData.ReadLong(); unsigned short aKeyLen = theData.ReadShort(); if(!mPubKey.SetPublicKey(theData.ReadBytes(aKeyLen),aKeyLen)) return false; theData.ReadWString(mUserName); unsigned char aCommunityCount = theData.ReadByte(); for(int i=0; i<aCommunityCount; i++) mCommunityTrustMap[theData.ReadLong()] = theData.ReadShort(); } break; case 1: // user data { DWORD aCommunityId = theData.ReadLong(); mUserDataMap[aCommunityId] = theData.ReadBuf(2); } break; case 2: // nickname { wstring aKey, aVal; theData.ReadWString(aKey); theData.ReadWString(aVal); mNicknameMap[aKey] = aVal; } break; case 3: // KeyId data block { DWORD aCommunityId = theData.ReadLong(); DWORD aKeyId = theData.ReadLong(); mKeyIdMap[aCommunityId] = aKeyId; } break; } theData.ReadBytes(aDataLen - (theData.pos() - aPos)); } return true; }
WONStatus RoutingRegisterClientOp::HandleReply(unsigned char theMsgType, ReadBuffer &theMsg) { WONStatus aStatus; if(theMsgType==RoutingGetClientListReply || theMsgType==RoutingGetClientListReplyEx) { if(!(mRegisterFlags&RoutingRegisterClientFlag_GetClientListEx)) // clientlistex includes clientlist ( == 0x14) return WS_RoutingOp_DontWantReply; RoutingGetClientListOpPtr anOp = new RoutingGetClientListOp(mConnection); aStatus = anOp->HandleReply(theMsgType,theMsg); mClientMap = anOp->GetClientMap(); mReplyCount++; } else if(theMsgType==RoutingRegisterClientReply) { aStatus = (WONStatus)theMsg.ReadShort(); if(aStatus==WS_Success) { mClientId = theMsg.ReadShort(); theMsg.ReadWString(mClientName); mReconnectId = theMsg.ReadLong(); } mReplyCount++; } else return WS_RoutingOp_DontWantReply; if(aStatus!=WS_Success || mReplyCount==mNumRepliesNeeded) return aStatus; else return WS_RoutingOp_NeedMoreReplies; }
WONStatus RoutingServerAlertOp::HandleReply(unsigned char theMsgType, ReadBuffer &theMsg) { if(theMsgType!=RoutingServerAlert) return WS_RoutingOp_DontWantReply; theMsg.ReadWString(mAlertText); return WS_Success; }
WONStatus RoutingGroupNameChangedOp::HandleReply(unsigned char theMsgType, ReadBuffer &theMsg) { if(theMsgType!=RoutingGroupNameChanged) return WS_RoutingOp_DontWantReply; mGroupId = theMsg.ReadShort(); theMsg.ReadWString(mNewGroupName); return WS_Success; }
WONStatus RoutingGroupJoinAttemptOp::HandleReply(unsigned char theMsgType, ReadBuffer &theMsg) { if(theMsgType!=RoutingGroupJoinAttempt) return WS_RoutingOp_DontWantReply; mClientId = theMsg.ReadShort(); mGroupId = theMsg.ReadShort(); theMsg.ReadWString(mComment); mJoinGroupFlags = theMsg.ReadByte(); return WS_Success; }
WONStatus RoutingGroupInvitationOp::HandleReply(unsigned char theMsgType, ReadBuffer &theMsg) { if(theMsgType!=RoutingGroupInvitation) return WS_RoutingOp_DontWantReply; mGroupId = theMsg.ReadShort(); mCaptainId = theMsg.ReadShort(); mAmInvited = theMsg.ReadBool(); theMsg.ReadWString(mComment); return WS_Success; }
WONStatus RoutingYouWereBannedOp::HandleReply(unsigned char theMsgType, ReadBuffer &theMsg) { if(theMsgType!=RoutingYouWereBanned) return WS_RoutingOp_DontWantReply; mGroupId = theMsg.ReadShort(); mAmBanned = theMsg.ReadBool(); theMsg.ReadWString(mBanComment); mBanTime = theMsg.ReadLong(); return WS_Success; }
void RoutingGetGroupListOp::ParseReplyExceptForStatus(ReadBuffer &theMsg) { mGroupMap.clear(); mFlags = theMsg.ReadShort(); unsigned short aNumGroups = theMsg.ReadShort(); for(int i=0; i<aNumGroups; i++) { unsigned short aLen = theMsg.ReadShort(); unsigned long aBeginPos = theMsg.pos(); RoutingGroupInfoPtr anInfo = GetNewGroupInfo(); anInfo->mId = theMsg.ReadShort(); if (HasGroupName()) theMsg.ReadWString(anInfo->mName); if (HasCaptainId()) anInfo->mCaptainId = theMsg.ReadShort(); if (HasMaxPlayers()) anInfo->mMaxPlayers = theMsg.ReadShort(); if (HasGroupFlags()) anInfo->mFlags = theMsg.ReadLong(); if (HasAsyncFlags()) anInfo->mAsyncFlags = theMsg.ReadLong(); if (HasObserverCount()) anInfo->mObserverCount = theMsg.ReadShort(); if (HasMemberCount()) anInfo->mMemberCount = theMsg.ReadShort(); if (HasMembers()) { for(int j=0; j<anInfo->mMemberCount; j++) { RoutingMemberInfoPtr aMemberInfo = GetNewMemberInfo(); aMemberInfo->mClientId = theMsg.ReadShort(); aMemberInfo->mFlags = theMsg.ReadByte(); anInfo->mMemberMap[aMemberInfo->mClientId] = aMemberInfo; } } // if (theMsg.HasMoreBytes()) // anInfo->mParentId = theMsg.ReadShort(); mGroupMap[anInfo->mId] = anInfo; theMsg.ReadBytes(aLen - (theMsg.pos() - aBeginPos)); } if(HasClientCount() && theMsg.HasMoreBytes()) mClientCount = theMsg.ReadShort(); }
bool LobbyGame::ReadSummary(ReadBuffer &theMsg) { try { if(mGameType==LobbyGameType_Internet) mIPAddr.SetSixByte(theMsg.ReadBytes(6)); else { unsigned short aLanProductId = theMsg.ReadShort(); if(aLanProductId!=LobbyMisc::GetLanProductId()) return false; } mInProgress = theMsg.ReadBool(); if(mGameType!=LobbyGameType_Internet) { std::wstring aName; theMsg.ReadWString(aName); mName = aName; } mSkillLevel = (LobbySkillLevel)theMsg.ReadByte(); if(mSkillLevel<LobbySkillLevel_None || mSkillLevel>=LobbySkillLevel_Max) mSkillLevel = LobbySkillLevel_None; if(mGameType!=LobbyGameType_Internet) { unsigned char aProtectionFlags = theMsg.ReadByte(); mHasPassword = (aProtectionFlags & 0x01)?true:false; mInviteOnly = (aProtectionFlags & 0x02)?true:false; mAskToJoin = (aProtectionFlags & 0x04)?true:false; } mNumPlayers = theMsg.ReadShort(); mMaxPlayers = theMsg.ReadShort(); return ReadSummaryHook(theMsg); } catch(ReadBufferException&) { } return false; }
WONStatus RoutingGetMembersOfGroupOp::HandleReply(unsigned char theMsgType, ReadBuffer &theMsg) { if(theMsgType!=RoutingGetMembersOfGroupReply) return WS_RoutingOp_DontWantReply; WONStatus aStatus = (WONStatus)theMsg.ReadShort(); unsigned short aGroupId = theMsg.ReadShort(); if(aGroupId!=mGroupId) return WS_RoutingOp_DontWantReply; if(aStatus==WS_Success) { unsigned char aFlags = theMsg.ReadByte(); mHasClientNames = ((aFlags & RoutingGroupAsyncFlag_DistributeClientName) != 0); mHasClientFlags = ((aFlags & RoutingGroupAsyncFlag_DistributeClientFlags) != 0); mObserverCount = theMsg.ReadShort(); unsigned short aNumMembers = theMsg.ReadShort(); for(int j=0; j<aNumMembers; j++) { unsigned short aLen = theMsg.ReadShort(); unsigned long aBeginPos = theMsg.pos(); RoutingMemberInfoPtr aMemberInfo = GetNewMemberInfo(); aMemberInfo->mClientId = theMsg.ReadShort(); aMemberInfo->mFlags = theMsg.ReadByte(); mMemberMap[aMemberInfo->mClientId] = aMemberInfo; if(aFlags!=0) aMemberInfo->mClientInfo = GetNewClientInfo(); if(mHasClientNames) theMsg.ReadWString(aMemberInfo->mClientInfo->mName); if(mHasClientFlags) aMemberInfo->mClientInfo->mFlags = theMsg.ReadLong(); theMsg.ReadBytes(aLen - (theMsg.pos() - aBeginPos)); } } return aStatus; }