//用户通知 bool CClientKernel::OnIPCUser(const IPC_Head * pHead, const void * pIPCBuffer, WORD wDataSize, HWND hWndSend) { ASSERT(pHead->wMainCmdID==IPC_MAIN_USER); switch (pHead->wSubCmdID) { case IPC_SUB_USER_COME: //用户消息 { //效验参数 ASSERT(wDataSize>=sizeof(tagUserInfoHead)); if (wDataSize<sizeof(tagUserInfoHead)) return false; //读取基本信息 tagUserData UserData; memset(&UserData,0,sizeof(UserData)); tagUserInfoHead * pUserInfoHead=(tagUserInfoHead *)pIPCBuffer; UserData.wFaceID=pUserInfoHead->wFaceID; UserData.wTableID=pUserInfoHead->wTableID; UserData.wChairID=pUserInfoHead->wChairID; UserData.cbGender=pUserInfoHead->cbGender; UserData.cbUserStatus=pUserInfoHead->cbUserStatus; UserData.cbMemberOrder=pUserInfoHead->cbMemberOrder; UserData.cbMasterOrder=pUserInfoHead->cbMasterOrder; UserData.dwUserID=pUserInfoHead->dwUserID; UserData.dwGameID=pUserInfoHead->dwGameID; UserData.dwGroupID=pUserInfoHead->dwGroupID; UserData.dwUserRight=pUserInfoHead->dwUserRight; UserData.dwMasterRight=pUserInfoHead->dwMasterRight; UserData.lScore=pUserInfoHead->UserScoreInfo.lScore; UserData.lWinCount=pUserInfoHead->UserScoreInfo.lWinCount; UserData.lLostCount=pUserInfoHead->UserScoreInfo.lLostCount; UserData.lDrawCount=pUserInfoHead->UserScoreInfo.lDrawCount; UserData.lFleeCount=pUserInfoHead->UserScoreInfo.lFleeCount; UserData.lExperience=pUserInfoHead->UserScoreInfo.lExperience; //读取扩展信息 void * pDataBuffer=NULL; tagDataDescribe DataDescribe; CRecvPacketHelper RecvPacket(pUserInfoHead+1,wDataSize-sizeof(tagUserInfoHead)); while (true) { pDataBuffer=RecvPacket.GetData(DataDescribe); if (DataDescribe.wDataDescribe==DTP_NULL) break; switch (DataDescribe.wDataDescribe) { case DTP_USER_ACCOUNTS: //用户帐户 { ASSERT(pDataBuffer!=NULL); ASSERT(DataDescribe.wDataSize<=sizeof(UserData.szName)); if (DataDescribe.wDataSize<=sizeof(UserData.szName)) { CopyMemory(&UserData.szName,pDataBuffer,DataDescribe.wDataSize); UserData.szName[CountArray(UserData.szName)-1]=0; } break; } case DTP_UNDER_WRITE: //个性签名 { ASSERT(pDataBuffer!=NULL); ASSERT(DataDescribe.wDataSize<=sizeof(UserData.szUnderWrite)); if (DataDescribe.wDataSize<=sizeof(UserData.szUnderWrite)) { CopyMemory(&UserData.szUnderWrite,pDataBuffer,DataDescribe.wDataSize); UserData.szUnderWrite[CountArray(UserData.szUnderWrite)-1]=0; } break; } case DTP_USER_GROUP_NAME: //用户社团 { ASSERT(pDataBuffer!=NULL); ASSERT(DataDescribe.wDataSize<=sizeof(UserData.szGroupName)); if (DataDescribe.wDataSize<=sizeof(UserData.szGroupName)) { CopyMemory(&UserData.szGroupName,pDataBuffer,DataDescribe.wDataSize); UserData.szGroupName[CountArray(UserData.szGroupName)-1]=0; } break; } case DTP_USER_COMPANION: //用户关系 { ASSERT(pDataBuffer!=NULL); ASSERT(DataDescribe.wDataSize<=sizeof(UserData.cbCompanion)); if (DataDescribe.wDataSize<=sizeof(UserData.cbCompanion)) { CopyMemory(&UserData.cbCompanion,pDataBuffer,DataDescribe.wDataSize); } break; } } } //增加用户 ActiveUserItem(&UserData); return true; } case IPC_SUB_USER_STATUS: //用户状态 { //效验参数 ASSERT(wDataSize>=sizeof(IPC_UserStatus)); if (wDataSize<sizeof(IPC_UserStatus)) return false; //消息处理 IPC_UserStatus * pUserStatus=(IPC_UserStatus *)pIPCBuffer; if (pUserStatus->cbUserStatus<US_SIT) { if (pUserStatus->dwUserID==m_dwUserID) { ResetClientKernel(); return true; } else DeleteUserItem(pUserStatus->dwUserID); } else UpdateUserItem(pUserStatus->dwUserID,pUserStatus->cbUserStatus,pUserStatus->wNetDelay); return true; } case IPC_SUB_USER_SCORE: //用户积分 { //效验参数 ASSERT(wDataSize>=sizeof(IPC_UserScore)); if (wDataSize<sizeof(IPC_UserScore)) return false; //消息处理 IPC_UserScore * pUserScore=(IPC_UserScore *)pIPCBuffer; UpdateUserItem(pUserScore->dwUserID,&pUserScore->UserScore); return true; } case IPC_SUB_GAME_START: //游戏开始 { //设置用户 for (WORD i=0;i<m_ServerAttribute.wChairCount;i++) { if (m_pUserItem[i]!=NULL) { m_pUserItem[i]->cbUserStatus=US_PLAY; m_pIClientKernelSink->OnEventUserStatus(m_pUserItem[i],m_pUserItem[i]->wChairID,false); } } return true; } case IPC_SUB_GAME_FINISH: //游戏结束 { //设置用户 for (WORD i=0;i<m_ServerAttribute.wChairCount;i++) { if (m_pUserItem[i]!=NULL) { m_pUserItem[i]->cbUserStatus=US_SIT; m_pIClientKernelSink->OnEventUserStatus(m_pUserItem[i],m_pUserItem[i]->wChairID,false); } } return true; } } return false; }
//用户通知 bool CClientKernel::OnIPCUser(const IPC_Head * pHead, const void * pIPCBuffer, WORD wDataSize, HWND hWndSend) { switch (pHead->wSubCmdID) { case IPC_SUB_USER_COME: //用户消息 { //效验参数 if (wDataSize<sizeof(tagUserInfoHead)) return false; //读取基本信息 tagUserData *pUserData = new tagUserData; tagUserInfoHead * pUserInfoHead=(tagUserInfoHead *)pIPCBuffer; pUserData->wFaceID=pUserInfoHead->wFaceID; //pUserData->dwCustomFaceVer=pUserInfoHead->dwCustomFaceVer; pUserData->wTableID=pUserInfoHead->wTableID; pUserData->wChairID=pUserInfoHead->wChairID; pUserData->cbGender=pUserInfoHead->cbGender; pUserData->cbUserStatus=pUserInfoHead->cbUserStatus; pUserData->cbMemberOrder=pUserInfoHead->cbMemberOrder; pUserData->cbMasterOrder=pUserInfoHead->cbMasterOrder; pUserData->dwUserID=pUserInfoHead->dwUserID; pUserData->dwGameID=pUserInfoHead->dwGameID; pUserData->dwGroupID=pUserInfoHead->dwGroupID; pUserData->dwUserRight=pUserInfoHead->dwUserRight; //pUserData->dwLoveliness=pUserInfoHead->dwLoveliness; pUserData->dwMasterRight=pUserInfoHead->dwMasterRight; pUserData->lScore=pUserInfoHead->UserScoreInfo.lScore; //pUserData->lGameGold=pUserInfoHead->UserScoreInfo.lGameGold; //pUserData->lInsureScore=pUserInfoHead->UserScoreInfo.lInsureScore; pUserData->lWinCount=pUserInfoHead->UserScoreInfo.lWinCount; pUserData->lLostCount=pUserInfoHead->UserScoreInfo.lLostCount; pUserData->lDrawCount=pUserInfoHead->UserScoreInfo.lDrawCount; pUserData->lFleeCount=pUserInfoHead->UserScoreInfo.lFleeCount; pUserData->lExperience=pUserInfoHead->UserScoreInfo.lExperience; //for ( WORD wPropID = 0; wPropID < PROPERTY_COUNT; ++wPropID ) //{ //pUserData->dwPropResidualTime[wPropID] = pUserInfoHead->dwPropResidualTime[wPropID]; //} //读取扩展信息 void * pDataBuffer=NULL; tagDataDescribe DataDescribe; CRecvPacketHelper RecvPacket(pUserInfoHead+1,wDataSize-sizeof(tagUserInfoHead)); while (true) { pDataBuffer=RecvPacket.GetData(DataDescribe); if (DataDescribe.wDataDescribe==DTP_NULL) break; switch (DataDescribe.wDataDescribe) { case DTP_USER_ACCOUNTS: //用户帐户 { if (DataDescribe.wDataSize<=sizeof(pUserData->szName)) { CopyMemory(&pUserData->szName,pDataBuffer,DataDescribe.wDataSize); //pUserData->szName[sizeof(pUserData->czNickName)-1]=0; } break; } case DTP_UNDER_WRITE: //个性签名 { if (DataDescribe.wDataSize<=sizeof(pUserData->szUnderWrite)) { CopyMemory(&pUserData->szUnderWrite,pDataBuffer,DataDescribe.wDataSize); //pUserData->szUnderWrite[CountArray(UserData.szUnderWrite)-1]=0; } break; } case DTP_USER_GROUP_NAME: //用户社团 { if (DataDescribe.wDataSize<=sizeof(pUserData->szGroupName)) { CopyMemory(&pUserData->szGroupName,pDataBuffer,DataDescribe.wDataSize); //pUserData->szGroupName[CountArray(UserData.szGroupName)-1]=0; } break; } case DTP_USER_COMPANION: //用户关系 { if (DataDescribe.wDataSize<=sizeof(pUserData->cbCompanion)) { CopyMemory(&pUserData->cbCompanion,pDataBuffer,DataDescribe.wDataSize); } break; } //case DTP_USER_NICKNAME: //用户昵称 // { // if (DataDescribe.wDataSize<=sizeof(pUserData->czNickName)) // { // CopyMemory(&pUserData->szNickName,pDataBuffer,DataDescribe.wDataSize); // } // break; // } } } //增加用户 ActiveUserItem(pUserData); return true; } case IPC_SUB_USER_STATUS: //用户状态 { //效验参数 if (wDataSize<sizeof(IPC_UserStatus)) return false; //消息处理 IPC_UserStatus * pUserStatus=(IPC_UserStatus *)pIPCBuffer; if (pUserStatus->cbUserStatus<US_SIT) { if (pUserStatus->dwUserID==m_dwUserID) { ResetClientKernel(); return true; } else DeleteUserItem(pUserStatus->dwUserID); } else UpdateUserItem(pUserStatus->dwUserID,pUserStatus->cbUserStatus,pUserStatus->wNetDelay); return true; } case IPC_SUB_USER_SCORE: //用户积分 { //效验参数 if (wDataSize<sizeof(IPC_UserScore)) return false; //消息处理 IPC_UserScore * pUserScore=(IPC_UserScore *)pIPCBuffer; //tagUserData *pUserData = SearchUserItem(pUserScore->dwUserID); //pUserData->dwLoveliness = pUserScore->UserScore->dwLoveliness; UpdateUserItem(pUserScore->dwUserID,&pUserScore->UserScore); return true; } //case IPC_SUB_MEMBERORDER: //会员等级 // { // //效验参数 // if (wDataSize<sizeof(IPC_MemberOrder)) return false; // //消息处理 // IPC_MemberOrder * pMemberOrder=(IPC_MemberOrder *)pIPCBuffer; // tagUserData *pUserData = SearchUserItem(pMemberOrder->dwUserID); // pUserData->cbMemberOrder = pMemberOrder->cbMember; // //更新界面 // m_pIClientKernelSink->OnEventUserMemberOrder(pUserData,pUserData->wChairID,false); // return true; // } case IPC_SUB_GAME_START: //游戏开始 { //设置用户 for (WORD i=0;i<m_ServerAttribute.wChairCount;i++) { if (m_pUserItem[i]!=NULL) { m_pUserItem[i]->cbUserStatus=US_PLAY; m_pIClientKernelSink->OnEventUserStatus(m_pUserItem[i],m_pUserItem[i]->wChairID,false); } } return true; } case IPC_SUB_GAME_FINISH: //游戏结束 { //设置用户 for (WORD i=0;i<m_ServerAttribute.wChairCount;i++) { if (m_pUserItem[i]!=NULL) { m_pUserItem[i]->cbUserStatus=US_SIT; m_pIClientKernelSink->OnEventUserStatus(m_pUserItem[i],m_pUserItem[i]->wChairID,false); } } return true; } //case IPC_SUB_UPDATE_FACE: //更新头像 // { // return true; // } } return false; }