#include "stdafx.h" #include "gamesrv.h" #include "PartyUnionManager.h" #include "Player.h" #include "ObjectManager.h" #include "GridManager.h" #include "InfluenceObject.h" #include "SkillManager.h" cPartyUnionManager* cPartyUnionManager::mpSingleton = 0; cPartyUnionManager::cPartyUnionManager() { mpSingleton = this; } cPartyUnionManager::~cPartyUnionManager() { Release(); mpSingleton = 0; } bool cPartyUnionManager::Init() { mPartyPool.Reserve( 100, 10 ); return true; } void cPartyUnionManager::Release() { cPartyUnionMap::cIterator i = mPartyUnionMap.Begin(); cPartyUnionMap::cIterator end = mPartyUnionMap.End(); for( ; i != end; ++i ) { cPartyUnion* p = (cPartyUnion*)(*i).mSecond; SAFE_DELETE( p ); } mPartyUnionMap.Clear(); } void cPartyUnionManager::Process( unsigned long, unsigned long accumTime ) { if( mPartyUnionMap.IsEmpty() ) return; /// ÀÏÁ¤½Ã°£¸¶´Ù ÆÄƼÀÇ Á¤º¸¸¦ send cPartyUnionMap::cIterator i = mPartyUnionMap.Begin(); cPartyUnionMap::cIterator end = mPartyUnionMap.End(); for( ; i != end; ++i ) { cPartyUnion* p = (cPartyUnion*)(i->mSecond); if( p && accumTime - p->GetLastAccumTime() > PARTYUNION_UPDATETIME ) { // Àüü °»½Å SendUnionUpdate( p ); // ±×·ì °»½Å SendUnionGroupUpdate( p ); p->SetLastAccumTime( accumTime ); } } } // ¿¬ÇÕ »ý¼º unsigned long cPartyUnionManager::CreateUnion() { cPartyUnion* p = new cPartyUnion; if( !p ) { SAFE_DELETE( p ); NETWORK2->PostServerEvent( "Error cPartyUnionManager::CreateUnion : failed to create union" ); assert(0); return 0; } unsigned long index = mIndexGen.GeneratIdx(); if( mPartyUnionMap.Insert( index, p ) == false ) { SAFE_DELETE( p ); NETWORK2->PostServerEvent( "Error cPartyUnionManager::AddParty : failed to insert union map" ); assert(0); return 0; } p->SetIndex( index ); return index; } bool cPartyUnionManager::DeleteUnion( unsigned long index ) { cPartyUnion* p = GetUnion( index ); if( p ) { if( p->GetCount() > 0 ) return false; // »èÁ¦ mPartyUnionMap.Erase( index ); mIndexGen.DelIdx( index ); SAFE_DELETE( p ); } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::DeleteUnion : failed to find union(%d)", index ); return false; } return true; } cPartyUnion* cPartyUnionManager::GetUnion( unsigned long index ) { return (cPartyUnion*)mPartyUnionMap.GetAt( index ); } bool cPartyUnionManager::AddUser( unsigned long index, unsigned long userIdx ) { cPlayer* newUser = OBJECTMANAGER->GetPlayer( userIdx ); if( newUser != NULL ) { /* cPartyUnion* p = GetUnion( index ); if( !p ) { NETWORK2->PostServerEvent( "Error cPartyUnionManager::AddUser : failed to find union(%d)", index ); assert(0); return false; }*/ // ÀÌ¹Ì ÆÄƼ³ª ¿¬ÇÕ¿¡ °¡ÀÔÁßÀÎÁö °Ë»ç if( newUser->GetPartyIndex() > 0 ) { //DeleteUnion( index ); NETWORK2->PostServerEvent( "Error cPartyUnionManager::AddUser : already party(%d, %d)", index, newUser->GetPartyIndex() ); return false; } if( newUser->GetPartyUnionIndex() > 0 ) { DeleteUnion( index ); // ÀοøÀ» º¸°í »èÁ¦ÇϹǷΠ»ó°ü¾ø´Ù NETWORK2->PostServerEvent( "Error cPartyUnionManager::AddUser : already party union(%d, %d)", index, newUser->GetPartyUnionIndex() ); return false; } cPartyUnion* p = GetUnion( index ); if( !p ) { NETWORK2->PostServerEvent( "Error cPartyUnionManager::AddUser : failed to find union(%d)", index ); assert(0); return false; } int count = p->GetCount(); if( count >= MAX_PARTYUNION ) { NETWORK2->PostServerEvent( "Error cPartyUnionManager::AddUser : count(%d)", count ); assert(0); return false; } // ÇÑ¸íµµ ¾øÀ¸¸é Ãß°¡µÇ´Â À¯Àú°¡ ¸®´õ bool isLeader = ( count == 0 ) ? true : false; int arrIdx = p->AddUser( userIdx ); if( arrIdx == -1 ) { DeleteUnion( index ); NETWORK2->PostServerEvent( "Error cPartyUnionManager::AddUser : failed to insert user(%d,%d)", index, userIdx ); assert(0); return false; } if( isLeader ) p->SetLeader( userIdx ); // ÇØ´ç À¯Àú¿¡ ÆÄƼ¿¬ÇÕ °¡ÀÔÁß Á¤º¸ ¼¼ÆÃ newUser->SetPartyUnionIndex( index ); // Ãß°¡µÈ À¯Àú¿¡°Ô´Â ¿¬ÇÕ¸®½ºÆ® SendUnionList( index, userIdx ); // ±âÁ¸ À¯Àúµé¿¡°Ô´Â Ãß°¡µÈ À¯Àú Á¤º¸ SendUnionAddOne( index, userIdx, arrIdx ); } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::AddUser : failed to find user(%d)", userIdx ); assert(0); return false; } return true; } bool cPartyUnionManager::DeleteUser( cPlayer* player ) { if( player == NULL ) { NETWORK2->PostServerEvent( "Error cPartyUnionManager::DeleteUser : player is null" ); return false; } unsigned long unionIndex = player->GetPartyUnionIndex(); unsigned long playerIndex = player->GetObjectID(); cPartyUnion* p = GetUnion( unionIndex ); if( !p ) { NETWORK2->PostServerEvent( "Error cPartyUnionManager::DeleteUser : failed to find union(%d)", unionIndex ); assert(0); return false; } unsigned long leaderIndex = p->GetLeader(); // ÇØ´ç À¯Àú Á¤º¸ »èÁ¦ if( p->DeleteUser( playerIndex ) == false ) { NETWORK2->PostServerEvent( "Error cPartyUnionManager::DeleteUser : failed to delete player(%d,%d)", playerIndex, unionIndex ); assert(0); return false; } // ÇØ´ç À¯Àú¿¡°Ô Å»ÅðµÊÀ» ¾Ë¸² NETWORK2->SendMsgError( player->GetConnectionIdx(), NM_PARTYUNION, NM_PARTYUNION_OUT_RES, ERROR_PARTYUNION_OUT_SUCESS ); // ±âÁ¸ À¯Àúµé¿¡°Ô Å»Åð ¾Ë¸² SendUnionOutSyn( unionIndex, playerIndex ); // Å»Åð À¯Àú°¡ ¿¬ÇÕÀåÀÎ °æ¿ì ¿¬ÇÕÀå À§ÀÓ if( leaderIndex == playerIndex ) { unsigned long findNextLeader = p->FindNextLeader(); if( findNextLeader != -1 ) { // »õ·Î¿î ¿¬ÇÕÀå À§ÀÓ ChangeLeader( leaderIndex, findNextLeader ); } else { p->SetLeader( 0 ); } } // Á¤º¸ ÃʱâÈ­ player->SetPartyUnionIndex( 0 ); if( p->GetCount() == 0 ) { DeleteUnion( unionIndex ); } return true; } int cPartyUnionManager::MoveUser( unsigned long leaderIdx, unsigned char i0, unsigned char i1 ) { cPlayer* leader = OBJECTMANAGER->GetPlayer( leaderIdx ); if( leader != NULL ) { // ±×·ì °Ë»ö unsigned long index = leader->GetPartyUnionIndex(); cPartyUnion* p = GetUnion( index ); if( !p ) { assert(0); NETWORK2->PostServerEvent( "Error cPartyUnionManager::MoveUser : failed to find union(%d)", index ); return ERROR_PARTYUNION_MOVEGROUP_FAIL; } // ¸®´õ °Ë»ç if( leaderIdx != p->GetLeader() ) return ERROR_PARTYUNION_MOVEGROUP_LEADER; // if( p->MoveUser( i0, i1 ) == false ) { NETWORK2->PostServerEvent( "Error cPartyUnionManager::MoveUser : failed to move user(%d,%d,%d)", leaderIdx, i0, i1 ); return ERROR_PARTYUNION_MOVEGROUP_FAIL; } // ±âÁ¸ À¯Àúµé¿¡°Ô ±×·ìº¯°æ ¾Ë¸² SendUnionMoveUser( index, i0, i1 ); } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::MoveUser : failed to find leader(%d)", leaderIdx ); assert(0); return ERROR_PARTYUNION_MOVEGROUP_FAIL; } return ERROR_PARTYUNION_MOVEGROUP_SUCESS; } // ¿¬ÇÕÀå À§ÀÓ int cPartyUnionManager::ChangeLeader( unsigned long leaderIdx, unsigned long userIdx ) { cPlayer* leader = OBJECTMANAGER->GetPlayer( leaderIdx ); cPlayer* user = OBJECTMANAGER->GetPlayer( userIdx ); if( leader && user ) { unsigned long index = leader->GetPartyUnionIndex(); cPartyUnion* p = GetUnion( index ); if( !p ) { assert(0); NETWORK2->PostServerEvent( "Error cPartyUnionManager::DeleteUser : failed to find union(%d)", index ); return ERROR_PARTYUNION_CHANGELEADER_FAIL; } if( leader->GetPartyUnionIndex() == 0 || user->GetPartyUnionIndex() == 0 ) { assert(0); NETWORK2->PostServerEvent( "Error cPartyUnionManager::ChangeLeader : not partyunion", index, leaderIdx, userIdx ); return ERROR_PARTYUNION_CHANGELEADER_FAIL; } // ÆÄƼ¿¬ÇÕ °Ë»ç if( leader->GetPartyUnionIndex() != user->GetPartyUnionIndex() ) return ERROR_PARTYUNION_CHANGELEADER_FAIL; // ¸®´õ °Ë»ç if( leaderIdx != p->GetLeader() ) return ERROR_PARTYUNION_CHANGELEADER_LEADER; // ÀÚ±â ÀÚ½ÅÀÎÁö °Ë»ç if( leaderIdx == userIdx ) return ERROR_PARTYUNION_CHANGELEADER_FAIL; // ¿¬ÇÕÀå Á¤º¸ º¯°æ p->SetLeader( userIdx ); // ±âÁ¸ À¯Àúµé¿¡°Ô º¯°æ ¾Ë¸² SendUnionChangeLeader( index, userIdx ); } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::ChangeLeader : failed to change leader(%d,%d)", leaderIdx, userIdx ); assert(0); return ERROR_PARTYUNION_CHANGELEADER_FAIL; } return ERROR_PARTYUNION_CHANGELEADER_SUCESS; } void cPartyUnionManager::MapIn( cPlayer* player ) { if( player != NULL ) { unsigned long unionIndex = player->GetPartyUnionIndex(); if( unionIndex != 0 ) { SendUnionList( unionIndex, player->GetObjectID() ); } } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::MapIn : player is null" ); assert(0); } } // »õ user ¿¡°Ô ¿¬ÇÕÁ¤º¸ ¸®½ºÆ® º¸³»±â void cPartyUnionManager::SendUnionList( unsigned long index, unsigned long userIdx ) { cPartyUnion* p = GetUnion( index ); cPlayer* newUser = OBJECTMANAGER->GetPlayer( userIdx ); if( newUser && p ) { HANDLE handle = NULL; MSG_SYN_PARTYUNION_LIST* sendMsg = (MSG_SYN_PARTYUNION_LIST*)NETWORK2->GetMsgRoot( &handle, newUser->GetConnectionIdx(), NM_PARTYUNION, NM_PARTYUNION_LIST_SYN ); if( sendMsg != NULL ) { unsigned long length = sizeof(MSG_SYN_PARTYUNION_LIST) - sizeof(sendMsg->mTable); sendMsg->mIndex = p->GetIndex(); sendMsg->mLeaderIndex = p->GetLeader(); sUnionUserData* data = sendMsg->mTable; unsigned long* userArr = p->GetUserArr(); for( int i = 0; i < MAX_PARTYUNION; ++i, ++userArr ) { if( (*userArr) == 0 ) continue; cPlayer* player = OBJECTMANAGER->GetPlayer( (*userArr) ); if( player != NULL ) { data->idx = i; data->userIndex = (*userArr); wcscpy( data->name, player->GetName() ); data->level = player->GetLevel(); data->job = (unsigned short)player->GetJob(); data->mapNum = player->GetMapNumber(); data->channelNum = NETWORK2->GetChannelNum(); data->posX = player->GetXPos(); data->posY = player->GetYPos(); data->hp = player->GetHP(); data->maxhp = player->GetMaxHP(); data->mp = player->GetMP(); data->maxmp = player->GetMaxMP(); data++; sendMsg->RowCount++; } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionList : not exist user %d", (*userArr) ); continue; } } length += ( sendMsg->RowCount * sizeof(sendMsg->mTable) ); NETWORK2->SendMsgRoot( handle, length ); } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionList : sendMsg is null" ); assert(0); } } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionList(%d,%d)", index, userIdx ); assert(0); } } // ±âÁ¸ ¿¬ÇÕ À¯Àúµé¿¡°Ô »õ user Á¤º¸ º¸³»±â void cPartyUnionManager::SendUnionAddOne( unsigned long index, unsigned long userIdx, unsigned int arrIdx ) { cPartyUnion* p = GetUnion( index ); cPlayer* newUser = OBJECTMANAGER->GetPlayer( userIdx ); if( p && newUser ) { if( p->GetCount() == 0 ) return; cPlayer* player = 0; unsigned long* userArr = p->GetUserArr(); for( int i = 0; i < MAX_PARTYUNION; ++i, ++userArr ) { if( (*userArr) == 0 ) continue; // »õ À¯Àú´Â Á¦¿Ü if( userIdx == (*userArr) ) continue; player = OBJECTMANAGER->GetPlayer( (*userArr) ); if( player != NULL ) { HANDLE handle = NULL; MSG_SYN_PARTYUNION_ADDONE* sendMsg = (MSG_SYN_PARTYUNION_ADDONE*)NETWORK2->GetMsgRoot( &handle, player->GetConnectionIdx(), NM_PARTYUNION, NM_PARTYUNION_ADDONE_SYN ); if( sendMsg != NULL ) { sendMsg->mTable.idx = arrIdx; sendMsg->mTable.userIndex = userIdx; wcscpy( sendMsg->mTable.name, newUser->GetName() ); sendMsg->mTable.level = newUser->GetLevel(); sendMsg->mTable.job = (unsigned short)newUser->GetJob(); sendMsg->mTable.posX = newUser->GetXPos(); sendMsg->mTable.posY = newUser->GetYPos(); sendMsg->mTable.hp = newUser->GetHP(); sendMsg->mTable.maxhp = newUser->GetMaxHP(); sendMsg->mTable.mp = newUser->GetMP(); sendMsg->mTable.maxmp = newUser->GetMaxMP(); sendMsg->mTable.mapNum = newUser->GetMapNumber(); sendMsg->mTable.channelNum = NETWORK2->GetChannelNum(); NETWORK2->SendMsgRoot( handle, sizeof(MSG_SYN_PARTYUNION_ADDONE) ); } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionAddOne : sendMsg is null" ); assert(0); } } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionAddOne : not exist user %d", (*userArr) ); assert(0); } } } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionAddOne(%d,%d)", index, userIdx ); assert(0); } } void cPartyUnionManager::SendUnionOutSyn( unsigned long index, unsigned long userIdx ) { cPartyUnion* p = GetUnion( index ); if( p != NULL ) { if( p->GetCount() == 0 ) return; cPlayer* player = 0; unsigned long* userArr = p->GetUserArr(); for( int i = 0; i < MAX_PARTYUNION; ++i, ++userArr ) { if( (*userArr) == 0 ) continue; player = OBJECTMANAGER->GetPlayer( (*userArr) ); if( player != NULL ) { HANDLE handle = NULL; MSG_SYN_PARTYUNION_OUT* sendMsg = (MSG_SYN_PARTYUNION_OUT*)NETWORK2->GetMsgRoot( &handle, player->GetConnectionIdx(), NM_PARTYUNION, NM_PARTYUNION_OUT_SYN ); if( sendMsg != NULL ) { sendMsg->mPlayerIndex = userIdx; NETWORK2->SendMsgRoot( handle, sizeof(MSG_SYN_PARTYUNION_OUT) ); } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionOutSyn : sendMsg is null" ); assert(0); } } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionOutSyn : not exist user %d", (*userArr) ); assert(0); } } } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionOutSyn(%d,%d)", index, userIdx ); assert(0); } } // ¿¬ÇÕÀå À§ÀÓ ¾Ë¸² void cPartyUnionManager::SendUnionChangeLeader( unsigned long index, unsigned long userIdx ) { cPartyUnion* p = GetUnion( index ); if( p != NULL ) { if( p->GetCount() == 0 ) return; cPlayer* player = 0; unsigned long* userArr = p->GetUserArr(); for( int i = 0; i < MAX_PARTYUNION; ++i, ++userArr ) { if( (*userArr) == 0 ) continue; player = OBJECTMANAGER->GetPlayer( (*userArr) ); if( player != NULL ) { HANDLE handle = NULL; MSG_SYN_PARTYUNION_CHANGELEADER* sendMsg = (MSG_SYN_PARTYUNION_CHANGELEADER*)NETWORK2->GetMsgRoot( &handle, player->GetConnectionIdx(), NM_PARTYUNION, NM_PARTYUNION_CHANGELEADER_SYN ); if( sendMsg != NULL ) { sendMsg->mPlayerIndex = userIdx; NETWORK2->SendMsgRoot( handle, sizeof(MSG_SYN_PARTYUNION_CHANGELEADER) ); } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionChangeLeader : sendMsg is null" ); assert(0); } } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionChangeLeader : not exist user %d", (*userArr) ); assert(0); } } } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionChangeLeader(%d,%d)", index, userIdx ); assert(0); } } // ±×·ì À̵¿ ¾Ë¸² void cPartyUnionManager::SendUnionMoveUser( unsigned long index, unsigned char i0, unsigned char i1 ) { cPartyUnion* p = GetUnion( index ); if( p != NULL ) { if( p->GetCount() == 0 ) return; cPlayer* player = 0; unsigned long* userArr = p->GetUserArr(); for( int i = 0; i < MAX_PARTYUNION; ++i, ++userArr ) { if( (*userArr) == 0 ) continue; player = OBJECTMANAGER->GetPlayer( (*userArr) ); if( player != NULL ) { HANDLE handle = NULL; MSG_SYN_PARTYUNION_MOVEGROUP* sendMsg = (MSG_SYN_PARTYUNION_MOVEGROUP*)NETWORK2->GetMsgRoot( &handle, player->GetConnectionIdx(), NM_PARTYUNION, NM_PARTYUNION_MOVEGROUP_SYN ); if( sendMsg != NULL ) { sendMsg->mIndex0 = i0; sendMsg->mIndex1 = i1; NETWORK2->SendMsgRoot( handle, sizeof(MSG_SYN_PARTYUNION_MOVEGROUP) ); } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionMoveUser : sendMsg is null" ); assert(0); } } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionMoveUser : not exist user %d", (*userArr) ); assert(0); } } } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionMoveUser(%d)", index ); assert(0); } } // Àüü ¿¬ÇÕ Á¤º¸ °»½Å void cPartyUnionManager::SendUnionUpdate( cPartyUnion* p ) { if( p != NULL ) { if( p->GetCount() == 0 ) return; unsigned long* userArr1 = p->GetUserArr(); unsigned long* userArr2 = p->GetUserArr(); for( int i = 0; i < MAX_PARTYUNION; ++i ) { unsigned long playerIdx1 = *(userArr1+i); if( playerIdx1 == 0 ) continue; cPlayer* player1 = OBJECTMANAGER->GetPlayer( playerIdx1 ); if( player1 == NULL ) { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionUpdate( player1 : %d,%d )", p->GetIndex(), playerIdx1 ); assert(0); continue; } HANDLE handle = NULL; MSG_SYN_PARTYUNION_UPDATE* sendMsg = (MSG_SYN_PARTYUNION_UPDATE*)NETWORK2->GetMsgRoot( &handle, player1->GetConnectionIdx(), NM_PARTYUNION, NM_PARTYUNION_UPDATE_SYN ); if( sendMsg != NULL ) { sendMsg->rowCount = 0; // 18¸í Á¤º¸¸¦ Ã߸² sUnionUpdate* table = sendMsg->table; for( int j = 0; j < MAX_PARTYUNION; ++j ) { unsigned long playerIdx2 = *(userArr2+j); if( playerIdx2 == 0 ) continue; cPlayer* player2 = OBJECTMANAGER->GetPlayer( playerIdx2 ); if( player2 == NULL ) { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionUpdate( player2 : %d,%d )", p->GetIndex(), playerIdx2 ); assert(0); continue; } /// 1. ¸Ê À§Ä¡ °Ë»ç if( player1->GetMapNumber() != player2->GetMapNumber() ) continue; /// 2. ±×¸®µå °Ë»ç - ±ÙÁ¢ ±×¸®µå¾È¿¡ ¾ø´Â À¯ÀúÁ¤º¸¸¸ Ãß·Á¼­ ½ð´Ù if( GRIDMANAGER->IsSight( player1, player2 ) == false ) { // Á¤º¸ ´ã±â table->idx = j; table->userIndex = playerIdx2; table->maxhp = player2->GetMaxHP(); table->hp = player2->GetHP(); table->posX = player2->GetXPos(); table->posY = player2->GetYPos(); table++; sendMsg->rowCount++; } } // ½î±â if( sendMsg->rowCount > 0 ) { NETWORK2->SendMsgRoot( handle, sendMsg->GetMsgLength() ); } else { NETWORK2->ReleaseMsgRoot( (PerIoContext*)handle, sendMsg->GetMsgLength() ); } } } } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionUpdate - not exist party union" ); assert(0); } } // ±×·ì Á¤º¸ °»½Å void cPartyUnionManager::SendUnionGroupUpdate( cPartyUnion* p ) { if( p != NULL ) { if( p->GetCount() == 0 ) return; typedef tHashSet cSkillInfluenceSet; unsigned long* userArr1 = p->GetUserArr(); for( int i = 0; i < MAX_PARTYUNION; ++i ) { unsigned long playerIdx1 = *(userArr1+i); if( playerIdx1 == 0 ) continue; cPlayer* player1 = OBJECTMANAGER->GetPlayer( playerIdx1 ); if( player1 == NULL ) { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionGroupUpdate( player1 : %d,%d )", p->GetIndex(), playerIdx1 ); assert(0); continue; } int groupIndex = p->GetGroup( playerIdx1 ); if( groupIndex == -1 ) { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionGroupUpdate - GetGroup(%d,%d)", p->GetIndex(), playerIdx1 ); assert(0); continue; } unsigned long* userArr2 = p->GetGroupArr( playerIdx1 ); if( userArr2 == 0 ) { NETWORK2->PostServerEvent( "Error cPartyUnionManager::GetGroupArr - GetGroupArr(%d,%d)", p->GetIndex(), playerIdx1 ); assert(0); continue; } for( unsigned int j = 0; j < MAX_PARTYUSER; ++j ) { unsigned long playerIdx2 = *(userArr2+j); if( playerIdx2 == 0 ) continue; // ÀÚ±âÀڽŠÁ¤º¸´Â º¸³»Áö ¾Ê´Â´Ù if( playerIdx1 == playerIdx2 ) continue; cPlayer* player2 = OBJECTMANAGER->GetPlayer( playerIdx2 ); if( player2 == NULL ) { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionUpdate( player2 : %d,%d )", p->GetIndex(), playerIdx2 ); assert(0); continue; } /// 1. ¸Ê À§Ä¡ °Ë»ç if( player1->GetMapNumber() != player2->GetMapNumber() ) continue; /// 2. ±×¸®µå °Ë»ç - ±ÙÁ¢ ±×¸®µå¾È¿¡ ¾ø´Â À¯ÀúÁ¤º¸¸¸ Ãß·Á¼­ ½ð´Ù if( GRIDMANAGER->IsSight( player1, player2 ) == false ) { HANDLE handle = NULL; MSG_SYN_PARTYUNION_GROUPUPDATE* sendMsg = (MSG_SYN_PARTYUNION_GROUPUPDATE*)NETWORK2->GetMsgRoot( &handle, player1->GetConnectionIdx(), NM_PARTYUNION, NM_PARTYUNION_GROUPUPDATE_SYN ); if( sendMsg != NULL ) { sendMsg->idx = (groupIndex * MAX_PARTYUSER) + j; sendMsg->userIndex = playerIdx2; sendMsg->level = player2->GetLevel(); sendMsg->maxhp = player2->GetMaxHP(); sendMsg->hp = player2->GetHP(); sendMsg->maxmp = player2->GetMaxMP(); sendMsg->mp = player2->GetMP(); sendMsg->posX = player2->GetXPos(); sendMsg->posY = player2->GetYPos(); sendMsg->rowCount = 0; /// ¹öÇÁ¸®½ºÆ® ´ã±â cSkillInfluenceSet* influenceSet = player2->GetInfluenceSet(); if( influenceSet && influenceSet->GetSize() > 0 ) { cSkillInfluenceSet::cIterator i = influenceSet->Begin(); cSkillInfluenceSet::cIterator end = influenceSet->End(); short& buffCount = sendMsg->rowCount; cInfluenceObject* pObj = 0; for( ; i != end; ++i ) { pObj = SKILLMANAGER->GetInfluence( (unsigned long)(*i) ); if( !pObj ) { assert(0); NETWORK2->PostServerEvent("cPartyUnionManager::SendUnionGroupUpdate[%d,%d,%d]", NM_PARTYUNION_UPDATE_SYN, player1->GetConnectionIdx(), playerIdx2 ); continue; } sendMsg->table[buffCount].mInfluenceClassIdx = pObj->GetInfluenceClassIdx(); sendMsg->table[buffCount].mUniqueIdx = pObj->GetUniqueIdx(); sendMsg->table[buffCount].mRestTime = 0; buffCount++; } } NETWORK2->SendMsgRoot( handle, sendMsg->GetMsgLength() ); } } } } } else { NETWORK2->PostServerEvent( "Error cPartyUnionManager::SendUnionGroupUpdate - not exist party union" ); assert(0); } }