diff --git a/source/glest_game/type_instances/object.h b/source/glest_game/type_instances/object.h index 352fc16e..9a430899 100644 --- a/source/glest_game/type_instances/object.h +++ b/source/glest_game/type_instances/object.h @@ -73,7 +73,8 @@ public: Object(ObjectType *objectType, const Vec3f &pos, const Vec2i &mapPos); virtual ~Object(); - void end(); //to kill particles + virtual void end(); //to kill particles + virtual void logParticleInfo(string info) {}; void initParticles(); void initParticlesFromTypes(const ModelParticleSystemTypes *particleTypes); static void setStateCallback(ObjectStateInterface *value) { stateCallback=value; } diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 617504cf..aee5f9b1 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -646,6 +646,19 @@ void Unit::dumpMemoryList() { } #endif +void Unit::logParticleInfo(string info) { + networkCRCParticleInfoList.push_back(info); +} +string Unit::getParticleInfo() const { + string result = ""; + if(networkCRCParticleInfoList.empty() == false) { + for(unsigned int index = 0; index < networkCRCParticleInfoList.size(); ++index) { + result += networkCRCParticleInfoList[index] + "|"; + } + } + return result; +} + void Unit::end(ParticleSystem *particleSystem) { vector::iterator iterFind = find(attackParticleSystems.begin(),attackParticleSystems.end(),particleSystem); if(iterFind != attackParticleSystems.end()) { @@ -4278,6 +4291,9 @@ std::string Unit::toString(bool crcMode) const { result += "getNetworkCRCDecHpList() = " + getNetworkCRCDecHpList() + "\n"; } + if(getParticleInfo() != "") { + result += "getParticleInfo() = " + getParticleInfo() + "\n"; + } for(unsigned int index = 0; index < attackParticleSystems.size(); ++index) { ParticleSystem *ps = attackParticleSystems[index]; if(ps != NULL && @@ -5262,6 +5278,10 @@ Checksum Unit::getCRC() { if(consoleDebug) printf("#17 Unit: %d CRC: %u\n",id,crcForUnit.getSum()); + if(getParticleInfo() != "") { + crcForUnit.addString(this->getParticleInfo()); + } + crcForUnit.addInt64((int64)attackParticleSystems.size()); for(unsigned int index = 0; index < attackParticleSystems.size(); ++index) { ParticleSystem *ps = attackParticleSystems[index]; diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index ede21d13..b7582f1e 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -488,6 +488,8 @@ private: string networkCRCParticleObserverLogInfo; vector networkCRCDecHpList; + vector networkCRCParticleInfoList; + public: Unit(int id, UnitPathInterface *path, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map, CardinalDir placeFacing); virtual ~Unit(); @@ -794,6 +796,9 @@ public: Checksum getCRC(); virtual void end(ParticleSystem *particleSystem); + virtual void logParticleInfo(string info); + void clearParticleInfo() { networkCRCParticleInfoList.clear(); } + string getParticleInfo() const; void addNetworkCRCDecHp(string info) { networkCRCDecHpList.push_back(info); } diff --git a/source/shared_lib/include/graphics/particle.h b/source/shared_lib/include/graphics/particle.h index fc55e328..86e28f0e 100644 --- a/source/shared_lib/include/graphics/particle.h +++ b/source/shared_lib/include/graphics/particle.h @@ -85,7 +85,9 @@ public: class ParticleOwner { public: + virtual ~ParticleOwner() {} virtual void end(ParticleSystem *particleSystem)= 0; + virtual void logParticleInfo(string info)= 0; }; // ===================================================== diff --git a/source/shared_lib/sources/graphics/particle.cpp b/source/shared_lib/sources/graphics/particle.cpp index 44b9b8d3..b7e801b9 100644 --- a/source/shared_lib/sources/graphics/particle.cpp +++ b/source/shared_lib/sources/graphics/particle.cpp @@ -1816,6 +1816,13 @@ void ProjectileParticleSystem::update(){ //arrive destination arriveDestinationDistance = truncateDecimal(flatPos.dist(endPos),6); + + if(this->particleOwner != NULL) { + char szBuf[8096]=""; + snprintf(szBuf,8095,"LINE: %d arriveDestinationDistance = %f",__LINE__,arriveDestinationDistance); + this->particleOwner->logParticleInfo(szBuf); + } + if(arriveDestinationDistance < 0.5f) { fade(); model= NULL; @@ -2143,6 +2150,12 @@ void SplashParticleSystem::update() { t= clamp(t, 0.0f, 1.0f); setTween(t,t); + if(this->particleOwner != NULL) { + char szBuf[8096]=""; + snprintf(szBuf,8095,"LINE: %d emissionRate = %f",__LINE__,emissionRate); + this->particleOwner->logParticleInfo(szBuf); + } + if(emissionRate < 0.0f) {//otherwise this system lives forever! fade(); }