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 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 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(); }
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; }
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::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 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 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 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 MComponent::expand( WString& c, const MCommand& cmd ) { if( cmd.size() > 0 ) { cmd.expand( c, _target, _config->nilTool(), _mask, NULL, _mode ); c.concat( "\n" ); _project->insertBlanks( c ); } }
MCommandParameterCommand::MCommandParameterCommand(const MCommand& Command) : MCommandParameter(MPT_CMD) { Size = Command.GetSize(); Data = new char[Size]; OwnsData = true; Command.GetData(Data, Size); }
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 MProject::expand( ContFile& pmak, const MCommand& cmd, const char* head ) { if( cmd.size() > 0 ) { pmak.printf( "%s\n", head ); MCommand c; cmd.expand( c, &_filename, _config->nilTool(), "*", NULL, 0 ); insertBlanks( c ); pmak.puts( c ); pmak.puts( "\n" ); } }
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 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::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)); } }
MCommand* MCommandCommunicator::MakeCmdFromSaneTunnelingBlob(const MUID& Sender, const MUID& Receiver, const void* pBlob, size_t Size) { MCommand* pCmd = new MCommand(); if (!pCmd->SetData((char*)pBlob, &m_CommandManager, (u16)Size)) { delete pCmd; return nullptr; } pCmd->m_Sender = Sender; pCmd->m_Receiver = Receiver; return pCmd; }
MCommand* MMatchClient::MakeCmdFromTunnelingBlob(const MUID& uidSender, void* pBlob, int nBlobArrayCount) { if (nBlobArrayCount != 1) { mlog("MakeCmdFromTunnelingBlob: BlobArrayCount is not 1\n"); return NULL; } char* pPacket = (char*)MGetBlobArrayElement(pBlob, 0); int nSize = MGetBlobArraySize(pBlob) - (sizeof(int) * 2); if ((nSize <= 0) || (nSize >= MAX_BLOB_SIZE)) { mlog("MakeCmdFromTunnelingBlob: Blob Size Error(size = %d)\n", nSize); return NULL; } char* pData = new char[nSize]; if (!m_PeerPacketCrypter.Decrypt(pPacket, nSize, pData, nSize)) { delete [] pData; return NULL; } MCommand* pCmd = new MCommand(); if (!pCmd->SetData(pData, &m_CommandManager)) { delete [] pData; delete pCmd; return NULL; } delete [] pData; pCmd->m_Sender = uidSender; pCmd->m_Receiver = m_This; MMatchPeerInfo* pPeer = FindPeer(uidSender); if (pPeer == NULL) { delete pCmd; return NULL; } return pCmd; }
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 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 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 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 임시로 사용 } } }
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 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); } }
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::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 ); }
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); }