#include "StdAfx.h" // _NA_005026_20120527_CHAOS_ZONE_BATTLE_GROUND #include <../Common/PacketStruct_AG_ChaosZoneSystem.h> #include #include #include #include #include #include #include #include #include <../ProgramCommon/PacketStruct_CG.h> #include #include #include #include #include //-------------------------------------------------------------------------------------------------- bool SortFunc( BattleGroundMemberInfo* info_a, BattleGroundMemberInfo* info_b) { return (info_a->equip_item_score > info_b->equip_item_score); } //-------------------------------------------------------------------------------------------------- void BattleGroundMatchingSystem::Init() { matching_group_pool_ = new MatchingGroupPool(); matching_group_pool_->Initialize(60); update_timer_.SetTimer(1000); #ifdef _NA_008679_20160202_REWORK_BATTLEGROUND failed_members_list_.clear(); #endif //_NA_008679_20160202_REWORK_BATTLEGROUND } void BattleGroundMatchingSystem::Release() { MatchingGroupMap::const_iterator const_itr = matching_groups_map_.begin(); for (; const_itr != matching_groups_map_.end(); ++const_itr) { matching_group_pool_->Free(const_itr->second); } matching_groups_map_.clear(); SAFE_DELETE(matching_group_pool_); #ifdef _NA_008679_20160202_REWORK_BATTLEGROUND failed_members_list_.clear(); #endif //_NA_008679_20160202_REWORK_BATTLEGROUND } #ifdef _NA_008679_20160202_REWORK_BATTLEGROUND bool BattleGroundMatchingSystem::ProcessMatching(const MAPCODE map_code) { BattleGroundManager* const battle_ground_manager = BattleGroundManager::Instance(); BattleGroundMemberList* const member_list = battle_ground_manager->FindStandbyGroupMemberList(map_code); if (member_list == NULL) { return false; } // ¸Åα׷ìµé »ý¼º // ±×·ì¿¡ ¸â¹öµé »ðÀÔ _ProcessMatching(map_code, member_list); //¸ÅĪ±×·ì¿¡ ¸Â´Â InstanceDungeon»ý¼º FOREACH_CONTAINER(MatchingGroupMap::value_type& node, matching_groups_map_, MatchingGroupMap) { MatchingGroup* group = node.second; KEYTYPE group_key = group->group_key; if (group->matching_state == kStartBattleGround) { // ÀÌ¹Ì ½ÃÀÛµÈ ±×·ì continue; } //¹æ»ý¼º ¿äû.. if (CreateInstanceRoom(group_key, map_code) == false) { // ¸ÅĪ Ãë¼Ò.. MatchingGroupCancel(group_key); return false; } //BRD.. ¸ÅĪ±×·ì¿¡ ¼ÓÇÑ ¸â¹öµé¿¡°Ô 1Â÷ ¸ÅĪÀÌ µÇ¾ú´Ù°í ¾Ë·ÁÁÜ. MSG_CG_BATTLE_GROUND_MATCHING_RESULT_BRD brd_msg; { brd_msg.result_type = 0; #ifdef _NA_006620_20130402_GM_BATTLE_GROUND_EVENT_GAME brd_msg.map_code = group->map_code; #endif // _NA_006620_20130402_GM_BATTLE_GROUND_EVENT_GAME } battle_ground_manager->SendPacketAllMember(&group->matching_group_list, &brd_msg, sizeof(brd_msg)); } return true; } BOOL BattleGroundMatchingSystem::_ProcessMatching(const MAPCODE map_code, BattleGroundMemberList* member_list) { // 1Â÷ ¸ÅĪ.. if (member_list == NULL) { return FALSE; } const BattleGroundInfo* const battle_ground_Info = BattleGroundInfoParser::Instance()->FindData(map_code); BYTE max_team_count = battle_ground_Info->team_max; BYTE min_team_count = battle_ground_Info->team_min; BYTE group_members_count = max_team_count; int number_of_members = member_list->size(); //¿¹¾àÇÑ Ç÷¹ÀÌ¾î ¼ö // [¸Åα׷ìµé »ý¼º] _CreateMatchingGroups(map_code, member_list); // [¸ÅĪ ½ÇÆÐÇÑ ±×·ì] _CreateFailedGroup(map_code, member_list); _RequestMismatchingReward(); return TRUE; } BOOL BattleGroundMatchingSystem::_CreateMatchingGroups( const MAPCODE& map_code, BattleGroundMemberList* member_list ) { const BattleGroundInfo* const battle_ground_Info = BattleGroundInfoParser::Instance()->FindData(map_code); if (battle_ground_Info == NULL) { return FALSE; } if (member_list->size() == 0) { return FALSE; } BYTE max_team_count = battle_ground_Info->team_max; BYTE min_team_count = battle_ground_Info->team_min; int count = max_team_count; while (count >= min_team_count) { int member_count = count * 2; // ±×·ì¿¡ ³ÖÀ» Àοø¼ö int remained_members = member_list->size(); if (remained_members < member_count) { //ÇØ´ç ÀοøÀÇ ¸Åα׷ìÀ» ¸¸µé Á¤µµÀÇ ÀοøÀÌ ¾ø´Ù --count; continue; } // [¸ÅĪ ±×·ì »ý¼º] std::stable_sort(member_list->begin(), member_list->end(), SortFunc); MatchingGroup* matching_group = static_cast(matching_group_pool_->Alloc()); if (matching_group == NULL) { return FALSE; } for (int man = 0; man < member_count; ++man) { BattleGroundMemberInfo* const member_info = *(member_list->begin()); if (member_info == NULL) { continue; } if (BattleGroundManager::Instance()->IsValidReservationMember(member_info->user_guid) == false) { continue; } member_info->member_state = kStandbyPriority; matching_group->matching_group_list.push_back(member_info); BattleGroundManager::Instance()->RemoveMemberStandbyGroup(member_info); } const KEYTYPE group_key = _AllocKey(); matching_group->group_key = group_key; //¸¸µé¾îÁø ½Ã°£ ¼³Á¤ matching_group->matching_time = util::TimeSync::_time64(NULL); matching_group->matching_state = kWaitCreateRoom; // ±×·ì ¸Ê¿¡ ³Ö´Â´Ù matching_groups_map_.insert(MatchingGroupMap::value_type(group_key, matching_group)); } return TRUE; } BOOL BattleGroundMatchingSystem::_CreateFailedGroup( const MAPCODE& map_code, const BattleGroundMemberList* member_list ) { // [¸ÅĪ ½ÇÆÐÇÑ ±×·ì] // ÃÖ¼Ò Àοø±×·ì±îÁö ¸ðµÎ ¸¸µé¾úÀ» °æ¿ì // ´õÀÌ»ó ±×·ìÀ» ¸¸µé ¼ö ¾ø´Â Àοø¼ö°¡ µÇ¾úÀ» °æ¿ì // ¸ÅĪ ½ÇÆÐÇÑ ¸â¹öµéÀ» ¸®½ºÆ®¿¡ µû·Î ¸ð¾ÆµÐ´Ù const BattleGroundInfo* const battle_ground_Info = BattleGroundInfoParser::Instance()->FindData(map_code); if (battle_ground_Info == NULL) { return FALSE; } BYTE min_team_count = battle_ground_Info->team_min; int remained_members = member_list->size(); if (remained_members <= 0) { return FALSE; } // ¸â¹ö ¸®½ºÆ® º¹»ç //failed_members_list_.assign(member_list->begin(), member_list->end()); std::copy(member_list->begin(), member_list->end(), std::back_inserter(failed_members_list_)); // ¿¹¾à Ãë¼Ò ¹× Ŭ¶óÀÌ¾ðÆ®¿¡°Ô Ãë¼Ò ¾Ë¸² while(member_list->size() > 0) { BattleGroundMemberInfo* const member_info = *(member_list->begin()); User* user = UserManager::Instance()->GetUser(member_info->user_guid); if (user != NULL) { MSG_CG_BATTLE_GROUND_RESERVATION_CANCEL_ACK cmd_msg; cmd_msg.result_code = BattleGroundManager::Instance()->CancelReservation(user); user->SendPacket(&cmd_msg, sizeof(cmd_msg)); } } return TRUE; } VOID BattleGroundMatchingSystem::_RequestMismatchingReward() { while (failed_members_list_.size() > 0) { BattleGroundMemberList::iterator itr = failed_members_list_.begin(); BattleGroundMemberInfo* info = *itr; User* user = UserManager::Instance()->GetUser(info->user_guid); MSG_AG_BATTLE_GROUND_MISMATCHING_REWARD_CMD syn_msg; syn_msg.user_guid = info->user_guid; syn_msg.battleground_mapcode = info->map_code; syn_msg.result_type = eBG_RESULT_MISMATCHING; user->SendToLinkedServer(&syn_msg, sizeof(syn_msg)); failed_members_list_.erase(itr); } } BOOL BattleGroundMatchingSystem::StartBattleGround() { FOREACH_CONTAINER(MatchingGroupMap::value_type& node, matching_groups_map_, MatchingGroupMap) { MatchingGroup* group = node.second; if (group == NULL) { continue; } if (group->matching_state == kStartBattleGround) { // ÀÌ¹Ì ½ÃÀÛÇÑ ±×·ì continue; } // // ±×·ìÀÇ roomÀÌ ¸¸µé¾îÁø »óÅÂÀ̸é if (group->matching_state == kCreatedRoom) // script.. { // 1. ÆÀ¸ÅĪ 2. ÆÄƼ»ý¼º // MoveZone ÁøÇà if (OnTeamMatching(group) == false || // 2Â÷ ÆÀ ¸ÅĪ OnCreateParty(group) == false || // ÆÀº°·Î ÆÄƼ±¸¼º SendMembersToBattleGround(group) == false) // À¯Àú À̵¿ { // ¸ÅĪ Ãë¼Ò MatchingGroupCancel(group->group_key); continue; } group->matching_state = kStartBattleGround; } } return TRUE; } #endif //_NA_008679_20160202_REWORK_BATTLEGROUND bool BattleGroundMatchingSystem::RemoveMatchigGroup(const KEYTYPE group_key) { BattleGroundManager* const battle_ground_manager = BattleGroundManager::Instance(); MatchingGroupMap::iterator itr = matching_groups_map_.find(group_key); MatchingGroup* const matching_group = itr->second; BattleGroundMemberList::const_iterator list_itr = matching_group->matching_group_list.begin(); for (;list_itr != matching_group->matching_group_list.end(); ++list_itr) { BattleGroundMemberInfo* const member_info = *list_itr; battle_ground_manager->RemoveReservationMember(member_info->user_guid); } _FreeKey(group_key); matching_group_pool_->Free(itr->second); matching_groups_map_.erase(itr); return true; } MatchingGroup* BattleGroundMatchingSystem::FindMatchingGroup(const KEYTYPE group_key) { MatchingGroupMap::const_iterator const_itr = matching_groups_map_.find(group_key); if (const_itr == matching_groups_map_.end()) { return NULL; } return const_itr->second; } MatchingGroup* BattleGroundMatchingSystem::FindMatchingGroupByZoneKey(const KEYTYPE zone_key) { MatchingGroupMap::const_iterator const_itr = matching_groups_map_.begin(); for (; const_itr != matching_groups_map_.end(); ++const_itr) { MatchingGroup* const matching_group = const_itr->second; if (matching_group->zone_key != zone_key) { continue; } return matching_group; } return NULL; } bool BattleGroundMatchingSystem::CreateInstanceRoom(const KEYTYPE group_key, const MAPCODE map_code) { InstanceDungeon* instance_dungeon = NULL; const RC::eROOM_RESULT rt = g_ZoneManager.CreateInstanceDungeon( \ 0, NULL, map_code, (InstanceDungeon *&)instance_dungeon, INDUN_KIND_CHAOS_ZONE, FALSE); if (!instance_dungeon || rt != RC::RC_ROOM_SUCCESS) { return false; } instance_dungeon->SetRoomState(eROOMSTATE_GENERNAL); MatchingGroup* const matching_group = FindMatchingGroup(group_key); matching_group->matching_state = kCreatedRoom; matching_group->zone_key = instance_dungeon->GetKey(); matching_group->map_code = instance_dungeon->GetMapCode(); return true; } class EquipScoreGreater { public: bool operator () ( BattleGroundMemberInfo *pLeft, BattleGroundMemberInfo *pRight ) const { return pLeft->equip_item_score > pRight->equip_item_score; } }; namespace SecondTeamMatching { bool TeamMatchingRule( \ const BattleGroundMemberInfo* player_left, const BattleGroundMemberInfo* player_right) { if ( player_left->is_healer && !player_right->is_healer) return false; if (!player_left->is_healer && player_right->is_healer) return true; if ( player_left->is_healer && player_right->is_healer) return (player_left->equip_item_score < player_right->equip_item_score); return (player_left->equip_item_score > player_right->equip_item_score); } void TeamSetUp(BattleGroundMemberInfo* member_, MatchingGroup* const matching_group, \ ChaosZoneTeam team_) { member_->team_division = team_; member_->group_key = matching_group->group_key; UserManager* const user_manager = UserManager::Instance(); User* const user = user_manager->GetUser(member_->user_guid); if (user == NULL) { return; } user->SetTRRoomKey(matching_group->zone_key); user->SetGroupKey(matching_group->group_key); user->SetTeam(member_->team_division); // »óꝰæ.. ;{ user->SetBehaveState(PLAYER_BEHAVE_IDLE_STATE); MSG_AG_BATTLE_GROUND_STATUS_CHANGE_STATE_CMD cmd_msg; cmd_msg.behave_sate = PLAYER_BEHAVE_IDLE_STATE; user->SendToLinkedServer(&cmd_msg, sizeof(cmd_msg)); }; } }; bool BattleGroundMatchingSystem::OnTeamMatching(MatchingGroup* const matching_group) { if (matching_group == NULL) { return false; } const BattleGroundMemberList& matching_group_list = matching_group->matching_group_list; // 2Â÷ ¸ÅĪ if (matching_group_list.size()%2 != 0) { return false; } BattleGroundMemberList member_info_list = matching_group_list; // copy std::stable_sort(member_info_list.begin(), member_info_list.end(), &SecondTeamMatching::TeamMatchingRule); BattleGroundMemberList::const_iterator it = member_info_list.begin(); while(it != member_info_list.end()) { std::size_t flag = random(0,1); SecondTeamMatching::TeamSetUp((*it++), matching_group, (flag ? kRed : kBlue)); SecondTeamMatching::TeamSetUp((*it++), matching_group, (flag ? kBlue : kRed )); } return true; } bool BattleGroundMatchingSystem::SendMembersToBattleGround(MatchingGroup* const matching_group) { if (matching_group == NULL) { return false; } InstanceDungeon* const target_room = \ static_cast(g_ZoneManager.FindZone(matching_group->zone_key)); if (target_room == NULL) { return false; } BattleGroundMemberList::const_iterator const_itr = matching_group->matching_group_list.begin(); for (; const_itr != matching_group->matching_group_list.end(); ++const_itr) { BattleGroundMemberInfo* const find_member = *const_itr; User* const user = UserManager::Instance()->GetUser(find_member->user_guid); if (user == NULL) { continue; } ZoneInterface* current_zone = g_ZoneManager.FindZone(user->GetZoneKey()); if (current_zone == NULL) { SUNLOG(eCRITICAL_LOG, __FUNCTION__ " : Not found zone : %d", user->GetUserGUID()); continue; } user->BeginTransaction(TR_LEAVE_FIELD_FOR_INSTANCE); CheckMoveZonePolicy* const check_move_zone_policy = MoveZonePolicy::AlignInfo(user, user->GetZoneType(), target_room->GetType(), user->GetZoneKey(), target_room->GetKey()); RoomArgument argument(eZONEPUBLIC_PUBLIC, NULL); RC::eROOM_RESULT rt = g_ZoneManager.MoveZone(check_move_zone_policy, RoomArgument::GetEmpty()); //if (rt != RC::RC_ROOM_SUCCESS) //{ // return false; //} } return true; } bool BattleGroundMatchingSystem::OnCreateParty(MatchingGroup* const matching_group) { if (matching_group == NULL) { return false; } ZoneInterface* const zone_interface = g_ZoneManager.FindZone(matching_group->zone_key); if (zone_interface == NULL) { return false; } InstanceDungeon* const instance_dungeon = static_cast(zone_interface); BattleGroundMemberList red_team; BattleGroundMemberList blue_team; BattleGroundMemberList::const_iterator const_itr = matching_group->matching_group_list.begin(); for (; const_itr != matching_group->matching_group_list.end(); ++const_itr) { BattleGroundMemberInfo* member = *const_itr; if (member->team_division == kBlue) { blue_team.push_back(member); } else { red_team.push_back(member); } } std::stable_sort(red_team.begin(), red_team.end(), EquipScoreGreater()); std::stable_sort(blue_team.begin(), blue_team.end(), EquipScoreGreater()); // µÎÆÀ Áß ÇÑ¸íµµ ¾ø´Â ÆÀÀÌ Á¸ÀçÇÑ´Ù¸é.. ÀüÀåÀ¸·Î º¸³»Áö ¾Ê´Â´Ù.. if (red_team.size() == 0 || blue_team.size() == 0) { return false; } // GameServer¿¡ ÆÀ Á¤º¸ Àü¼Û. if (EnterTeam(red_team) == false || EnterTeam(blue_team) == false) { return false; } //red_team << team_key : 1 _CreateBattlegroundParty(instance_dungeon, red_team); //blue_team << team_key : 2 _CreateBattlegroundParty(instance_dungeon, blue_team); return true; } bool BattleGroundMatchingSystem::EnterTeam(const BattleGroundMemberList member_list) { BattleGroundMemberList::const_iterator const_itr = member_list.begin(); if (const_itr == member_list.end()) { return false; } BattleGroundMemberInfo* const master_member = *const_itr; if (master_member == NULL) { return false; } MatchingGroup* const matching_group = FindMatchingGroup(master_member->group_key); if (matching_group == NULL) { return false; } const BattleGroundInfoParser* const battle_ground_info_parser = \ BattleGroundInfoParser::Instance(); const BattleGroundInfo* const battle_ground_Info = \ battle_ground_info_parser->FindData(matching_group->map_code); const ZoneInterface* const zone = g_ZoneManager.FindZone(matching_group->zone_key); if (zone == NULL) { SUNLOG(eCRITICAL_LOG, TEXT("[BattleGroundMatchingSystem::EnterTeam] Not exist zone [%d]!!"), matching_group->zone_key); return false; } MSG_AG_BATTLE_GROUND_ENTER_TEAM_CMD send_msg; send_msg.zone_key = matching_group->zone_key; send_msg.team_key = (*const_itr)->team_division; BYTE user_count = 0; #ifdef _NA_008679_20160202_REWORK_BATTLEGROUND BYTE _team_index = 1; #endif //_NA_008679_20160202_REWORK_BATTLEGROUND for (; const_itr != member_list.end(); ++const_itr) { BattleGroundMemberInfo* member = *const_itr; send_msg.user_key_list[user_count] = member->user_guid; #ifdef _NA_008679_20160202_REWORK_BATTLEGROUND member->team_index_ = _team_index; ++_team_index; send_msg.user_team_index_array[user_count] = member->team_index_; #endif //_NA_008679_20160202_REWORK_BATTLEGROUND ++user_count; } if (user_count > battle_ground_Info->team_max) { //ÆÀ ÃÖ´ëÀοø¼ö¸¦ ³Ñ°åÀ» °æ¿ì SUNLOG(eCRITICAL_LOG, TEXT("[EnterTeam] BattleGroundTeamCount[%d]!!"), user_count); } send_msg.user_count = user_count; const InstanceDungeon* const instance_dungeon = static_cast(zone); if (instance_dungeon == NULL) { return false; } ServerSession* const server_session = instance_dungeon->GetLinkedServer(); if(server_session == NULL || server_session->GetServerType() != BATTLE_SERVER) { SUNLOG(eFULL_LOG, "¹èƲ¼­¹ö°¡ ¾Æ´Ñ ¼¼¼ÇÀ» ¿¬°áÇÏ·ÁÇÑ´Ù.2\n"); return false; } server_session->SendPacket(&send_msg, sizeof(send_msg)); return true; } bool BattleGroundMatchingSystem::MatchingGroupCancel(const KEYTYPE group_key) { MatchingGroup* const matching_group = FindMatchingGroup(group_key); if (matching_group == NULL) { return false; } // ¸ÅĪµÈ ¸â¹öµéÀ» ´ë±â¿­·Î µ¹·Áº¸³½´Ù. if (ReturnUserInsertStandbyGroupList(matching_group) == false) { return false; } // ¸Åα׷ì Á¦°Å if (RemoveMatchigGroup(group_key) == false) { return false; } return true; } bool BattleGroundMatchingSystem::ReturnUserInsertStandbyGroupList(MatchingGroup* const matching_group) { BattleGroundMemberList::const_iterator const_itr = matching_group->matching_group_list.begin(); for (; const_itr != matching_group->matching_group_list.end(); ++const_itr) { BattleGroundMemberInfo* member = *const_itr; if (BattleGroundManager::Instance()->ReturnUserInsertStandbyGroupList(member) == false) { return false; } // »óꝰæ.. ;{ MSG_AG_BATTLE_GROUND_STATUS_CHANGE_STATE_CMD cmd_msg; cmd_msg.behave_sate = PLAYER_BEHAVE_RESERVATION_BATTLE_GROUND_ZONE; User* const user = UserManager::Instance()->GetUser(member->user_guid); if (user) user->SendToLinkedServer(&cmd_msg, sizeof(cmd_msg)); }; } return true; } bool BattleGroundMatchingSystem::RemoveMemberMatchingGroup(const BattleGroundMemberInfo* member) { if (member == NULL) { return false; } MatchingGroup* const matching_group = FindMatchingGroup(member->group_key); if (matching_group == NULL) { return false; } BattleGroundMemberList::iterator itr = matching_group->matching_group_list.begin(); for (;itr != matching_group->matching_group_list.end(); ++itr) { if ((*itr)->user_guid == member->user_guid) { matching_group->matching_group_list.erase(itr); return true; } } return false; } //-------------------------------------------------------------------------------------------------- /*bool BattleGroundMatchingSystem::CheckMatching(MAPCODE map_code) { BattleGroundManager* const battle_ground_manager = BattleGroundManager::Instance(); const BattleGroundMemberList* const member_list = \ battle_ground_manager->FindStandbyGroupMemberList(map_code); if (member_list == NULL) { return false; } if (CanCreateMatchingGroup(map_code) == false) { return false; } if (CreateMatchingGroup(map_code) == false) { // ¸Þ¼¼Áö Àü´Þ.. ¸ÅĪ±×·ì ¸¸µé±â ½ÇÆÐ.. return false; } return true; }*/ VOID BattleGroundMatchingSystem::_CreateBattlegroundParty( InstanceDungeon* instance_dungeon, BattleGroundMemberList& team_list ) { AgentPartyManager* const party_manager = AgentPartyManager::Instance(); AgentParty* base_party = NULL; BattleGroundMemberInfo* red_member = NULL; User* red_user = NULL; BattleGroundMemberList::const_iterator red_itr = team_list.begin(); for (; red_itr != team_list.end(); ++red_itr) { red_member = *red_itr; red_user = UserManager::Instance()->GetUser(red_member->user_guid); if (red_user == NULL) { continue; } if (base_party == NULL) { base_party = \ static_cast(party_manager->CreateParty(red_user->GetPlayerKey(), ePARTY_INSTANCE)); if (base_party == NULL) { continue; } base_party->SetPartySubType(ePARTY_SUB_BATTLEGROUND); static JoinPartyOperator Opr; Opr.Init(eUSER_OPERATOR_JOINPARTY, base_party->GetPartyKey()); Opr(red_user); instance_dungeon->LinkParty(base_party->GetPartyKey()); } if (base_party) { party_manager->JoinParty(base_party->GetPartyKey(), red_user); } } } #ifdef _NA_008679_20160202_REWORK_BATTLEGROUND #else void BattleGroundMatchingSystem::Update() { if (update_timer_.IsExpired() == false) { return; } CTime current_time = util::TimeSync::_time64(NULL); const BattleGroundInfoParser* const battle_ground_Info_parser = BattleGroundInfoParser::Instance(); MatchingGroupMap::iterator itr = matching_groups_map_.begin(); while (itr != matching_groups_map_.end()) { // ¸Åα׷ì MatchingGroupMap::iterator cur_itr = itr++; //!!!!! MatchingGroup* const matching_group = cur_itr->second; if (matching_group == NULL) { matching_groups_map_.erase(cur_itr); continue; } // ½ºÅ©¸³Æ® µ¥ÀÌÅÍ const BattleGroundInfo* battle_ground_Info = \ battle_ground_Info_parser->FindData(matching_group->map_code); if (battle_ground_Info == NULL) { continue; } // ÀüÀå Ãâ¹ß ½Ã°£ÀÌ °æ°úÇϸé Ãâ¹ß.. if (matching_group->matching_state == kCreatedRoom && current_time >= matching_group->matching_time + CTimeSpan(0, 0, 0, battle_ground_Info->start_time)) // script.. { if (OnTeamMatching(matching_group) == false || // 2Â÷ ÆÀ ¸ÅĪ OnCreateParty(matching_group) == false || // ÆÀº°·Î ÆÄƼ±¸¼º SendMembersToBattleGround(matching_group) == false) // À¯Àú À̵¿ { // ¸ÅĪ Ãë¼Ò MatchingGroupCancel(matching_group->group_key); continue; } matching_group->matching_state = kStartBattleGround; } } } bool BattleGroundMatchingSystem::ProcessMatching(const MAPCODE map_code) { BattleGroundManager* const battle_ground_manager = BattleGroundManager::Instance(); BattleGroundMemberList* const member_list = battle_ground_manager->FindStandbyGroupMemberList(map_code); if (member_list == NULL) { return false; } // ¸ÅĪ±×·ì »ý¼º // ±×·ì¿¡ ¸â¹öµé »ðÀÔ MatchingGroup* const matching_group = _ProcessMatching(map_code, member_list); if (matching_group == NULL) { return false; } const KEYTYPE group_key = _AllocKey(); matching_group->group_key = group_key; //¸¸µé¾îÁø ½Ã°£ ¼³Á¤ matching_group->matching_time = util::TimeSync::_time64(NULL); matching_group->matching_state = kWaitCreateRoom; matching_groups_map_.insert( \ MatchingGroupMap::value_type(group_key, matching_group)); //¹æ»ý¼º ¿äû.. if (CreateInstanceRoom(group_key, map_code) == false) { // ¸ÅĪ Ãë¼Ò.. MatchingGroupCancel(group_key); return false; } //BRD.. ¸ÅĪ±×·ì¿¡ ¼ÓÇÑ ¸â¹öµé¿¡°Ô 1Â÷ ¸ÅĪÀÌ µÇ¾ú´Ù°í ¾Ë·ÁÁÜ. MSG_CG_BATTLE_GROUND_MATCHING_RESULT_BRD brd_msg; { brd_msg.result_type = 0; #ifdef _NA_006620_20130402_GM_BATTLE_GROUND_EVENT_GAME brd_msg.map_code = matching_group->map_code; #endif // _NA_006620_20130402_GM_BATTLE_GROUND_EVENT_GAME } battle_ground_manager->SendPacketAllMember(&matching_group->matching_group_list, &brd_msg, sizeof(brd_msg)); return true; } MatchingGroup* BattleGroundMatchingSystem::_ProcessMatching(const MAPCODE map_code, const BattleGroundMemberList* member_list) { // 1Â÷ ¸ÅĪ.. if (member_list == NULL) { return NULL; } //Àοø¼ö°¡ °ú¹ÝÀÌ ¾È³ÑÀ¸¸é ¸ÅĪ ½ÇÆÐ const BattleGroundInfoParser* const battle_ground_info_parser = \ BattleGroundInfoParser::Instance(); const BattleGroundInfo* const battle_ground_Info = battle_ground_info_parser->FindData(map_code); int extract_list = static_cast(battle_ground_Info->team_max); if ((extract_list%2) != 0) extract_list += 1; if ((int)member_list->size() < extract_list) { return NULL; } //¸ÅĪ ±×·ì ¼±¹ß MatchingGroup* matching_group = static_cast(matching_group_pool_->Alloc()); if (matching_group == NULL) { return NULL; } // ´ë±â¿­ ÀοøÀÌ ÃÖ´ëÀοøÀÌ ¾Æ´Ï°í Ȧ¼ö Àϰæ¿ì..ÇѸíÀ» Á¦¿Ü½ÃŲ´Ù. int memeber_size = static_cast(member_list->size()); if (memeber_size%2 != 0) { memeber_size -= 1; } for (int i = 0; i < memeber_size; ++i) //script.. { BattleGroundMemberInfo* const member_info = *(member_list->begin()); if (member_info == NULL) { continue; } if (BattleGroundManager::Instance()->IsValidReservationMember(member_info->user_guid) == false) { continue; } member_info->member_state = kStandbyPriority; matching_group->matching_group_list.push_back(member_info); BattleGroundManager::Instance()->RemoveMemberStandbyGroup(member_info); } return matching_group; } bool BattleGroundMatchingSystem::CanCreateMatchingGroup(const MAPCODE map_code) { BattleGroundManager* const battle_ground_manager = BattleGroundManager::Instance(); const BattleGroundMemberList* const member_list = \ battle_ground_manager->FindStandbyGroupMemberList(map_code); const BattleGroundInfoParser* const battle_ground_info_parser = \ BattleGroundInfoParser::Instance(); const BattleGroundInfo* const battle_ground_Info = battle_ground_info_parser->FindData(map_code); int extract_list = static_cast(battle_ground_Info->team_max); if ((int)member_list->size() < extract_list * 2) //script.. { return false; } return true; } #endif //_NA_008679_20160202_REWORK_BATTLEGROUND