Batch #3636 by Yommy: 0 byte-identical, 6 confirmed by peer review. - fn_19267 ?Alloc@?$CEffectMemoryPool@VCEZ2STRParticle@@@?A0xfabdc4b6@@UAEPAVCParticle@@XZ: logic confirmed by peer review - fn_19269 ?Alloc@?$CEffectMemoryPool@VCParticle@@@?A0xfabdc4b6@@UAEPAVCParticle@@XZ: logic confirmed by peer review - fn_19275 ?Free@?$CEffectMemoryPool@VCEZ2STRParticle@@@?A0xfabdc4b6@@UAEXPAVCParticle@@@Z: logic confirmed by peer review - fn_19276 ?Free@?$CEffectMemoryPool@VCMultiTexParticle@@@?A0xfabdc4b6@@UAEXPAVCParticle@@@Z: logic confirmed by peer review - fn_19277 ?Free@?$CEffectMemoryPool@VCParticle@@@?A0xfabdc4b6@@UAEXPAVCParticle@@@Z: logic confirmed by peer review - fn_19278 ?Free@?$CEffectMemoryPool@VCSpriteParticle@@@?A0xfabdc4b6@@UAEXPAVCParticle@@@Z: logic confirmed by peer review Peer-reviewed-by: eAthena, ntrl, meitogi Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). Adds to the build: Source/Contents/Effects/EffectMemoryMgr.cpp
75 lines
1.8 KiB
C++
75 lines
1.8 KiB
C++
#include "Contents/Effects/NyanggrassEffect.h"
|
|
#include "Contents/Effects/Particle.h"
|
|
#include "Contents/Effects/SpriteParticle.h"
|
|
#include "Utility/Math/Vector3d.h"
|
|
|
|
#include <deque>
|
|
#include <new>
|
|
|
|
namespace {
|
|
|
|
class IEffectMemoryPool {
|
|
public:
|
|
virtual ~IEffectMemoryPool() {
|
|
}
|
|
|
|
virtual CParticle* Alloc() = 0;
|
|
virtual void Free(CParticle* particle) = 0;
|
|
};
|
|
|
|
template <class T>
|
|
class CEffectMemoryPool : public IEffectMemoryPool {
|
|
public:
|
|
/* 0004 */ std::deque<T*> m_free;
|
|
|
|
CParticle* Alloc() override;
|
|
void Free(CParticle* particle) override;
|
|
};
|
|
|
|
// OFFSET: 0x00B81D00
|
|
// FUNCTION: fn_19267
|
|
template <>
|
|
CParticle* CEffectMemoryPool<CEZ2STRParticle>::Alloc() {
|
|
if (!this->m_free.empty()) {
|
|
CEZ2STRParticle* particle = this->m_free.front();
|
|
particle->Clear();
|
|
this->m_free.pop_front();
|
|
return particle;
|
|
}
|
|
|
|
return new (std::nothrow) CEZ2STRParticle(vector3d(), -1);
|
|
}
|
|
|
|
// OFFSET: 0x00B81EE0
|
|
// FUNCTION: fn_19269
|
|
template <>
|
|
CParticle* CEffectMemoryPool<CParticle>::Alloc() {
|
|
if (!this->m_free.empty()) {
|
|
CParticle* particle = this->m_free.front();
|
|
particle->Reset();
|
|
this->m_free.pop_front();
|
|
return particle;
|
|
}
|
|
|
|
return new (std::nothrow) CParticle(vector3d(), -1);
|
|
}
|
|
|
|
// OFFSET: 0x00B825B0
|
|
// OFFSET: 0x00B826D0
|
|
// OFFSET: 0x00B82640
|
|
// OFFSET: 0x00B82520
|
|
// FUNCTION: fn_19276
|
|
// FUNCTION: fn_19278
|
|
// FUNCTION: fn_19277
|
|
// FUNCTION: fn_19275
|
|
template <class T>
|
|
void CEffectMemoryPool<T>::Free(CParticle* particle) {
|
|
this->m_free.push_back(static_cast<T*>(particle));
|
|
}
|
|
|
|
template class CEffectMemoryPool<CParticle>;
|
|
template class CEffectMemoryPool<CEZ2STRParticle>;
|
|
template void CEffectMemoryPool<CSpriteParticle>::Free(CParticle* particle);
|
|
template void CEffectMemoryPool<CMultiTexParticle>::Free(CParticle* particle);
|
|
|
|
}
|