DragonNest/GameCommon/TotalLevelSkillSystem.cpp

602 lines
33 KiB
C++
Raw Normal View History

2024-12-20 16:56:44 +08:00
<EFBFBD><EFBFBD>#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;
//0<EFBFBD><EFBFBD><EFBFBD><EFBFBD>D<EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD><EFBFBD><EFBFBD> D<EFBFBD> \<EFBFBD>1<EFBFBD>T<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><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;
//<EFBFBD><EFBFBD>i<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD>\<EFBFBD> U<EFBFBD>x<EFBFBD>..
if (m_TotalLevel < pSkillInfo->m_TotalLevelLimit)
return false;
//a<EFBFBD>0<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <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;
//<EFBFBD><EFBFBD>o<EFBFBD>t<EFBFBD> \<EFBFBD>1<EFBFBD>T<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD>ǔ<EFBFBD><EFBFBD><EFBFBD> U<EFBFBD>x<EFBFBD>.
bool bSlotActivate = false;
std::map<int, bool>::iterator slotActivateIter = m_TotalLevelSkillSlotActivate.find(slotIndex);
if (slotActivateIter != m_TotalLevelSkillSlotActivate.end())
{
bSlotActivate = slotActivateIter->second;
}
//<EFBFBD><EFBFBD>o<EFBFBD>t<EFBFBD> \<EFBFBD>1<EFBFBD>T<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> J<EFBFBD><<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> H<EFBFBD>(<EFBFBD>...
if (bSlotActivate == false)
return TotalLevelSystem_Error_NotActivateSlot;
//<EFBFBD><EFBFBD><EFBFBD> X<EFBFBD>$<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>i<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD>¬<EFBFBD> <EFBFBD>Ѕ<EFBFBD> U<EFBFBD>x<EFBFBD>..
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;
//<EFBFBD><EFBFBD>l<EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD>t<EFBFBD> \<EFBFBD>1<EFBFBD>T<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><<EFBFBD>t<EFBFBD> 4<EFBFBD>p<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><EFBFBD>
if (_info.m_isCashSlot == true)
nErrorCode = TotalLevelSystem_Error_None;
else
{
if (m_ActiveTotalLevelSkillList.empty() == true)
nErrorCode = TotalLevelSystem_Error_None;
else
{
bool bExistSkillType = false;
//<EFBFBD>@<EFBFBD> <EFBFBD><EFBFBD>i<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD>¬<EFBFBD> <EFBFBD>Ѕ<EFBFBD>t<EFBFBD> t<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> H<EFBFBD>(<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;
//<EFBFBD>@<EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD> indexx<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>@<EFBFBD> <EFBFBD>Ѕ<EFBFBD>X<EFBFBD> <EFBFBD>¬<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><<EFBFBD>t<EFBFBD> 4<EFBFBD><EFBFBD><EFBFBD> X<EFBFBD><EFBFBD><EFBFBD> <EFBFBD>¬<EFBFBD> <EFBFBD><EFBFBD><EFBFBD>\<EFBFBD><EFBFBD><EFBFBD>.
if (activateSkillIter->first == slotIndex)
{
if (nTotalLevelSkillType == nAddSkillType)
{
if (hSkill->GetClassID() == activateSkillIter->second->GetClassID())
{
nErrorCode = TotalLevelSystem_Error_NotUsable;
return nErrorCode;
}
}
}
else
{
//t<EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD>t<EFBFBD>|<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>...
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD>t<EFBFBD> D<EFBFBD>Ȳ<EFBFBD><EFBFBD>, <EFBFBD>@<EFBFBD> <EFBFBD>¬<EFBFBD> <EFBFBD>Ѕ<EFBFBD>t<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> H<EFBFBD>(<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;
}
}
}
}
//<EFBFBD>@<EFBFBD> <EFBFBD>¬<EFBFBD> <EFBFBD>Ѕ<EFBFBD>t<EFBFBD> <EFBFBD>Ŵ<EFBFBD>|<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> (<EFBFBD>.
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;
//0<EFBFBD>t<EFBFBD><EFBFBD><EFBFBD> <EFBFBD>ǔ<EFBFBD> <EFBFBD>¬<EFBFBD>@<EFBFBD> <EFBFBD>p<EFBFBD> X<EFBFBD><EFBFBD><EFBFBD>
if (hActivateSkill)
m_hActor->RemoveSkill(hActivateSkill->GetClassID());
if (hSkill)
m_hActor->OnAddSkill(hSkill, isInitialize);
//0<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><<EFBFBD>t<EFBFBD> <EFBFBD>¬<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> X<EFBFBD><EFBFBD><EFBFBD>,
if (findIter != m_ActiveTotalLevelSkillList.end())
{
//<EFBFBD><EFBFBD>\<EFBFBD> <EFBFBD><EFBFBD>]<EFBFBD>`<EFBFBD> <EFBFBD>¬<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><<EFBFBD>t<EFBFBD> <EFBFBD>¬<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>X<EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>\<EFBFBD> <EFBFBD><EFBFBD>]<EFBFBD>`<EFBFBD> <EFBFBD>¬<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD>p<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());
//<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>¸<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>¬<EFBFBD> <EFBFBD>0<EFBFBD>T<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)
{
//<EFBFBD><EFBFBD>o<EFBFBD>t<EFBFBD> D<EFBFBD> \<EFBFBD>1<EFBFBD>T<EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0<EFBFBD>t<EFBFBD>X<EFBFBD> <EFBFBD>¬<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><<EFBFBD>t<EFBFBD> <EFBFBD>¬<EFBFBD> <EFBFBD>p<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;
//<EFBFBD><EFBFBD>o<EFBFBD> \<EFBFBD>1<EFBFBD>T<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> 1<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)
{
_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)
{
//<EFBFBD><EFBFBD>o<EFBFBD> \<EFBFBD>1<EFBFBD>T<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> 1<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)
{
_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;
//<EFBFBD>¬<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>t<EFBFBD> D<EFBFBD>Ȳt<EFBFBD> t<EFBFBD><EFBFBD><EFBFBD>.
_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)
{
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD>̹ U<EFBFBD>x<EFBFBD> \<EFBFBD><EFBFBD><EFBFBD>.
if (iter->second.m_isCashSlot == true)
{
int slotIndex = iter->first;
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD>t<EFBFBD> \<EFBFBD>1<EFBFBD>T<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> J<EFBFBD><<EFBFBD>t<EFBFBD> t<EFBFBD><EFBFBD><EFBFBD>.
if (IsActivateSlot(slotIndex) == false)
continue;
std::map<int, DnSkillHandle>::iterator findSkillIter = m_ActiveTotalLevelSkillList.find(slotIndex);
if (findSkillIter != m_ActiveTotalLevelSkillList.end())
{
//t<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD>X<EFBFBD> <EFBFBD>¬<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><<EFBFBD>t<EFBFBD> t<EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD>D<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> \<EFBFBD><EFBFBD><EFBFBD>.
if (!findSkillIter->second)
{
nSelectedSlotIndex = slotIndex;
break;
}
else
{
//<EFBFBD>@<EFBFBD> <EFBFBD>¬<EFBFBD> <EFBFBD>Ѕ<EFBFBD> t<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> X<EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>x<EFBFBD> <EFBFBD>¬<EFBFBD> <EFBFBD>Ѕ<EFBFBD>t<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> X<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>.
_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;
//<EFBFBD>¬<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>t<EFBFBD> D<EFBFBD>Ȳt<EFBFBD> t<EFBFBD><EFBFBD><EFBFBD>.
_TotalLevelSkillInfo* pSkillInfo = GetTotalLevelSkillInfo(nSkillID);
if (pSkillInfo == NULL)
return nSelectedSlotIndex;
std::map<int, int> normalEmptySlotList;
//1. <EFBFBD>@<EFBFBD> <EFBFBD>¬<EFBFBD> <EFBFBD>Ѕ<EFBFBD>D<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD>D<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)
{
//|<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD>̹ U<EFBFBD>x<EFBFBD> \<EFBFBD><EFBFBD><EFBFBD>.
if (iter->second.m_isCashSlot == false)
{
int slotIndex = iter->first;
//<EFBFBD><EFBFBD>o<EFBFBD>t<EFBFBD> \<EFBFBD>1<EFBFBD>T<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> J<EFBFBD><<EFBFBD>t<EFBFBD> t<EFBFBD><EFBFBD><EFBFBD>.
if (IsActivateSlot(slotIndex) == false)
continue;
std::map<int, DnSkillHandle>::iterator findSkillIter = m_ActiveTotalLevelSkillList.find(slotIndex);
if (findSkillIter != m_ActiveTotalLevelSkillList.end())
{
//<EFBFBD>¬<EFBFBD>t<EFBFBD> <EFBFBD>ǔ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (findSkillIter->second)
{
//<EFBFBD>@<EFBFBD> <EFBFBD>¬<EFBFBD> <EFBFBD>Ѕ<EFBFBD> t<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> X<EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>x<EFBFBD> <EFBFBD>¬<EFBFBD> <EFBFBD>Ѕ<EFBFBD>t<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> X<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>.
int nOldSkillID = findSkillIter->second->GetClassID();
_TotalLevelSkillInfo* pOldSkillInfo = GetTotalLevelSkillInfo(nOldSkillID);
if (pOldSkillInfo &&
pSkillInfo->m_SkillType == pOldSkillInfo->m_SkillType)
{
if (nSkillID != nOldSkillID)
{
nSelectedSlotIndex = slotIndex;
break;
}
else
{
//<EFBFBD>@<EFBFBD> <EFBFBD>Ѕ<EFBFBD>X<EFBFBD> <EFBFBD>¬<EFBFBD>t<EFBFBD> t<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>t<EFBFBD>..
nSelectedSlotIndex = -2;
}
}
}
//<EFBFBD>¬<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><<EFBFBD>t<EFBFBD> H<EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
else
{
normalEmptySlotList.insert(std::make_pair(slotIndex, slotIndex));
}
}
}
}
//<EFBFBD>@<EFBFBD> <EFBFBD>¬<EFBFBD> D<EFBFBD>t<EFBFBD><EFBFBD>|<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>, H<EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><<EFBFBD>t<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> T<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>%<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> J<EFBFBD>ij]<EFBFBD> X<EFBFBD>0<EFBFBD> <EFBFBD>t<EFBFBD> nSelectedSlotIndex|<EFBFBD> -2\<EFBFBD> $<EFBFBD><EFBFBD>h<EFBFBD>.
if (nSelectedSlotIndex == -2 && normalEmptySlotList.empty())
{
return nSelectedSlotIndex;
}
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>@<EFBFBD> <EFBFBD>Ѕ<EFBFBD>X<EFBFBD> <EFBFBD>¬<EFBFBD>D<EFBFBD> ><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><<EFBFBD>t<EFBFBD> H<EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD>D<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. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>o<EFBFBD> U<EFBFBD>x<EFBFBD>.
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