📄 statusfactory.cpp
字号:
#include "StdAfx.h"
#include "StatusFactory.h"
#include "AbilityStatus.h"
#include "WoundStatus.h"
#include "StunStatus.h"
#include "AbsorbStatus.h"
#include "CureStatus.h"
#include "BlindStatus.h"
#include "MagicShieldStatus.h"
#include "FearStatus.h"
#include "SPBonusStatus.h"
#include "ChaosStatus.h"
#include "WindShieldStatus.h"
#include "MirrorStatus.h"
#include "ThrustStatus.h"
#include "SleepStatus.h"
#include "StyleThrust.h"
#include "StyleStun.h"
#include "StyleDown.h"
#include "RecoverStatus.h"
#include "LowHPStatus.h"
#include "BonusDamageStatus.h"
StatusFactory::StatusFactory()
{
m_pBasePool = new CMemoryPoolFactory<BaseStatus>;
m_pAbilityPool = new CMemoryPoolFactory<AbilityStatus>;
m_pWoundPool = new CMemoryPoolFactory<WoundStatus>;
m_pStunPool = new CMemoryPoolFactory<StunStatus>;
m_pAbsorbPool = new CMemoryPoolFactory<AbsorbStatus>;
m_pCurePool = new CMemoryPoolFactory<CureStatus>;
m_pBlindPool = new CMemoryPoolFactory<BlindStatus>;
m_pMagicShieldPool = new CMemoryPoolFactory<MagicShieldStatus>;
m_pFearPool = new CMemoryPoolFactory<FearStatus>;
m_pSPBonusPool = new CMemoryPoolFactory<SPBonusStatus>;
m_pChaosPool = new CMemoryPoolFactory<ChaosStatus>;
m_pWindShieldPool = new CMemoryPoolFactory<WindShieldStatus>;
m_pMirrorPool = new CMemoryPoolFactory<MirrorStatus>;
m_pThrustPool = new CMemoryPoolFactory<ThrustStatus>;
m_pSleepPool = new CMemoryPoolFactory<SleepStatus>;
m_pLowHPPool = new CMemoryPoolFactory<LowHPStatus>;
m_pBonusDamagePool = new CMemoryPoolFactory<BonusDamageStatus>;
m_pStyleThrustPool = new CMemoryPoolFactory<StyleThrust>;
m_pStyleStunPool = new CMemoryPoolFactory<StyleStun>;
m_pStyleDownPool = new CMemoryPoolFactory<StyleDown>;
m_pRecoverPool = new CMemoryPoolFactory<RecoverStatus>;
}
StatusFactory::~StatusFactory()
{
Release();
SAFE_DELETE( m_pBasePool ); SAFE_DELETE( m_pAbilityPool );
SAFE_DELETE( m_pWoundPool ); SAFE_DELETE( m_pStunPool );
SAFE_DELETE( m_pAbsorbPool ); SAFE_DELETE( m_pCurePool );
SAFE_DELETE( m_pBlindPool ); SAFE_DELETE( m_pMagicShieldPool );
SAFE_DELETE( m_pFearPool ); SAFE_DELETE( m_pSPBonusPool );
SAFE_DELETE( m_pChaosPool ); SAFE_DELETE( m_pWindShieldPool );
SAFE_DELETE( m_pMirrorPool ); SAFE_DELETE( m_pThrustPool );
SAFE_DELETE( m_pSleepPool ); SAFE_DELETE( m_pLowHPPool );
SAFE_DELETE( m_pBonusDamagePool );
SAFE_DELETE( m_pStyleThrustPool ); SAFE_DELETE( m_pStyleStunPool );
SAFE_DELETE( m_pStyleDownPool ); SAFE_DELETE( m_pRecoverPool );
}
VOID StatusFactory::Release()
{
if( m_pBasePool ) m_pBasePool->Release();
if( m_pAbilityPool ) m_pAbilityPool->Release();
if( m_pWoundPool ) m_pWoundPool->Release();
if( m_pStunPool ) m_pStunPool->Release();
if( m_pAbsorbPool ) m_pAbsorbPool->Release();
if( m_pCurePool ) m_pCurePool->Release();
if( m_pBlindPool ) m_pBlindPool->Release();
if( m_pMagicShieldPool ) m_pMagicShieldPool->Release();
if( m_pFearPool ) m_pFearPool->Release();
if( m_pSPBonusPool ) m_pSPBonusPool->Release();
if( m_pChaosPool ) m_pChaosPool->Release();
if( m_pWindShieldPool ) m_pWindShieldPool->Release();
if( m_pMirrorPool ) m_pMirrorPool->Release();
if( m_pThrustPool ) m_pThrustPool->Release();
if( m_pSleepPool ) m_pSleepPool->Release();
if( m_pLowHPPool ) m_pLowHPPool->Release();
if( m_pBonusDamagePool ) m_pBonusDamagePool->Release();
if( m_pStyleThrustPool ) m_pStyleThrustPool->Release();
if( m_pStyleStunPool ) m_pStyleStunPool->Release();
if( m_pStyleDownPool ) m_pStyleDownPool->Release();
if( m_pRecoverPool ) m_pRecoverPool->Release();
}
// Player + Monster 惑怕甫 葛滴 绊妨茄促.
VOID StatusFactory::Init( DWORD dwCharPool )
{
m_pBasePool->Initialize( dwCharPool, dwCharPool/2+1 );
m_pAbilityPool->Initialize( dwCharPool*3, dwCharPool*3/2+1 );
m_pWoundPool->Initialize( dwCharPool*3/2, dwCharPool*3/4+1 );
m_pStunPool->Initialize( dwCharPool*2, dwCharPool+1 );
m_pRecoverPool->Initialize( dwCharPool*2, dwCharPool+1 );
m_pAbsorbPool->Initialize( dwCharPool/2, dwCharPool/4+1 );
m_pCurePool->Initialize( dwCharPool/2, dwCharPool/4+1 );
m_pBlindPool->Initialize( dwCharPool/2, dwCharPool/4+1 );
m_pMagicShieldPool->Initialize( dwCharPool/2, dwCharPool/4+1 );
m_pFearPool->Initialize( dwCharPool/2, dwCharPool/4+1 );
m_pSPBonusPool->Initialize( dwCharPool/2, dwCharPool/4+1 );
m_pChaosPool->Initialize( dwCharPool/2, dwCharPool/4+1 );
m_pWindShieldPool->Initialize( dwCharPool/2, dwCharPool/4+1 );
m_pMirrorPool->Initialize( dwCharPool/2, dwCharPool/4+1 );
m_pSleepPool->Initialize( dwCharPool/2, dwCharPool/4+1 );
m_pLowHPPool->Initialize( dwCharPool/2, dwCharPool/4+1 );
m_pBonusDamagePool->Initialize( dwCharPool/2, dwCharPool/4+1 );
m_pThrustPool->Initialize( dwCharPool, dwCharPool/2+1 );
m_pStyleThrustPool->Initialize( dwCharPool/2, dwCharPool/4+1 );
m_pStyleStunPool->Initialize( dwCharPool/2, dwCharPool/4+1 );
m_pStyleDownPool->Initialize( dwCharPool/2, dwCharPool/4+1 );
}
BaseStatus * StatusFactory::AllocStatus( eCHAR_STATE_TYPE eStateID, BOOL bAbility )
{
if( bAbility )
return AllocAbility( eStateID );
else
return AllocEtc( eStateID );
}
BaseStatus * StatusFactory::AllocAbility( eCHAR_STATE_TYPE eStateID )
{
BaseStatus * pStatus = NULL;
switch( eStateID )
{
case eCHAR_STATE_POISON: case eCHAR_STATE_WOUND: case eCHAR_STATE_FIRE_WOUND: case eCHAR_STATE_PERIODIC_DAMAGE:
pStatus = m_pWoundPool->Alloc(); break;
case eCHAR_STATE_STUN: case eCHAR_STATE_DOWN: case eCHAR_STATE_DELAY: case eCHAR_STATE_FROZEN:
pStatus = m_pStunPool->Alloc(); break;
case eCHAR_STATE_ABSORB:
pStatus = m_pAbsorbPool->Alloc(); break;
case eCHAR_STATE_CURE:
pStatus = m_pCurePool->Alloc(); break;
case eCHAR_STATE_BLIND:
pStatus = m_pBlindPool->Alloc(); break;
case eCHAR_STATE_MAGIC_SHIELD:
pStatus = m_pMagicShieldPool->Alloc(); break;
case eCHAR_STATE_FEAR:
pStatus = m_pFearPool->Alloc(); break;
case eCHAR_STATE_SP_BONUS:
pStatus = m_pSPBonusPool->Alloc(); break;
case eCHAR_STATE_CHAOS:
pStatus = m_pChaosPool->Alloc(); break;
case eCHAR_STATE_BUF_RANGE_DAMAGE:
pStatus = m_pWindShieldPool->Alloc(); break;
case eCHAR_STATE_REFLECT_DAMAGE: case eCHAR_STATE_REFLECT_SLOW: case eCHAR_STATE_REFLECT_FROZEN:
case eCHAR_STATE_REFLECT_SLOWDOWN: case eCHAR_STATE_REFLECT_STUN: case eCHAR_STATE_REFLECT_FEAR:
pStatus = m_pMirrorPool->Alloc(); break;
case eCHAR_STATE_THRUST:
pStatus = m_pThrustPool->Alloc(); break;
case eCHAR_STATE_SLEEP:
pStatus = m_pSleepPool->Alloc(); break;
case eCHAR_STATE_STAT_LOWHP_ATTACK_DECREASE: case eCHAR_STATE_STAT_LOWHP_DEFENSE_DECREASE:
case eCHAR_STATE_STAT_LOWHP_ATTACK_INCREASE: case eCHAR_STATE_STAT_LOWHP_DEFENSE_INCREASE:
pStatus = m_pLowHPPool->Alloc(); break;
case eCHAR_STATE_STAT_DAMAGE_ADD:
pStatus = m_pBonusDamagePool->Alloc(); break;
default:
pStatus = m_pAbilityPool->Alloc();
}
return pStatus;
}
BaseStatus * StatusFactory::AllocEtc( eCHAR_STATE_TYPE eStateID )
{
BaseStatus * pStatus = NULL;
switch( eStateID )
{
case eCHAR_STATE_STYLE_THRUST:
pStatus = m_pStyleThrustPool->Alloc(); break;
case eCHAR_STATE_STYLE_STUN:
pStatus = m_pStyleStunPool->Alloc(); break;
case eCHAR_STATE_STYLE_DOWN:
pStatus = m_pStyleDownPool->Alloc(); break;
case eCHAR_STATE_ETC_AUTO_RECOVER_HP: case eCHAR_STATE_ETC_AUTO_RECOVER_MP: case eCHAR_STATE_ETC_AUTO_RECOVER_HPMP:
case eCHAR_STATE_ETC_ITEM_RECOVER_HP: case eCHAR_STATE_ETC_ITEM_RECOVER_MP:
pStatus = m_pRecoverPool->Alloc(); break;
default:
pStatus = m_pBasePool->Alloc();
}
return pStatus;
}
VOID StatusFactory::FreeStatus( BaseStatus* pStatus )
{
switch( pStatus->GetStateID() )
{
case eCHAR_STATE_POISON: case eCHAR_STATE_WOUND: case eCHAR_STATE_FIRE_WOUND: case eCHAR_STATE_PERIODIC_DAMAGE:
m_pWoundPool->Free( (WoundStatus*)pStatus ); break;
case eCHAR_STATE_STUN: case eCHAR_STATE_DOWN: case eCHAR_STATE_DELAY: case eCHAR_STATE_FROZEN:
m_pStunPool->Free( (StunStatus*)pStatus ); break;
case eCHAR_STATE_ABSORB:
m_pAbsorbPool->Free( (AbsorbStatus*)pStatus ); break;
case eCHAR_STATE_CURE:
m_pCurePool->Free( (CureStatus*)pStatus ); break;
case eCHAR_STATE_BLIND:
m_pBlindPool->Free( (BlindStatus*)pStatus ); break;
case eCHAR_STATE_MAGIC_SHIELD:
m_pMagicShieldPool->Free( (MagicShieldStatus*)pStatus );break;
case eCHAR_STATE_FEAR:
m_pFearPool->Free( (FearStatus*)pStatus ); break;
case eCHAR_STATE_SP_BONUS:
m_pSPBonusPool->Free( (SPBonusStatus*)pStatus ); break;
case eCHAR_STATE_CHAOS:
m_pChaosPool->Free( (ChaosStatus*)pStatus ); break;
case eCHAR_STATE_BUF_RANGE_DAMAGE:
m_pWindShieldPool->Free( (WindShieldStatus*)pStatus ); break;
case eCHAR_STATE_REFLECT_DAMAGE: case eCHAR_STATE_REFLECT_SLOW: case eCHAR_STATE_REFLECT_FROZEN:
case eCHAR_STATE_REFLECT_SLOWDOWN: case eCHAR_STATE_REFLECT_STUN: case eCHAR_STATE_REFLECT_FEAR:
m_pMirrorPool->Free( (MirrorStatus*)pStatus ); break;
case eCHAR_STATE_THRUST:
m_pThrustPool->Free( (ThrustStatus*)pStatus ); break;
case eCHAR_STATE_SLEEP:
m_pSleepPool->Free( (SleepStatus*)pStatus ); break;
case eCHAR_STATE_STYLE_THRUST:
m_pStyleThrustPool->Free( (StyleThrust*)pStatus ); break;
case eCHAR_STATE_STYLE_STUN:
m_pStyleStunPool->Free( (StyleStun*)pStatus ); break;
case eCHAR_STATE_STYLE_DOWN:
m_pStyleDownPool->Free( (StyleDown*)pStatus ); break;
case eCHAR_STATE_ETC_AUTO_RECOVER_HP: case eCHAR_STATE_ETC_AUTO_RECOVER_MP: case eCHAR_STATE_ETC_AUTO_RECOVER_HPMP:
case eCHAR_STATE_ETC_ITEM_RECOVER_HP: case eCHAR_STATE_ETC_ITEM_RECOVER_MP:
m_pRecoverPool->Free( (RecoverStatus*)pStatus ); break;
case eCHAR_STATE_STAT_LOWHP_ATTACK_DECREASE: case eCHAR_STATE_STAT_LOWHP_DEFENSE_DECREASE:
case eCHAR_STATE_STAT_LOWHP_ATTACK_INCREASE: case eCHAR_STATE_STAT_LOWHP_DEFENSE_INCREASE:
m_pLowHPPool->Free( (LowHPStatus*)pStatus ); break;
case eCHAR_STATE_STAT_DAMAGE_ADD:
m_pBonusDamagePool->Free( (BonusDamageStatus*)pStatus );break;
default:
if( pStatus->IsAbilityStatus() )
{
m_pAbilityPool->Free( (AbilityStatus*)pStatus );
}
else
{
m_pBasePool->Free( (BaseStatus*)pStatus );
}
}
}
VOID StatusFactory::DisplayPoolInfo()
{
DISPMSG( "[%4u,%4u][band:%u node:%u] m_pAbilityPool\n", m_pAbilityPool->GetPoolBasicSize(), m_pAbilityPool->GetPoolExtendSize(),
m_pAbilityPool->GetNumberOfBands(), m_pAbilityPool->GetAvailableNumberOfTypes() );
DISPMSG( "[%4u,%4u][band:%u node:%u] m_pStunPool\n", m_pStunPool->GetPoolBasicSize(), m_pStunPool->GetPoolExtendSize(),
m_pStunPool->GetNumberOfBands(), m_pStunPool->GetAvailableNumberOfTypes() );
DISPMSG( "[%4u,%4u][band:%u node:%u] m_pBasePool\n", m_pBasePool->GetPoolBasicSize(), m_pBasePool->GetPoolExtendSize(),
m_pBasePool->GetNumberOfBands(), m_pBasePool->GetAvailableNumberOfTypes() );
DISPMSG( "[%4u,%4u][band:%u node:%u] m_pStyleThrustPool\n", m_pStyleThrustPool->GetPoolBasicSize(), m_pStyleThrustPool->GetPoolExtendSize(),
m_pStyleThrustPool->GetNumberOfBands(), m_pStyleThrustPool->GetAvailableNumberOfTypes() );
DISPMSG( "[%4u,%4u][band:%u node:%u] m_pStyleStunPool\n", m_pStyleStunPool->GetPoolBasicSize(), m_pStyleStunPool->GetPoolExtendSize(),
m_pStyleStunPool->GetNumberOfBands(), m_pStyleStunPool->GetAvailableNumberOfTypes() );
DISPMSG( "[%4u,%4u][band:%u node:%u] m_pStyleDownPool\n", m_pStyleDownPool->GetPoolBasicSize(), m_pStyleDownPool->GetPoolExtendSize(),
m_pStyleDownPool->GetNumberOfBands(), m_pStyleDownPool->GetAvailableNumberOfTypes() );
DISPMSG( "[%4u,%4u][band:%u node:%u] m_pRecoverPool\n", m_pRecoverPool->GetPoolBasicSize(), m_pRecoverPool->GetPoolExtendSize(),
m_pRecoverPool->GetNumberOfBands(), m_pRecoverPool->GetAvailableNumberOfTypes() );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -