void MMatchServer::OnAsyncExpelClanMember(MAsyncJob* pJobResult) { MAsyncDBJob_ExpelClanMember* pJob = (MAsyncDBJob_ExpelClanMember*)pJobResult; MMatchObject* pAdminObject = GetObject(pJob->GetAdminUID()); if (pJobResult->GetResult() != MASYNC_RESULT_SUCCEED) { if (IsEnabledObject(pAdminObject)) { RouteResponseToListener(pAdminObject, MC_MATCH_CLAN_ADMIN_RESPONSE_EXPEL_MEMBER, MERR_CLAN_CANNOT_EXPEL_FOR_NO_MEMBER); } return; } int nDBRet = pJob->GetDBResult(); switch (nDBRet) { case MMatchDBMgr::ER_NO_MEMBER: { if (IsEnabledObject(pAdminObject)) { RouteResponseToListener(pAdminObject, MC_MATCH_CLAN_ADMIN_RESPONSE_EXPEL_MEMBER, MERR_CLAN_CANNOT_EXPEL_FOR_NO_MEMBER); } return; } break; case MMatchDBMgr::ER_WRONG_GRADE: { if (IsEnabledObject(pAdminObject)) { RouteResponseToListener(pAdminObject, MC_MATCH_CLAN_ADMIN_RESPONSE_EXPEL_MEMBER, MERR_CLAN_CANNOT_CHANGE_GRADE); } return; } break; } // 만약 당사자가 접속해있으면 클랜탈퇴되었다고 알려줘야한다. MMatchObject* pMemberObject = GetPlayerByName(pJob->GetTarMember()); if (IsEnabledObject(pMemberObject)) { UpdateCharClanInfo(pMemberObject, 0, "", MCG_NONE); // 임시코드... 잘못된 MMatchObject*가 온다면 체크하여 잡기위함...20090224 by kammir if(pMemberObject->GetCharInfo()->m_ClanInfo.GetClanID() >= 9000000) LOG(LOG_FILE, "[OnAsyncExpelClanMember()] %s's ClanID:%d.", pMemberObject->GetAccountName(), pMemberObject->GetCharInfo()->m_ClanInfo.GetClanID()); } if (IsEnabledObject(pAdminObject)) { RouteResponseToListener(pAdminObject, MC_MATCH_CLAN_ADMIN_RESPONSE_EXPEL_MEMBER, MOK); } }
void MMatchServer::OnAdminHide(const MUID& uidAdmin) { MMatchObject* pObj = GetObject(uidAdmin); if (!IsEnabledObject(pObj)) return; // 관리자 권한을 가진 사람이 아니면 연결을 끊는다. if (!IsAdminGrade(pObj)) { // DisconnectObject(uidAdmin); return; } #if defined(LOCALE_NHNUSA) || defined(_DEBUG) m_HackingChatList.Init(); mlog( "reload hacking chat list.\n" ); #endif if (pObj->CheckPlayerFlags(MTD_PlayerFlags_AdminHide)) { pObj->SetPlayerFlag(MTD_PlayerFlags_AdminHide, false); Announce(pObj, "Now Revealing..."); } else { pObj->SetPlayerFlag(MTD_PlayerFlags_AdminHide, true); Announce(pObj, "Now Hiding..."); } }
void MMatchClanMap::AddObject(const MUID& uid, MMatchObject* pObj) { if (! IsEnabledObject(pObj)) return; int nCLID = pObj->GetCharInfo()->m_ClanInfo.m_nClanID; if (nCLID == 0) return; // 임시코드... AddObject()하는 어느곳에서 잘못된 값을 가져와서 서버 크래쉬 유발시키기 때문에 일단 여기서 막음 // 또한 AddObject()하는곳에서 log를 남겨 배포후 원인을 잡는 과정이 있을거임...20090224 by kammir if (nCLID <= -1) return; // nCLID는 정수형 if (nCLID >= 9000000) return; // 현재(20090224) 한국 최고 클랜ID가 "1399559"이다.(DB에서는 1씩증가시킴) // 클랜이 없으면 새로 생성 iterator itor = find(nCLID); if (itor == end()) { CreateClan(nCLID, pObj->GetCharInfo()->m_ClanInfo.m_szClanName); } itor = find(nCLID); if (itor != end()) { MMatchClan* pClan = (*itor).second; pClan->AddObject(uid, pObj); } }
int MClanGameStrategy::ValidateChallenge(CCMatchObject** ppMemberObject, int nMemberCount) { if ((nMemberCount<0) || (nMemberCount > MAX_CLANBATTLE_TEAM_MEMBER)) return MERR_CB_NO_TEAM_MEMBER; // 팀원수 체크 bool bFit = false; for (int i = 0; i < CCLADDERTYPE_MAX; i++) { if (nMemberCount == CCMatchServer::GetInstance()->GetLadderMgr()->GetNeedMemberCount(CCLADDERTYPE(i))) { bFit = true; break; } } if (!bFit) return MERR_CB_NO_TEAM_MEMBER; // 적당한 인원수가 아님 bool bAllSameClan = true; int nCLIDs[MAX_CLANBATTLE_TEAM_MEMBER] = {0, }; for (int i = 0; i < nMemberCount; i++) { if (! IsEnabledObject(ppMemberObject[i])) return MERR_CB_NO_TEAM_MEMBER; if (!ppMemberObject[i]->GetCharInfo()->m_ClanInfo.IsJoined()) return MERR_CB_WRONG_TEAM_MEMBER; if (ppMemberObject[i]->IsLadderChallenging() == true) return MERR_CB_EXIST_CANNOT_CHALLENGE_MEMBER; nCLIDs[i] = ppMemberObject[i]->GetCharInfo()->m_ClanInfo.m_nClanID; } // 같은 클랜인지 체크 for (int i = 0; i < nMemberCount-1; i++) { for (int j = i+1; j < nMemberCount; j++) { if (nCLIDs[i] != nCLIDs[j]) return MERR_CB_WRONG_TEAM_MEMBER; } } // 모두 같은 채널에 있는지 체크 CCUID uidLastChannel = ppMemberObject[0]->GetChannelUID(); for (int i = 1; i < nMemberCount; i++) { if (ppMemberObject[i]->GetChannelUID() != uidLastChannel) { return MERR_LADDER_EXIST_CANNOT_CHALLENGE_MEMBER; } uidLastChannel = ppMemberObject[i]->GetChannelUID(); } return MOK; }
void MMatchClanMap::RemoveObject(const MUID& uid, MMatchObject* pObj) { if (! IsEnabledObject(pObj)) return; int nCLID = pObj->GetCharInfo()->m_ClanInfo.m_nClanID; if (nCLID == 0) return; iterator itor = find(nCLID); if (itor != end()) { MMatchClan* pClan = (*itor).second; pClan->RemoveObject(uid); } }
void CCQuestPlayerManager::AddPlayer(CCUID& uidPlayer) { CCQuestPlayerInfo* pPlayerInfo = new CCQuestPlayerInfo(); CCMatchObject* pPlayerObject = CCMatchServer::GetInstance()->GetObject(uidPlayer); if (IsEnabledObject(pPlayerObject)) { int nPlayerLevel = pPlayerObject->GetCharInfo()->m_nLevel; int nQL = CCQuestFormula::CalcQL(nPlayerLevel); pPlayerInfo->Init(pPlayerObject, nQL); insert(value_type(uidPlayer, pPlayerInfo)); } }
void MMatchServer::OnAsyncGetFriendList(MAsyncJob* pJobInput) { MAsyncDBJob_FriendList* pJob = (MAsyncDBJob_FriendList*)pJobInput; if (pJob->GetResult() != MASYNC_RESULT_SUCCEED) { return; } MMatchObject* pObj = GetObject(pJob->GetUID()); if (!IsEnabledObject(pObj)) return; pObj->SetFriendInfo(pJob->GetFriendInfo()); // Save Async Result FriendList(pObj->GetUID()); }
int MLadderGameStrategy::ValidateChallenge(CCMatchObject** ppMemberObject, int nMemberCount) { if (nMemberCount > MAX_LADDER_TEAM_MEMBER) return MERR_LADDER_NO_TEAM_MEMBER; int nCIDs[MAX_LADDER_TEAM_MEMBER]; for (int i = 0; i < nMemberCount; i++) { if (! IsEnabledObject(ppMemberObject[i])) return MERR_LADDER_NO_TEAM_MEMBER; if (ppMemberObject[i]->IsLadderChallenging() != false) return MERR_LADDER_EXIST_CANNOT_CHALLENGE_MEMBER; nCIDs[i] = ppMemberObject[i]->GetCharInfo()->m_nCID; } int nTeamID = CCMatchServer::GetInstance()->GetLadderTeamIDFromDB(nMemberCount, nCIDs, nMemberCount); if (nTeamID == 0) return MERR_LADDER_WRONG_TEAM_MEMBER; return MOK; }
void MMatchServer::OnAdminRequestSwitchLadderGame(const MUID& uidAdmin, const bool bEnabled) { MMatchObject* pObj = GetObject(uidAdmin); if (!IsEnabledObject(pObj)) return; // 관리자 권한을 가진 사람이 아니면 연결을 끊는다. if (!IsAdminGrade(pObj)) { // DisconnectObject(uidAdmin); return; } MGetServerConfig()->SetEnabledCreateLadderGame(bEnabled); char szMsg[256] = "설정되었습니다."; Announce(pObj, szMsg); }
void CCVoteMgr::StopVote( const CCUID& uidUser ) { delete m_pDiscuss; m_pDiscuss = NULL; CCMatchObject* pObj = CCMatchServer::GetInstance()->GetObject( uidUser ); if( !IsEnabledObject(pObj) ) return; CCCommand* pCmd = CCMatchServer::GetInstance()->CreateCommand( MC_MATCH_VOTE_STOP, CCUID(0, 0) ); if( 0 == pCmd ) return; CCMatchStage* pStage = CCMatchServer::GetInstance()->FindStage( pObj->GetStageUID() ); if( 0 == pStage ) return; CCMatchServer::GetInstance()->RouteToStage( pStage->GetUID(), pCmd ); }
void MMatchClanMap::AddObject(const MUID& uid, MMatchObject* pObj) { if (! IsEnabledObject(pObj)) return; int nCLID = pObj->GetCharInfo()->m_ClanInfo.m_nClanID; if (nCLID == 0) return; // 클랜이 없으면 새로 생성 iterator itor = find(nCLID); if (itor == end()) { CreateClan(nCLID, pObj->GetCharInfo()->m_ClanInfo.m_szClanName); } itor = find(nCLID); if (itor != end()) { MMatchClan* pClan = (*itor).second; pClan->AddObject(uid, pObj); } }
void MMatchServer::OnAsyncCreateClan(MAsyncJob* pJobResult) { MAsyncDBJob_CreateClan* pJob = (MAsyncDBJob_CreateClan*)pJobResult; MUID uidMaster = pJob->GetMasterUID(); MMatchObject* pMasterObject = GetObject(uidMaster); if (pJob->GetResult() != MASYNC_RESULT_SUCCEED) { if (IsEnabledObject(pMasterObject)) { RouteResponseToListener(pMasterObject, MC_MATCH_CLAN_RESPONSE_AGREED_CREATE_CLAN, MERR_CLAN_CANNOT_CREATE); } return; } int nNewCLID = pJob->GetNewCLID(); if ( (pJob->GetDBResult() == false) || (nNewCLID ==0) ) { if (IsEnabledObject(pMasterObject)) { RouteResponseToListener(pMasterObject, MC_MATCH_CLAN_RESPONSE_AGREED_CREATE_CLAN, MERR_CLAN_CANNOT_CREATE); } return; } // 마스터의 바운티를 깎는다. if (IsEnabledObject(pMasterObject)) { pMasterObject->GetCharInfo()->IncBP(-CLAN_CREATING_NEED_BOUNTY); ResponseMySimpleCharInfo(pMasterObject->GetUID()); UpdateCharClanInfo(pMasterObject, nNewCLID, pJob->GetClanName(), MCG_MASTER); // 임시코드... 잘못된 MMatchObject*가 온다면 체크하여 잡기위함...20090224 by kammir if(pMasterObject->GetCharInfo()->m_ClanInfo.GetClanID() >= 9000000) LOG(LOG_FILE, "[OnAsyncCreateClan()] %s's ClanID:%d.", pMasterObject->GetAccountName(), pMasterObject->GetCharInfo()->m_ClanInfo.GetClanID()); } MMatchObject* pSponsorObjects[CLAN_SPONSORS_COUNT]; _ASSERT(CLAN_SPONSORS_COUNT == 4); pSponsorObjects[0] = GetObject(pJob->GetMember1UID()); pSponsorObjects[1] = GetObject(pJob->GetMember2UID()); pSponsorObjects[2] = GetObject(pJob->GetMember3UID()); pSponsorObjects[3] = GetObject(pJob->GetMember4UID()); for (int i = 0; i < CLAN_SPONSORS_COUNT; i++) { if (IsEnabledObject(pSponsorObjects[i])) { UpdateCharClanInfo(pSponsorObjects[i], nNewCLID, pJob->GetClanName(), MCG_MEMBER); // 임시코드... 잘못된 MMatchObject*가 온다면 체크하여 잡기위함...20090224 by kammir if(pSponsorObjects[i]->GetCharInfo()->m_ClanInfo.GetClanID() >= 9000000) LOG(LOG_FILE, "[OnAsyncCreateClan()] %s's ClanID:%d.", pSponsorObjects[i]->GetAccountName(), pSponsorObjects[i]->GetCharInfo()->m_ClanInfo.GetClanID()); RouteResponseToListener(pSponsorObjects[i], MC_MATCH_RESPONSE_RESULT, MRESULT_CLAN_CREATED); } } if (IsEnabledObject(pMasterObject)) { RouteResponseToListener(pMasterObject, MC_MATCH_CLAN_RESPONSE_AGREED_CREATE_CLAN, MOK); } }
void MClanGameStrategy::SavePointOnFinishGame(CCMatchStage* pStage, CCMatchTeam nWinnerTeam, bool bIsDrawGame, CCMatchLadderTeamInfo* pRedLadderInfo, CCMatchLadderTeamInfo* pBlueLadderInfo) { int nWinnerCLID = 0, nLoserCLID = 0; CCMatchTeam nLoserTeam = (nWinnerTeam == CCMT_RED) ? CCMT_BLUE : CCMT_RED; // red팀 승리 if (bIsDrawGame == true) { nWinnerCLID = pRedLadderInfo->nCLID; nLoserCLID = pBlueLadderInfo->nCLID; } else if (nWinnerTeam == CCMT_RED) { nWinnerCLID = pRedLadderInfo->nCLID; nLoserCLID = pBlueLadderInfo->nCLID; } else if (nWinnerTeam == CCMT_BLUE) { nWinnerCLID = pBlueLadderInfo->nCLID; nLoserCLID = pRedLadderInfo->nCLID; } else { _ASSERT(0); } if ((nWinnerCLID == 0) || (nLoserCLID == 0)) return; CCMatchClan* pWinnerClan = CCMatchServer::GetInstance()->GetClanMap()->GetClan(nWinnerCLID); CCMatchClan* pLoserClan = CCMatchServer::GetInstance()->GetClanMap()->GetClan(nLoserCLID); if ((!pWinnerClan) || (!pLoserClan)) return; int nFirstMemberCount = pRedLadderInfo->nFirstMemberCount; char szWinnerMembers[512] = ""; char szLoserMembers[512] = ""; list<CCUID> WinnerObjUIDs; for (CCUIDRefCache::iterator itor=pStage->GetObjBegin(); itor!=pStage->GetObjEnd(); itor++) { CCMatchObject* pObj = (CCMatchObject*)(*itor).second; if (IsEnabledObject(pObj)) { if (pObj->GetTeam() == nWinnerTeam) { WinnerObjUIDs.push_back(pObj->GetUID()); strcat(szWinnerMembers, pObj->GetCharInfo()->m_szName); strcat(szWinnerMembers, " "); } else { strcat(szLoserMembers, pObj->GetCharInfo()->m_szName); strcat(szLoserMembers, " "); } } } int nMapID = pStage->GetStageSetting()->GetMapIndex(); int nGameType = (int)pStage->GetStageType(); int nRoundWins = pStage->GetTeamScore(nWinnerTeam); int nRoundLosses = pStage->GetTeamScore(nLoserTeam); int nLoserSeriesOfVictories = pLoserClan->GetSeriesOfVictories(); float fPointRatio = 1.0f; if (!bIsDrawGame) { // MatchMakingSystem 통계 입력 CCLadderStatistics* pLS = CCMatchServer::GetInstance()->GetLadderMgr()->GetStatistics(); pLS->InsertLevelRecord(pRedLadderInfo->nCharLevel, pBlueLadderInfo->nCharLevel, nWinnerTeam); pLS->InsertContPointRecord(pRedLadderInfo->nContPoint, pBlueLadderInfo->nContPoint, nWinnerTeam); pLS->InsertClanPointRecord(pWinnerClan->GetClanInfoEx()->nPoint, pLoserClan->GetClanInfoEx()->nPoint, CCMT_RED); // 방송 int nWinnerSeriesOfVictories = pWinnerClan->GetSeriesOfVictories(); if (nLoserSeriesOfVictories >= 10) { CCMatchServer::GetInstance()->BroadCastClanInterruptVictories(pWinnerClan->GetName(), pLoserClan->GetName(), nLoserSeriesOfVictories+1); fPointRatio = 2.0f; } else if ((nWinnerSeriesOfVictories == 3) || (nWinnerSeriesOfVictories == 5) || (nWinnerSeriesOfVictories == 7) || (nWinnerSeriesOfVictories >= 10)) { CCMatchServer::GetInstance()->BroadCastClanRenewVictories(pWinnerClan->GetName(), pLoserClan->GetName(), nWinnerSeriesOfVictories); } } CCMatchServer::GetInstance()->SaveClanPoint(pWinnerClan, pLoserClan, bIsDrawGame, nRoundWins, nRoundLosses, nMapID, nGameType, nFirstMemberCount, WinnerObjUIDs, szWinnerMembers, szLoserMembers, fPointRatio); }
bool DBQuestCachingData::DoUpdateDBCharQuestItemInfo() { // 퀘스트 서버인지 먼저 검사. if( MSM_TEST != MGetServerConfig()->GetServerMode() ) return false; // 정상적인 Object인지 검사. if( !IsEnabledObject(m_pObject) ) return false; // 현재 상태가 업데이트 가능한지 검사. if( !IsRequestUpdate() ) { // 다음 업데이트를 검사를 위해서 마지막 업데이트 검사 시간을 저장해 놓음. m_dwLastUpdateTime = timeGetTime(); return false; } MAsyncDBJob_UpdateQuestItemInfo* pAsyncJob = new MAsyncDBJob_UpdateQuestItemInfo(m_pObject->GetUID()); if( 0 == pAsyncJob ) { mlog( "DBQuestCachingData::DoUpdateDBCharQuestItemInfo - QuestItemUpdate async작업 실패.\n" ); return false; } if( !pAsyncJob->Input(m_pObject->GetCharInfo()->m_nCID, m_pObject->GetCharInfo()->m_QuestItemList, m_pObject->GetCharInfo()->m_QMonsterBible) ) { return false; } MMatchServer::GetInstance()->PostAsyncJob( pAsyncJob ); #ifdef _DEBUG { // 업데이트 정보가 정상적으로 되는지 로그를 남김. char szDbgOut[ 1000 ] = {0}; MQuestItemMap::iterator it, end; strcat( szDbgOut, "Quest Item Caching UpdateDB\n" ); strcat( szDbgOut, m_pObject->GetName() ); strcat( szDbgOut, "\n" ); it = m_pObject->GetCharInfo()->m_QuestItemList.begin(); end = m_pObject->GetCharInfo()->m_QuestItemList.end(); for( ; it != end; ++it ) { char tmp[ 100 ] = {0}; sprintf( tmp, "%s : %d\n", it->second->GetDesc()->m_szQuestItemName, it->second->GetCount() ); strcat( szDbgOut, tmp ); } strcat( szDbgOut, "\n" ); MMatchServer::GetInstance()->LOG( MMatchServer::LOG_PROG, szDbgOut ); } #endif // 업데이트가 성공하면 다음 검사를 위해서 다시 설정함. Reset(); return true; }