DragonNest/GameCommon/TotalLevelSkillSystem.cpp

602 lines
16 KiB
C++
Raw Permalink Normal View History

#include "Stdafx.h"
#include "TotalLevelSkillSystem.h"
#include "DnTableDB.h"
#include "DnActor.h"
#ifdef _DEBUG
#define new new(_NORMAL_BLOCK,__FILE__,__LINE__)
#endif
#if defined(PRE_ADD_TOTAL_LEVEL_SKILL)
CDnTotalLevelSkillSystem::CDnTotalLevelSkillSystem(DnActorHandle hActor)
{
m_hActor = hActor;
m_TotalLevel = 0;
//<2F><EFBFBD><E2BABB><EFBFBD><EFBFBD> <20><><EFBFBD>Ե<EFBFBD> <20><> Ȱ<><C8B0>ȭ <20><><EFBFBD><EFBFBD> <20><><EFBFBD>´<EFBFBD>.
for (int i = 0; i < TotallevelSkill_Slot_Count; ++i)
{
DnSkillHandle hSkill;
ActivateTotalLevelSkillSlot(i, false);
AddTotalLevelSkill(i, hSkill);
}
LoadTotalLevelSkillList();
LoadTotalLevelSkillSlotInfo();
}
CDnTotalLevelSkillSystem::~CDnTotalLevelSkillSystem()
{
std::map<int, DnSkillHandle>::iterator iter = m_ActiveTotalLevelSkillList.begin();
std::map<int, DnSkillHandle>::iterator endIter = m_ActiveTotalLevelSkillList.end();
for (; iter != endIter; ++iter)
{
if (m_hActor && iter->second)
m_hActor->RemoveSkill(iter->second->GetClassID());
}
SAFE_RELEASE_SPTRVEC( m_vlTotalLevelSkillList );
m_TotalLevelSkillInfoList.clear();
m_TotalLevelSlotInfoList.clear();
}
void CDnTotalLevelSkillSystem::LoadTotalLevelSkillList()
{
SAFE_RELEASE_SPTRVEC( m_vlTotalLevelSkillList );
m_TotalLevelSkillInfoList.clear();
DNTableFileFormat* pSox = GetDNTable( CDnTableDB::TTOTALLEVELSKILL );
if( pSox == NULL )
{
DN_ASSERT( 0, "Invalid TotalLevelSkill" );
return;
}
for( int i=0; i<=pSox->GetItemCount(); i++ )
{
int nItemID = pSox->GetItemID( i );
if (nItemID == -1)
continue;
_TotalLevelSkillInfo _info;
_info.m_SkillID = pSox->GetFieldFromLablePtr( nItemID, "_SkillTableID" )->GetInteger();
_info.m_TotalLevelLimit = pSox->GetFieldFromLablePtr( nItemID, "_TotalLevelLimit" )->GetInteger();
_info.m_ActorLevelLimit = pSox->GetFieldFromLablePtr( nItemID, "_LevelLimit" )->GetInteger();
_info.m_SkillType = pSox->GetFieldFromLablePtr( nItemID, "_SkillType" )->GetInteger();
_info.m_SkillTreeSlotIndex = pSox->GetFieldFromLablePtr( nItemID, "_TreeSlotIndex" )->GetInteger();
m_TotalLevelSkillInfoList.insert(std::make_pair(_info.m_SkillID, _info));
DnSkillHandle hSkill;
hSkill = CDnSkill::CreateSkill( m_hActor, _info.m_SkillID, 1 );
if( hSkill )
{
m_vlTotalLevelSkillList.push_back( hSkill );
}
}
}
void CDnTotalLevelSkillSystem::LoadTotalLevelSkillSlotInfo()
{
m_TotalLevelSlotInfoList.clear();
DNTableFileFormat* pSox = GetDNTable( CDnTableDB::TTOTALLEVELLSKILLSLOT );
if( pSox == NULL )
{
DN_ASSERT( 0, "Invalid TotalLevelSkillSlot" );
return;
}
for( int i=0; i<=pSox->GetItemCount(); i++ )
{
int nItemID = pSox->GetItemID( i );
if (nItemID == -1)
continue;
_TotalLevelSkillSlotInfo _info;
_info.m_LevelLimit = pSox->GetFieldFromLablePtr( nItemID, "_LevelLimit" )->GetInteger();
_info.m_SlotIndex = pSox->GetFieldFromLablePtr( nItemID, "_SlotID" )->GetInteger() - 1;
_info.m_isCashSlot = pSox->GetFieldFromLablePtr( nItemID, "_IsCash" )->GetBool();
_info.m_ExpireDate = 0;
m_TotalLevelSlotInfoList.insert(std::make_pair(_info.m_SlotIndex, _info));
}
}
DnSkillHandle CDnTotalLevelSkillSystem::FindTotalLevelSkill( int nSkillTableID )
{
DnSkillHandle hRetSkill;
vector<DnSkillHandle>::iterator iter = m_vlTotalLevelSkillList.begin();
for( ; iter != m_vlTotalLevelSkillList.end(); iter++ )
{
DnSkillHandle hSkill = (*iter);
if( hSkill->GetClassID() == nSkillTableID )
{
hRetSkill = (*iter);
break;
}
}
return hRetSkill;
}
bool CDnTotalLevelSkillSystem::IsTotalLevelSkill( int nSkillTableID )
{
DnSkillHandle hSkill = FindTotalLevelSkill( nSkillTableID );
if( hSkill )
return true;
return false;
}
CDnTotalLevelSkillSystem::_TotalLevelSkillInfo* CDnTotalLevelSkillSystem::GetTotalLevelSkillInfo(int nSkillID)
{
_TotalLevelSkillInfo* pInfo = NULL;
std::map<int, _TotalLevelSkillInfo>::iterator skillInfoIter = m_TotalLevelSkillInfoList.find(nSkillID);
if (skillInfoIter != m_TotalLevelSkillInfoList.end())
pInfo = &skillInfoIter->second;
return pInfo;
}
bool CDnTotalLevelSkillSystem::IsUsableSkill(DnSkillHandle hSkill)
{
if (!hSkill)
return false;
if (!m_hActor)
return false;
_TotalLevelSkillInfo* pSkillInfo = GetTotalLevelSkillInfo(hSkill->GetClassID());
if (pSkillInfo == NULL)
return false;
//<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Ȯ<><C8AE>..
if (m_TotalLevel < pSkillInfo->m_TotalLevelLimit)
return false;
//<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
int nActorLevel = m_hActor->GetLevel();
if (nActorLevel < pSkillInfo->m_ActorLevelLimit)
return false;
return true;
}
int CDnTotalLevelSkillSystem::CanAddSkill(int slotIndex, DnSkillHandle hSkill)
{
int nErrorCode = 0;
if (IsUsableSkill(hSkill) == false)
return TotalLevelSystem_Error_NotUsable;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ȱ<><C8B0>ȭ <20>Ǿ<EFBFBD> <20>ִ<EFBFBD><D6B4><EFBFBD> Ȯ<><C8AE>.
bool bSlotActivate = false;
std::map<int, bool>::iterator slotActivateIter = m_TotalLevelSkillSlotActivate.find(slotIndex);
if (slotActivateIter != m_TotalLevelSkillSlotActivate.end())
{
bSlotActivate = slotActivateIter->second;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ȱ<><C8B0>ȭ <20>Ǿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>߰<EFBFBD> <20>ȵ<EFBFBD>...
if (bSlotActivate == false)
return TotalLevelSystem_Error_NotActivateSlot;
//<2F>߰<EFBFBD> <20>Ϸ<EFBFBD><CFB7><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ų Ÿ<><C5B8> Ȯ<><C8AE>..
int nAddSkillType = TotalLevelSkill_Type_None;
_TotalLevelSkillInfo* pSkillInfo = GetTotalLevelSkillInfo(hSkill->GetClassID());
if (pSkillInfo)
nAddSkillType = pSkillInfo->m_SkillType;
else
return TotalLevelSystem_Error_NotUsable;
bool bCheckSlotType = false;
std::map<int, _TotalLevelSkillSlotInfo>::iterator slotIter = m_TotalLevelSlotInfoList.find(slotIndex);
if (slotIter != m_TotalLevelSlotInfoList.end())
{
_TotalLevelSkillSlotInfo& _info = slotIter->second;
//ij<><C4B3> <20><><EFBFBD>Կ<EFBFBD> <20>߰<EFBFBD><DFB0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ȱ<><C8B0>ȭ <20>Ǿ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>߰<EFBFBD>
if (_info.m_isCashSlot == true)
nErrorCode = TotalLevelSystem_Error_None;
else
{
if (m_ActiveTotalLevelSkillList.empty() == true)
nErrorCode = TotalLevelSystem_Error_None;
else
{
bool bExistSkillType = false;
//<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ų Ÿ<><C5B8><EFBFBD><EFBFBD> <20>̹<EFBFBD> <20>߰<EFBFBD> <20>Ǿ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>߰<EFBFBD> <20>ȵ<EFBFBD>..
std::map<int, DnSkillHandle>::iterator activateSkillIter = m_ActiveTotalLevelSkillList.begin();
std::map<int, DnSkillHandle>::iterator activateSkillEndIter = m_ActiveTotalLevelSkillList.end();
for (; activateSkillIter != activateSkillEndIter; ++activateSkillIter)
{
if (!activateSkillIter->second)
continue;
int nTotalLevelSkillType = TotalLevelSkill_Type_None;
pSkillInfo = GetTotalLevelSkillInfo(activateSkillIter->second->GetClassID());
if (pSkillInfo)
nTotalLevelSkillType = pSkillInfo->m_SkillType;
//<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> index<65><78> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Ÿ<><C5B8><EFBFBD><EFBFBD> <20><>ų<EFBFBD><C5B3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ϰ<EFBFBD> <20><>ų <20>߰<EFBFBD><DFB0>Ѵ<EFBFBD>.
if (activateSkillIter->first == slotIndex)
{
if (nTotalLevelSkillType == nAddSkillType)
{
if (hSkill->GetClassID() == activateSkillIter->second->GetClassID())
{
nErrorCode = TotalLevelSystem_Error_NotUsable;
return nErrorCode;
}
}
}
else
{
//<2F><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ij<><C4B3> <20><><EFBFBD><EFBFBD><EFBFBD>̶<EFBFBD><CCB6><EFBFBD> <20>߰<EFBFBD> <20><><EFBFBD><EFBFBD>...
//ij<><C4B3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƴϰ<C6B4>, <20><><EFBFBD><EFBFBD> <20><>ų Ÿ<><C5B8><EFBFBD≯<EFBFBD> <20>߰<EFBFBD> <20>ȵ<EFBFBD>.
std::map<int, _TotalLevelSkillSlotInfo>::iterator oldSlotIter = m_TotalLevelSlotInfoList.find(activateSkillIter->first);
if (oldSlotIter != m_TotalLevelSlotInfoList.end())
{
if (oldSlotIter->second.m_isCashSlot != true &&
nTotalLevelSkillType == nAddSkillType)
{
bExistSkillType = true;
break;
}
}
}
}
//<2F><><EFBFBD><EFBFBD> <20><>ų Ÿ<><C5B8><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>߰<EFBFBD> <20><>.
if (bExistSkillType == false)
nErrorCode = TotalLevelSystem_Error_None;
else
nErrorCode = TotalLevelSystem_Error_SameSkillType;
}
}
}
return nErrorCode;
}
void CDnTotalLevelSkillSystem::AddTotalLevelSkill(int slotIndex, DnSkillHandle hSkill, bool isInitialize/* = false*/)
{
DnSkillHandle hActivateSkill;
std::map<int, DnSkillHandle>::iterator findIter = m_ActiveTotalLevelSkillList.find(slotIndex);
if (findIter != m_ActiveTotalLevelSkillList.end())
hActivateSkill = findIter->second;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ<EFBFBD> <20><>ų<EFBFBD><C5B3> <20><><EFBFBD><EFBFBD> <20>ϰ<EFBFBD>
if (hActivateSkill)
m_hActor->RemoveSkill(hActivateSkill->GetClassID());
if (hSkill)
m_hActor->OnAddSkill(hSkill, isInitialize);
//<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ų <20><>ü <20>ϰ<EFBFBD>,
if (findIter != m_ActiveTotalLevelSkillList.end())
{
//<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ų<EFBFBD><C5B3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ų <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD>, <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ų<EFBFBD><C5B3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
if (hSkill)
findIter->second = hSkill;
else
findIter->second.Identity();
}
else
{
m_ActiveTotalLevelSkillList.insert(std::make_pair(slotIndex, hSkill));
}
}
DnSkillHandle CDnTotalLevelSkillSystem::GetActivateTotalLevelSkill(int slotIndex)
{
DnSkillHandle hActivateSkill;
std::map<int, DnSkillHandle>::iterator findIter = m_ActiveTotalLevelSkillList.find(slotIndex);
if (findIter != m_ActiveTotalLevelSkillList.end())
hActivateSkill = findIter->second;
return hActivateSkill;
}
void CDnTotalLevelSkillSystem::RemoveTotallevelSkill(int slotIndex)
{
DnSkillHandle hActivateSkill = GetActivateTotalLevelSkill(slotIndex);
if (hActivateSkill)
{
m_hActor->RemoveSkill(hActivateSkill->GetClassID());
//<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD> <20><>ų <20>ʱ<EFBFBD>ȭ..
RemoveTotalLevelSkillFromList(slotIndex);
}
}
void CDnTotalLevelSkillSystem::RemoveTotalLevelSkillFromList(int slotIndex)
{
std::map<int, DnSkillHandle>::iterator findIter = m_ActiveTotalLevelSkillList.find(slotIndex);
if (findIter != m_ActiveTotalLevelSkillList.end())
findIter->second.Identity();
}
void CDnTotalLevelSkillSystem::ActivateTotalLevelSkillSlot(int slotIndex, bool bActivate)
{
if (bActivate == false)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> Ȱ<><C8B0>ȭ <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ų<EFBFBD><C5B3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ų <20><><EFBFBD><EFBFBD>..
DnSkillHandle hActivateSkill = GetActivateTotalLevelSkill(slotIndex);
if (hActivateSkill)
RemoveTotallevelSkill(slotIndex);
}
std::map<int, bool>::iterator iter = m_TotalLevelSkillSlotActivate.find(slotIndex);
if (iter != m_TotalLevelSkillSlotActivate.end())
iter->second = bActivate;
else
m_TotalLevelSkillSlotActivate.insert(std::make_pair(slotIndex, bActivate));
}
void CDnTotalLevelSkillSystem::SetTotalLevel(int totalLevel)
{
if (m_TotalLevel == totalLevel)
return;
m_TotalLevel = totalLevel;
UpdateTotalLevel();
}
void CDnTotalLevelSkillSystem::UpdateTotalLevel()
{
int nCharLevel = m_hActor ? m_hActor->GetLevel() : -1;
//<2F><><EFBFBD><EFBFBD> Ȱ<><C8B0>ȭ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
std::map<int, _TotalLevelSkillSlotInfo>::iterator iter = m_TotalLevelSlotInfoList.begin();
std::map<int, _TotalLevelSkillSlotInfo>::iterator endIter = m_TotalLevelSlotInfoList.end();
for (; iter != endIter; ++iter)
{
_TotalLevelSkillSlotInfo& _info = iter->second;
if (_info.m_isCashSlot == false)
{
bool bActivate = nCharLevel != -1 ? nCharLevel >= _info.m_LevelLimit : false;
ActivateTotalLevelSkillSlot(_info.m_SlotIndex, bActivate);
}
}
}
void CDnTotalLevelSkillSystem::ActivateTotalLevelSkillCashSlot(int nSlotIndex, bool bActivate, __time64_t tExpireDate)
{
//<2F><><EFBFBD><EFBFBD> Ȱ<><C8B0>ȭ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
std::map<int, _TotalLevelSkillSlotInfo>::iterator iter = m_TotalLevelSlotInfoList.begin();
std::map<int, _TotalLevelSkillSlotInfo>::iterator endIter = m_TotalLevelSlotInfoList.end();
for (; iter != endIter; ++iter)
{
_TotalLevelSkillSlotInfo& _info = iter->second;
if (_info.m_SlotIndex == nSlotIndex && _info.m_isCashSlot == true)
{
ActivateTotalLevelSkillSlot(_info.m_SlotIndex, bActivate);
_info.m_ExpireDate = tExpireDate;
}
}
}
void CDnTotalLevelSkillSystem::Process(LOCAL_TIME localTime, float fDelta)
{
vector<DnSkillHandle>::iterator iter = m_vlTotalLevelSkillList.begin();
vector<DnSkillHandle>::iterator endIter = m_vlTotalLevelSkillList.end();
for (; iter != endIter; ++iter)
{
DnSkillHandle hSkill = (*iter);
if( hSkill)
hSkill->Process( localTime, fDelta );
}
}
int CDnTotalLevelSkillSystem::FindEmptySlot()
{
int nSlotIndex = -1;
std::map<int, DnSkillHandle>::iterator iter = m_ActiveTotalLevelSkillList.begin();
std::map<int, DnSkillHandle>::iterator endIter = m_ActiveTotalLevelSkillList.end();
for (; iter != endIter; ++iter)
{
if (!iter->second)
{
int slotIndex = iter->first;
bool bSlotActivate = false;
std::map<int, bool>::iterator slotActivateIter = m_TotalLevelSkillSlotActivate.find(slotIndex);
if (slotActivateIter != m_TotalLevelSkillSlotActivate.end())
{
bSlotActivate = slotActivateIter->second;
}
if (bSlotActivate == false)
continue;
nSlotIndex = iter->first;
break;
}
}
return nSlotIndex;
}
int CDnTotalLevelSkillSystem::FindEmptyCashSlot(int nSkillID)
{
int nSelectedSlotIndex = -1;
//<2F><>ų <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƴϸ<C6B4> <20>dzʶ<C7B3>.
_TotalLevelSkillInfo* pSkillInfo = GetTotalLevelSkillInfo(nSkillID);
if (pSkillInfo == NULL)
return nSelectedSlotIndex;
std::map<int, _TotalLevelSkillSlotInfo>::iterator iter = m_TotalLevelSlotInfoList.begin();
std::map<int, _TotalLevelSkillSlotInfo>::iterator endIter = m_TotalLevelSlotInfoList.end();
for (; iter != endIter; ++iter)
{
//ij<><C4B3> <20><><EFBFBD>Ը<EFBFBD> Ȯ<><C8AE> <20>Ѵ<EFBFBD>.
if (iter->second.m_isCashSlot == true)
{
int slotIndex = iter->first;
//ij<><C4B3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ȱ<><C8B0>ȭ <20>Ǿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>dzʶ<C7B3>.
if (IsActivateSlot(slotIndex) == false)
continue;
std::map<int, DnSkillHandle>::iterator findSkillIter = m_ActiveTotalLevelSkillList.find(slotIndex);
if (findSkillIter != m_ActiveTotalLevelSkillList.end())
{
//<2F>ش<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ų<EFBFBD><C5B3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ѵ<EFBFBD>.
if (!findSkillIter->second)
{
nSelectedSlotIndex = slotIndex;
break;
}
else
{
//<2F><><EFBFBD><EFBFBD> <20><>ų Ÿ<><C5B8> <20≯<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ϰ<EFBFBD>, <20>ٸ<EFBFBD> <20><>ų Ÿ<><C5B8><EFBFBD≯<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ʴ´<CAB4>.
_TotalLevelSkillInfo* pOldSkillInfo = GetTotalLevelSkillInfo(findSkillIter->second->GetClassID());
if (pOldSkillInfo && pSkillInfo->m_SkillType == pOldSkillInfo->m_SkillType)
{
nSelectedSlotIndex = slotIndex;
break;
}
}
}
}
}
return nSelectedSlotIndex;
}
int CDnTotalLevelSkillSystem::FindEmptyNormalSlot(int nSkillID)
{
int nSelectedSlotIndex = -1;
//<2F><>ų <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƴϸ<C6B4> <20>dzʶ<C7B3>.
_TotalLevelSkillInfo* pSkillInfo = GetTotalLevelSkillInfo(nSkillID);
if (pSkillInfo == NULL)
return nSelectedSlotIndex;
std::map<int, int> normalEmptySlotList;
//1. <20><><EFBFBD><EFBFBD> <20><>ų Ÿ<><C5B8><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ã<>´<EFBFBD>.
std::map<int, _TotalLevelSkillSlotInfo>::iterator iter = m_TotalLevelSlotInfoList.begin();
std::map<int, _TotalLevelSkillSlotInfo>::iterator endIter = m_TotalLevelSlotInfoList.end();
for (; iter != endIter; ++iter)
{
//<2F>Ϲ<EFBFBD> <20><><EFBFBD>Ը<EFBFBD> Ȯ<><C8AE> <20>Ѵ<EFBFBD>.
if (iter->second.m_isCashSlot == false)
{
int slotIndex = iter->first;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ȱ<><C8B0>ȭ <20>Ǿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>dzʶ<C7B3>.
if (IsActivateSlot(slotIndex) == false)
continue;
std::map<int, DnSkillHandle>::iterator findSkillIter = m_ActiveTotalLevelSkillList.find(slotIndex);
if (findSkillIter != m_ActiveTotalLevelSkillList.end())
{
//<2F><>ų<EFBFBD><C5B3> <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD>
if (findSkillIter->second)
{
//<2F><><EFBFBD><EFBFBD> <20><>ų Ÿ<><C5B8> <20≯<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ϰ<EFBFBD>, <20>ٸ<EFBFBD> <20><>ų Ÿ<><C5B8><EFBFBD≯<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ʴ´<CAB4>.
int nOldSkillID = findSkillIter->second->GetClassID();
_TotalLevelSkillInfo* pOldSkillInfo = GetTotalLevelSkillInfo(nOldSkillID);
if (pOldSkillInfo &&
pSkillInfo->m_SkillType == pOldSkillInfo->m_SkillType)
{
if (nSkillID != nOldSkillID)
{
nSelectedSlotIndex = slotIndex;
break;
}
else
{
//<2F><><EFBFBD><EFBFBD> Ÿ<><C5B8><EFBFBD><EFBFBD> <20><>ų<EFBFBD><C5B3> <20>̹<EFBFBD> <20>ִٸ<D6B4>..
nSelectedSlotIndex = -2;
}
}
}
//<2F><>ų<EFBFBD><C5B3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>Կ<EFBFBD> <20>߰<EFBFBD> <20>س<EFBFBD><D8B3>´<EFBFBD>.
else
{
normalEmptySlotList.insert(std::make_pair(slotIndex, slotIndex));
}
}
}
}
//<2F><><EFBFBD><EFBFBD> <20><>ų <20><><EFBFBD>̵<EFBFBD><CCB5><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ְ<EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>޽<EFBFBD><DEBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ʵ<EFBFBD><CAB5><EFBFBD> <20>ϱ<EFBFBD> <20><><EFBFBD><EFBFBD> nSelectedSlotIndex<65><78> -2<><32> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
if (nSelectedSlotIndex == -2 && normalEmptySlotList.empty())
{
return nSelectedSlotIndex;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Ÿ<><C5B8><EFBFBD><EFBFBD> <20><>ų<EFBFBD><C5B3> ã<><C3A3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ã<>´<EFBFBD>.
if (nSelectedSlotIndex == -1)
{
if (normalEmptySlotList.empty() == false)
{
std::map<int, int>::iterator emtpySlotIter = normalEmptySlotList.begin();
if (emtpySlotIter != normalEmptySlotList.end())
nSelectedSlotIndex = emtpySlotIter->first;
}
}
return nSelectedSlotIndex;
}
int CDnTotalLevelSkillSystem::FindEmptySlot(int nSkillID)
{
int nSlotIndex = -1;
//1. ij<><C4B3> <20><><EFBFBD><EFBFBD> Ȯ<><C8AE>.
nSlotIndex = FindEmptyCashSlot(nSkillID);
if (nSlotIndex == -1)
nSlotIndex = FindEmptyNormalSlot(nSkillID);
return nSlotIndex;
}
CDnTotalLevelSkillSystem::_TotalLevelSkillSlotInfo* CDnTotalLevelSkillSystem::GetSlotInfo(int nSlotIndex)
{
_TotalLevelSkillSlotInfo* pInfo = NULL;
std::map<int, _TotalLevelSkillSlotInfo>::iterator findIter = m_TotalLevelSlotInfoList.find(nSlotIndex);
if (findIter != m_TotalLevelSlotInfoList.end())
pInfo = &(findIter->second);
return pInfo;
}
bool CDnTotalLevelSkillSystem::IsActivateSlot(int nSlotIndex)
{
std::map<int, bool>::iterator findIter = m_TotalLevelSkillSlotActivate.find(nSlotIndex);
if (findIter != m_TotalLevelSkillSlotActivate.end())
return findIter->second;
else
return false;
}
#endif // PRE_ADD_TOTAL_LEVEL_SKILL