bool MMatchNPCManager::Spawn(MUID& uidNPC, MUID& uidController, unsigned char nSpawnPositionIndex) { MMatchObject* pObject = MMatchServer::GetInstance()->GetObject(uidController); if ((pObject) && (m_pStage)) { MMatchNPCObject* pNPCObject = GetNPCObject(uidNPC); if (pNPCObject) { SetNPCObjectToControllerInfo(uidController, pNPCObject); // route cmd MCommand* pCmd = MMatchServer::GetInstance()->CreateCommand(MC_QUEST_NPC_SPAWN, uidController); pCmd->AddParameter(new MCmdParamUID(uidController)); pCmd->AddParameter(new MCmdParamUID(uidNPC)); pCmd->AddParameter(new MCmdParamUChar((unsigned char)pNPCObject->GetType())); pCmd->AddParameter(new MCmdParamUChar((unsigned char)nSpawnPositionIndex)); MMatchServer::GetInstance()->RouteToBattle(m_pStage->GetUID(), pCmd); // #ifdef _DEBUG // char text[256]; // sprintf(text, "Spawn(%u:%u) - (%u:%u)\n", uidNPC.High, uidNPC.Low, uidController.High, uidController.Low); // OutputDebugString(text); // #endif return true; } } return false; }
void MMatchServer::OnAsyncInsertEvent( MAsyncJob* pJobResult ) { if( 0 == pJobResult ) return; MAsyncDBJob_EventLog* pEventJob = reinterpret_cast< MAsyncDBJob_EventLog* >( pJobResult ); if( pEventJob->GetAnnounce().empty() ) return; if( MASYNC_RESULT_SUCCEED == pJobResult->GetResult() ) { MCommand* pCmd; AsyncEventObjVec::const_iterator it, end; const AsyncEventObjVec& EventObjList = pEventJob->GetEventObjList(); end = EventObjList.end(); for( it = EventObjList.begin(); it != end; ++it ) { if( MUID(0, 0) != it->uidUser ) { pCmd = CreateCommand( MC_MATCH_ANNOUNCE, it->uidUser ); if( 0 != pCmd ) { pCmd->AddParameter( new MCmdParamUInt(0) ); pCmd->AddParameter( new MCmdParamStr(pEventJob->GetAnnounce().c_str()) ); Post( pCmd ); } } } } }
void MMatchClient::SendCommandByTunneling(MCommand* pCommand) { if (GetAllowTunneling() == false) { } else { if (GetBridgePeerFlag() == false) { MCommand* pCmd = CreateCommand(MC_AGENT_TUNNELING_TCP, GetAgentServerUID()); pCmd->AddParameter(new MCmdParamUID(GetPlayerUID())); pCmd->AddParameter(new MCmdParamUID(pCommand->GetReceiverUID())); // Create Param : Command Blob //// if (!MakeTunnelingCommandBlob(pCmd, pCommand)) { delete pCmd; pCmd=NULL; return; } /////////////////////////////////// SendCommandToAgent(pCmd); delete pCmd; // PACKETQUEUE 만들때까지 delete 임시로 사용 } else { MCommand* pCmd = CreateCommand(MC_AGENT_TUNNELING_UDP, GetAgentServerUID()); pCmd->AddParameter(new MCmdParamUID(GetPlayerUID())); pCmd->AddParameter(new MCmdParamUID(pCommand->GetReceiverUID())); // Create Param : Command Blob //// if (!MakeTunnelingCommandBlob(pCmd, pCommand)) { delete pCmd; pCmd=NULL; return; } /////////////////////////////////// SendCommandByUDP(pCmd, GetAgentIP(), GetAgentPeerPort()); delete pCmd; // PACKETQUEUE 만들때까지 delete 임시로 사용 } } }
bool MMatchNPCManager::AssignControl(MUID& uidNPC, MUID& uidPlayer) { MMatchObject* pObject = MMatchServer::GetInstance()->GetObject(uidPlayer); if (!pObject) return false; MMatchNPCObject* pNPCObject = GetNPCObject(uidNPC); if (!pNPCObject) return false; // ControllerInfo 세팅 SetNPCObjectToControllerInfo(uidPlayer, pNPCObject); // route cmd MCommand* pCmd = MMatchServer::GetInstance()->CreateCommand(MC_QUEST_ENTRUST_NPC_CONTROL, uidPlayer); pCmd->AddParameter(new MCmdParamUID(uidPlayer)); pCmd->AddParameter(new MCmdParamUID(uidNPC)); MMatchServer::GetInstance()->RouteToBattle(m_pStage->GetUID(), pCmd); #ifdef _DEBUG char text[256]; sprintf(text, "AssignControl(%u:%u) - (%u:%u)\n", uidNPC.High, uidNPC.Low, uidPlayer.High, uidPlayer.Low); OutputDebugString(text); #endif return true; }
void MMatchServer::OnAsyncBuyQuestItem( MAsyncJob* pJobReslt ) { MAsyncDBJob_BuyQuestItem* pJob = (MAsyncDBJob_BuyQuestItem*)pJobReslt; if( MASYNC_RESULT_SUCCEED != pJob->GetResult() ){ return; } MMatchObject* pPlayer = GetObject( pJob->GetPlayerUID() ); if( NULL == pPlayer ) { return; } MMatchCharInfo* pCharInfo = pPlayer->GetCharInfo(); if( NULL == pCharInfo ) { return; } // 아이템 거래 카운트 증가. 내부에서 디비 업데이트 결정. pCharInfo->GetDBQuestCachingData().IncreaseShopTradeCount(pJob->GetItemCount()); pCharInfo->m_nBP -= pJob->GetPrice(); MCommand* pNewCmd = CreateCommand( MC_MATCH_RESPONSE_BUY_QUEST_ITEM, pJob->GetPlayerUID() ); if( 0 == pNewCmd ) { mlog( "MMatchServer::OnResponseBuyQuestItem - new Command실패.\n" ); return; } pNewCmd->AddParameter( new MCmdParamInt(MOK) ); pNewCmd->AddParameter( new MCmdParamInt(pCharInfo->m_nBP) ); PostSafeQueue( pNewCmd ); // 퀘스트 아이템 리스트를 다시 전송함. OnRequestCharQuestItemList( pJob->GetPlayerUID() ); }
MCommand* MMatchObjectCacheBuilder::GetResultCmd(MATCHCACHEMODE nMode, MCommandCommunicator* pCmdComm) { MCommand* pCmd = pCmdComm->CreateCommand(MC_MATCH_OBJECT_CACHE, MUID(0,0)); pCmd->AddParameter(new MCmdParamUChar(nMode)); int nCount = (int)m_ObjectCacheList.size(); void* pCacheArray = MMakeBlobArray(sizeof(MMatchObjCache), nCount); int nIndex=0; for (MMatchObjCacheList::iterator itor=m_ObjectCacheList.begin(); itor!=m_ObjectCacheList.end(); itor++) { MMatchObjCache* pTrgCache = (MMatchObjCache*)MGetBlobArrayElement(pCacheArray, nIndex++); MMatchObjCache* pSrcCache = (*itor); pTrgCache->SetInfo(pSrcCache->GetUID(), pSrcCache->GetName(), pSrcCache->GetClanName(), pSrcCache->GetLevel(), pSrcCache->GetUGrade(), pSrcCache->GetPGrade() , pSrcCache->GetRank(), pSrcCache->GetKillCount(), pSrcCache->GetDeathCount(), pSrcCache->GetDTGrade() ); pTrgCache->SetFlags(pSrcCache->GetFlags()); pTrgCache->SetCLID(pSrcCache->GetCLID()); pTrgCache->SetEmblemChecksum(pSrcCache->GetEmblemChecksum()); pTrgCache->AssignCostume(pSrcCache->GetCostume()); } pCmd->AddParameter(new MCmdParamBlob(pCacheArray, MGetBlobArraySize(pCacheArray))); MEraseBlobArray(pCacheArray); return pCmd; }
void MMatchClient::CastStageBridgePeer(const MUID& uidChar, const MUID& uidStage) { MCommand* pCmd = new MCommand(m_CommandManager.GetCommandDescByID(MC_MATCH_BRIDGEPEER), GetServerUID(), m_This); pCmd->AddParameter(new MCommandParameterUID(uidChar)); pCmd->AddParameter(new MCommandParameterUInt(0)); // 수신측에서 IP로 치환됨 pCmd->AddParameter(new MCommandParameterUInt(0)); // 수신측에서 Port로 치환됨 MSafeUDP* pSafeUDP = GetSafeUDP(); SendCommandByUDP(pCmd, GetServerIP(), GetServerPeerPort()); delete pCmd; }
void MMatchServer::OnReport(const MUID& uidSender, const char* pName, const char* pReason) { MMatchObject* pObj = GetObject(uidSender); if (pObj && IsAdminGrade(pObj)) { char message[512]; if (strstr(pName, "%") || strstr(pReason, "%")) return; sprintf(message, "[REPORT]<%s> - %s : %s", pObj->GetCharInfo()->m_szName, pName, pReason); MCommand* pCmd = CreateCommand(MC_MATCH_ANNOUNCE, MUID(0,0)); pCmd->AddParameter(new MCommandParameterUInt(0)); pCmd->AddParameter(new MCommandParameterString(message)); } }
void MMatchClient::CastAgentPeerConnect() { MCommand* pCmd = new MCommand(m_CommandManager.GetCommandDescByID(MC_AGENT_PEER_BINDUDP), GetAgentServerUID(), m_This); pCmd->AddParameter(new MCommandParameterUID(GetPlayerUID())); pCmd->AddParameter(new MCommandParameterString("localhost")); pCmd->AddParameter(new MCommandParameterUInt(0)); pCmd->AddParameter(new MCommandParameterString("")); // 수신측에서 IP로 치환됨 pCmd->AddParameter(new MCommandParameterUInt(0)); // 수신측에서 Port로 치환됨 // MSafeUDP* pSafeUDP = GetSafeUDP(); SendCommandByUDP(pCmd, GetAgentIP(), GetAgentPeerPort()); delete pCmd; }
void MMatchServer::OnAsyncGetAccountItemList( MAsyncJob* pJobResult ) { MAsyncDBJob_GetAccountItemList* pJob = (MAsyncDBJob_GetAccountItemList*)pJobResult; if( MASYNC_RESULT_SUCCEED != pJob->GetResult() ) { mlog("GetAccountItemList Failed\n"); return; } MMatchObject* pObj = GetObject( pJob->GetPlayerUID() ); if( NULL == pObj ) return; if( !pJob->GetExpiredAccountItems().empty() ) { ResponseExpiredItemIDList(pObj, pJob->GetExpiredAccountItems()); } const int nAccountItemCount = pJob->GetAccountItemCount(); if (nAccountItemCount > 0) { MAccountItemNode* accountItems = pJob->GetAccountItemList(); if( NULL == accountItems ) return; MCommand* pNew = CreateCommand(MC_MATCH_RESPONSE_ACCOUNT_ITEMLIST, pObj->GetUID()); // 갖고 있는 아이템 리스트 전송 int nCountableAccountItemCount = 0; for(int i = 0; i < nAccountItemCount; i++ ) { if( accountItems[i].nCount > 0 && accountItems[i].nItemID > 0 ) { nCountableAccountItemCount++; } } void* pItemArray = MMakeBlobArray(sizeof(MTD_AccountItemNode), nCountableAccountItemCount); int nIndex = 0; for (int i = 0; i < nAccountItemCount; i++) { if( accountItems[i].nItemID == 0 ) continue; MTD_AccountItemNode* pItemNode = (MTD_AccountItemNode*)MGetBlobArrayElement(pItemArray, nIndex); _ASSERTE( ((NULL != MGetMatchItemDescMgr()->GetItemDesc(accountItems[i].nItemID)) || (NULL != m_GambleMachine.GetGambleItemByGambleItemID(accountItems[i].nItemID))) && "zitem.xml or GambleItem에 기술되어 있지 않는 아이템입니다." ); if( accountItems[i].nCount > 0 ) { Make_MTDAccountItemNode(pItemNode, accountItems[i].nAIID, accountItems[i].nItemID , accountItems[i].nRentMinutePeriodRemainder, accountItems[i].nCount); nIndex++; if( nIndex == nCountableAccountItemCount ) { break; } } } pNew->AddParameter(new MCommandParameterBlob(pItemArray, MGetBlobArraySize(pItemArray))); MEraseBlobArray(pItemArray); PostSafeQueue( pNew ); } }
void MMatchServer::OnAdminRequestKickPlayer(const MUID& uidAdmin, const char* szPlayer) { MMatchObject* pObj = GetObject(uidAdmin); if (pObj == NULL) return; if (!IsAdminGrade(pObj)) return; if ((strlen(szPlayer)) < 2) return; int nRet = MOK; MMatchObject* pTargetObj = GetPlayerByName(szPlayer); if (pTargetObj != NULL) { #ifdef LOCALE_KOREA pTargetObj->DisconnectHacker( MMHT_COMMAND_BLOCK_BY_ADMIN ); #else // Notify Message 필요 -> 관리자 전용 - 해결(특별한 메세지 필요 없음) Disconnect(pTargetObj->GetUID()); #endif } else { nRet = MERR_ADMIN_NO_TARGET; } MCommand* pNew = CreateCommand(MC_ADMIN_RESPONSE_KICK_PLAYER, MUID(0,0)); pNew->AddParameter(new MCmdParamInt(nRet)); RouteToListener(pObj, pNew); }
void MMatchServer::OnAdminRequestBlockPlayer(const MUID& uidAdmin, const char* szPlayer, const int nPenaltyHour) { MMatchObject* pObj = GetObject(uidAdmin); if (pObj == NULL) return; if (!IsAdminGrade(pObj)) return; if ((strlen(szPlayer)) < 2) return; int nRet = MOK; MMatchObject* pTargetObj = GetPlayerByName(szPlayer); if (pTargetObj != NULL) { pTargetObj->GetAccountPenaltyInfo()->SetPenaltyInfo(MPC_CONNECT_BLOCK, nPenaltyHour); const MPenaltyInfo* pPenaltyInfo = pTargetObj->GetAccountPenaltyInfo()->GetPenaltyInfo(MPC_CONNECT_BLOCK); if( m_MatchDBMgr.InsertAccountPenaltyInfo(pTargetObj->GetAccountInfo()->m_nAID , pPenaltyInfo->nPenaltyCode, nPenaltyHour, pObj->GetAccountName()) == false ) { pTargetObj->GetAccountPenaltyInfo()->ClearPenaltyInfo(MPC_CONNECT_BLOCK); nRet = MERR_ADNIN_CANNOT_PENALTY_ON_DB; } } else { nRet = MERR_ADMIN_NO_TARGET; } MCommand* pNew = CreateCommand(MC_ADMIN_RESPONSE_BLOCK_PLAYER, MUID(0,0)); pNew->AddParameter(new MCmdParamInt(nRet)); if( nRet == MOK ) { Disconnect(pTargetObj->GetUID()); } RouteToListener(pObj, pNew); }
void MMatchActiveTrapMgr::RouteTrapActivationForForcedEnterd(MMatchActiveTrap* pTrap) { OutputDebugStr("Notify Trap activation to ForcedEnteredPlayer\n"); if (!pTrap || !pTrap->IsActivated()) { _ASSERT(0); return; } if (!m_pStage) return; int numTarget = (int)pTrap->m_vecUidForcedEntered.size(); if (numTarget <= 0) return; void* pTrapArray = MMakeBlobArray(sizeof(MTD_ActivatedTrap), 1); MTD_ActivatedTrap* pNode = (MTD_ActivatedTrap*)MGetBlobArrayElement(pTrapArray, 0); Make_MTDActivatedTrap(pNode, pTrap); MCommand* pCommand = MMatchServer::GetInstance()->CreateCommand(MC_MATCH_NOTIFY_ACTIATED_TRAPITEM_LIST, MUID(0,0)); pCommand->AddParameter(new MCommandParameterBlob(pTrapArray, MGetBlobArraySize(pTrapArray))); MMatchObject* pObj; for (int i=0; i<numTarget; ++i) { pObj = m_pStage->GetObj( pTrap->m_vecUidForcedEntered[i]); if (!pObj) continue; MCommand* pSendCmd = pCommand->Clone(); MMatchServer::GetInstance()->RouteToListener(pObj, pSendCmd); } delete pCommand; MEraseBlobArray(pTrapArray); pTrap->m_vecUidForcedEntered.clear(); }
void MMatchClient::OnResponseAgentLogin() { MCommand* pCmd = CreateCommand(MC_AGENT_PEER_BINDTCP, GetAgentServerUID()); pCmd->AddParameter(new MCmdParamUID(GetPlayerUID())); Post(pCmd); mlog("Logged in Agent, Bind TCP \n"); }
void MMatchServer::OnAsyncSurvivalModePrivateRanking(MAsyncJob* pJobResult) { MAsyncDBJob_GetSurvivalModePrivateRanking* pJob = (MAsyncDBJob_GetSurvivalModePrivateRanking*)pJobResult; if( MASYNC_RESULT_SUCCEED != pJob->GetResult() ) { mlog("MMatchServer::OnAsyncSurvivalModePrivateRanking - 실패! stageUID[%d] playerCID[%d]\n", pJob->GetStageUID(), pJob->GetCID()); return; } #ifdef _DEBUG mlog("MMatchServer::OnAsyncSurvivalModePrivateRanking - Test Log입니다. 성공!\n"); // 다음은 MAsyncDBJob_GetSurvivalModePrivateRanking Class의 사용 요령입니다. // Class에서 더 필요한 부분이 있으면 수정하시면 됩니다. mlog("-------- User Ranking Info --------\n"); mlog("User CID = %d\n", pJob->GetCID()); for(DWORD dwScenarioID = 1; dwScenarioID < MAX_SURVIVAL_SCENARIO_COUNT + 1; dwScenarioID++) { RANKINGINFO* pRankingInfo = pJob->GetPrivateRankingInfo(dwScenarioID); mlog("Scenario ID = %01d, Ranking = %d, Ranking Point = %d\n", dwScenarioID, pRankingInfo->dwRanking, pRankingInfo->dwRankingPoint); } #endif _ASSERT( pJob->GetScenarioID()-1 < MAX_SURVIVAL_SCENARIO_COUNT ); RANKINGINFO* pRankingInfo = pJob->GetPrivateRankingInfo( pJob->GetScenarioID() ); if (pRankingInfo) { // 플레이어에게 랭킹 정보를 보낸다 MCommand* pCmdPrivateRanking = MGetMatchServer()->CreateCommand( MC_SURVIVAL_PRIVATERANKING, MUID(0, 0) ); if( NULL == pCmdPrivateRanking ) return; pCmdPrivateRanking->AddParameter( new MCommandParameterUInt(pRankingInfo->dwRanking) ); pCmdPrivateRanking->AddParameter( new MCommandParameterUInt(pRankingInfo->dwRankingPoint) ); RouteToObjInStage(pJob->GetStageUID(), pJob->GetPlayerUID(), pCmdPrivateRanking); } else _ASSERT(0); }
void MMatchActiveTrapMgr::RouteAllTraps(MMatchObject* pObj) { // 난입한 유저에게 현재 월드에 발동되어 있는 트랩 아이템들을 알려주기 위한 함수 OutputDebugStr("Trap RouteAllTrap to ForcedEntered\n"); MMatchActiveTrap* pTrap; // 아직 발동되지 않은 트랩(던져서 날아가고 있는 중)은 이후 발동할 때 따로 알려줄 수 있도록 표시해둔다 for (ItorTrap it=m_listTrap.begin(); it!=m_listTrap.end(); ++it) { pTrap = *it; if (!pTrap->IsActivated()) { pTrap->AddForcedEnteredPlayer(pObj->GetUID()); OutputDebugStr("Trap RESERVE To NOTIFY AddForcedEnteredPlayer\n"); } } // 발동되어 있는 트랩은 목록을 보내준다 int num = 0; for (ItorTrap it=m_listTrap.begin(); it!=m_listTrap.end(); ++it) if ((*it)->IsActivated()) ++num; if (num <= 0) return; void* pTrapArray = MMakeBlobArray(sizeof(MTD_ActivatedTrap), num); MTD_ActivatedTrap* pNode; int nIndex = 0; for (ItorTrap it=m_listTrap.begin(); it!=m_listTrap.end(); ++it) { pTrap = *it; if (pTrap->IsActivated()) { pNode = (MTD_ActivatedTrap*)MGetBlobArrayElement(pTrapArray, nIndex++); Make_MTDActivatedTrap(pNode, pTrap); } else { // 아직 발동되지 않은 트랩(던져서 날아가고 있는 중)은 이후 발동할 때 따로 알려줄 수 있도록 표시해둔다 pTrap->AddForcedEnteredPlayer(pObj->GetUID()); OutputDebugStr("Trap RESERVE To NOTIFY AddForcedEnteredPlayer\n"); } } MCommand* pCmd = MMatchServer::GetInstance()->CreateCommand(MC_MATCH_NOTIFY_ACTIATED_TRAPITEM_LIST, MUID(0,0)); pCmd->AddParameter(new MCommandParameterBlob(pTrapArray, MGetBlobArraySize(pTrapArray))); MEraseBlobArray(pTrapArray); MMatchServer::GetInstance()->RouteToListener(pObj, pCmd); }
void MMatchServer::OnAdminForumAnnounce(const MUID& uidAdmin, const char* szChat) { MMatchObject* pObj = GetObject(uidAdmin); if (pObj == NULL) return; // 관리자 권한을 가진 사람이 아니면 연결을 끊는다. if (!IsAdminGrade(pObj)) { // DisconnectObject(uidAdmin); return; } char szMsg[256]; strcpy(szMsg, szChat); MCommand* pCmd = CreateCommand(MC_ADMIN_FORUM_ANNOUNCE, MUID(0,0)); pCmd->AddParameter(new MCmdParamUID(uidAdmin)); pCmd->AddParameter(new MCmdParamStr(szMsg)); RouteToAllClient(pCmd); }
void MMatchServer::AdminTerminalOutput(const MUID& uidAdmin, const char* szText) { MMatchObject* pObj = GetObject(uidAdmin); if (pObj == NULL) return; // 관리자 권한을 가진 사람이 아니면 연결을 끊는다. if (pObj->GetAccountInfo()->m_nUGrade != MMUG_ADMIN) { // DisconnectObject(uidAdmin); return; } char szMsg[65535]; strcpy_safe(szMsg, szText); MCommand* pCmd = CreateCommand(MC_ADMIN_TERMINAL, MUID(0,0)); pCmd->AddParameter(new MCmdParamUID(uidAdmin)); pCmd->AddParameter(new MCmdParamStr(szMsg)); RouteToListener(pObj, pCmd); }
void MMatchServer::OnAsyncCreateChar(MAsyncJob* pJobResult) { MAsyncDBJob_CreateChar* pJob = (MAsyncDBJob_CreateChar*)pJobResult; if (pJob->GetResult() != MASYNC_RESULT_SUCCEED) { char szTime[128]=""; _strtime(szTime); mlog("[%s] Async DB Query(CreateChar) Failed\n", szTime); return; } MMatchObject* pObj = GetObject(pJob->GetUID()); if (pObj == NULL) return; // Make Result MCommand* pNewCmd = CreateCommand(MC_MATCH_RESPONSE_CREATE_CHAR, MUID(0,0)); pNewCmd->AddParameter(new MCommandParameterInt(pJob->GetDBResult())); // result pNewCmd->AddParameter(new MCommandParameterString(pJob->GetCharName())); // 만들어진 캐릭터 이름 RouteToListener( pObj, pNewCmd ); }
void MMatchRuleAssassinate::OnRoundBegin() { MMatchServer* pServer = MMatchServer::GetInstance(); MMatchStage* pStage = GetStage(); if (pServer==NULL || pStage==NULL) return; m_uidRedCommander = ChooseCommander(MMT_RED); m_uidBlueCommander = ChooseCommander(MMT_BLUE); if ( (m_uidRedCommander == MUID(0,0)) || (m_uidBlueCommander == MUID(0,0)) ) { // Wait the game SetRoundState(MMATCH_ROUNDSTATE_FREE); return; } // Let players know the commander... MCommand* pCmd = pServer->CreateCommand(MC_MATCH_ASSIGN_COMMANDER, MUID(0,0)); pCmd->AddParameter(new MCmdParamUID(m_uidRedCommander)); pCmd->AddParameter(new MCmdParamUID(m_uidBlueCommander)); pServer->RouteToStage(pStage->GetUID(), pCmd); // OutputDebugString("Assassinate::OnRoundBegin() \n"); }
void MMatchServer::OnAdminTerminal(const MUID& uidAdmin, const char* szText) { MMatchObject* pObj = GetObject(uidAdmin); if (pObj == NULL) return; // 관리자 권한을 가진 사람이 아니면 연결을 끊는다. if (!IsAdminGrade(pObj)) { // DisconnectObject(uidAdmin); return; } char szOut[32768]; szOut[0] = 0; if (m_Admin.Execute(uidAdmin, szText)) { MCommand* pNew = CreateCommand(MC_ADMIN_TERMINAL, MUID(0,0)); pNew->AddParameter(new MCmdParamUID(MUID(0,0))); pNew->AddParameter(new MCmdParamStr(szOut)); RouteToListener(pObj, pNew); } }
bool MMatchServer::OnAdminExecute(MAdminArgvInfo* pAI, char* szOut, int maxlen) { szOut[0] = 0; if (pAI->cargc <= 0) return false; // wall if (!_stricmp(pAI->cargv[0], "wall")) { if (pAI->cargc < 3) { sprintf_safe(szOut, maxlen, "인자가 부족합니다."); return true; } char szMsg[256]; int nMsgType = 0; strcpy_safe(szMsg, pAI->cargv[1]); nMsgType = atoi(pAI->cargv[2]); MCommand* pCmd = CreateCommand(MC_ADMIN_ANNOUNCE, MUID(0,0)); pCmd->AddParameter(new MCmdParamUID(MUID(0,0))); pCmd->AddParameter(new MCmdParamStr(szMsg)); pCmd->AddParameter(new MCmdParamUInt(nMsgType)); RouteToAllClient(pCmd); } else { sprintf_safe(szOut, maxlen, "%s: no such command", pAI->cargv[0]); } return true; }
void MMatchServer::OnStop(const MUID& uidSender, const char* pName) { MMatchObject* pObj = GetObject(uidSender); if (pObj && IsAdminGrade(pObj)) { MMatchObject* pTarget = GetPlayerByName(pName); if (pTarget) { MCommand* pCmd = CreateCommand(MC_ADMIN_STOP, MUID(0,0)); pCmd->AddParameter(new MCmdParamStr(pName)); RouteToListener(pTarget, pCmd); } LogCommand("stop", pObj->GetCharInfo()->m_szName, ""); } }
void MMatchServer::OnAdminPingToAll(const MUID& uidAdmin) { MMatchObject* pObj = GetObject(uidAdmin); if (pObj == NULL) return; // 관리자 권한을 가진 사람이 아니면 연결을 끊는다. if (!IsAdminGrade(pObj)) { // DisconnectObject(uidAdmin); return; } MCommand* pNew = CreateCommand(MC_NET_PING, MUID(0,0)); pNew->AddParameter(new MCmdParamUInt(GetGlobalClockCount())); RouteToAllConnection(pNew); }
void MMatchClient::UpdateUDPTestProcess() { int nProcessCount = 0; for (MMatchPeerInfoList::iterator i=m_Peers.begin(); i!=m_Peers.end(); i++) { MMatchPeerInfo* pPeer = (*i).second; if (pPeer->GetProcess()) { pPeer->UseTestCount(); if (pPeer->GetTestCount() <= 0) { pPeer->StopUDPTest(); MCommand* pCmd = CreateCommand(MC_MATCH_REQUEST_PEER_RELAY, GetServerUID()); pCmd->AddParameter(new MCmdParamUID(GetPlayerUID())); pCmd->AddParameter(new MCmdParamUID(pPeer->uidChar)); Post(pCmd); } else { nProcessCount++; } } } if (nProcessCount <= 0) SetUDPTestProcess(false); }
void MMatchServer::OnAsyncGetAccountCharList(MAsyncJob* pJobResult) { MAsyncDBJob_GetAccountCharList* pJob = (MAsyncDBJob_GetAccountCharList*)pJobResult; if (pJob->GetResult() != MASYNC_RESULT_SUCCEED) { char szTime[128]=""; _strtime(szTime); mlog("[%s] Async DB Query(ResponseAccountCharList) Failed\n", szTime); return; } MMatchObject* pObj = GetObject(pJob->GetUID()); if (pObj == NULL) return; const int nCharCount = pJob->GetCharCount(); const MTD_AccountCharInfo * pCharList = pJob->GetCharList(); MTD_AccountCharInfo* pTransCharInfo = NULL; int nCharMaxLevel = 0; MCommand* pNewCmd = CreateCommand(MC_MATCH_RESPONSE_ACCOUNT_CHARLIST, MUID(0,0)); void* pCharArray = MMakeBlobArray(sizeof(MTD_AccountCharInfo), nCharCount); for (int i = 0; i < nCharCount; i++) { pTransCharInfo = (MTD_AccountCharInfo*)MGetBlobArrayElement(pCharArray, i); memcpy(pTransCharInfo, &pCharList[i], sizeof(MTD_AccountCharInfo)); nCharMaxLevel = max(nCharMaxLevel, pTransCharInfo->nLevel); } pObj->CheckNewbie( nCharMaxLevel ); pNewCmd->AddParameter(new MCommandParameterBlob(pCharArray, MGetBlobArraySize(pCharArray))); MEraseBlobArray(pCharArray); RouteToListener( pObj, pNewCmd ); }
bool MBMatchServer::AddClanServerAnnounceSchedule() { char szTest[] = "클랜전 게임을 11시 50분에 닫도록 하겠습니다."; MCommand* pCmd = CreateCommand( MC_MATCH_SCHEDULE_ANNOUNCE_MAKE, MUID(0, 0) ); if( 0 == pCmd ) return false; MCommandParameterString* pCmdPrmStr = new MCommandParameterString( szTest ); if( 0 == pCmdPrmStr ){ delete pCmd; return false; } if( !pCmd->AddParameter(pCmdPrmStr) ){ delete pCmd; return false; } tm t; MMatchGetLocalTime(&t); MMatchScheduleData* pScheduleData = m_pScheduler->MakeOnceScheduleData( t.tm_year - 100, t.tm_mon + 1, GetMaxDay(), 23, 40, pCmd ); if( 0 == pScheduleData ){ delete pCmd; return false; } if( !m_pScheduler->AddDynamicSchedule(pScheduleData) ){ pScheduleData->Release(); delete pScheduleData; return false; } return true; }
bool ZGameClient::OnCommand(MCommand* pCommand) { bool ret = MMatchClient::OnCommand(pCommand); switch (pCommand->GetID()) { case MC_MATCH_PING_LIST: { auto Param = pCommand->GetParameter(0); if (Param->GetType() != MPT_BLOB) break; void* Blob = Param->GetPointer(); int Count = MGetBlobArrayCount(Blob); for (int i = 0; i < Count; i++) { auto& Ping = *static_cast<MTD_PingInfo*>(MGetBlobArrayElement(Blob, i)); if (Ping.UID == GetPlayerUID()) { PingToServer = Ping.Ping; continue; } auto Peer = GetPeers()->Find(Ping.UID); if (Peer) Peer->UpdatePing(GetGlobalTimeMS(), Ping.Ping); auto Char = ZGetCharacterManager()->Find(Ping.UID); if (Char) Char->Ping = Ping.Ping; } } break; case MC_MATCH_RESPONSE_LOGIN_FAILED: { char szReason[4096]; if (!pCommand->GetParameter(szReason, 0, MPT_STR, sizeof(szReason))) break; ZGetGameInterface()->ShowErrorMessage(szReason); ZPostDisconnect(); } break; case MC_MATCH_RESPONSE_CREATE_ACCOUNT: { char szMessage[128]; if (!pCommand->GetParameter(szMessage, 0, MPT_STR, sizeof(szMessage))) break; ZGetGameInterface()->ShowErrorMessage(szMessage); } break; case MC_NET_ONDISCONNECT: break; case MC_NET_ONERROR: break; case ZC_CHANGESKIN: { char szSkinName[256]; pCommand->GetParameter(szSkinName, 0, MPT_STR, sizeof(szSkinName)); if (ZApplication::GetGameInterface()->ChangeInterfaceSkin(szSkinName)) { MClient::OutputMessage(MZMOM_LOCALREPLY, "Change Skin To %s", szSkinName); } else { MClient::OutputMessage(MZMOM_LOCALREPLY, "Change Skin Failed"); } } break; case MC_ADMIN_TERMINAL: { #ifndef _PUBLISH char szText[65535]; szText[0] = 0; MUID uidChar; pCommand->GetParameter(&uidChar, 0, MPT_UID); pCommand->GetParameter(szText, 1, MPT_STR, sizeof(szText)); OutputToConsole(szText); #endif } break; case MC_NET_CHECKPING: { MUID uid; if (pCommand->GetParameter(&uid, 0, MPT_UID) == false) break; MCommand* pNew = new MCommand(m_CommandManager.GetCommandDescByID(MC_NET_PING), uid, m_This); pNew->AddParameter(new MCommandParameterUInt(GetGlobalTimeMS())); Post(pNew); return true; } case MC_NET_PING: { unsigned int nTimeStamp; if (pCommand->GetParameter(&nTimeStamp, 0, MPT_UINT) == false) break; MCommand* pNew = new MCommand(m_CommandManager.GetCommandDescByID(MC_NET_PONG), pCommand->m_Sender, m_This); pNew->AddParameter(new MCommandParameterUInt(nTimeStamp)); Post(pNew); return true; } case MC_NET_PONG: { int nTimeStamp; pCommand->GetParameter(&nTimeStamp, 0, MPT_UINT); MClient::OutputMessage(MZMOM_LOCALREPLY, "Ping from (%u:%u) = %d", pCommand->GetSenderUID().High, pCommand->GetSenderUID().Low, GetGlobalTimeMS() - nTimeStamp); } break; case ZC_CON_CONNECT: { char szBuf[256]; sprintf_safe(szBuf, "Net.Connect %s:%d", ZGetConfiguration()->GetServerIP(), ZGetConfiguration()->GetServerPort()); ConsoleInputEvent(szBuf); SetServerAddr(ZGetConfiguration()->GetServerIP(), ZGetConfiguration()->GetServerPort()); } break; case ZC_CON_DISCONNECT: { ConsoleInputEvent("Net.Disconnect"); } break; case ZC_CON_CLEAR: { if (ZGetConsole()) ZGetConsole()->ClearMessage(); } break; case ZC_CON_HIDE: { if (ZGetConsole()) ZGetConsole()->Show(false); } break; case ZC_CON_SIZE: { if (ZGetConsole()) { int iConWidth, iConHeight; pCommand->GetParameter(&iConWidth, 0, MPT_INT); pCommand->GetParameter(&iConHeight, 1, MPT_INT); if ((iConWidth > 30) && (iConHeight > 30)) { MPOINT point = ZGetConsole()->GetPosition(); ZGetConsole()->SetBounds(point.x, point.y, iConWidth, iConHeight); } } } break; case MC_CLOCK_SYNCHRONIZE: { u32 nGlobalClock; pCommand->GetParameter(&nGlobalClock, 0, MPT_UINT); u32 nLocalClock = GetClockCount(); if (nGlobalClock > nLocalClock) m_bIsBigGlobalClock = true; else m_bIsBigGlobalClock = false; m_nClockDistance = ZGetClockDistance(nGlobalClock, nLocalClock); } break; case MC_MATCH_NOTIFY: { unsigned int nMsgID = 0; if (pCommand->GetParameter(&nMsgID, 0, MPT_UINT) == false) break; OnMatchNotify(nMsgID); } break; case MC_MATCH_BRIDGEPEER_ACK: { MUID uidChar; int nCode; pCommand->GetParameter(&uidChar, 0, MPT_UID); pCommand->GetParameter(&nCode, 1, MPT_INT); OnBridgePeerACK(uidChar, nCode); } break; case MC_MATCH_STAGE_RESPONSE_FORCED_ENTRY: { int nResult; pCommand->GetParameter(&nResult, 0, MPT_INT); if (nResult == MOK) { OnForcedEntryToGame(); } else { ZApplication::GetGameInterface()->ShowMessage("Forced entry rejected"); } } break; case MC_MATCH_STAGE_JOIN: { MUID uidChar, uidStage; unsigned int nRoomNo = 0; char szStageName[256] = ""; pCommand->GetParameter(&uidChar, 0, MPT_UID); pCommand->GetParameter(&uidStage, 1, MPT_UID); pCommand->GetParameter(&nRoomNo, 2, MPT_UINT); pCommand->GetParameter(szStageName, 3, MPT_STR, sizeof(szStageName)); OnStageJoin(uidChar, uidStage, nRoomNo, szStageName); } break; case MC_MATCH_STAGE_LEAVE: { MUID uidChar, uidStage; pCommand->GetParameter(&uidChar, 0, MPT_UID); pCommand->GetParameter(&uidStage, 1, MPT_UID); OnStageLeave(uidChar, uidStage); } break; case MC_MATCH_STAGE_START: { MUID uidChar, uidStage; int nCountdown; pCommand->GetParameter(&uidChar, 0, MPT_UID); pCommand->GetParameter(&uidStage, 1, MPT_UID); pCommand->GetParameter(&nCountdown, 2, MPT_INT); OnStageStart(uidChar, uidStage, nCountdown); } break; case MC_MATCH_STAGE_LAUNCH: { MUID uidStage; char szMapName[_MAX_DIR]; pCommand->GetParameter(&uidStage, 0, MPT_UID); pCommand->GetParameter(szMapName, 1, MPT_STR, sizeof(szMapName)); OnStageLaunch(uidStage, szMapName); } break; case MC_MATCH_STAGE_FINISH_GAME: { MUID uidStage; pCommand->GetParameter(&uidStage, 0, MPT_UID); OnStageFinishGame(uidStage); } break; case MC_MATCH_STAGE_MAP: { MUID uidStage; char szMapName[_MAX_DIR]; pCommand->GetParameter(&uidStage, 0, MPT_UID); pCommand->GetParameter(szMapName, 1, MPT_STR, sizeof(szMapName)); OnStageMap(uidStage, szMapName); } break; case MC_MATCH_STAGE_TEAM: { MUID uidChar, uidStage; unsigned int nTeam; pCommand->GetParameter(&uidChar, 0, MPT_UID); pCommand->GetParameter(&uidStage, 1, MPT_UID); pCommand->GetParameter(&nTeam, 2, MPT_UINT); OnStageTeam(uidChar, uidStage, nTeam); } break; case MC_MATCH_STAGE_PLAYER_STATE: { MUID uidChar, uidStage; int nObjectStageState; pCommand->GetParameter(&uidChar, 0, MPT_UID); pCommand->GetParameter(&uidStage, 1, MPT_UID); pCommand->GetParameter(&nObjectStageState, 2, MPT_INT); OnStagePlayerState(uidChar, uidStage, MMatchObjectStageState(nObjectStageState)); } break; case MC_MATCH_STAGE_MASTER: { MUID uidChar, uidStage; pCommand->GetParameter(&uidStage, 0, MPT_UID); pCommand->GetParameter(&uidChar, 1, MPT_UID); OnStageMaster(uidStage, uidChar); } break; case MC_MATCH_STAGE_CHAT: { MUID uidStage, uidChar; static char szChat[512]; pCommand->GetParameter(&uidChar, 0, MPT_UID); pCommand->GetParameter(&uidStage, 1, MPT_UID); pCommand->GetParameter(szChat, 2, MPT_STR, sizeof(szChat)); OnStageChat(uidChar, uidStage, szChat); } break; case MC_MATCH_STAGE_LIST: { char nPrevStageCount, nNextStageCount; pCommand->GetParameter(&nPrevStageCount, 0, MPT_CHAR); pCommand->GetParameter(&nNextStageCount, 1, MPT_CHAR); MCommandParameter* pParam = pCommand->GetParameter(2); if (pParam->GetType() != MPT_BLOB) break; void* pBlob = pParam->GetPointer(); int nCount = MGetBlobArrayCount(pBlob); OnStageList((int)nPrevStageCount, (int)nNextStageCount, pBlob, nCount); } break; case MC_MATCH_CHANNEL_RESPONSE_PLAYER_LIST: { unsigned char nTotalPlayerCount, nPage; pCommand->GetParameter(&nTotalPlayerCount, 0, MPT_UCHAR); pCommand->GetParameter(&nPage, 1, MPT_UCHAR); MCommandParameter* pParam = pCommand->GetParameter(2); if (pParam->GetType() != MPT_BLOB) break; void* pBlob = pParam->GetPointer(); int nCount = MGetBlobArrayCount(pBlob); OnChannelPlayerList((int)nTotalPlayerCount, (int)nPage, pBlob, nCount); } break; case MC_MATCH_CHANNEL_RESPONSE_ALL_PLAYER_LIST: { MUID uidChannel; pCommand->GetParameter(&uidChannel, 0, MPT_UID); MCommandParameter* pParam = pCommand->GetParameter(1); if (pParam->GetType() != MPT_BLOB) break; void* pBlob = pParam->GetPointer(); int nCount = MGetBlobArrayCount(pBlob); OnChannelAllPlayerList(uidChannel, pBlob, nCount); } break; case MC_MATCH_RESPONSE_FRIENDLIST: { MCommandParameter* pParam = pCommand->GetParameter(0); if (pParam->GetType() != MPT_BLOB) break; void* pBlob = pParam->GetPointer(); int nCount = MGetBlobArrayCount(pBlob); OnResponseFriendList(pBlob, nCount); } break; case MC_MATCH_RESPONSE_STAGESETTING: { MUID uidStage; pCommand->GetParameter(&uidStage, 0, MPT_UID); MCommandParameter* pStageParam = pCommand->GetParameter(1); if (pStageParam->GetType() != MPT_BLOB) break; void* pStageBlob = pStageParam->GetPointer(); int nStageCount = MGetBlobArrayCount(pStageBlob); MCommandParameter* pCharParam = pCommand->GetParameter(2); if (pCharParam->GetType() != MPT_BLOB) break; void* pCharBlob = pCharParam->GetPointer(); int nCharCount = MGetBlobArrayCount(pCharBlob); int nStageState; pCommand->GetParameter(&nStageState, 3, MPT_INT); MUID uidMaster; pCommand->GetParameter(&uidMaster, 4, MPT_UID); OnResponseStageSetting(uidStage, pStageBlob, nStageCount, pCharBlob, nCharCount, static_cast<STAGE_STATE>(nStageState), uidMaster); } break; case MC_MATCH_RESPONSE_PEER_RELAY: { MUID uidPeer; if (pCommand->GetParameter(&uidPeer, 0, MPT_UID) == false) break; OnResponsePeerRelay(uidPeer); } break; case MC_MATCH_LOADING_COMPLETE: { MUID uidChar; int nPercent; if (pCommand->GetParameter(&uidChar, 0, MPT_UID) == false) break; if (pCommand->GetParameter(&nPercent, 1, MPT_INT) == false) break; OnLoadingComplete(uidChar, nPercent); } break; case MC_MATCH_ANNOUNCE: { unsigned int nType; char szMsg[256]; pCommand->GetParameter(&nType, 0, MPT_UINT); pCommand->GetParameter(szMsg, 1, MPT_STR, sizeof(szMsg)); OnAnnounce(nType, szMsg); } break; case MC_MATCH_CHANNEL_RESPONSE_JOIN: { MUID uidChannel; int nChannelType; char szChannelName[256]; pCommand->GetParameter(&uidChannel, 0, MPT_UID); pCommand->GetParameter(&nChannelType, 1, MPT_INT); pCommand->GetParameter(szChannelName, 2, MPT_STR, sizeof(szChannelName)); OnChannelResponseJoin(uidChannel, (MCHANNEL_TYPE)nChannelType, szChannelName); } break; case MC_MATCH_CHANNEL_CHAT: { MUID uidChannel, uidChar; char szChat[512]; char szName[256]; int nGrade; pCommand->GetParameter(&uidChannel, 0, MPT_UID); pCommand->GetParameter(szName, 1, MPT_STR, sizeof(szName)); pCommand->GetParameter(szChat, 2, MPT_STR, sizeof(szChat)); pCommand->GetParameter(&nGrade, 3, MPT_INT); OnChannelChat(uidChannel, szName, szChat, nGrade); } break; case MC_MATCH_CHANNEL_LIST: { MCommandParameter* pParam = pCommand->GetParameter(0); if (pParam->GetType() != MPT_BLOB) break; void* pBlob = pParam->GetPointer(); int nCount = MGetBlobArrayCount(pBlob); OnChannelList(pBlob, nCount); } break; case MC_MATCH_CHANNEL_RESPONSE_RULE: { MUID uidChannel; pCommand->GetParameter(&uidChannel, 0, MPT_UID); char szRuleName[128]; pCommand->GetParameter(szRuleName, 1, MPT_STR, sizeof(szRuleName)); OnChannelResponseRule(uidChannel, szRuleName); } break; case MC_MATCH_RESPONSE_RECOMMANDED_CHANNEL: { MUID uidChannel; pCommand->GetParameter(&uidChannel, 0, MPT_UID); OnResponseRecommandedChannel(uidChannel); } break; case MC_ADMIN_ANNOUNCE: { char szChat[512]; u32 nMsgType = 0; pCommand->GetParameter(szChat, 1, MPT_STR, sizeof(szChat)); pCommand->GetParameter(&nMsgType, 2, MPT_UINT); OnAdminAnnounce(szChat, ZAdminAnnounceType(nMsgType)); } break; case MC_MATCH_GAME_LEVEL_UP: { MUID uidChar; pCommand->GetParameter(&uidChar, 0, MPT_UID); OnGameLevelUp(uidChar); } break; case MC_MATCH_GAME_LEVEL_DOWN: { MUID uidChar; pCommand->GetParameter(&uidChar, 0, MPT_UID); OnGameLevelDown(uidChar); } break; case MC_MATCH_RESPONSE_GAME_INFO: { MUID uidStage; pCommand->GetParameter(&uidStage, 0, MPT_UID); MCommandParameter* pParam = pCommand->GetParameter(1); if (pParam->GetType() != MPT_BLOB) break; void* pGameInfoBlob = pParam->GetPointer(); pParam = pCommand->GetParameter(2); if (pParam->GetType() != MPT_BLOB) break; void* pRuleInfoBlob = pParam->GetPointer(); pParam = pCommand->GetParameter(3); if (pParam->GetType() != MPT_BLOB) break; void* pPlayerInfoBlob = pParam->GetPointer(); OnResponseGameInfo(uidStage, pGameInfoBlob, pRuleInfoBlob, pPlayerInfoBlob); } break; case MC_MATCH_OBTAIN_WORLDITEM: { MUID uidPlayer; int nItemUID; pCommand->GetParameter(&uidPlayer, 0, MPT_UID); pCommand->GetParameter(&nItemUID, 1, MPT_INT); OnObtainWorldItem(uidPlayer, nItemUID); } break; case MC_MATCH_SPAWN_WORLDITEM: { MCommandParameter* pParam = pCommand->GetParameter(0); if (pParam->GetType() != MPT_BLOB) break; void* pSpawnInfoBlob = pParam->GetPointer(); OnSpawnWorldItem(pSpawnInfoBlob); } break; case MC_MATCH_REMOVE_WORLDITEM: { int nItemUID; pCommand->GetParameter(&nItemUID, 0, MPT_INT); OnRemoveWorldItem(nItemUID); } break; case MC_MATCH_USER_WHISPER: { char szSenderName[128] = ""; char szTargetName[128] = ""; char szMessage[1024] = ""; pCommand->GetParameter(szSenderName, 0, MPT_STR, sizeof(szSenderName)); pCommand->GetParameter(szTargetName, 1, MPT_STR, sizeof(szTargetName)); pCommand->GetParameter(szMessage, 2, MPT_STR, sizeof(szMessage)); OnUserWhisper(szSenderName, szTargetName, szMessage); } break; case MC_MATCH_CHATROOM_JOIN: { char szPlayerName[128] = ""; char szChatRoomName[128] = ""; pCommand->GetParameter(szPlayerName, 0, MPT_STR, sizeof(szPlayerName)); pCommand->GetParameter(szChatRoomName, 1, MPT_STR, sizeof(szChatRoomName)); OnChatRoomJoin(szPlayerName, szChatRoomName); } break; case MC_MATCH_CHATROOM_LEAVE: { char szPlayerName[128] = ""; char szChatRoomName[128] = ""; pCommand->GetParameter(szPlayerName, 0, MPT_STR, sizeof(szPlayerName)); pCommand->GetParameter(szChatRoomName, 1, MPT_STR, sizeof(szChatRoomName)); OnChatRoomLeave(szPlayerName, szChatRoomName); } break; case MC_MATCH_CHATROOM_SELECT_WRITE: { char szChatRoomName[128] = ""; pCommand->GetParameter(szChatRoomName, 0, MPT_STR, sizeof(szChatRoomName)); OnChatRoomSelectWrite(szChatRoomName); } break; case MC_MATCH_CHATROOM_INVITE: { char szSenderName[64] = ""; char szTargetName[64] = ""; char szRoomName[128] = ""; pCommand->GetParameter(szSenderName, 0, MPT_STR, sizeof(szSenderName)); pCommand->GetParameter(szTargetName, 1, MPT_STR, sizeof(szTargetName)); pCommand->GetParameter(szRoomName, 2, MPT_STR, sizeof(szRoomName)); OnChatRoomInvite(szSenderName, szRoomName); } break; case MC_MATCH_CHATROOM_CHAT: { char szChatRoomName[128] = ""; char szPlayerName[128] = ""; char szChat[128] = ""; pCommand->GetParameter(szChatRoomName, 0, MPT_STR, sizeof(szChatRoomName)); pCommand->GetParameter(szPlayerName, 1, MPT_STR, sizeof(szPlayerName)); pCommand->GetParameter(szChat, 2, MPT_STR, sizeof(szChat)); OnChatRoomChat(szChatRoomName, szPlayerName, szChat); } break; case ZC_REPORT_119: { OnLocalReport119(); } break; case ZC_MESSAGE: { int nMessageID; pCommand->GetParameter(&nMessageID, 0, MPT_INT); ZGetGameInterface()->ShowMessage(nMessageID); }break; case MC_TEST_PEERTEST_PING: { MUID uidSender = pCommand->GetSenderUID(); char szLog[128]; sprintf_safe(szLog, "PEERTEST_PING: from (%d%d)", uidSender.High, uidSender.Low); ZChatOutput(szLog, ZChat::CMT_SYSTEM); } break; case MC_TEST_PEERTEST_PONG: { } break; case MC_MATCH_CLAN_RESPONSE_CREATE_CLAN: { int nResult, nRequestID; pCommand->GetParameter(&nResult, 0, MPT_INT); pCommand->GetParameter(&nRequestID, 1, MPT_INT); OnResponseCreateClan(nResult, nRequestID); } break; case MC_MATCH_CLAN_RESPONSE_AGREED_CREATE_CLAN: { int nResult; pCommand->GetParameter(&nResult, 0, MPT_INT); OnResponseAgreedCreateClan(nResult); } break; case MC_MATCH_CLAN_ASK_SPONSOR_AGREEMENT: { int nRequestID; char szClanName[256]; MUID uidMasterObject; char szMasterName[256]; pCommand->GetParameter(&nRequestID, 0, MPT_INT); pCommand->GetParameter(szClanName, 1, MPT_STR, sizeof(szClanName)); pCommand->GetParameter(&uidMasterObject, 2, MPT_UID); pCommand->GetParameter(szMasterName, 3, MPT_STR, sizeof(szMasterName)); OnClanAskSponsorAgreement(nRequestID, szClanName, uidMasterObject, szMasterName); } break; case MC_MATCH_CLAN_ANSWER_SPONSOR_AGREEMENT: { MUID uidClanMaster; int nRequestID; bool bAnswer; char szCharName[256]; pCommand->GetParameter(&nRequestID, 0, MPT_INT); pCommand->GetParameter(&uidClanMaster, 1, MPT_UID); pCommand->GetParameter(szCharName, 2, MPT_STR, sizeof(szCharName)); pCommand->GetParameter(&bAnswer, 3, MPT_BOOL); OnClanAnswerSponsorAgreement(nRequestID, uidClanMaster, szCharName, bAnswer); } break; case MC_MATCH_CLAN_RESPONSE_CLOSE_CLAN: { int nResult; pCommand->GetParameter(&nResult, 0, MPT_INT); OnClanResponseCloseClan(nResult); } break; case MC_MATCH_CLAN_RESPONSE_JOIN_CLAN: { int nResult; pCommand->GetParameter(&nResult, 0, MPT_INT); OnClanResponseJoinClan(nResult); } break; case MC_MATCH_CLAN_ASK_JOIN_AGREEMENT: { char szClanName[256], szClanAdmin[256]; MUID uidClanAdmin; pCommand->GetParameter(szClanName, 0, MPT_STR, sizeof(szClanName)); pCommand->GetParameter(&uidClanAdmin, 1, MPT_UID); pCommand->GetParameter(szClanAdmin, 2, MPT_STR, sizeof(szClanAdmin)); OnClanAskJoinAgreement(szClanName, uidClanAdmin, szClanAdmin); } break; case MC_MATCH_CLAN_ANSWER_JOIN_AGREEMENT: { MUID uidClanAdmin; bool bAnswer; char szJoiner[256]; pCommand->GetParameter(&uidClanAdmin, 0, MPT_UID); pCommand->GetParameter(szJoiner, 1, MPT_STR, sizeof(szJoiner)); pCommand->GetParameter(&bAnswer, 2, MPT_BOOL); OnClanAnswerJoinAgreement(uidClanAdmin, szJoiner, bAnswer); } break; case MC_MATCH_CLAN_RESPONSE_AGREED_JOIN_CLAN: { int nResult; pCommand->GetParameter(&nResult, 0, MPT_INT); OnClanResponseAgreedJoinClan(nResult); } break; case MC_MATCH_CLAN_UPDATE_CHAR_CLANINFO: { MCommandParameter* pParam = pCommand->GetParameter(0); if (pParam->GetType() != MPT_BLOB) break; void* pBlob = pParam->GetPointer(); OnClanUpdateCharClanInfo(pBlob); } break; case MC_MATCH_CLAN_RESPONSE_LEAVE_CLAN: { int nResult; pCommand->GetParameter(&nResult, 0, MPT_INT); OnClanResponseLeaveClan(nResult); } break; case MC_MATCH_CLAN_MASTER_RESPONSE_CHANGE_GRADE: { int nResult; pCommand->GetParameter(&nResult, 0, MPT_INT); OnClanResponseChangeGrade(nResult); } break; case MC_MATCH_CLAN_ADMIN_RESPONSE_EXPEL_MEMBER: { int nResult; pCommand->GetParameter(&nResult, 0, MPT_INT); OnClanResponseExpelMember(nResult); } break; case MC_MATCH_CLAN_MSG: { char szSenderName[256]; char szMsg[512]; pCommand->GetParameter(szSenderName, 0, MPT_STR, sizeof(szSenderName)); pCommand->GetParameter(szMsg, 1, MPT_STR, sizeof(szMsg)); OnClanMsg(szSenderName, szMsg); } break; case MC_MATCH_CLAN_RESPONSE_MEMBER_LIST: { MCommandParameter* pParam = pCommand->GetParameter(0); if (pParam->GetType() != MPT_BLOB) break; void* pBlob = pParam->GetPointer(); OnClanMemberList(pBlob); } break; case MC_MATCH_CLAN_RESPONSE_CLAN_INFO: { MCommandParameter* pParam = pCommand->GetParameter(0); if (pParam->GetType() != MPT_BLOB) break; void* pBlob = pParam->GetPointer(); OnClanResponseClanInfo(pBlob); } break; case MC_MATCH_CLAN_RESPONSE_EMBLEMURL: { int nCLID = 0; int nEmblemChecksum = 0; char szURL[4096] = ""; pCommand->GetParameter(&nCLID, 0, MPT_INT); pCommand->GetParameter(&nEmblemChecksum, 1, MPT_INT); pCommand->GetParameter(szURL, 2, MPT_STR, sizeof(szURL)); OnClanResponseEmblemURL(nCLID, nEmblemChecksum, szURL); } break; case MC_MATCH_CLAN_LOCAL_EMBLEMREADY: { int nCLID = 0; char szURL[4096] = ""; pCommand->GetParameter(&nCLID, 0, MPT_INT); pCommand->GetParameter(szURL, 1, MPT_STR, sizeof(szURL)); OnClanEmblemReady(nCLID, szURL); } break; case MC_MATCH_RESPONSE_RESULT: { int nResult; pCommand->GetParameter(&nResult, 0, MPT_INT); if (nResult != MOK) { ZApplication::GetGameInterface()->ShowErrorMessage(nResult); } } break; case MC_MATCH_RESPONSE_CHARINFO_DETAIL: { MCommandParameter* pParam = pCommand->GetParameter(0); if (pParam->GetType() != MPT_BLOB) break; void* pBlob = pParam->GetPointer(); OnResponseCharInfoDetail(pBlob); } break; case MC_MATCH_RESPONSE_PROPOSAL: { int nResult, nProposalMode, nRequestID; pCommand->GetParameter(&nResult, 0, MPT_INT); pCommand->GetParameter(&nProposalMode, 1, MPT_INT); pCommand->GetParameter(&nRequestID, 2, MPT_INT); OnResponseProposal(nResult, MMatchProposalMode(nProposalMode), nRequestID); } break; case MC_MATCH_ASK_AGREEMENT: { MUID uidProposer; int nProposalMode, nRequestID; pCommand->GetParameter(&uidProposer, 0, MPT_UID); MCommandParameter* pParam = pCommand->GetParameter(1); void* pMemberNamesBlob = pParam->GetPointer(); pCommand->GetParameter(&nProposalMode, 2, MPT_INT); pCommand->GetParameter(&nRequestID, 3, MPT_INT); OnAskAgreement(uidProposer, pMemberNamesBlob, MMatchProposalMode(nProposalMode), nRequestID); } break; case MC_MATCH_REPLY_AGREEMENT: { MUID uidProposer, uidChar; char szReplierName[256]; int nProposalMode, nRequestID; bool bAgreement; pCommand->GetParameter(&uidProposer, 0, MPT_UID); pCommand->GetParameter(&uidChar, 1, MPT_UID); pCommand->GetParameter(szReplierName, 2, MPT_STR, sizeof(szReplierName)); pCommand->GetParameter(&nProposalMode, 3, MPT_INT); pCommand->GetParameter(&nRequestID, 4, MPT_INT); pCommand->GetParameter(&bAgreement, 5, MPT_BOOL); OnReplyAgreement(uidProposer, uidChar, szReplierName, MMatchProposalMode(nProposalMode), nRequestID, bAgreement); } break; case MC_MATCH_LADDER_SEARCH_RIVAL: { ZGetGameInterface()->OnArrangedTeamGameUI(true); }break; case MC_MATCH_LADDER_CANCEL_CHALLENGE: { ZGetGameInterface()->OnArrangedTeamGameUI(false); char szCharName[MATCHOBJECT_NAME_LENGTH]; pCommand->GetParameter(szCharName, 0, MPT_STR, sizeof(szCharName)); if (szCharName[0] != 0) { char szOutput[256]; ZTransMsg(szOutput, MSG_LADDER_CANCEL, 1, szCharName); ZChatOutput(MCOLOR(ZCOLOR_CHAT_SYSTEM), szOutput); } else { ZChatOutput(MCOLOR(ZCOLOR_CHAT_SYSTEM), ZMsg(MSG_LADDER_FAILED)); } }break; case MC_MATCH_LADDER_RESPONSE_CHALLENGE: { int nResult; pCommand->GetParameter(&nResult, 0, MPT_INT); OnLadderResponseChallenge(nResult); } break; case MC_MATCH_LADDER_PREPARE: { MUID uidStage; pCommand->GetParameter(&uidStage, 0, MPT_UID); int nTeam; pCommand->GetParameter(&nTeam, 1, MPT_INT); OnLadderPrepare(uidStage, nTeam); }break; case MC_MATCH_LADDER_LAUNCH: { MUID uidStage; pCommand->GetParameter(&uidStage, 0, MPT_UID); char szMapName[128]; pCommand->GetParameter(szMapName, 1, MPT_STR, sizeof(szMapName)); OnLadderLaunch(uidStage, szMapName); }break; case MC_MATCH_CLAN_STANDBY_CLAN_LIST: { int nPrevStageCount, nNextStageCount; pCommand->GetParameter(&nPrevStageCount, 0, MPT_INT); pCommand->GetParameter(&nNextStageCount, 1, MPT_INT); MCommandParameter* pParam = pCommand->GetParameter(2); if (pParam->GetType() != MPT_BLOB) break; void* pBlob = pParam->GetPointer(); OnClanStandbyClanList(nPrevStageCount, nNextStageCount, pBlob); } break; case MC_MATCH_CLAN_MEMBER_CONNECTED: { char szMember[256]; pCommand->GetParameter(szMember, 0, MPT_STR, sizeof(szMember)); OnClanMemberConnected(szMember); } break; case MC_MATCH_NOTIFY_CALLVOTE: { char szDiscuss[128] = ""; char szArg[256] = ""; pCommand->GetParameter(szDiscuss, 0, MPT_STR, sizeof(szDiscuss)); pCommand->GetParameter(szArg, 1, MPT_STR, sizeof(szArg)); OnNotifyCallVote(szDiscuss, szArg); } break; case MC_MATCH_NOTIFY_VOTERESULT: { char szDiscuss[128]; int nResult = 0; pCommand->GetParameter(szDiscuss, 0, MPT_STR, sizeof(szDiscuss)); pCommand->GetParameter(&nResult, 1, MPT_INT); OnNotifyVoteResult(szDiscuss, nResult); } break; case MC_MATCH_VOTE_RESPONSE: { int nMsgCode = 0; pCommand->GetParameter(&nMsgCode, 0, MPT_INT); OnVoteAbort(nMsgCode); } break; case MC_MATCH_BROADCAST_CLAN_RENEW_VICTORIES: { char szWinnerClanName[256], szLoserClanName[256]; int nVictories; pCommand->GetParameter(szWinnerClanName, 0, MPT_STR, sizeof(szWinnerClanName)); pCommand->GetParameter(szLoserClanName, 1, MPT_STR, sizeof(szLoserClanName)); pCommand->GetParameter(&nVictories, 2, MPT_INT); OnBroadcastClanRenewVictories(szWinnerClanName, szLoserClanName, nVictories); } break; case MC_MATCH_BROADCAST_CLAN_INTERRUPT_VICTORIES: { char szWinnerClanName[256], szLoserClanName[256]; int nVictories; pCommand->GetParameter(szWinnerClanName, 0, MPT_STR, sizeof(szWinnerClanName)); pCommand->GetParameter(szLoserClanName, 1, MPT_STR, sizeof(szLoserClanName)); pCommand->GetParameter(&nVictories, 2, MPT_INT); OnBroadcastClanInterruptVictories(szWinnerClanName, szLoserClanName, nVictories); } break; case MC_MATCH_BROADCAST_DUEL_RENEW_VICTORIES: { char szChannelName[256], szChampionName[256]; int nVictories, nRoomNo; pCommand->GetParameter(szChampionName, 0, MPT_STR, sizeof(szChampionName)); pCommand->GetParameter(szChannelName, 1, MPT_STR, sizeof(szChannelName)); pCommand->GetParameter(&nRoomNo, 2, MPT_INT); pCommand->GetParameter(&nVictories, 3, MPT_INT); OnBroadcastDuelRenewVictories(szChampionName, szChannelName, nRoomNo, nVictories); } break; case MC_MATCH_BROADCAST_DUEL_INTERRUPT_VICTORIES: { char szChampionName[256], szInterrupterName[256]; int nVictories; pCommand->GetParameter(szChampionName, 0, MPT_STR, sizeof(szChampionName)); pCommand->GetParameter(szInterrupterName, 1, MPT_STR, sizeof(szInterrupterName)); pCommand->GetParameter(&nVictories, 2, MPT_INT); OnBroadcastDuelInterruptVictories(szChampionName, szInterrupterName, nVictories); } break; case MC_MATCH_RESPONSE_STAGE_FOLLOW: { int nMsgID; pCommand->GetParameter(&nMsgID, 0, MPT_INT); OnFollowResponse(nMsgID); } break; case MC_MATCH_SCHEDULE_ANNOUNCE_SEND: { char cAnnounce[512] = { 0 }; pCommand->GetParameter(cAnnounce, 0, MPT_STR, sizeof(cAnnounce)); ZChatOutput(cAnnounce); } break; case MC_MATCH_EXPIRED_RENT_ITEM: { MCommandParameter* pParam = pCommand->GetParameter(0); if (pParam->GetType() != MPT_BLOB) break; void* pBlob = pParam->GetPointer(); OnExpiredRentItem(pBlob); } break; case MC_MATCH_FIND_HACKING: { } break; case MC_MATCH_ROUTE_UPDATE_STAGE_EQUIP_LOOK: { MUID uidPlayer; int nParts; int nItemID; pCommand->GetParameter(&uidPlayer, 0, MPT_UID); pCommand->GetParameter(&nParts, 1, MPT_INT); pCommand->GetParameter(&nItemID, 2, MPT_INT); OnResponseUpdateStageEquipLook(uidPlayer, nParts, nItemID); } break; default: if (!ret) { } break; } if (m_fnOnCommandCallback) ret = m_fnOnCommandCallback(pCommand); return ret; }
MCommand* MMatchServer::CreateCmdMatchResponseLoginOK(const MUID& uidComm, MUID& uidPlayer, const char* szUserID, MMatchUserGradeID nUGradeID, MMatchPremiumGradeID nPGradeID, int nECoins, // const unsigned char* szRandomValue, const unsigned char* pbyGuidReqMsg) { MCommand* pCmd = CreateCommand(MC_MATCH_RESPONSE_LOGIN, uidComm); pCmd->AddParameter(new MCommandParameterInt(MOK)); pCmd->AddParameter(new MCommandParameterString(MGetServerConfig()->GetServerName())); pCmd->AddParameter(new MCommandParameterChar((char)MGetServerConfig()->GetServerMode())); pCmd->AddParameter(new MCommandParameterString(szUserID)); pCmd->AddParameter(new MCommandParameterUChar((unsigned char)nUGradeID)); pCmd->AddParameter(new MCommandParameterInt((int)nPGradeID)); pCmd->AddParameter(new MCommandParameterInt(nECoins)); pCmd->AddParameter(new MCommandParameterUID(uidPlayer)); pCmd->AddParameter(new MCommandParameterBool((bool)MGetServerConfig()->IsEnabledSurvivalMode())); pCmd->AddParameter(new MCommandParameterBool((bool)MGetServerConfig()->IsEnabledDuelTournament())); // pCmd->AddParameter(new MCommandParameterString(szRandomValue)); // void* pBlob1 = MMakeBlobArray(sizeof(unsigned char), 64); // unsigned char *pCmdBlock1 = (unsigned char*)MGetBlobArrayElement(pBlob1, 0); // CopyMemory(pCmdBlock1, szRandomValue, 64); // pCmd->AddParameter(new MCommandParameterBlob(pBlob1, MGetBlobArraySize(pBlob1))); // MEraseBlobArray(pBlob1); void* pBlob = MMakeBlobArray(sizeof(unsigned char), SIZEOF_GUIDREQMSG); unsigned char* pCmdBlock = (unsigned char*)MGetBlobArrayElement(pBlob, 0); CopyMemory(pCmdBlock, pbyGuidReqMsg, SIZEOF_GUIDREQMSG); pCmd->AddParameter(new MCommandParameterBlob(pBlob, MGetBlobArraySize(pBlob))); MEraseBlobArray(pBlob); return pCmd; }
MCommand* MMatchServer::CreateCmdMatchResponseLoginFailed(const MUID& uidComm, const int nResult) { MCommand* pCmd = CreateCommand(MC_MATCH_RESPONSE_LOGIN, uidComm); pCmd->AddParameter(new MCommandParameterInt(nResult)); pCmd->AddParameter(new MCommandParameterString(MGetServerConfig()->GetServerName())); pCmd->AddParameter(new MCommandParameterChar((char)MGetServerConfig()->GetServerMode())); pCmd->AddParameter(new MCommandParameterString("Ana")); pCmd->AddParameter(new MCommandParameterUChar((unsigned char)MMUG_FREE)); pCmd->AddParameter(new MCommandParameterInt((int)MMPG_FREE)); pCmd->AddParameter(new MCommandParameterInt(0)); pCmd->AddParameter(new MCommandParameterUID(MUID(0,0))); pCmd->AddParameter(new MCommandParameterBool((bool)MGetServerConfig()->IsEnabledSurvivalMode())); pCmd->AddParameter(new MCommandParameterBool((bool)MGetServerConfig()->IsEnabledDuelTournament())); // pCmd->AddParameter(new MCommandParameterString("A")); // unsigned char tmp1 = 'A'; // void* pBlob1 = MMakeBlobArray(sizeof(unsigned char), sizeof(unsigned char)); // unsigned char* pCmdBlock1 = (unsigned char*)MGetBlobArrayElement(pBlob1, 0); // CopyMemory(pCmdBlock1, &tmp1, sizeof(unsigned char)); // pCmd->AddParameter(new MCommandParameterBlob(pBlob1, MGetBlobArraySize(pBlob1))); // MEraseBlobArray(pBlob1); unsigned char tmp = 0; void* pBlob = MMakeBlobArray(sizeof(unsigned char), sizeof(unsigned char)); unsigned char* pCmdBlock = (unsigned char*)MGetBlobArrayElement(pBlob, 0); CopyMemory(pCmdBlock, &tmp, sizeof(unsigned char)); pCmd->AddParameter(new MCommandParameterBlob(pBlob, MGetBlobArraySize(pBlob))); MEraseBlobArray(pBlob); return pCmd; }