From 3648ef4687967c7363c9c61f4610679484dc478e Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Wed, 13 Jan 2021 00:07:24 +0300 Subject: lcs particle --- src/render/ParticleMgr.cpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'src/render/ParticleMgr.cpp') diff --git a/src/render/ParticleMgr.cpp b/src/render/ParticleMgr.cpp index f6919435..c802067d 100644 --- a/src/render/ParticleMgr.cpp +++ b/src/render/ParticleMgr.cpp @@ -4,18 +4,31 @@ #include "FileMgr.h" #include "ParticleMgr.h" +// --LCS: File done + cParticleSystemMgr mod_ParticleSystemManager; const char *ParticleFilename = "PARTICLE.CFG"; cParticleSystemMgr::cParticleSystemMgr() { - memset(this, 0, sizeof(*this)); +#ifdef FIX_BUGS + m_aParticles = nil; +#endif +} + +cParticleSystemMgr::~cParticleSystemMgr() +{ +#ifdef FIX_BUGS + if ( m_aParticles ) + delete [] m_aParticles; +#endif } void cParticleSystemMgr::Initialise() { - LoadParticleData(); + if ( gMakeResources ) + LoadParticleData(); for ( int32 i = 0; i < MAX_PARTICLES; i++ ) m_aParticles[i].m_pParticles = nil; @@ -23,20 +36,31 @@ void cParticleSystemMgr::Initialise() void cParticleSystemMgr::LoadParticleData() { - CFileMgr::SetDir("DATA"); - CFileMgr::LoadFile(ParticleFilename, work_buff, ARRAY_SIZE(work_buff), "r"); +#ifdef FIX_BUGS + if ( m_aParticles ) + delete [] m_aParticles; +#endif + m_aParticles = new tParticleSystemData[MAX_PARTICLES]; + + memset(m_aParticles, 0, sizeof(tParticleSystemData)*MAX_PARTICLES); + + CFileMgr::SetDir("Data"); + ssize_t len = CFileMgr::LoadFile(ParticleFilename, work_buff, ARRAY_SIZE(work_buff), "r"); CFileMgr::SetDir(""); + ASSERT(!(len <= 0)); + tParticleSystemData *entry = nil; int32 type = PARTICLE_FIRST; + char *buffEnd = (char *)&work_buff[len]; char *lineStart = (char *)work_buff; char *lineEnd = lineStart + 1; char line[500]; char delims[4]; - while ( true ) + while ( lineStart < buffEnd ) { ASSERT(lineStart != nil); ASSERT(lineEnd != nil); -- cgit v1.2.3 From 96fdbac69a650db2884a84776e9b8cb5261b38a1 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Sat, 16 Jan 2021 01:12:27 +0300 Subject: rem null checks --- src/render/ParticleMgr.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/render/ParticleMgr.cpp') diff --git a/src/render/ParticleMgr.cpp b/src/render/ParticleMgr.cpp index c802067d..263c4ae1 100644 --- a/src/render/ParticleMgr.cpp +++ b/src/render/ParticleMgr.cpp @@ -20,8 +20,7 @@ cParticleSystemMgr::cParticleSystemMgr() cParticleSystemMgr::~cParticleSystemMgr() { #ifdef FIX_BUGS - if ( m_aParticles ) - delete [] m_aParticles; + delete [] m_aParticles; #endif } @@ -37,8 +36,7 @@ void cParticleSystemMgr::Initialise() void cParticleSystemMgr::LoadParticleData() { #ifdef FIX_BUGS - if ( m_aParticles ) - delete [] m_aParticles; + delete [] m_aParticles; #endif m_aParticles = new tParticleSystemData[MAX_PARTICLES]; -- cgit v1.2.3