From dff810a5b1b6fd10f413f4c04aa3ca8e5c808951 Mon Sep 17 00:00:00 2001 From: titiger Date: Thu, 10 Jul 2014 23:34:39 +0200 Subject: [PATCH] multishot with more than one attack particle system --- source/glest_game/types/skill_type.cpp | 36 +++++++++++++----------- source/glest_game/types/skill_type.h | 4 +-- source/glest_game/world/unit_updater.cpp | 3 +- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/source/glest_game/types/skill_type.cpp b/source/glest_game/types/skill_type.cpp index 75fbd499..e939b243 100644 --- a/source/glest_game/types/skill_type.cpp +++ b/source/glest_game/types/skill_type.cpp @@ -806,7 +806,6 @@ AttackSkillType::AttackSkillType() { splashRadius= 0; spawnUnit=""; spawnUnitcount=0; - projectileParticleSystemType= NULL; splashParticleSystemType= NULL; for(int i = 0; i < fieldCount; ++i) { @@ -821,8 +820,8 @@ AttackSkillType::AttackSkillType() { } AttackSkillType::~AttackSkillType() { - delete projectileParticleSystemType; - projectileParticleSystemType = NULL; + + deleteValues(projectileParticleSystemTypes.begin(), projectileParticleSystemTypes.end()); delete splashParticleSystemType; splashParticleSystemType = NULL; @@ -887,16 +886,18 @@ void AttackSkillType::load(const XmlNode *sn, const XmlNode *attackBoostsNode, if(projectile){ //proj particle - const XmlNode *particleNode= projectileNode->getChild("particle"); - bool particleEnabled= particleNode->getAttribute("value")->getBoolValue(); - if(particleEnabled){ - string path= particleNode->getAttribute("path")->getRestrictedValue(); - projectileParticleSystemType= new ParticleSystemTypeProjectile(); - projectileParticleSystemType->load(particleNode, dir, currentPath + path, - &Renderer::getInstance(), loadedFileList, parentLoader, - tt->getPath()); - loadedFileList[currentPath + path].push_back(make_pair(parentLoader,particleNode->getAttribute("path")->getRestrictedValue())); - projectileParticleSystemTypes.push_back(projectileParticleSystemType); + if(projectileNode->hasChild("particle")){ + const XmlNode *particleNode= projectileNode->getChild("particle"); + bool particleEnabled= particleNode->getAttribute("value")->getBoolValue(); + if(particleEnabled){ + string path= particleNode->getAttribute("path")->getRestrictedValue(); + ParticleSystemTypeProjectile* projectileParticleSystemType= new ParticleSystemTypeProjectile(); + projectileParticleSystemType->load(particleNode, dir, currentPath + path, + &Renderer::getInstance(), loadedFileList, parentLoader, + tt->getPath()); + loadedFileList[currentPath + path].push_back(make_pair(parentLoader,particleNode->getAttribute("path")->getRestrictedValue())); + projectileParticleSystemTypes.push_back(projectileParticleSystemType); + } } //extra projectiles @@ -907,7 +908,7 @@ void AttackSkillType::load(const XmlNode *sn, const XmlNode *attackBoostsNode, for(int i = 0; i < (int)extraParticlesNode->getChildCount(); ++i) { const XmlNode *extraParticleFileNode= extraParticlesNode->getChild("particle-file", i); string path= extraParticleFileNode->getAttribute("path")->getRestrictedValue(); - projectileParticleSystemType= new ParticleSystemTypeProjectile(); + ParticleSystemTypeProjectile* projectileParticleSystemType= new ParticleSystemTypeProjectile(); projectileParticleSystemType->load(extraParticleFileNode, dir, currentPath + path, &Renderer::getInstance(), loadedFileList, parentLoader, tt->getPath()); @@ -1007,9 +1008,10 @@ void AttackSkillType::saveGame(XmlNode *rootNode) { // bool projectile; attackSkillTypeNode->addAttribute("projectile",intToStr(projectile), mapTagReplacements); // ParticleSystemTypeProjectile* projectileParticleSystemType; - if(projectileParticleSystemType != NULL) { - projectileParticleSystemType->saveGame(attackSkillTypeNode); - } +// save a skill_type ???? + // if(projectileParticleSystemType != NULL) { +// projectileParticleSystemType->saveGame(attackSkillTypeNode); +// } // SoundContainer projSounds; // // bool splash; diff --git a/source/glest_game/types/skill_type.h b/source/glest_game/types/skill_type.h index 6b1853e5..e0b79ce7 100644 --- a/source/glest_game/types/skill_type.h +++ b/source/glest_game/types/skill_type.h @@ -271,7 +271,7 @@ private: string spawnUnit; int spawnUnitcount; bool projectile; - ParticleSystemTypeProjectile* projectileParticleSystemType; + //ParticleSystemTypeProjectile* projectileParticleSystemType; SoundContainer projSounds; bool splash; @@ -299,7 +299,7 @@ public: //get proj inline bool getProjectile() const {return projectile;} - inline ParticleSystemTypeProjectile * getProjParticleType() const {return projectileParticleSystemType;} + //inline ParticleSystemTypeProjectile * getProjParticleType() const {return projectileParticleSystemType;} inline StaticSound *getProjSound() const {return projSounds.getRandSound();} //get splash diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index bdea2950..8fb76f91 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -2601,7 +2601,7 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){ if(ast == NULL) { throw megaglest_runtime_error("Start attack particle ast == NULL!"); } - ParticleSystemTypeProjectile *pstProj= ast->getProjParticleType(); + ParticleSystemTypeProjectile *pstProj= NULL; ParticleSystemTypeSplash *pstSplash= ast->getSplashParticleType(); Vec3f startPos= unit->getCurrVector(); @@ -2626,6 +2626,7 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){ } renderer.manageParticleSystem(psProj, rsGame); unit->addAttackParticleSystem(psProj); + pstProj=(*pit); } // if no projectile, still deal damage..