#include "stdafx.h" #include "PartyUnionManager.h" #include "Protocol.h" #include "ChatManager.h" #include "ObjectManager.h" #include "Hero.h" #include "PartyUnionWindow.h" #include "GameUIManager.h" #include "PartyStateWindow.h" #include "SkillObject.h" #include "PartyWindow.h" #include "InputSystem.h" #include "SmallMiniMapWindow.h" #include "MiniMapWindow.h" #include "GameResourceManager.h" #include "SkillExecuter.h" cPartyUnionManager* cPartyUnionManager::mpSingleton = 0; cPartyUnionManager::cPartyUnionManager() : mIndex(0) , mLeaderIndex(0) , mpLinkedIcon(0) , mTempSlot(UINT_MAX) , mGroup( eUNION_MAX ) , mHPAccumTime(0) , mPosAccumTime(0) , mPvpLeaderIndex(0) , mFlagPlayerIndex(0) { mpSingleton = this; ::memset( &mParty, 0, sizeof(mParty) ); } cPartyUnionManager::~cPartyUnionManager() { mpSingleton = 0; } void cPartyUnionManager::Close() { Clear(); } void cPartyUnionManager::Clear() { mIndex = 0; mLeaderIndex = 0; mTempSlot = UINT_MAX; for( unsigned int i = 0; i < MAX_PARTYUNION; ++i ) { DeletePlayer( i ); } cPartyWindow* partyWin = GAMEUI->GetPartyWindow(); if( partyWin ) partyWin->Hide(); for( int i = 0; i < MAX_PARTY; ++i ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( i ); if( state ) { state->Clear(); state->Hide(); } cPartyStateMiniWindow* statemini = GAMEUI->GetPartyStateMiniWindow( i ); if( statemini ) { statemini->Clear(); statemini->Hide(); } } // mGroup = eUNION_MAX; mHPAccumTime = 0; mPosAccumTime = 0; mPvpLeaderIndex = 0; mFlagPlayerIndex = 0; if( HERO ) HERO->SetPartyUnionIndex( 0 ); } void cPartyUnionManager::Process( unsigned long accumTime ) { if( mIndex == 0 ) return; /// ÀÏÁ¤ °»½Å½Ã°£ if( accumTime - mHPAccumTime > PARTYUNION_DATAUPDATE ) { /// HP °»½Å for( int i = 0; i < MAX_PARTYUNION; ++i ) { if( mParty[i].userIndex == 0 ) continue; cPlayer* user = OBJECTMAN->GetPlayer( mParty[i].userIndex ); if( user ) { // Á¤º¸ °»½Å ¹× ¿¬ÇÕ ui¼¼ÆÃ UpdatePlayer( i, mParty[i].userIndex, user->GetLevel(), user->GetMaxHP(), user->GetMaxMP(), user->GetHP(), user->GetMP(), user->GetXPos(), user->GetYPos() ); // Á¤º¸ °»½Å ¹× ÆÄƼ ui¼¼ÆÃ if( IsHeroGroup( i ) == true ) { if( UpdateGroup( i ) == false ) assert(0); } } } mHPAccumTime = accumTime; } // ¹Ì´Ï¸Ê ¼¼ÆÃ if( accumTime - mPosAccumTime > PARTYUNION_POSUPDATE ) { UpdateMinimap(); mPosAccumTime = accumTime; } } void cPartyUnionManager::NetworkMsgParser( char* msg ) { MSGROOT* tempMsg = (MSGROOT*)msg; cStringT str; switch( tempMsg->Protocol ) { case NM_PARTYUNION_LIST_SYN: { // ¿¬ÇÕ ¸®½ºÆ® MSG_SYN_PARTYUNION_LIST* pmsg = (MSG_SYN_PARTYUNION_LIST*)msg; // Clear(); // Á¤º¸ ¼¼ÆÃ mIndex = pmsg->mIndex; mLeaderIndex = pmsg->mLeaderIndex; // À¯Àú Á¤º¸ ¼¼ÆÃ sUnionUserData* p = pmsg->mTable; for( unsigned char i = 0; i < pmsg->RowCount; ++i, ++p ) { if( AddPlayer( p->idx, p ) == false ) { assert(0); continue; } } UpdateLeader(); // Hero °¡ ¼ÓÇÑ ±×·ì Á¤º¸ ¼¼ÆÃ int i = FindUser( HERO->GetObjectID() ); ChangeHeroGroup( i ); // SetGroupList(); // hero¿¡ ÆÄƼ¿¬ÇÕÁ¤º¸ ¼¼ÆÃ HERO->SetPartyUnionIndex( mIndex ); if( HERO->IsOpenNpcTalk() == false && GAMEUI->IsDuelMode() == false ) { ShowLargeUnionUI( true ); } } break; case NM_PARTYUNION_ADDONE_SYN: { // 1¸í Ãß°¡ MSG_SYN_PARTYUNION_ADDONE* pmsg = (MSG_SYN_PARTYUNION_ADDONE*)msg; if( AddPlayer( pmsg->mTable.idx, &pmsg->mTable ) == false ) { assert(0); return; } // ÇØ´ç À¯Àú°¡ HERO ±×·ìÀ̸é if( IsHeroGroup( pmsg->mTable.idx ) == true ) { SetGroupList(); } // str.Format( GAMERESOURCEMAN->GetGameText(1400), pmsg->mTable.name ); CHATMANAGER->AddSystemMsg( eSYSTEM_NORMAL, (LPCTSTR)str.Cstr() ); } break; case NM_PARTYUNION_OUT_RES: { // ¿¬ÇÕ Å»Åð MSG_RES_PARTYUNION_OUT* pmsg = (MSG_RES_PARTYUNION_OUT*)msg; switch( pmsg->ErrorCode ) { case ERROR_PARTYUNION_OUT_SUCESS: { CHATMANAGER->AddSystemMsg( eSYSTEM_NORMAL, GAMERESOURCEMAN->GetGameText(1401) ); // ÆÄƼ¿¬ÇÕÁ¤º¸ »èÁ¦ Clear(); // HERO->SetPartyUnionIndex( 0 ); cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) win->Hide(); cPartyUnionSmallWindow* smallWin = GAMEUI->GetPartyUnionSmallWindow(); if( smallWin ) smallWin->Hide(); } break; case ERROR_PARTYUNION_OUT_FAIL: { CHATMANAGER->AddSystemMsg( eSYSTEM_NORMAL, GAMERESOURCEMAN->GetGameText(1402) ); } break; } } break; case NM_PARTYUNION_OUT_SYN: { // ´Ù¸¥ À¯Àú ¿¬ÇÕ Å»Åð MSG_SYN_PARTYUNION_OUT* pmsg = (MSG_SYN_PARTYUNION_OUT*)msg; int i = FindUser( pmsg->mPlayerIndex ); if( i >= 0 ) { str.Format( GAMERESOURCEMAN->GetGameText(1403), mParty[i].name ); CHATMANAGER->AddSystemMsg( eSYSTEM_NORMAL, (LPCTSTR)str.Cstr() ); // DeletePlayer( i ); // ÇØ´ç À¯Àú°¡ ¾î´À±×·ìÀÎÁö ÆÇ´ÜÈÄ ¸ÂÀ¸¸é if( IsHeroGroup( i ) == true ) { SetGroupList(); } } else assert(0); } break; case NM_PARTYUNION_CHANGELEADER_RES: { // ¿¬ÇÕÀå À§ÀÓ MSG_RES_PARTYUNION_CHANGELEADER* pmsg = (MSG_RES_PARTYUNION_CHANGELEADER*)msg; switch( pmsg->ErrorCode ) { case ERROR_PARTYUNION_CHANGELEADER_SUCESS: break; case ERROR_PARTYUNION_CHANGELEADER_LEADER: CHATMANAGER->AddSystemMsg( eSYSTEM_NORMAL, GAMERESOURCEMAN->GetGameText(1404) ); break; case ERROR_PARTYUNION_CHANGELEADER_FAIL: CHATMANAGER->AddSystemMsg( eSYSTEM_NORMAL, GAMERESOURCEMAN->GetGameText(1405) ); break; } cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) win->NetUnLock(); } break; case NM_PARTYUNION_CHANGELEADER_SYN: { MSG_SYN_PARTYUNION_CHANGELEADER* pmsg = (MSG_SYN_PARTYUNION_CHANGELEADER*)msg; int i = FindUser( pmsg->mPlayerIndex ); if( i >= 0 ) { str.Format( GAMERESOURCEMAN->GetGameText(1406), mParty[i].name ); CHATMANAGER->AddSystemMsg( eSYSTEM_NORMAL, (LPCTSTR)str.Cstr() ); // mLeaderIndex = pmsg->mPlayerIndex; // UpdateLeader(); } else assert(0); } break; case NM_PARTYUNION_MOVEGROUP_RES: { // ±×·ì À̵¿ MSG_RES_PARTYUNION_MOVEGROUP* pmsg = (MSG_RES_PARTYUNION_MOVEGROUP*)msg; switch( pmsg->ErrorCode ) { case ERROR_PARTYUNION_MOVEGROUP_SUCESS: break; case ERROR_PARTYUNION_MOVEGROUP_LEADER: CHATMANAGER->AddSystemMsg( eSYSTEM_NORMAL, GAMERESOURCEMAN->GetGameText(1407) ); break; case ERROR_PARTYUNION_MOVEGROUP_FAIL: CHATMANAGER->AddSystemMsg( eSYSTEM_NORMAL, GAMERESOURCEMAN->GetGameText(1408) ); break; } cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) win->NetUnLock(); } break; case NM_PARTYUNION_MOVEGROUP_SYN: { MSG_SYN_PARTYUNION_MOVEGROUP* pmsg = (MSG_SYN_PARTYUNION_MOVEGROUP*)msg; if( ChangePlayer( pmsg->mIndex0, pmsg->mIndex1 ) == true ) { UpdateLeader(); // hero °¡ À̵¿µÇ¾úÀ¸¸é ±×·ìÁ¤º¸ °»½Å if( mParty[pmsg->mIndex0].userIndex == HERO->GetObjectID() ) { ChangeHeroGroup( pmsg->mIndex0 ); } else if( mParty[pmsg->mIndex1].userIndex == HERO->GetObjectID() ) { ChangeHeroGroup( pmsg->mIndex1 ); } // hero ±×·ìÀÌ¸é °»½Å if( IsHeroGroup( pmsg->mIndex0 ) == true || IsHeroGroup( pmsg->mIndex1 ) == true ) { SetGroupList(); } } } break; case NM_PARTYUNION_UPDATE_SYN: { // Á¤º¸ °»½Å MSG_SYN_PARTYUNION_UPDATE* pmsg = (MSG_SYN_PARTYUNION_UPDATE*)msg; sUnionUpdate* data = pmsg->table; for( unsigned char i = 0; i < pmsg->rowCount; ++i, ++data ) { UpdatePlayer( data->idx, data->userIndex, data->maxhp, data->hp, data->posX, data->posY ); } } break; case NM_PARTYUNION_GROUPUPDATE_SYN: { // µ¿ÀÏ ±×·ì Á¤º¸ °»½Å MSG_SYN_PARTYUNION_GROUPUPDATE* pmsg = (MSG_SYN_PARTYUNION_GROUPUPDATE*)msg; // Á¤º¸ °»½Å UpdatePlayer( pmsg->idx, pmsg->userIndex, pmsg->level, pmsg->maxhp, pmsg->maxmp, pmsg->hp, pmsg->mp, pmsg->posX, pmsg->posY ); // ÆÄƼ UI °»½Å if( IsHeroGroup( pmsg->idx ) == true ) { if( UpdateGroup( pmsg->idx ) == false ) { assert(0); return; } // ¹öÇÁ °»½Å if( UpdateGroupBuff( pmsg->idx, pmsg->table, pmsg->rowCount ) == false ) { assert(0); return; } UpdateMouseHover(); } else assert(0); } break; default: assert(0); break; } } void cPartyUnionManager::LinkIcon( cUnionIcon* icon ) { if( icon ) { if( mpLinkedIcon == icon ) return; if( mpLinkedIcon ) { mpLinkedIcon->SetColor( NiColorA::WHITE ); assert(0); } NiColorA check; mpLinkedIcon = icon; mpLinkedIcon->SetColor( 0.5f, 0.5f, 0.5f, 1.0f ); } else assert(0); } void cPartyUnionManager::UnLinkIcon() { if( mpLinkedIcon ) { mpLinkedIcon->SetColor( NiColorA::WHITE ); mpLinkedIcon = 0; } } bool cPartyUnionManager::AddPlayer( unsigned int i, sUnionUserData* data ) { // ¸Ê ³Ñ¹ö °»½Å ÆÐŶ ¸¸µé±â Àü±îÁö´Â ¿ì¼± hero ²¨·Î ¼¼ÆÃÇÏÀÚ 09.06.19 data->mapNum = HERO->GetMapNum(); /// data mParty[i] = *data; /// ui setting cSmallMiniMapWindow* minimap = GAMEUI->GetSmallMinimapWindow(); cMiniMapWindow* pWide = GAMEUI->GetMinimapWindow(); if( minimap && pWide ) { minimap->AddUnion( data ); pWide->AddUnion( data ); } cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) { win->SetInfo( i, data->name, data->maxhp, data->hp, data->job, data->level ); } else { assert(0); return false; } return true; } bool cPartyUnionManager::DeletePlayer( unsigned int i ) { /// data setting sUnionUserData* data = &mParty[i]; // cSmallMiniMapWindow* minimap = GAMEUI->GetSmallMinimapWindow(); cMiniMapWindow* pWide = GAMEUI->GetMinimapWindow(); if( minimap && pWide ) { minimap->DeleteUnion( data->userIndex ); pWide->DeleteUnion( data->userIndex ); } ::memset( data, 0, sizeof(sUnionUserData) ); /// ui setting cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) { win->ClearInfo( i ); } else { assert(0); return false; } return true; } bool cPartyUnionManager::ChangePlayer( unsigned int i0, unsigned int i1 ) { if( i0 < MAX_PARTYUNION && i1 < MAX_PARTYUNION ) { // data sUnionUserData p0 = mParty[i0]; sUnionUserData p1 = mParty[i1]; sUnionUserData temp; ::memset( &temp, 0, sizeof(temp) ); if( p0.userIndex == 0 ) assert(0); temp = p0; p0 = p1; p1 = temp; mParty[i0] = p0; mParty[i1] = p1; // cSmallMiniMapWindow* minimap = GAMEUI->GetSmallMinimapWindow(); cMiniMapWindow* pWide = GAMEUI->GetMinimapWindow(); if( minimap && pWide ) { // »èÁ¦ & »ðÀÔ if( mParty[i0].userIndex > 0 ) { minimap->DeleteUnion( mParty[i0].userIndex ); pWide->DeleteUnion( mParty[i0].userIndex ); minimap->AddUnion( &mParty[i0] ); pWide->AddUnion( &mParty[i0] ); /// ¼öÀå Ç¥½Ã °»½Å if( mParty[i0].userIndex == mPvpLeaderIndex ) { if( minimap ) minimap->SetPvpLeader( mPvpLeaderIndex ); if( pWide ) pWide->SetPvpLeader( mPvpLeaderIndex ); } } if( mParty[i1].userIndex > 0 ) { minimap->DeleteUnion( mParty[i1].userIndex ); pWide->DeleteUnion( mParty[i1].userIndex ); minimap->AddUnion( &mParty[i1] ); pWide->AddUnion( &mParty[i1] ); /// ¼öÀå Ç¥½Ã °»½Å if( mParty[i1].userIndex == mPvpLeaderIndex ) { if( minimap ) minimap->SetPvpLeader( mPvpLeaderIndex ); if( pWide ) pWide->SetPvpLeader( mPvpLeaderIndex ); } } } // ui cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) { win->ClearInfo( i0 ); win->ClearInfo( i1 ); if( mParty[i0].userIndex > 0 ) { win->SetInfo( i0, mParty[i0].name, mParty[i0].maxhp, mParty[i0].hp, mParty[i0].job, mParty[i0].level ); /// ¼öÀå, ±ê¹ß °¡Áø À¯Àú Ç¥½Ã if( mParty[i0].userIndex == mPvpLeaderIndex ) win->SetPvpLeader( i0 ); else if( mParty[i0].userIndex == mFlagPlayerIndex ) win->SetFlagPlayer( i0 ); } if( mParty[i1].userIndex > 0 ) { win->SetInfo( i1, mParty[i1].name, mParty[i1].maxhp, mParty[i1].hp, mParty[i1].job, mParty[i1].level ); /// ¼öÀå, ±ê¹ß °¡Áø À¯Àú Ç¥½Ã if( mParty[i1].userIndex == mPvpLeaderIndex ) win->SetPvpLeader( i1 ); else if( mParty[i1].userIndex == mFlagPlayerIndex ) win->SetFlagPlayer( i1 ); } win->SetSelect( mTempSlot ); mTempSlot = UINT_MAX; } else { assert(0); return false; } } else { assert(0); return false; } return true; } void cPartyUnionManager::UpdatePlayer( unsigned int i, unsigned long userIndex, unsigned char level, unsigned int maxhp, unsigned int maxmp, unsigned int hp, unsigned int mp, float posX, float posY ) { if( i >= 0 && i < MAX_PARTYUNION ) { if( mParty[i].userIndex == userIndex ) { // Á¤º¸ °»½Å mParty[i].level = level; mParty[i].maxhp = maxhp; mParty[i].hp = hp; mParty[i].maxmp = maxmp; mParty[i].mp = mp; mParty[i].posX = posX; mParty[i].posY = posY; // ui ¼¼ÆÃ cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) { win->UpdateInfo( i, mParty[i].maxhp, mParty[i].hp ); } else assert(0); } else assert(0); } else assert(0); } void cPartyUnionManager::UpdatePlayer( unsigned int i, unsigned long userIndex, unsigned int maxhp, unsigned int hp, float posX, float posY ) { if( i >= 0 && i < MAX_PARTYUNION ) { if( mParty[i].userIndex == userIndex ) { // Á¤º¸ °»½Å mParty[i].maxhp = maxhp; mParty[i].hp = hp; mParty[i].posX = posX; mParty[i].posY = posY; // ui ¼¼ÆÃ cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) { win->UpdateInfo( i, mParty[i].maxhp, mParty[i].hp ); } else assert(0); } else assert(0); } else assert(0); } void cPartyUnionManager::UpdateLeader() { cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) { int i = FindUser( mLeaderIndex ); if( i >= 0 ) { win->SetLeader( i ); } bool enable = ( HERO->GetObjectID() == mLeaderIndex ); win->EnableLeader( enable ); } else assert(0); } /// party ui¿¡ ÆÄƼ ¿¬ÇÕ Á¤º¸ °»½Å bool cPartyUnionManager::SetGroupList() { cPartyWindow* partyWin = GAMEUI->GetPartyWindow(); if( partyWin ) partyWin->Hide(); // ÃʱâÈ­ for( int i = 0; i < MAX_PARTYUNION; ++i ) { cPlayer* player = OBJECTMAN->GetPlayer( mParty[i].userIndex ); if( player ) player->PartyOut_Init(); } // ÃʱâÈ­ for( int i = 0; i < MAX_PARTY; ++i ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( i ); if( state ) { state->Clear(); state->Hide(); } cPartyStateMiniWindow* statemini = GAMEUI->GetPartyStateMiniWindow( i ); if( statemini ) { statemini->Clear(); statemini->Hide(); } } int cnt = 0; for( int i = 0; i < MAX_PARTYUSER; ++i ) { // µ¥ÀÌÅÍ ¼¼ÆÃ int idx = i + ( MAX_PARTYUSER * mGroup ); sUnionUserData* p = &mParty[idx]; // hero Á¤º¸´Â ¼¼ÆÃÇÏÁö ¾Ê´Â´Ù if( p->userIndex == HERO->GetObjectID() ) continue; cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( cnt ); cPartyStateMiniWindow* statemini = GAMEUI->GetPartyStateMiniWindow( cnt ); if( state && statemini ) { // ÃʱâÈ­ state->Clear(); statemini->Clear(); // Á¤º¸ ¼¼ÆÃ if( p->userIndex > 0 ) { state->SetInfo( p->userIndex, p->name, p->level, (ePLAYER_JOB)p->job, p->maxhp, p->hp, p->maxmp, p->mp, p->mapNum, 0, p->channelNum, cnt ); statemini->SetInfo( p->userIndex, p->name, p->maxhp, p->hp, p->maxmp, p->mp, p->mapNum, 0, p->channelNum, cnt ); ShowStateUI( cnt ); cPlayer* player = OBJECTMAN->GetPlayer( p->userIndex ); if( player ) player->PartyIn_Init(); cnt++; } else { HideStateUI( cnt ); } } // ¹öÇÁ ¼¼ÆÃ cPlayer* user = OBJECTMAN->GetPlayer( mParty[i].userIndex ); if( user ) { UpdateGroupBuff( i, user ); UpdateMouseHover(); } } return true; } // ÇÑ»ç¶÷ °»½Å - ÆÄƼâ °»½Å bool cPartyUnionManager::UpdateGroup( unsigned int i ) { sUnionUserData* p = &mParty[i]; // if( p->userIndex == HERO->GetObjectID() ) return true; for( int idx = 0; idx < MAX_PARTY; ++idx ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( idx ); cPartyStateMiniWindow* statemini = GAMEUI->GetPartyStateMiniWindow( idx ); if( state && statemini ) { if( state->GetUserIndex() == p->userIndex && statemini->GetUserIndex() == p->userIndex ) { state->UpdateInfo( p->level, p->maxhp, p->hp, p->maxmp, p->mp ); statemini->UpdateInfo( p->maxhp, p->hp, p->maxmp, p->mp ); return true; } } } return false; } bool cPartyUnionManager::UpdateGroupBuff( unsigned int i, sInfluenceClient* data, long count ) { sUnionUserData* p = &mParty[i]; if( p->userIndex == HERO->GetObjectID() ) return true; for( int idx = 0; idx < MAX_PARTY; ++idx ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( idx ); if( state && state->GetUserIndex() == p->userIndex ) { // ¼¼ÆÃ state->ClearBuff(); for( long i = 0; i < count; ++i, ++data ) { state->AddBuff( data->mUniqueIdx, data->mInfluenceClassIdx ); } return true; } } return false; } void cPartyUnionManager::ClearAllBuff( unsigned long objectIdx ) { int i = FindUser( objectIdx ); if( i >= 0 && i < MAX_PARTYUNION ) { for( int idx = 0; idx < MAX_PARTY; ++idx ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( idx ); if( state && state->GetUserIndex() == objectIdx ) { state->ClearBuff(); return; } } } else assert(0); } void cPartyUnionManager::AddBuff( unsigned long objectIdx, unsigned long uniqueIdx, unsigned long influenceIdx ) { int i = FindUser( objectIdx ); if( i >= 0 && i < MAX_PARTYUNION ) { for( int idx = 0; idx < MAX_PARTY; ++idx ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( idx ); if( state && state->GetUserIndex() == objectIdx ) { state->AddBuff( uniqueIdx, influenceIdx ); UpdateMouseHover(); return; } } } } void cPartyUnionManager::DeleteBuff( unsigned long objectIdx, unsigned long uniqueIdx ) { int i = FindUser( objectIdx ); if( i >= 0 && i < MAX_PARTYUNION ) { for( int idx = 0; idx < MAX_PARTY; ++idx ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( idx ); if( state && state->GetUserIndex() == objectIdx ) { state->DelBuff( uniqueIdx ); UpdateMouseHover(); return; } } } } void cPartyUnionManager::DeleteDeBuff( unsigned long objectIdx, unsigned long uniqueIdx ) { int i = FindUser( objectIdx ); if( i >= 0 && i < MAX_PARTYUNION ) { for( int idx = 0; idx < MAX_PARTY; ++idx ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( idx ); if( state && state->GetUserIndex() == objectIdx ) { state->DelDeBuff( uniqueIdx ); UpdateMouseHover(); return; } } } } bool cPartyUnionManager::UpdateGroupBuff( unsigned int i, cPlayer* player ) { typedef tPointerHashMap cInfluenceMap; if( player != NULL ) { for( int idx = 0; idx < MAX_PARTY; ++idx ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( idx ); if( state && state->GetUserIndex() == player->GetObjectID() ) { // ¼¼ÆÃ state->ClearBuff(); cInfluenceMap* buffMap = player->GetBufMap(); cInfluenceMap* debuffMap = player->GetDeBufMap(); if( buffMap ) { /// ¹öÇÁ Á¤º¸ ¼¼ÆÃ cInfluenceMap::cIterator b = buffMap->Begin(); cInfluenceMap::cIterator end = buffMap->End(); for( ; b != end; ++b ) { unsigned long uniqueIndex = (unsigned long)(b->mFirst); cInfluenceObject* p = (cInfluenceObject*)(b->mSecond); if( p ) state->AddBuff( uniqueIndex, p->GetInfluenceIdx() ); } } if( debuffMap ) { /// µð¹öÇÁ Á¤º¸ ¼¼ÆÃ cInfluenceMap::cIterator b = debuffMap->Begin(); cInfluenceMap::cIterator end = debuffMap->End(); for( ; b != end; ++b ) { unsigned long uniqueIndex = (unsigned long)(b->mFirst); cInfluenceObject* p = (cInfluenceObject*)(b->mSecond); if( p ) state->AddBuff( uniqueIndex, p->GetInfluenceIdx() ); } } return true; } } } else { assert(0); return false; } return true; } void cPartyUnionManager::UpdateMouseHover() { for( int i = 0; i < MAX_PARTY; ++i ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( i ); if( state ) state->UpdateMouseHover( cUIPos( MOUSE->GetMouseX(), MOUSE->GetMouseY() )); } } void cPartyUnionManager::UpdateMinimap() { cSmallMiniMapWindow* minimap = GAMEUI->GetSmallMinimapWindow(); cMiniMapWindow* pWide = GAMEUI->GetMinimapWindow(); if( minimap && pWide ) { sUnionUserData* p = mParty; for( int i = 0; i < MAX_PARTYUNION; ++i, ++p ) { if( p->userIndex > 0 ) { minimap->UpdateUnion( p->userIndex, p->posX, p->posY ); pWide->UpdateUnion( p->userIndex, p->posX, p->posY ); } } } } void cPartyUnionManager::ShowUI() { if( HERO->GetPartyUnionIndex() == 0 ) return; cPartyWindow* partyWin = GAMEUI->GetPartyWindow(); if( partyWin ) partyWin->Hide(); for( int i = 0; i < MAX_PARTY; ++i ) { ShowStateUI( i ); } ShowLargeUnionUI( true ); } void cPartyUnionManager::HideUI() { for( int i = 0; i < MAX_PARTY; ++i ) { HideStateUI( i ); } cPartyWindow* partyWin = GAMEUI->GetPartyWindow(); if( partyWin ) partyWin->Hide(); cPartyUnionWindow* unionWin = GAMEUI->GetPartyUnionWindow(); if( unionWin ) unionWin->Hide(); cPartyUnionSmallWindow* smallWin = GAMEUI->GetPartyUnionSmallWindow(); if( smallWin ) smallWin->Hide(); } // display ¸ðµå¿¡ µû¸¥ À©µµ¿ì º¸±â ¼³Á¤ void cPartyUnionManager::ShowStateUI( int i ) { // npc ´ëÈ­Áß, ȤÀº °áÅõ ¸ðµåÀÌ¸é ¸®ÅÏ if( HERO->IsOpenNpcTalk() || GAMEUI->IsDuelMode() ) return; cPartyWindow* partyWin = GAMEUI->GetPartyWindow(); if( partyWin ) { bool show = false; switch( partyWin->GetDisplayType() ) { case ePARTY_STATE_DISPLAY_NORMAL: { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( i ); if( state && state->GetUserIndex() > 0 ) { bool isPvpLeader = (state->GetUserIndex() == mPvpLeaderIndex ) ; state->SetPvpLeaderVisible( isPvpLeader ); bool isFlagPlayer = (state->GetUserIndex() == mFlagPlayerIndex ) ; state->SetFlagPlayerVisible( isFlagPlayer ); show = true; state->Show(); } } break; case ePARTY_STATE_DISPLAY_MINI: { cPartyStateMiniWindow* statemini = GAMEUI->GetPartyStateMiniWindow( i ); if( statemini && statemini->GetUserIndex() > 0 ) { bool isPvpLeader = (statemini->GetUserIndex() == mPvpLeaderIndex) ; statemini->SetPvpLeaderVisible( isPvpLeader ); bool isFlagPlayer = (statemini->GetUserIndex() == mFlagPlayerIndex ) ; statemini->SetFlagPlayerVisible( isFlagPlayer ); show = true; statemini->Show(); } } break; case ePARTY_STATE_DISPLAY_HIDE: { show = true; } break; } if( show == true ) { partyWin->SetUnion(); partyWin->Show(); } } } void cPartyUnionManager::HideStateUI( int i ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( i ); if( state ) state->Hide(); cPartyStateMiniWindow* statemini = GAMEUI->GetPartyStateMiniWindow( i ); if( statemini ) statemini->Hide(); } // void cPartyUnionManager::ChangeDisplayType( unsigned char type ) { for( int i = 0; i < MAX_PARTY; ++i ) { HideStateUI( i ); } // hide ¸ðµå°¡ ¾Æ´Ï¸é ´Ù½Ã º¸¿©ÁÖ±â if( type != ePARTY_STATE_DISPLAY_HIDE ) { for( int i = 0; i < MAX_PARTY; ++i ) { ShowStateUI( i ); } } } // â °°ÀÌ ¿­¸®Áö ¾Êµµ·Ï Á¶Á¤ void cPartyUnionManager::ShowLargeUnionUI( bool show ) { if( show == true ) { cPartyUnionWindow* unionWin = GAMEUI->GetPartyUnionWindow(); if( unionWin ) unionWin->Show(); cPartyUnionSmallWindow* smallWin = GAMEUI->GetPartyUnionSmallWindow(); if( smallWin ) smallWin->Hide(); } else { cPartyUnionWindow* unionWin = GAMEUI->GetPartyUnionWindow(); if( unionWin ) unionWin->Hide(); cPartyUnionSmallWindow* smallWin = GAMEUI->GetPartyUnionSmallWindow(); if( smallWin ) smallWin->Show(); } } // request bool cPartyUnionManager::TryToMovePlayer( unsigned char i0, unsigned char i1 ) { cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( !win ) { assert(0); return false; } if( win->IsNetLock() ) return true; if( i0 >= MAX_PARTYUNION || i1 >= MAX_PARTYUNION ) { assert(0); return false; } if( mParty[i0].userIndex == 0 ) { assert(0); return false; } if( HERO->GetObjectID() != mLeaderIndex ) { CHATMANAGER->AddSystemMsg( eSYSTEM_NORMAL, GAMERESOURCEMAN->GetGameText(1407) ); return false; } MSG_REQ_PARTYUNION_MOVEGROUP msg; ::memset( &msg, 0, sizeof(msg) ); msg.Category = NM_PARTYUNION; msg.Protocol = NM_PARTYUNION_MOVEGROUP_REQ; msg.mIndex0 = i0; msg.mIndex1 = i1; NETWORK->SendNetworkMsg( (char*)&msg, sizeof(msg) ); mTempSlot = i1; // win->NetLock(); return true; } bool cPartyUnionManager::TryToChangeLeader( unsigned long playerIndex ) { cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( !win ) { assert(0); return false; } if( win->IsNetLock() ) return true; if( playerIndex == 0 ) return true; if( HERO->GetObjectID() != mLeaderIndex ) { CHATMANAGER->AddSystemMsg( eSYSTEM_NORMAL, GAMERESOURCEMAN->GetGameText(1404) ); return false; } MSG_REQ_PARTYUNION_CHANGELEADER msg; ::memset( &msg, 0, sizeof(msg) ); msg.Category = NM_PARTYUNION; msg.Protocol = NM_PARTYUNION_CHANGELEADER_REQ; msg.mPlayerIndex = playerIndex; NETWORK->SendNetworkMsg( (char*)&msg, sizeof(msg) ); win->NetLock(); return true; } void cPartyUnionManager::ChangeHeroGroup( int i ) { if( i >= 0 && i < MAX_PARTYUSER ) { mGroup = eUNION_GROUP1; } else if( i >= MAX_PARTYUSER && i < MAX_PARTYUSER * eUNION_GROUP3 ) { mGroup = eUNION_GROUP2; } else if( i >= MAX_PARTYUSER * eUNION_GROUP3 && i < MAX_PARTYUSER * eUNION_MAX ) { mGroup = eUNION_GROUP3; } else assert(0); } int cPartyUnionManager::GetGroup( unsigned long userIndex ) { int i = FindUser( userIndex ); if( i >= 0 ) { if( i < MAX_PARTYUSER ) { return eUNION_GROUP1; } else if( i >= MAX_PARTYUSER && i < MAX_PARTYUSER * eUNION_GROUP3 ) { return eUNION_GROUP2; } else if( i >= MAX_PARTYUSER * eUNION_GROUP3 && i < MAX_PARTYUSER * eUNION_MAX ) { return eUNION_GROUP3; } } return -1; } // i ¹øÂ° À¯Àú°¡ hero ±×·ìÀÎÁö ÆÇ´Ü bool cPartyUnionManager::IsHeroGroup( int i ) { switch( mGroup ) { case eUNION_GROUP1: if( i >= 0 && i < MAX_PARTYUSER ) return true; break; case eUNION_GROUP2: if( i >= MAX_PARTYUSER && i < MAX_PARTYUSER * eUNION_GROUP3 ) return true; break; case eUNION_GROUP3: if( i >= MAX_PARTYUSER * eUNION_GROUP3 && i < MAX_PARTYUSER * eUNION_MAX ) return true; break; default: assert(0); break; } return false; } int cPartyUnionManager::FindUser( unsigned long playerIndex ) { if( playerIndex == 0 ) return -1; for( int i = 0; i < MAX_PARTYUNION; ++i ) { if( mParty[i].userIndex == playerIndex ) return i; } return -1; } bool cPartyUnionManager::IsHeroLeader() { return (HERO->GetObjectID() == mLeaderIndex); } bool cPartyUnionManager::IsHeroParty( unsigned long userIndex ) { int i = FindUser( userIndex ); if( i > -1 ) { return IsHeroGroup( i ); } return false; } void cPartyUnionManager::SetTargetByUI( unsigned long userIndex ) { if( HERO->GetPartyUnionIndex() == 0 ) return; int i = FindUser( userIndex ); if( i >= 0 && i < MAX_PARTYUNION ) { if( SKILLEXECUTER->IsSkillCharge() == true ) { cBaseObject* curTarget = HERO->GetTargetObject(); if( curTarget == 0 || curTarget->GetState() == eOBJECT_STATE_DIE ) { /// ½Å±Ô Ÿ°Ù µî·ÏÈÄ ¹ßµ¿ HERO->SetTargetObject( eOBJECTTYPE_PLAYER, userIndex ); } else { /// Ÿ°Ù º¯°æ ¾øÀÌ ¹ßµ¿ cBaseObject* target = OBJECTMAN->GetObject( eOBJECTTYPE_PLAYER, userIndex ); sChargeInfo chargeInfo = SKILLEXECUTER->GetChargeSkill(); SKILLEXECUTER->ExecuteSkill( chargeInfo.mSkillIdx, chargeInfo.mSkillStep, target ); return; } } else { HERO->SetTargetObject( eOBJECTTYPE_PLAYER, userIndex ); } // ÆÄƼ¿¬ÇÕ À©µµ¿ì ¼¼ÆÃ cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) win->SetSelect( i ); // ÆÄƼ À©µµ¿ì¼¼ÆÃ for( unsigned int w = 0; w < MAX_PARTY; ++w ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( w ); cPartyStateMiniWindow* statemini = GAMEUI->GetPartyStateMiniWindow( w ); if( state && statemini ) { bool select = ( state->GetUserIndex() == userIndex ); state->SetSelect( select ); bool selectmini = ( statemini->GetUserIndex() == userIndex ); statemini->SetSelect( selectmini ); } } // HERO->SetTargetObject( eOBJECTTYPE_PLAYER, userIndex ); } else assert(0); } void cPartyUnionManager::SetTargetByHero( unsigned long userIndex ) { if( HERO->GetPartyUnionIndex() == 0 ) return; if( HERO->GetObjectID() == userIndex ) return; int i = FindUser( userIndex ); if( i >= 0 && i < MAX_PARTYUNION ) { // ÆÄƼ¿¬ÇÕ À©µµ¿ì ¼¼ÆÃ cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) win->SetSelect( i ); // ÆÄƼ À©µµ¿ì¼¼ÆÃ for( unsigned int w = 0; w < MAX_PARTY; ++w ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( w ); cPartyStateMiniWindow* statemini = GAMEUI->GetPartyStateMiniWindow( w ); if( state && statemini ) { bool select = ( state->GetUserIndex() == userIndex ); state->SetSelect( select ); bool selectmini = ( statemini->GetUserIndex() == userIndex ); statemini->SetSelect( selectmini ); } } } } void cPartyUnionManager::ClearTarget() { if( HERO->GetPartyUnionIndex() == 0 ) return; cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) win->SetSelect( UINT_MAX ); } /// ÀüÀå¿¡¼­ ¼öÀå Ç¥½Ã. void cPartyUnionManager::SetPvpLeader( unsigned long characterIndex ) { int arrIndex = FindUser( characterIndex ); if( arrIndex >= 0 && arrIndex < MAX_PARTYUNION ) { mPvpLeaderIndex = characterIndex; cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) win->SetPvpLeader( arrIndex ); // ÆÄƼ À©µµ¿ì¼¼ÆÃ for( unsigned int w = 0; w < MAX_PARTY; ++w ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( w ); cPartyStateMiniWindow* statemini = GAMEUI->GetPartyStateMiniWindow( w ); if( state && statemini ) { bool select = ( state->GetUserIndex() == characterIndex ); state->SetPvpLeaderVisible( select ); bool selectmini = ( statemini->GetUserIndex() == characterIndex ); statemini->SetPvpLeaderVisible( selectmini ); } } } else { assert(0 && "Bad character index"); cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) win->SetPvpLeader( UINT_MAX ); // ÆÄƼ À©µµ¿ì¼¼ÆÃ for( unsigned int w = 0; w < MAX_PARTY; ++w ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( w ); cPartyStateMiniWindow* statemini = GAMEUI->GetPartyStateMiniWindow( w ); if( state && statemini ) { state->SetPvpLeaderVisible( false ); statemini->SetPvpLeaderVisible( false ); } } } } /// Ç÷¡±× ¸ÅÄ¡¿¡¼­ ±ê¹ß µç À¯Àú Ç¥½Ã void cPartyUnionManager::SetFlagPlayer( unsigned long characterIndex ) { int arrIndex = FindUser( characterIndex ); if( arrIndex >= 0 && arrIndex < MAX_PARTYUNION ) { mFlagPlayerIndex = characterIndex; cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) win->SetFlagPlayer( arrIndex ); // ÆÄƼ À©µµ¿ì¼¼ÆÃ for( unsigned int w = 0; w < MAX_PARTY; ++w ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( w ); cPartyStateMiniWindow* statemini = GAMEUI->GetPartyStateMiniWindow( w ); if( state && statemini ) { bool select = ( state->GetUserIndex() == characterIndex ); state->SetFlagPlayerVisible( select ); bool selectmini = ( statemini->GetUserIndex() == characterIndex ); statemini->SetFlagPlayerVisible( selectmini ); } } } else { mFlagPlayerIndex = 0; cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) win->SetFlagPlayer( UINT_MAX ); // ÆÄƼ À©µµ¿ì¼¼ÆÃ for( unsigned int w = 0; w < MAX_PARTY; ++w ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( w ); cPartyStateMiniWindow* statemini = GAMEUI->GetPartyStateMiniWindow( w ); if( state && statemini ) { state->SetFlagPlayerVisible( false ); statemini->SetFlagPlayerVisible( false ); } } } } void cPartyUnionManager::ClearFlagPlayer() { mFlagPlayerIndex = 0; cPartyUnionWindow* win = GAMEUI->GetPartyUnionWindow(); if( win ) win->SetFlagPlayer( UINT_MAX ); // ÆÄƼ À©µµ¿ì¼¼ÆÃ for( unsigned int w = 0; w < MAX_PARTY; ++w ) { cPartyStateWindow* state = GAMEUI->GetPartyStateWindow( w ); cPartyStateMiniWindow* statemini = GAMEUI->GetPartyStateMiniWindow( w ); if( state && statemini ) { state->SetFlagPlayerVisible( false ); statemini->SetFlagPlayerVisible( false ); } } } LPCTSTR cPartyUnionManager::GetPlayerName( unsigned long characterIndex ) { if( characterIndex == 0 ) return NULL; for( int i = 0; i < MAX_PARTYUNION; ++i ) { if( mParty[i].userIndex == characterIndex ) return mParty[i].name; } return NULL; }