attempt for big cleanup of out of synch issues, please test!
This commit is contained in:
parent
440ec7dd7e
commit
3a6544a257
|
@ -1450,7 +1450,7 @@ void MainWindow::loadProjectileParticle(string path) {
|
||||||
for(std::vector<ParticleSystemTypeProjectile *>::const_iterator it= projectileParticleSystemTypes.begin();
|
for(std::vector<ParticleSystemTypeProjectile *>::const_iterator it= projectileParticleSystemTypes.begin();
|
||||||
it != projectileParticleSystemTypes.end(); ++it) {
|
it != projectileParticleSystemTypes.end(); ++it) {
|
||||||
|
|
||||||
ProjectileParticleSystem *ps = (*it)->create();
|
ProjectileParticleSystem *ps = (*it)->create(NULL);
|
||||||
|
|
||||||
if(size > 0) {
|
if(size > 0) {
|
||||||
Vec3f vec = Vec3f(0.f, height / 2.f, 0.f);
|
Vec3f vec = Vec3f(0.f, height / 2.f, 0.f);
|
||||||
|
@ -1559,7 +1559,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp
|
||||||
//ParticleSystemTypeSplash
|
//ParticleSystemTypeSplash
|
||||||
for(std::vector<ParticleSystemTypeSplash *>::const_iterator it= splashParticleSystemTypes.begin(); it != splashParticleSystemTypes.end(); ++it) {
|
for(std::vector<ParticleSystemTypeSplash *>::const_iterator it= splashParticleSystemTypes.begin(); it != splashParticleSystemTypes.end(); ++it) {
|
||||||
|
|
||||||
SplashParticleSystem *ps = (*it)->create();
|
SplashParticleSystem *ps = (*it)->create(NULL);
|
||||||
|
|
||||||
if(size > 0) {
|
if(size > 0) {
|
||||||
Vec3f vec = Vec3f(0.f, height / 2.f, 0.f);
|
Vec3f vec = Vec3f(0.f, height / 2.f, 0.f);
|
||||||
|
|
|
@ -250,11 +250,11 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
|
|
||||||
if(path->isStuck() == true &&
|
if(path->isStuck() == true &&
|
||||||
(unit->getLastStuckPos() == finalPos || path->getBlockCount() > 500) &&
|
(unit->getLastStuckPos() == finalPos || path->getBlockCount() > 500) &&
|
||||||
unit->isLastStuckFrameWithinCurrentFrameTolerance() == true) {
|
unit->isLastStuckFrameWithinCurrentFrameTolerance(frameIndex >= 0) == true) {
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"path->isStuck() == true unit->getLastStuckPos() [%s] finalPos [%s] path->getBlockCount() [%d] tolerance: %d",unit->getLastStuckPos().getString().c_str(),finalPos.getString().c_str(),path->getBlockCount(),unit->isLastStuckFrameWithinCurrentFrameTolerance());
|
snprintf(szBuf,8096,"path->isStuck() == true unit->getLastStuckPos() [%s] finalPos [%s] path->getBlockCount() [%d]",unit->getLastStuckPos().getString().c_str(),finalPos.getString().c_str(),path->getBlockCount());
|
||||||
unit->logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__,szBuf);
|
unit->logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__,szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -292,6 +292,7 @@ void ParticleSystemType::setValues(AttackParticleSystem *ats){
|
||||||
// add instances of all children; some settings will cascade to all children
|
// add instances of all children; some settings will cascade to all children
|
||||||
for(Children::iterator i=children.begin(); i!=children.end(); ++i){
|
for(Children::iterator i=children.begin(); i!=children.end(); ++i){
|
||||||
UnitParticleSystem *child = new UnitParticleSystem();
|
UnitParticleSystem *child = new UnitParticleSystem();
|
||||||
|
child->setParticleOwner(ats->getParticleOwner());
|
||||||
(*i)->setValues(child);
|
(*i)->setValues(child);
|
||||||
ats->addChild(child);
|
ats->addChild(child);
|
||||||
child->setState(ParticleSystem::sPlay);
|
child->setState(ParticleSystem::sPlay);
|
||||||
|
@ -439,9 +440,9 @@ void ParticleSystemTypeProjectile::load(const XmlNode* particleFileNode, const s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectileParticleSystem *ParticleSystemTypeProjectile::create() {
|
ProjectileParticleSystem *ParticleSystemTypeProjectile::create(ParticleOwner *owner) {
|
||||||
ProjectileParticleSystem *ps= new ProjectileParticleSystem();
|
ProjectileParticleSystem *ps= new ProjectileParticleSystem();
|
||||||
|
ps->setParticleOwner(owner);
|
||||||
ParticleSystemType::setValues(ps);
|
ParticleSystemType::setValues(ps);
|
||||||
|
|
||||||
ps->setTrajectory(ProjectileParticleSystem::strToTrajectory(trajectory));
|
ps->setTrajectory(ProjectileParticleSystem::strToTrajectory(trajectory));
|
||||||
|
@ -525,9 +526,9 @@ void ParticleSystemTypeSplash::load(const XmlNode* particleFileNode, const strin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SplashParticleSystem *ParticleSystemTypeSplash::create(){
|
SplashParticleSystem *ParticleSystemTypeSplash::create(ParticleOwner *owner) {
|
||||||
SplashParticleSystem *ps= new SplashParticleSystem();
|
SplashParticleSystem *ps= new SplashParticleSystem();
|
||||||
|
ps->setParticleOwner(owner);
|
||||||
ParticleSystemType::setValues(ps);
|
ParticleSystemType::setValues(ps);
|
||||||
|
|
||||||
ps->setEmissionRateFade(emissionRateFade);
|
ps->setEmissionRateFade(emissionRateFade);
|
||||||
|
|
|
@ -132,7 +132,7 @@ public:
|
||||||
void load(const XmlNode *particleFileNode, const string &dir, const string &path,
|
void load(const XmlNode *particleFileNode, const string &dir, const string &path,
|
||||||
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
|
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
|
||||||
string parentLoader, string techtreePath);
|
string parentLoader, string techtreePath);
|
||||||
ProjectileParticleSystem *create();
|
ProjectileParticleSystem *create(ParticleOwner *owner);
|
||||||
|
|
||||||
virtual void saveGame(XmlNode *rootNode);
|
virtual void saveGame(XmlNode *rootNode);
|
||||||
};
|
};
|
||||||
|
@ -148,7 +148,7 @@ public:
|
||||||
void load(const XmlNode *particleFileNode, const string &dir, const string &path,
|
void load(const XmlNode *particleFileNode, const string &dir, const string &path,
|
||||||
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
|
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
|
||||||
string parentLoader, string techtreePath);
|
string parentLoader, string techtreePath);
|
||||||
SplashParticleSystem *create();
|
SplashParticleSystem *create(ParticleOwner *owner);
|
||||||
|
|
||||||
virtual void saveGame(XmlNode *rootNode);
|
virtual void saveGame(XmlNode *rootNode);
|
||||||
|
|
||||||
|
|
|
@ -207,6 +207,7 @@ const void UnitParticleSystemType::setValues(UnitParticleSystem *ups){
|
||||||
// add instances of all children; some settings will cascade to all children
|
// add instances of all children; some settings will cascade to all children
|
||||||
for(Children::iterator i=children.begin(); i!=children.end(); ++i){
|
for(Children::iterator i=children.begin(); i!=children.end(); ++i){
|
||||||
UnitParticleSystem *child = new UnitParticleSystem();
|
UnitParticleSystem *child = new UnitParticleSystem();
|
||||||
|
child->setParticleOwner(ups->getParticleOwner());
|
||||||
(*i)->setValues(child);
|
(*i)->setValues(child);
|
||||||
ups->addChild(child);
|
ups->addChild(child);
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,6 +147,26 @@ std::string Command::toString(bool translatedValue) const {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Checksum Command::getCRC() {
|
||||||
|
Checksum crcForCmd;
|
||||||
|
|
||||||
|
crcForCmd.addInt(commandType->getId());
|
||||||
|
crcForCmd.addInt(originalPos.x);
|
||||||
|
crcForCmd.addInt(originalPos.y);
|
||||||
|
crcForCmd.addInt(pos.x);
|
||||||
|
crcForCmd.addInt(pos.y);
|
||||||
|
crcForCmd.addInt(unitRef.getUnitId());
|
||||||
|
crcForCmd.addInt(facing);
|
||||||
|
if(unitType != NULL) {
|
||||||
|
crcForCmd.addInt(unitType->getId());
|
||||||
|
}
|
||||||
|
crcForCmd.addInt(stateType);
|
||||||
|
crcForCmd.addInt(stateValue);
|
||||||
|
crcForCmd.addInt(unitCommandGroupId);
|
||||||
|
|
||||||
|
return crcForCmd;
|
||||||
|
}
|
||||||
|
|
||||||
void Command::saveGame(XmlNode *rootNode, Faction *faction) {
|
void Command::saveGame(XmlNode *rootNode, Faction *faction) {
|
||||||
std::map<string,string> mapTagReplacements;
|
std::map<string,string> mapTagReplacements;
|
||||||
XmlNode *commandNode = rootNode->addChild("Command");
|
XmlNode *commandNode = rootNode->addChild("Command");
|
||||||
|
|
|
@ -95,6 +95,8 @@ public:
|
||||||
|
|
||||||
void saveGame(XmlNode *rootNode, Faction *faction);
|
void saveGame(XmlNode *rootNode, Faction *faction);
|
||||||
static Command * loadGame(const XmlNode *rootNode,const UnitType *ut,World *world);
|
static Command * loadGame(const XmlNode *rootNode,const UnitType *ut,World *world);
|
||||||
|
|
||||||
|
Checksum getCRC();
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -2300,13 +2300,19 @@ Checksum Faction::getCRC() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Faction::addCRC_DetailsForWorldFrame(int worldFrameCount,bool isNetworkServer) {
|
void Faction::addCRC_DetailsForWorldFrame(int worldFrameCount,bool isNetworkServer) {
|
||||||
int MAX_FRAME_CACHE = 1500;
|
int MAX_FRAME_CACHE = 250;
|
||||||
if(isNetworkServer == true) {
|
if(isNetworkServer == true) {
|
||||||
MAX_FRAME_CACHE += 700;
|
MAX_FRAME_CACHE += 250;
|
||||||
}
|
}
|
||||||
crcWorldFrameDetails[worldFrameCount] = this->toString(true);
|
crcWorldFrameDetails[worldFrameCount] = this->toString(true);
|
||||||
//if(worldFrameCount <= 0) printf("Adding world frame: %d log entries: %lld\n",worldFrameCount,(long long int)crcWorldFrameDetails.size());
|
//if(worldFrameCount <= 0) printf("Adding world frame: %d log entries: %lld\n",worldFrameCount,(long long int)crcWorldFrameDetails.size());
|
||||||
|
|
||||||
|
for(unsigned int i = 0; i < units.size(); ++i) {
|
||||||
|
Unit *unit = units[i];
|
||||||
|
unit->getRandom()->clearLastCaller();
|
||||||
|
unit->clearNetworkCRCDecHpList();
|
||||||
|
}
|
||||||
|
|
||||||
if(crcWorldFrameDetails.size() > MAX_FRAME_CACHE) {
|
if(crcWorldFrameDetails.size() > MAX_FRAME_CACHE) {
|
||||||
//printf("===> Removing older world frame log entries: %lld\n",(long long int)crcWorldFrameDetails.size());
|
//printf("===> Removing older world frame log entries: %lld\n",(long long int)crcWorldFrameDetails.size());
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,7 @@ void Object::initParticlesFromTypes(const ModelParticleSystemTypes *particleType
|
||||||
particleTypes->empty() == false && unitParticleSystems.empty() == true) {
|
particleTypes->empty() == false && unitParticleSystems.empty() == true) {
|
||||||
for(ObjectParticleSystemTypes::const_iterator it= particleTypes->begin(); it != particleTypes->end(); ++it){
|
for(ObjectParticleSystemTypes::const_iterator it= particleTypes->begin(); it != particleTypes->end(); ++it){
|
||||||
UnitParticleSystem *ups= new UnitParticleSystem(200);
|
UnitParticleSystem *ups= new UnitParticleSystem(200);
|
||||||
|
ups->setParticleOwner(this);
|
||||||
(*it)->setValues(ups);
|
(*it)->setValues(ups);
|
||||||
ups->setPos(this->pos);
|
ups->setPos(this->pos);
|
||||||
ups->setRotation(this->rotation);
|
ups->setRotation(this->rotation);
|
||||||
|
@ -117,6 +118,13 @@ void Object::initParticlesFromTypes(const ModelParticleSystemTypes *particleType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Object::end(ParticleSystem *particleSystem) {
|
||||||
|
vector<UnitParticleSystem *>::iterator iterFind = find(unitParticleSystems.begin(),unitParticleSystems.end(),particleSystem);
|
||||||
|
if(iterFind != unitParticleSystems.end()) {
|
||||||
|
unitParticleSystems.erase(iterFind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Object::setHeight(float height) {
|
void Object::setHeight(float height) {
|
||||||
pos.y=height;
|
pos.y=height;
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
virtual ~ObjectStateInterface() {}
|
virtual ~ObjectStateInterface() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Object : public BaseColorPickEntity {
|
class Object : public BaseColorPickEntity, public ParticleOwner {
|
||||||
private:
|
private:
|
||||||
typedef vector<UnitParticleSystem*> UnitParticleSystems;
|
typedef vector<UnitParticleSystem*> UnitParticleSystems;
|
||||||
|
|
||||||
|
@ -109,6 +109,8 @@ public:
|
||||||
virtual string getUniquePickName() const;
|
virtual string getUniquePickName() const;
|
||||||
void saveGame(XmlNode *rootNode);
|
void saveGame(XmlNode *rootNode);
|
||||||
void loadGame(const XmlNode *rootNode,const TechTree *techTree);
|
void loadGame(const XmlNode *rootNode,const TechTree *techTree);
|
||||||
|
|
||||||
|
virtual void end(ParticleSystem *particleSystem);
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -440,7 +440,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos,
|
||||||
|
|
||||||
//RandomGen random;
|
//RandomGen random;
|
||||||
random.init(id);
|
random.init(id);
|
||||||
pathFindRefreshCellCount = random.randRange(10,20);
|
pathFindRefreshCellCount = random.randRange(10,20,intToStr(__LINE__));
|
||||||
|
|
||||||
if(map->isInside(pos) == false || map->isInsideSurface(map->toSurfCoords(pos)) == false) {
|
if(map->isInside(pos) == false || map->isInsideSurface(map->toSurfCoords(pos)) == false) {
|
||||||
throw megaglest_runtime_error("#2 Invalid path position = " + pos.getString());
|
throw megaglest_runtime_error("#2 Invalid path position = " + pos.getString());
|
||||||
|
@ -498,7 +498,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos,
|
||||||
if (type->hasSkillClass(scBeBuilt) == false) {
|
if (type->hasSkillClass(scBeBuilt) == false) {
|
||||||
float rot= 0.f;
|
float rot= 0.f;
|
||||||
random.init(id);
|
random.init(id);
|
||||||
rot+= random.randRange(-5, 5);
|
rot+= random.randRange(-5, 5,intToStr(__LINE__));
|
||||||
rotation= rot;
|
rotation= rot;
|
||||||
lastRotation= rot;
|
lastRotation= rot;
|
||||||
targetRotation= rot;
|
targetRotation= rot;
|
||||||
|
@ -560,8 +560,6 @@ Unit::~Unit() {
|
||||||
Renderer::getInstance().cleanupParticleSystems(fireParticleSystems,rsGame);
|
Renderer::getInstance().cleanupParticleSystems(fireParticleSystems,rsGame);
|
||||||
// Must set this to null of it will be used below in stopDamageParticles()
|
// Must set this to null of it will be used below in stopDamageParticles()
|
||||||
|
|
||||||
Renderer::getInstance().cleanupParticleSystems(attackParticleSystems,rsGame);
|
|
||||||
|
|
||||||
if(Renderer::getInstance().validateParticleSystemStillExists(this->fire,rsGame) == false) {
|
if(Renderer::getInstance().validateParticleSystemStillExists(this->fire,rsGame) == false) {
|
||||||
this->fire = NULL;
|
this->fire = NULL;
|
||||||
}
|
}
|
||||||
|
@ -587,6 +585,8 @@ Unit::~Unit() {
|
||||||
delete currentAttackBoostOriginatorEffect.currentAppliedEffect;
|
delete currentAttackBoostOriginatorEffect.currentAppliedEffect;
|
||||||
currentAttackBoostOriginatorEffect.currentAppliedEffect = NULL;
|
currentAttackBoostOriginatorEffect.currentAppliedEffect = NULL;
|
||||||
|
|
||||||
|
Renderer::getInstance().cleanupParticleSystems(attackParticleSystems,rsGame);
|
||||||
|
|
||||||
#ifdef LEAK_CHECK_UNITS
|
#ifdef LEAK_CHECK_UNITS
|
||||||
Unit::mapMemoryList2[this->unitPath] = this->getId();
|
Unit::mapMemoryList2[this->unitPath] = this->getId();
|
||||||
#endif
|
#endif
|
||||||
|
@ -1090,6 +1090,7 @@ void Unit::setCurrSkill(const SkillType *currSkill) {
|
||||||
//printf("Adding NON-queued particle system type [%s] [%f] [%f]\n",(*it)->getType().c_str(),(*it)->getStartTime(),(*it)->getEndTime());
|
//printf("Adding NON-queued particle system type [%s] [%f] [%f]\n",(*it)->getType().c_str(),(*it)->getStartTime(),(*it)->getEndTime());
|
||||||
|
|
||||||
UnitParticleSystem *ups = new UnitParticleSystem(200);
|
UnitParticleSystem *ups = new UnitParticleSystem(200);
|
||||||
|
ups->setParticleOwner(this);
|
||||||
(*it)->setValues(ups);
|
(*it)->setValues(ups);
|
||||||
ups->setPos(getCurrVector());
|
ups->setPos(getCurrVector());
|
||||||
if(getFaction()->getTexture()) {
|
if(getFaction()->getTexture()) {
|
||||||
|
@ -1286,15 +1287,15 @@ void Unit::setVisible(const bool visible) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(attackParticleSystems.empty() == false) {
|
//if(attackParticleSystems.empty() == false) {
|
||||||
for(vector<ParticleSystem*>::iterator it= attackParticleSystems.begin(); it != attackParticleSystems.end(); ++it) {
|
// for(vector<ParticleSystem*>::iterator it= attackParticleSystems.begin(); it != attackParticleSystems.end(); ++it) {
|
||||||
if(Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame) == true) {
|
// if(Renderer::getInstance().validateParticleSystemStillExists((*it),rsGame) == true) {
|
||||||
// Not sure this is a good idea since the unit be not be visible but the attack particle might be.
|
// Not sure this is a good idea since the unit be not be visible but the attack particle might be.
|
||||||
// This means you won't see the attacking projectile until the unit moves into view.
|
// This means you won't see the attacking projectile until the unit moves into view.
|
||||||
//(*it)->setVisible(visible);
|
//(*it)->setVisible(visible);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
if(currentAttackBoostEffects.empty() == false) {
|
if(currentAttackBoostEffects.empty() == false) {
|
||||||
for(unsigned int i = 0; i < currentAttackBoostEffects.size(); ++i) {
|
for(unsigned int i = 0; i < currentAttackBoostEffects.size(); ++i) {
|
||||||
|
@ -2106,6 +2107,7 @@ void Unit::updateAttackBoostProgress(const Game* game) {
|
||||||
//effect.upst = boost->unitParticleSystemTypeForAffectedUnit;
|
//effect.upst = boost->unitParticleSystemTypeForAffectedUnit;
|
||||||
|
|
||||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups = new UnitParticleSystem(200);
|
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups = new UnitParticleSystem(200);
|
||||||
|
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setParticleOwner(this);
|
||||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->upst->setValues(
|
currentAttackBoostOriginatorEffect.currentAppliedEffect->upst->setValues(
|
||||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups);
|
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups);
|
||||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setPos(
|
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setPos(
|
||||||
|
@ -2213,6 +2215,7 @@ void Unit::updateAttackBoostProgress(const Game* game) {
|
||||||
//effect.upst = boost->unitParticleSystemTypeForAffectedUnit;
|
//effect.upst = boost->unitParticleSystemTypeForAffectedUnit;
|
||||||
|
|
||||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups = new UnitParticleSystem(200);
|
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups = new UnitParticleSystem(200);
|
||||||
|
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setParticleOwner(this);
|
||||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->upst->setValues(
|
currentAttackBoostOriginatorEffect.currentAppliedEffect->upst->setValues(
|
||||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups);
|
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups);
|
||||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setPos(
|
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setPos(
|
||||||
|
@ -2466,6 +2469,7 @@ void Unit::updateTimedParticles() {
|
||||||
//printf("STARTING queued particle system type [%s] [%f] [%f] [%f] [%f]\n",pst->getType().c_str(),truncateDecimal<float>(pst->getStartTime()),truncateDecimal<float>(pst->getEndTime()),truncateDecimal<float>(animProgress),truncateDecimal<float>(lastAnimProgress));
|
//printf("STARTING queued particle system type [%s] [%f] [%f] [%f] [%f]\n",pst->getType().c_str(),truncateDecimal<float>(pst->getStartTime()),truncateDecimal<float>(pst->getEndTime()),truncateDecimal<float>(animProgress),truncateDecimal<float>(lastAnimProgress));
|
||||||
|
|
||||||
UnitParticleSystem *ups = new UnitParticleSystem(200);
|
UnitParticleSystem *ups = new UnitParticleSystem(200);
|
||||||
|
ups->setParticleOwner(this);
|
||||||
pst->setValues(ups);
|
pst->setValues(ups);
|
||||||
ups->setPos(getCurrVector());
|
ups->setPos(getCurrVector());
|
||||||
if(getFaction()->getTexture()) {
|
if(getFaction()->getTexture()) {
|
||||||
|
@ -2602,6 +2606,7 @@ bool Unit::applyAttackBoost(const AttackBoost *boost, const Unit *source) {
|
||||||
//effect.upst = boost->unitParticleSystemTypeForAffectedUnit;
|
//effect.upst = boost->unitParticleSystemTypeForAffectedUnit;
|
||||||
|
|
||||||
effect->ups = new UnitParticleSystem(200);
|
effect->ups = new UnitParticleSystem(200);
|
||||||
|
effect->ups->setParticleOwner(this);
|
||||||
effect->upst->setValues(effect->ups);
|
effect->upst->setValues(effect->ups);
|
||||||
effect->ups->setPos(getCurrVector());
|
effect->ups->setPos(getCurrVector());
|
||||||
if(getFaction()->getTexture()) {
|
if(getFaction()->getTexture()) {
|
||||||
|
@ -2973,14 +2978,18 @@ bool Unit::repair(){
|
||||||
}
|
}
|
||||||
|
|
||||||
//decrements HP and returns if dead
|
//decrements HP and returns if dead
|
||||||
bool Unit::decHp(int i) {
|
bool Unit::decHp(int decrementValue) {
|
||||||
|
char szBuf[8096]="";
|
||||||
|
snprintf(szBuf,8095,"this->hp = %d, decrementValue = %d",this->hp,decrementValue);
|
||||||
|
addNetworkCRCDecHp(szBuf);
|
||||||
|
|
||||||
if(this->hp == 0) {
|
if(this->hp == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkItemInVault(&this->hp,this->hp);
|
checkItemInVault(&this->hp,this->hp);
|
||||||
int original_hp = this->hp;
|
int original_hp = this->hp;
|
||||||
this->hp -= i;
|
this->hp -= decrementValue;
|
||||||
if(original_hp != this->hp) {
|
if(original_hp != this->hp) {
|
||||||
//printf("File: %s line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);
|
//printf("File: %s line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);
|
||||||
game->getScriptManager()->onUnitTriggerEvent(this,utet_HPChanged);
|
game->getScriptManager()->onUnitTriggerEvent(this,utet_HPChanged);
|
||||||
|
@ -3724,6 +3733,7 @@ void Unit::checkCustomizedParticleTriggers(bool force) {
|
||||||
//printf("STARTING customized particle trigger by HP [%d to %d] current hp = %d\n",pst->getMinHp(),pst->getMaxHp(),hp);
|
//printf("STARTING customized particle trigger by HP [%d to %d] current hp = %d\n",pst->getMinHp(),pst->getMaxHp(),hp);
|
||||||
|
|
||||||
UnitParticleSystem *ups = new UnitParticleSystem(200);
|
UnitParticleSystem *ups = new UnitParticleSystem(200);
|
||||||
|
ups->setParticleOwner(this);
|
||||||
pst->setValues(ups);
|
pst->setValues(ups);
|
||||||
ups->setPos(getCurrVector());
|
ups->setPos(getCurrVector());
|
||||||
if(getFaction()->getTexture()) {
|
if(getFaction()->getTexture()) {
|
||||||
|
@ -3748,6 +3758,7 @@ void Unit::startDamageParticles() {
|
||||||
|
|
||||||
if(pst->getMinmaxEnabled() == false && damageParticleSystemsInUse.find(i) == damageParticleSystemsInUse.end()) {
|
if(pst->getMinmaxEnabled() == false && damageParticleSystemsInUse.find(i) == damageParticleSystemsInUse.end()) {
|
||||||
UnitParticleSystem *ups = new UnitParticleSystem(200);
|
UnitParticleSystem *ups = new UnitParticleSystem(200);
|
||||||
|
ups->setParticleOwner(this);
|
||||||
pst->setValues(ups);
|
pst->setValues(ups);
|
||||||
ups->setPos(getCurrVector());
|
ups->setPos(getCurrVector());
|
||||||
if(getFaction()->getTexture()) {
|
if(getFaction()->getTexture()) {
|
||||||
|
@ -3763,6 +3774,7 @@ void Unit::startDamageParticles() {
|
||||||
// start fire
|
// start fire
|
||||||
if(type->getProperty(UnitType::pBurnable) && this->fire == NULL) {
|
if(type->getProperty(UnitType::pBurnable) && this->fire == NULL) {
|
||||||
FireParticleSystem *fps = new FireParticleSystem(200);
|
FireParticleSystem *fps = new FireParticleSystem(200);
|
||||||
|
fps->setParticleOwner(this);
|
||||||
const Game *game = Renderer::getInstance().getGame();
|
const Game *game = Renderer::getInstance().getGame();
|
||||||
fps->setSpeed(2.5f / game->getWorld()->getUpdateFps(this->getFactionIndex()));
|
fps->setSpeed(2.5f / game->getWorld()->getUpdateFps(this->getFactionIndex()));
|
||||||
fps->setPos(getCurrVector());
|
fps->setPos(getCurrVector());
|
||||||
|
@ -3776,6 +3788,7 @@ void Unit::startDamageParticles() {
|
||||||
if(showUnitParticles == true) {
|
if(showUnitParticles == true) {
|
||||||
// smoke
|
// smoke
|
||||||
UnitParticleSystem *ups= new UnitParticleSystem(400);
|
UnitParticleSystem *ups= new UnitParticleSystem(400);
|
||||||
|
ups->setParticleOwner(this);
|
||||||
ups->setColorNoEnergy(Vec4f(0.0f, 0.0f, 0.0f, 0.13f));
|
ups->setColorNoEnergy(Vec4f(0.0f, 0.0f, 0.0f, 0.13f));
|
||||||
ups->setColor(Vec4f(0.115f, 0.115f, 0.115f, 0.22f));
|
ups->setColor(Vec4f(0.115f, 0.115f, 0.115f, 0.22f));
|
||||||
ups->setPos(getCurrVector());
|
ups->setPos(getCurrVector());
|
||||||
|
@ -4017,15 +4030,25 @@ void Unit::setLastStuckFrameToCurrentFrame() {
|
||||||
lastStuckFrame = getFrameCount();
|
lastStuckFrame = getFrameCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Unit::isLastStuckFrameWithinCurrentFrameTolerance() {
|
bool Unit::isLastStuckFrameWithinCurrentFrameTolerance(bool evalMode) {
|
||||||
//const int MIN_FRAME_ELAPSED_RETRY = 300;
|
//const int MIN_FRAME_ELAPSED_RETRY = 300;
|
||||||
const int MAX_BLOCKED_FRAME_THRESHOLD = 25000;
|
const int MAX_BLOCKED_FRAME_THRESHOLD = 25000;
|
||||||
int MIN_FRAME_ELAPSED_RETRY = 6;
|
int MIN_FRAME_ELAPSED_RETRY = 6;
|
||||||
if(lastStuckFrame < MAX_BLOCKED_FRAME_THRESHOLD) {
|
if(lastStuckFrame < MAX_BLOCKED_FRAME_THRESHOLD) {
|
||||||
MIN_FRAME_ELAPSED_RETRY = random.randRange(2,6);
|
if(evalMode == true) {
|
||||||
|
MIN_FRAME_ELAPSED_RETRY = 4;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MIN_FRAME_ELAPSED_RETRY = random.randRange(6,8);
|
MIN_FRAME_ELAPSED_RETRY = random.randRange(2,6,intToStr(__LINE__));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(evalMode == true) {
|
||||||
|
MIN_FRAME_ELAPSED_RETRY = 7;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MIN_FRAME_ELAPSED_RETRY = random.randRange(6,8,intToStr(__LINE__));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bool result (getFrameCount() - lastStuckFrame <= (MIN_FRAME_ELAPSED_RETRY * 100));
|
bool result (getFrameCount() - lastStuckFrame <= (MIN_FRAME_ELAPSED_RETRY * 100));
|
||||||
return result;
|
return result;
|
||||||
|
@ -4069,6 +4092,41 @@ bool Unit::showTranslatedTechTree() const {
|
||||||
return (this->game != NULL ? this->game->showTranslatedTechTree() : true);
|
return (this->game != NULL ? this->game->showTranslatedTechTree() : true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Unit::end(ParticleSystem *particleSystem) {
|
||||||
|
vector<ParticleSystem*>::iterator iterFind = find(attackParticleSystems.begin(),attackParticleSystems.end(),particleSystem);
|
||||||
|
if(iterFind != attackParticleSystems.end()) {
|
||||||
|
attackParticleSystems.erase(iterFind);
|
||||||
|
}
|
||||||
|
vector<UnitParticleSystem*>::iterator iterFind1 = find(smokeParticleSystems.begin(),smokeParticleSystems.end(),particleSystem);
|
||||||
|
if(iterFind1 != smokeParticleSystems.end()) {
|
||||||
|
smokeParticleSystems.erase(iterFind1);
|
||||||
|
}
|
||||||
|
iterFind = find(fireParticleSystems.begin(),fireParticleSystems.end(),particleSystem);
|
||||||
|
if(iterFind != fireParticleSystems.end()) {
|
||||||
|
fireParticleSystems.erase(iterFind);
|
||||||
|
}
|
||||||
|
iterFind1 = find(damageParticleSystems.begin(),damageParticleSystems.end(),particleSystem);
|
||||||
|
if(iterFind1 != damageParticleSystems.end()) {
|
||||||
|
damageParticleSystems.erase(iterFind1);
|
||||||
|
}
|
||||||
|
|
||||||
|
iterFind1 = find(unitParticleSystems.begin(),unitParticleSystems.end(),particleSystem);
|
||||||
|
if(iterFind1 != unitParticleSystems.end()) {
|
||||||
|
unitParticleSystems.erase(iterFind1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(particleSystem == fire) {
|
||||||
|
fire = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string Unit::getNetworkCRCDecHpList() const {
|
||||||
|
string result = "";
|
||||||
|
for(unsigned int index = 0; index < networkCRCDecHpList.size(); ++index) {
|
||||||
|
result += networkCRCDecHpList[index] + " ";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
std::string Unit::toString(bool crcMode) const {
|
std::string Unit::toString(bool crcMode) const {
|
||||||
std::string result = "";
|
std::string result = "";
|
||||||
|
|
||||||
|
@ -4165,6 +4223,17 @@ std::string Unit::toString(bool crcMode) const {
|
||||||
}
|
}
|
||||||
result += "\n";
|
result += "\n";
|
||||||
|
|
||||||
|
// int obsIdx = 0;
|
||||||
|
// for(Observers::const_iterator iterList = observers.begin(); iterList != observers.end(); ++iterList) {
|
||||||
|
// const UnitObserver *observer = *iterList;
|
||||||
|
// if(observer != NULL) {
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// obsIdx++;
|
||||||
|
// }
|
||||||
|
|
||||||
|
result += "\n";
|
||||||
|
|
||||||
result += "modelFacing = " + intToStr(modelFacing.asInt()) + "\n";
|
result += "modelFacing = " + intToStr(modelFacing.asInt()) + "\n";
|
||||||
|
|
||||||
result += "retryCurrCommandCount = " + intToStr(retryCurrCommandCount) + "\n";
|
result += "retryCurrCommandCount = " + intToStr(retryCurrCommandCount) + "\n";
|
||||||
|
@ -4176,8 +4245,32 @@ std::string Unit::toString(bool crcMode) const {
|
||||||
result += "inBailOutAttempt = " + intToStr(inBailOutAttempt) + "\n";
|
result += "inBailOutAttempt = " + intToStr(inBailOutAttempt) + "\n";
|
||||||
|
|
||||||
result += "random = " + intToStr(random.getLastNumber()) + "\n";
|
result += "random = " + intToStr(random.getLastNumber()) + "\n";
|
||||||
|
result += "randomlastCaller = " + random.getLastCaller() + "\n";
|
||||||
result += "pathFindRefreshCellCount = " + intToStr(pathFindRefreshCellCount) + "\n";
|
result += "pathFindRefreshCellCount = " + intToStr(pathFindRefreshCellCount) + "\n";
|
||||||
|
|
||||||
|
result += "lastStuckFrame = " + uIntToStr(lastStuckFrame) + "\n";
|
||||||
|
result += "lastStuckPos = " + lastStuckPos.getString() + "\n";
|
||||||
|
|
||||||
|
if(attackParticleSystems.size() > 0) {
|
||||||
|
result += "attackParticleSystems count = " + intToStr(attackParticleSystems.size()) + "\n";
|
||||||
|
}
|
||||||
|
if(networkCRCParticleLogInfo != "") {
|
||||||
|
result += "networkCRCParticleLogInfo = " + networkCRCParticleLogInfo + "\n";
|
||||||
|
}
|
||||||
|
result += "networkCRCParticleObserverLogInfo = " + networkCRCParticleObserverLogInfo + "\n";
|
||||||
|
if(networkCRCDecHpList.size() > 0) {
|
||||||
|
result += "getNetworkCRCDecHpList() = " + getNetworkCRCDecHpList() + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
for(unsigned int index = 0; index < attackParticleSystems.size(); ++index) {
|
||||||
|
ParticleSystem *ps = attackParticleSystems[index];
|
||||||
|
if(ps != NULL &&
|
||||||
|
Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
|
||||||
|
|
||||||
|
result += "attackParticleSystems #" + intToStr(index) + " = " + ps->toString() + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4649,6 +4742,7 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction *
|
||||||
if(unitNode->hasChild("FireParticleSystem") == true) {
|
if(unitNode->hasChild("FireParticleSystem") == true) {
|
||||||
XmlNode *fireNode = unitNode->getChild("FireParticleSystem");
|
XmlNode *fireNode = unitNode->getChild("FireParticleSystem");
|
||||||
result->fire = new FireParticleSystem();
|
result->fire = new FireParticleSystem();
|
||||||
|
result->fire->setParticleOwner(result);
|
||||||
result->fire->loadGame(fireNode);
|
result->fire->loadGame(fireNode);
|
||||||
//result->fire->setTexture(CoreData::getInstance().getFireTexture());
|
//result->fire->setTexture(CoreData::getInstance().getFireTexture());
|
||||||
result->fireParticleSystems.push_back(result->fire);
|
result->fireParticleSystems.push_back(result->fire);
|
||||||
|
@ -4696,6 +4790,7 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction *
|
||||||
XmlNode *node = unitParticleSystemNodeList[i];
|
XmlNode *node = unitParticleSystemNodeList[i];
|
||||||
|
|
||||||
UnitParticleSystem *ups = new UnitParticleSystem();
|
UnitParticleSystem *ups = new UnitParticleSystem();
|
||||||
|
ups->setParticleOwner(result);
|
||||||
ups->loadGame(node);
|
ups->loadGame(node);
|
||||||
result->unitParticleSystems.push_back(ups);
|
result->unitParticleSystems.push_back(ups);
|
||||||
|
|
||||||
|
@ -4722,6 +4817,7 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction *
|
||||||
XmlNode *node = unitParticleSystemNodeList[i];
|
XmlNode *node = unitParticleSystemNodeList[i];
|
||||||
|
|
||||||
UnitParticleSystem *ups = new UnitParticleSystem();
|
UnitParticleSystem *ups = new UnitParticleSystem();
|
||||||
|
ups->setParticleOwner(result);
|
||||||
ups->loadGame(node);
|
ups->loadGame(node);
|
||||||
result->damageParticleSystems.push_back(ups);
|
result->damageParticleSystems.push_back(ups);
|
||||||
result->damageParticleSystemsInUse[i]=ups;
|
result->damageParticleSystemsInUse[i]=ups;
|
||||||
|
@ -4802,6 +4898,7 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction *
|
||||||
|
|
||||||
// printf("Load Smoke particle i = %d\n",i);
|
// printf("Load Smoke particle i = %d\n",i);
|
||||||
UnitParticleSystem *ups = new UnitParticleSystem();
|
UnitParticleSystem *ups = new UnitParticleSystem();
|
||||||
|
ups->setParticleOwner(result);
|
||||||
ups->loadGame(node);
|
ups->loadGame(node);
|
||||||
//ups->setTexture(CoreData::getInstance().getFireTexture());
|
//ups->setTexture(CoreData::getInstance().getFireTexture());
|
||||||
result->smokeParticleSystems.push_back(ups);
|
result->smokeParticleSystems.push_back(ups);
|
||||||
|
@ -5066,6 +5163,10 @@ Checksum Unit::getCRC() {
|
||||||
|
|
||||||
//Commands commands;
|
//Commands commands;
|
||||||
crcForUnit.addInt64((int64)commands.size());
|
crcForUnit.addInt64((int64)commands.size());
|
||||||
|
for(Commands::const_iterator it= commands.begin(); it != commands.end(); ++it) {
|
||||||
|
uint32 crc = (*it)->getCRC().getSum();
|
||||||
|
crcForUnit.addBytes(&crc,sizeof(uint32));
|
||||||
|
}
|
||||||
|
|
||||||
//printf("#11 Unit: %d CRC: %u observers.size(): %ld\n",id,crcForUnit.getSum(),observers.size());
|
//printf("#11 Unit: %d CRC: %u observers.size(): %ld\n",id,crcForUnit.getSum(),observers.size());
|
||||||
|
|
||||||
|
@ -5116,7 +5217,10 @@ Checksum Unit::getCRC() {
|
||||||
//bool ignoreCheckCommand;
|
//bool ignoreCheckCommand;
|
||||||
|
|
||||||
//uint32 lastStuckFrame;
|
//uint32 lastStuckFrame;
|
||||||
|
crcForUnit.addInt(lastStuckFrame);
|
||||||
//Vec2i lastStuckPos;
|
//Vec2i lastStuckPos;
|
||||||
|
crcForUnit.addInt(lastStuckPos.x);
|
||||||
|
crcForUnit.addInt(lastStuckPos.y);
|
||||||
|
|
||||||
//uint32 lastPathfindFailedFrame;
|
//uint32 lastPathfindFailedFrame;
|
||||||
//Vec2i lastPathfindFailedPos;
|
//Vec2i lastPathfindFailedPos;
|
||||||
|
@ -5155,6 +5259,16 @@ Checksum Unit::getCRC() {
|
||||||
|
|
||||||
if(consoleDebug) printf("#17 Unit: %d CRC: %u\n",id,crcForUnit.getSum());
|
if(consoleDebug) printf("#17 Unit: %d CRC: %u\n",id,crcForUnit.getSum());
|
||||||
|
|
||||||
|
crcForUnit.addInt64((int64)attackParticleSystems.size());
|
||||||
|
for(unsigned int index = 0; index < attackParticleSystems.size(); ++index) {
|
||||||
|
ParticleSystem *ps = attackParticleSystems[index];
|
||||||
|
if(ps != NULL &&
|
||||||
|
Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
|
||||||
|
uint32 crc = ps->getCRC().getSum();
|
||||||
|
crcForUnit.addBytes(&crc,sizeof(uint32));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return crcForUnit;
|
return crcForUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -320,7 +320,7 @@ public:
|
||||||
virtual void saveGame(XmlNode *rootNode);
|
virtual void saveGame(XmlNode *rootNode);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Unit : public BaseColorPickEntity, ValueCheckerVault {
|
class Unit : public BaseColorPickEntity, ValueCheckerVault, public ParticleOwner {
|
||||||
private:
|
private:
|
||||||
typedef list<Command*> Commands;
|
typedef list<Command*> Commands;
|
||||||
typedef list<UnitObserver*> Observers;
|
typedef list<UnitObserver*> Observers;
|
||||||
|
@ -477,6 +477,11 @@ private:
|
||||||
|
|
||||||
string networkCRCLogInfo;
|
string networkCRCLogInfo;
|
||||||
|
|
||||||
|
string networkCRCParticleLogInfo;
|
||||||
|
|
||||||
|
string networkCRCParticleObserverLogInfo;
|
||||||
|
vector<string> networkCRCDecHpList;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Unit(int id, UnitPathInterface *path, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map, CardinalDir placeFacing);
|
Unit(int id, UnitPathInterface *path, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map, CardinalDir placeFacing);
|
||||||
virtual ~Unit();
|
virtual ~Unit();
|
||||||
|
@ -744,7 +749,7 @@ public:
|
||||||
int64 getSpeedDenominator(int64 updateFPS);
|
int64 getSpeedDenominator(int64 updateFPS);
|
||||||
bool isChangedActiveCommand() const { return changedActiveCommand; }
|
bool isChangedActiveCommand() const { return changedActiveCommand; }
|
||||||
|
|
||||||
bool isLastStuckFrameWithinCurrentFrameTolerance();
|
bool isLastStuckFrameWithinCurrentFrameTolerance(bool evalMode);
|
||||||
inline uint32 getLastStuckFrame() const { return lastStuckFrame; }
|
inline uint32 getLastStuckFrame() const { return lastStuckFrame; }
|
||||||
inline void setLastStuckFrame(uint32 value) { lastStuckFrame = value; }
|
inline void setLastStuckFrame(uint32 value) { lastStuckFrame = value; }
|
||||||
void setLastStuckFrameToCurrentFrame();
|
void setLastStuckFrameToCurrentFrame();
|
||||||
|
@ -774,9 +779,19 @@ public:
|
||||||
|
|
||||||
void addAttackParticleSystem(ParticleSystem *ps);
|
void addAttackParticleSystem(ParticleSystem *ps);
|
||||||
|
|
||||||
|
void setNetworkCRCParticleLogInfo(string networkCRCParticleLogInfo) { this->networkCRCParticleLogInfo = networkCRCParticleLogInfo; }
|
||||||
|
void setNetworkCRCParticleObserverLogInfo(string networkCRCParticleObserverLogInfo) { this->networkCRCParticleObserverLogInfo = networkCRCParticleObserverLogInfo; }
|
||||||
|
|
||||||
|
void clearNetworkCRCDecHpList() { networkCRCDecHpList.clear(); }
|
||||||
|
|
||||||
Checksum getCRC();
|
Checksum getCRC();
|
||||||
|
|
||||||
|
virtual void end(ParticleSystem *particleSystem);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void addNetworkCRCDecHp(string info) { networkCRCDecHpList.push_back(info); }
|
||||||
|
string getNetworkCRCDecHpList() const;
|
||||||
|
|
||||||
float computeHeight(const Vec2i &pos) const;
|
float computeHeight(const Vec2i &pos) const;
|
||||||
void calculateXZRotation();
|
void calculateXZRotation();
|
||||||
void updateTarget();
|
void updateTarget();
|
||||||
|
|
|
@ -71,17 +71,17 @@ void DamageMultiplierTable::init(int attackTypeCount, int armorTypeCount){
|
||||||
this->armorTypeCount= armorTypeCount;
|
this->armorTypeCount= armorTypeCount;
|
||||||
|
|
||||||
int valueCount= attackTypeCount * armorTypeCount;
|
int valueCount= attackTypeCount * armorTypeCount;
|
||||||
values= new float[valueCount];
|
values= new double[valueCount];
|
||||||
for(int i=0; i<valueCount; ++i){
|
for(int i=0; i<valueCount; ++i){
|
||||||
values[i]= 1.f;
|
values[i]= 1.f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float DamageMultiplierTable::getDamageMultiplier(const AttackType *att, const ArmorType *art) const{
|
double DamageMultiplierTable::getDamageMultiplier(const AttackType *att, const ArmorType *art) const {
|
||||||
return values[attackTypeCount * art->getId() + att->getId()];
|
return values[attackTypeCount * art->getId() + att->getId()];
|
||||||
}
|
}
|
||||||
|
|
||||||
void DamageMultiplierTable::setDamageMultiplier(const AttackType *att, const ArmorType *art, float value){
|
void DamageMultiplierTable::setDamageMultiplier(const AttackType *att, const ArmorType *art, double value) {
|
||||||
values[attackTypeCount * art->getId() + att->getId()] = value;
|
values[attackTypeCount * art->getId() + att->getId()] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ void DamageMultiplierTable::saveGame(XmlNode *rootNode) {
|
||||||
int valueCount= attackTypeCount * armorTypeCount;
|
int valueCount= attackTypeCount * armorTypeCount;
|
||||||
for(unsigned int i=0; i < valueCount; ++i) {
|
for(unsigned int i=0; i < valueCount; ++i) {
|
||||||
XmlNode *valuesNode = damageMultiplierTableNode->addChild("values");
|
XmlNode *valuesNode = damageMultiplierTableNode->addChild("values");
|
||||||
valuesNode->addAttribute("value",intToStr(values[i]), mapTagReplacements);
|
valuesNode->addAttribute("value",doubleToStr(values[i]), mapTagReplacements);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
|
|
||||||
class DamageMultiplierTable {
|
class DamageMultiplierTable {
|
||||||
private:
|
private:
|
||||||
float *values;
|
double *values;
|
||||||
int attackTypeCount;
|
int attackTypeCount;
|
||||||
int armorTypeCount;
|
int armorTypeCount;
|
||||||
|
|
||||||
|
@ -88,8 +88,8 @@ public:
|
||||||
~DamageMultiplierTable();
|
~DamageMultiplierTable();
|
||||||
|
|
||||||
void init(int attackTypeCount, int armorTypeCount);
|
void init(int attackTypeCount, int armorTypeCount);
|
||||||
float getDamageMultiplier(const AttackType *att, const ArmorType *art) const;
|
double getDamageMultiplier(const AttackType *att, const ArmorType *art) const;
|
||||||
void setDamageMultiplier(const AttackType *att, const ArmorType *art, float value);
|
void setDamageMultiplier(const AttackType *att, const ArmorType *art, double value);
|
||||||
|
|
||||||
void saveGame(XmlNode *rootNode);
|
void saveGame(XmlNode *rootNode);
|
||||||
};
|
};
|
||||||
|
|
|
@ -238,7 +238,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
||||||
const XmlNode *damageMultiplierNode= damageMultipliersNode->getChild("damage-multiplier", i);
|
const XmlNode *damageMultiplierNode= damageMultipliersNode->getChild("damage-multiplier", i);
|
||||||
const AttackType *attackType= getAttackType(damageMultiplierNode->getAttribute("attack")->getRestrictedValue());
|
const AttackType *attackType= getAttackType(damageMultiplierNode->getAttribute("attack")->getRestrictedValue());
|
||||||
const ArmorType *armorType= getArmorType(damageMultiplierNode->getAttribute("armor")->getRestrictedValue());
|
const ArmorType *armorType= getArmorType(damageMultiplierNode->getAttribute("armor")->getRestrictedValue());
|
||||||
float multiplier= damageMultiplierNode->getAttribute("value")->getFloatValue();
|
double multiplier= damageMultiplierNode->getAttribute("value")->getFloatValue();
|
||||||
damageMultiplierTable.setDamageMultiplier(attackType, armorType, multiplier);
|
damageMultiplierTable.setDamageMultiplier(attackType, armorType, multiplier);
|
||||||
|
|
||||||
Window::handleEvent();
|
Window::handleEvent();
|
||||||
|
@ -446,7 +446,7 @@ const AttackType *TechTree::getAttackType(const string &name) const{
|
||||||
throw megaglest_runtime_error("Attack Type not found: "+name);
|
throw megaglest_runtime_error("Attack Type not found: "+name);
|
||||||
}
|
}
|
||||||
|
|
||||||
float TechTree::getDamageMultiplier(const AttackType *att, const ArmorType *art) const{
|
double TechTree::getDamageMultiplier(const AttackType *att, const ArmorType *art) const {
|
||||||
return damageMultiplierTable.getDamageMultiplier(att, art);
|
return damageMultiplierTable.getDamageMultiplier(att, art);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ public:
|
||||||
int getAttackTypeCount() const { return attackTypes.size(); }
|
int getAttackTypeCount() const { return attackTypes.size(); }
|
||||||
const AttackType * getAttackTypeByIndex(int index) const { return &attackTypes[index]; }
|
const AttackType * getAttackTypeByIndex(int index) const { return &attackTypes[index]; }
|
||||||
|
|
||||||
float getDamageMultiplier(const AttackType *att, const ArmorType *art) const;
|
double getDamageMultiplier(const AttackType *att, const ArmorType *art) const;
|
||||||
std::vector<std::string> validateFactionTypes();
|
std::vector<std::string> validateFactionTypes();
|
||||||
std::vector<std::string> validateResourceTypes();
|
std::vector<std::string> validateResourceTypes();
|
||||||
|
|
||||||
|
|
|
@ -137,8 +137,16 @@ bool UnitUpdater::updateUnit(Unit *unit) {
|
||||||
//start attack particle system
|
//start attack particle system
|
||||||
if(unit->getCurrSkill()->getClass() == scAttack) {
|
if(unit->getCurrSkill()->getClass() == scAttack) {
|
||||||
const AttackSkillType *ast= static_cast<const AttackSkillType*>(unit->getCurrSkill());
|
const AttackSkillType *ast= static_cast<const AttackSkillType*>(unit->getCurrSkill());
|
||||||
float attackStartTime= ast->getAttackStartTime();
|
double attackStartTime = truncateDecimal<double>(ast->getAttackStartTime());
|
||||||
if(attackStartTime>=unit->getLastAnimProgressAsFloat() && attackStartTime<unit->getAnimProgressAsFloat()){
|
double lastAnimProgress = truncateDecimal<double>(unit->getLastAnimProgressAsFloat());
|
||||||
|
double animProgress = truncateDecimal<double>(attackStartTime < unit->getAnimProgressAsFloat());
|
||||||
|
bool startAttackParticleSystemNow = (attackStartTime >= lastAnimProgress && attackStartTime < animProgress);
|
||||||
|
|
||||||
|
char szBuf[8096]="";
|
||||||
|
snprintf(szBuf,8095,"attackStartTime = %f, lastAnimProgress = %f, animProgress = %f startAttackParticleSystemNow = %d",attackStartTime,lastAnimProgress,animProgress,startAttackParticleSystemNow);
|
||||||
|
unit->setNetworkCRCParticleLogInfo(szBuf);
|
||||||
|
|
||||||
|
if(startAttackParticleSystemNow == true) {
|
||||||
startAttackParticleSystem(unit);
|
startAttackParticleSystem(unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2184,23 +2192,26 @@ void UnitUpdater::updateSwitchTeam(Unit *unit, int frameIndex) {
|
||||||
// ==================== attack ====================
|
// ==================== attack ====================
|
||||||
|
|
||||||
void UnitUpdater::hit(Unit *attacker){
|
void UnitUpdater::hit(Unit *attacker){
|
||||||
hit(attacker, static_cast<const AttackSkillType*>(attacker->getCurrSkill()), attacker->getTargetPos(), attacker->getTargetField());
|
hit(attacker, dynamic_cast<const AttackSkillType*>(attacker->getCurrSkill()), attacker->getTargetPos(), attacker->getTargetField());
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitUpdater::hit(Unit *attacker, const AttackSkillType* ast, const Vec2i &targetPos, Field targetField){
|
void UnitUpdater::hit(Unit *attacker, const AttackSkillType* ast, const Vec2i &targetPos, Field targetField){
|
||||||
//hit attack positions
|
//hit attack positions
|
||||||
if(ast->getSplash()){
|
if(ast != NULL && ast->getSplash()){
|
||||||
PosCircularIterator pci(map, targetPos, ast->getSplashRadius());
|
PosCircularIterator pci(map, targetPos, ast->getSplashRadius());
|
||||||
while(pci.next()) {
|
while(pci.next()) {
|
||||||
Unit *attacked= map->getCell(pci.getPos())->getUnit(targetField);
|
Unit *attacked= map->getCell(pci.getPos())->getUnit(targetField);
|
||||||
if(attacked != NULL) {
|
if(attacked != NULL) {
|
||||||
if(ast->getSplashDamageAll()
|
if(ast->getSplashDamageAll() ||
|
||||||
|| attacker->isAlly(attacked) == false
|
attacker->isAlly(attacked) == false ||
|
||||||
|| ( targetPos.x==pci.getPos().x && targetPos.y==pci.getPos().y )) {
|
( targetPos.x == pci.getPos().x && targetPos.y == pci.getPos().y )) {
|
||||||
|
|
||||||
attacker->setLastAttackedUnitId(attacked->getId());
|
attacker->setLastAttackedUnitId(attacked->getId());
|
||||||
scriptManager->onUnitAttacking(attacker);
|
scriptManager->onUnitAttacking(attacker);
|
||||||
|
|
||||||
damage(attacker, ast, attacked, pci.getPos().dist(targetPos));
|
double distance = pci.getPos().dist(targetPos);
|
||||||
|
distance = truncateDecimal<double>(distance);
|
||||||
|
damage(attacker, ast, attacked, distance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2229,22 +2240,25 @@ void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attac
|
||||||
int var = ast->getAttackVar();
|
int var = ast->getAttackVar();
|
||||||
int armor = attacked->getType()->getTotalArmor(attacked->getTotalUpgrade());
|
int armor = attacked->getType()->getTotalArmor(attacked->getTotalUpgrade());
|
||||||
double damageMultiplier = world->getTechTree()->getDamageMultiplier(ast->getAttackType(), attacked->getType()->getArmorType());
|
double damageMultiplier = world->getTechTree()->getDamageMultiplier(ast->getAttackType(), attacked->getType()->getArmorType());
|
||||||
|
damageMultiplier = truncateDecimal<double>(damageMultiplier);
|
||||||
|
|
||||||
//compute damage
|
//compute damage
|
||||||
//damage += random.randRange(-var, var);
|
//damage += random.randRange(-var, var);
|
||||||
damage += attacker->getRandom()->randRange(-var, var);
|
damage += attacker->getRandom()->randRange(-var, var, string(__FILE__) + intToStr(__LINE__));
|
||||||
damage /= distance+1;
|
damage /= distance+1;
|
||||||
damage -= armor;
|
damage -= armor;
|
||||||
damage *= damageMultiplier;
|
damage *= damageMultiplier;
|
||||||
|
damageMultiplier = truncateDecimal<double>(damageMultiplier);
|
||||||
|
|
||||||
if(damage < 1) {
|
if(damage < 1) {
|
||||||
damage= 1;
|
damage= 1;
|
||||||
}
|
}
|
||||||
|
int damageVal = static_cast<int>(damage);
|
||||||
|
|
||||||
attacked->setLastAttackerUnitId(attacker->getId());
|
attacked->setLastAttackerUnitId(attacker->getId());
|
||||||
|
|
||||||
//damage the unit
|
//damage the unit
|
||||||
if(attacked->decHp(static_cast<int>(damage))) {
|
if(attacked->decHp(damageVal)) {
|
||||||
world->getStats()->kill(attacker->getFactionIndex(), attacked->getFactionIndex(), attacker->getTeam() != attacked->getTeam(),attacked->getType()->getCountUnitDeathInStats(),attacked->getType()->getCountUnitKillInStats());
|
world->getStats()->kill(attacker->getFactionIndex(), attacked->getFactionIndex(), attacker->getTeam() != attacked->getTeam(),attacked->getType()->getCountUnitDeathInStats(),attacked->getType()->getCountUnitKillInStats());
|
||||||
if(attacked->getType()->getCountKillForUnitUpgrade() == true){
|
if(attacked->getType()->getCountKillForUnitUpgrade() == true){
|
||||||
attacker->incKills(attacked->getTeam());
|
attacker->incKills(attacked->getTeam());
|
||||||
|
@ -2274,7 +2288,10 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){
|
||||||
|
|
||||||
ProjectileParticleSystem *psProj = 0;
|
ProjectileParticleSystem *psProj = 0;
|
||||||
|
|
||||||
const AttackSkillType *ast= static_cast<const AttackSkillType*>(unit->getCurrSkill());
|
const AttackSkillType *ast= dynamic_cast<const AttackSkillType*>(unit->getCurrSkill());
|
||||||
|
if(ast == NULL) {
|
||||||
|
throw megaglest_runtime_error("Start attack particle ast == NULL!");
|
||||||
|
}
|
||||||
ParticleSystemTypeProjectile *pstProj= ast->getProjParticleType();
|
ParticleSystemTypeProjectile *pstProj= ast->getProjParticleType();
|
||||||
ParticleSystemTypeSplash *pstSplash= ast->getSplashParticleType();
|
ParticleSystemTypeSplash *pstSplash= ast->getSplashParticleType();
|
||||||
|
|
||||||
|
@ -2291,7 +2308,7 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){
|
||||||
|
|
||||||
//projectile
|
//projectile
|
||||||
if(pstProj!=NULL){
|
if(pstProj!=NULL){
|
||||||
psProj= pstProj->create();
|
psProj= pstProj->create(unit);
|
||||||
psProj->setPath(startPos, endPos);
|
psProj->setPath(startPos, endPos);
|
||||||
psProj->setObserver(new ParticleDamager(unit, this, gameCamera));
|
psProj->setObserver(new ParticleDamager(unit, this, gameCamera));
|
||||||
psProj->setVisible(visible);
|
psProj->setVisible(visible);
|
||||||
|
@ -2307,7 +2324,7 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){
|
||||||
|
|
||||||
//splash
|
//splash
|
||||||
if(pstSplash != NULL) {
|
if(pstSplash != NULL) {
|
||||||
SplashParticleSystem *psSplash= pstSplash->create();
|
SplashParticleSystem *psSplash= pstSplash->create(unit);
|
||||||
psSplash->setPos(endPos);
|
psSplash->setPos(endPos);
|
||||||
psSplash->setVisible(visible);
|
psSplash->setVisible(visible);
|
||||||
if(unit->getFaction()->getTexture()) {
|
if(unit->getFaction()->getTexture()) {
|
||||||
|
@ -2551,8 +2568,8 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isUltra || isMega) {
|
if(evalMode == false && (isUltra || isMega)) {
|
||||||
if( attackingEnemySeen!=NULL && unit->getRandom()->randRange(0,2)!=2 ) {
|
if( attackingEnemySeen!=NULL && unit->getRandom()->randRange(0,2,string(__FILE__) + intToStr(__LINE__)) != 2 ) {
|
||||||
*rangedPtr = attackingEnemySeen;
|
*rangedPtr = attackingEnemySeen;
|
||||||
enemySeen = attackingEnemySeen;
|
enemySeen = attackingEnemySeen;
|
||||||
//printf("Da hat er wen gefunden:%s\n",enemySeen->getType()->getName(false).c_str());
|
//printf("Da hat er wen gefunden:%s\n",enemySeen->getType()->getName(false).c_str());
|
||||||
|
@ -2837,8 +2854,14 @@ void ParticleDamager::update(ParticleSystem *particleSystem) {
|
||||||
Unit *attacker= attackerRef.getUnit();
|
Unit *attacker= attackerRef.getUnit();
|
||||||
|
|
||||||
if(attacker != NULL) {
|
if(attacker != NULL) {
|
||||||
|
//string auditBeforeHit = particleSystem->toString();
|
||||||
|
|
||||||
unitUpdater->hit(attacker, ast, targetPos, targetField);
|
unitUpdater->hit(attacker, ast, targetPos, targetField);
|
||||||
|
|
||||||
|
//char szBuf[8096]="";
|
||||||
|
//snprintf(szBuf,8095,"ParticleDamager::update attacker particleSystem before: %s\nafter: %s",auditBeforeHit.c_str(),particleSystem->toString().c_str());
|
||||||
|
//attacker->setNetworkCRCParticleObserverLogInfo(szBuf);
|
||||||
|
|
||||||
//play sound
|
//play sound
|
||||||
StaticSound *projSound= ast->getProjSound();
|
StaticSound *projSound= ast->getProjSound();
|
||||||
if(particleSystem->getVisible() && projSound != NULL) {
|
if(particleSystem->getVisible() && projSound != NULL) {
|
||||||
|
|
|
@ -701,7 +701,7 @@ void World::updateAllFactionUnits() {
|
||||||
|
|
||||||
int unitBlockCount = unit->getPath()->getBlockCount();
|
int unitBlockCount = unit->getPath()->getBlockCount();
|
||||||
bool isStuck = unit->getPath()->isStuck();
|
bool isStuck = unit->getPath()->isStuck();
|
||||||
bool isStuckWithinTolerance = unit->isLastStuckFrameWithinCurrentFrameTolerance();
|
bool isStuckWithinTolerance = unit->isLastStuckFrameWithinCurrentFrameTolerance(false);
|
||||||
uint32 lastStuckFrame = unit->getLastStuckFrame();
|
uint32 lastStuckFrame = unit->getLastStuckFrame();
|
||||||
|
|
||||||
if(unitUpdater.updateUnit(unit) == true) {
|
if(unitUpdater.updateUnit(unit) == true) {
|
||||||
|
|
|
@ -83,6 +83,11 @@ public:
|
||||||
virtual void loadGame(const XmlNode *rootNode, void *genericData) = 0;
|
virtual void loadGame(const XmlNode *rootNode, void *genericData) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ParticleOwner {
|
||||||
|
public:
|
||||||
|
virtual void end(ParticleSystem *particleSystem)= 0;
|
||||||
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class ParticleSystem
|
// class ParticleSystem
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
@ -145,6 +150,7 @@ protected:
|
||||||
int alternations;
|
int alternations;
|
||||||
int particleSystemStartDelay;
|
int particleSystemStartDelay;
|
||||||
ParticleObserver *particleObserver;
|
ParticleObserver *particleObserver;
|
||||||
|
ParticleOwner *particleOwner;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//conmstructor and destructor
|
//conmstructor and destructor
|
||||||
|
@ -198,15 +204,21 @@ public:
|
||||||
virtual void fade();
|
virtual void fade();
|
||||||
int isEmpty() const;
|
int isEmpty() const;
|
||||||
|
|
||||||
|
virtual void setParticleOwner(ParticleOwner *particleOwner) { this->particleOwner = particleOwner;}
|
||||||
|
virtual ParticleOwner * getParticleOwner() { return this->particleOwner;}
|
||||||
|
virtual void callParticleOwnerEnd(ParticleSystem *particleSystem);
|
||||||
|
|
||||||
//children
|
//children
|
||||||
virtual int getChildCount() { return 0; }
|
virtual int getChildCount() { return 0; }
|
||||||
virtual ParticleSystem* getChild(int i);
|
virtual ParticleSystem* getChild(int i);
|
||||||
|
|
||||||
string toString() const;
|
virtual string toString() const;
|
||||||
|
|
||||||
virtual void saveGame(XmlNode *rootNode);
|
virtual void saveGame(XmlNode *rootNode);
|
||||||
virtual void loadGame(const XmlNode *rootNode);
|
virtual void loadGame(const XmlNode *rootNode);
|
||||||
|
|
||||||
|
virtual Checksum getCRC();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//protected
|
//protected
|
||||||
Particle *createParticle();
|
Particle *createParticle();
|
||||||
|
@ -242,6 +254,10 @@ public:
|
||||||
|
|
||||||
virtual void saveGame(XmlNode *rootNode);
|
virtual void saveGame(XmlNode *rootNode);
|
||||||
virtual void loadGame(const XmlNode *rootNode);
|
virtual void loadGame(const XmlNode *rootNode);
|
||||||
|
|
||||||
|
virtual string toString() const;
|
||||||
|
|
||||||
|
virtual Checksum getCRC();
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
@ -279,6 +295,10 @@ public:
|
||||||
virtual void saveGame(XmlNode *rootNode);
|
virtual void saveGame(XmlNode *rootNode);
|
||||||
virtual void loadGame(const XmlNode *rootNode);
|
virtual void loadGame(const XmlNode *rootNode);
|
||||||
|
|
||||||
|
virtual string toString() const;
|
||||||
|
|
||||||
|
virtual Checksum getCRC();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef std::vector<UnitParticleSystem*> Children;
|
typedef std::vector<UnitParticleSystem*> Children;
|
||||||
Children children;
|
Children children;
|
||||||
|
@ -390,6 +410,10 @@ public:
|
||||||
|
|
||||||
virtual void saveGame(XmlNode *rootNode);
|
virtual void saveGame(XmlNode *rootNode);
|
||||||
virtual void loadGame(const XmlNode *rootNode);
|
virtual void loadGame(const XmlNode *rootNode);
|
||||||
|
|
||||||
|
virtual string toString() const;
|
||||||
|
|
||||||
|
virtual Checksum getCRC();
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
@ -413,6 +437,10 @@ public:
|
||||||
|
|
||||||
void setRadius(float radius);
|
void setRadius(float radius);
|
||||||
void setWind(float windAngle, float windSpeed);
|
void setWind(float windAngle, float windSpeed);
|
||||||
|
|
||||||
|
virtual string toString() const;
|
||||||
|
|
||||||
|
virtual Checksum getCRC();
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
@ -434,6 +462,10 @@ public:
|
||||||
|
|
||||||
void setRadius(float radius);
|
void setRadius(float radius);
|
||||||
void setWind(float windAngle, float windSpeed);
|
void setWind(float windAngle, float windSpeed);
|
||||||
|
|
||||||
|
virtual string toString() const;
|
||||||
|
|
||||||
|
virtual Checksum getCRC();
|
||||||
};
|
};
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
@ -459,6 +491,10 @@ public:
|
||||||
|
|
||||||
virtual void saveGame(XmlNode *rootNode);
|
virtual void saveGame(XmlNode *rootNode);
|
||||||
virtual void loadGame(const XmlNode *rootNode);
|
virtual void loadGame(const XmlNode *rootNode);
|
||||||
|
|
||||||
|
virtual string toString() const;
|
||||||
|
|
||||||
|
virtual Checksum getCRC();
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
@ -488,12 +524,13 @@ private:
|
||||||
Vec3f zVector;
|
Vec3f zVector;
|
||||||
|
|
||||||
Trajectory trajectory;
|
Trajectory trajectory;
|
||||||
float trajectorySpeed;
|
double trajectorySpeed;
|
||||||
|
|
||||||
//parabolic
|
//parabolic
|
||||||
float trajectoryScale;
|
double trajectoryScale;
|
||||||
float trajectoryFrequency;
|
double trajectoryFrequency;
|
||||||
|
|
||||||
|
double arriveDestinationDistance;
|
||||||
void rotateChildren();
|
void rotateChildren();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -509,9 +546,9 @@ public:
|
||||||
virtual void updateParticle(Particle *p);
|
virtual void updateParticle(Particle *p);
|
||||||
|
|
||||||
void setTrajectory(Trajectory trajectory) {this->trajectory= trajectory;}
|
void setTrajectory(Trajectory trajectory) {this->trajectory= trajectory;}
|
||||||
void setTrajectorySpeed(float trajectorySpeed) {this->trajectorySpeed= trajectorySpeed;}
|
void setTrajectorySpeed(double trajectorySpeed) {this->trajectorySpeed= trajectorySpeed;}
|
||||||
void setTrajectoryScale(float trajectoryScale) {this->trajectoryScale= trajectoryScale;}
|
void setTrajectoryScale(double trajectoryScale) {this->trajectoryScale= trajectoryScale;}
|
||||||
void setTrajectoryFrequency(float trajectoryFrequency) {this->trajectoryFrequency= trajectoryFrequency;}
|
void setTrajectoryFrequency(double trajectoryFrequency) {this->trajectoryFrequency= trajectoryFrequency;}
|
||||||
|
|
||||||
void setPath(Vec3f startPos, Vec3f endPos);
|
void setPath(Vec3f startPos, Vec3f endPos);
|
||||||
|
|
||||||
|
@ -519,6 +556,10 @@ public:
|
||||||
|
|
||||||
virtual void saveGame(XmlNode *rootNode);
|
virtual void saveGame(XmlNode *rootNode);
|
||||||
virtual void loadGame(const XmlNode *rootNode);
|
virtual void loadGame(const XmlNode *rootNode);
|
||||||
|
|
||||||
|
virtual string toString() const;
|
||||||
|
|
||||||
|
virtual Checksum getCRC();
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
@ -532,13 +573,13 @@ public:
|
||||||
private:
|
private:
|
||||||
ProjectileParticleSystem *prevParticleSystem;
|
ProjectileParticleSystem *prevParticleSystem;
|
||||||
|
|
||||||
float emissionRateFade;
|
double emissionRateFade;
|
||||||
float verticalSpreadA;
|
double verticalSpreadA;
|
||||||
float verticalSpreadB;
|
double verticalSpreadB;
|
||||||
float horizontalSpreadA;
|
double horizontalSpreadA;
|
||||||
float horizontalSpreadB;
|
double horizontalSpreadB;
|
||||||
|
|
||||||
float startEmissionRate;
|
double startEmissionRate;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SplashParticleSystem(int particleCount= 1000);
|
SplashParticleSystem(int particleCount= 1000);
|
||||||
|
@ -550,15 +591,18 @@ public:
|
||||||
|
|
||||||
virtual void initParticleSystem();
|
virtual void initParticleSystem();
|
||||||
|
|
||||||
void setEmissionRateFade(float emissionRateFade) {this->emissionRateFade= emissionRateFade;}
|
void setEmissionRateFade(double emissionRateFade) {this->emissionRateFade= emissionRateFade;}
|
||||||
void setVerticalSpreadA(float verticalSpreadA) {this->verticalSpreadA= verticalSpreadA;}
|
void setVerticalSpreadA(double verticalSpreadA) {this->verticalSpreadA= verticalSpreadA;}
|
||||||
void setVerticalSpreadB(float verticalSpreadB) {this->verticalSpreadB= verticalSpreadB;}
|
void setVerticalSpreadB(double verticalSpreadB) {this->verticalSpreadB= verticalSpreadB;}
|
||||||
void setHorizontalSpreadA(float horizontalSpreadA) {this->horizontalSpreadA= horizontalSpreadA;}
|
void setHorizontalSpreadA(double horizontalSpreadA) {this->horizontalSpreadA= horizontalSpreadA;}
|
||||||
void setHorizontalSpreadB(float horizontalSpreadB) {this->horizontalSpreadB= horizontalSpreadB;}
|
void setHorizontalSpreadB(double horizontalSpreadB) {this->horizontalSpreadB= horizontalSpreadB;}
|
||||||
|
|
||||||
virtual void saveGame(XmlNode *rootNode);
|
virtual void saveGame(XmlNode *rootNode);
|
||||||
virtual void loadGame(const XmlNode *rootNode);
|
virtual void loadGame(const XmlNode *rootNode);
|
||||||
|
|
||||||
|
virtual string toString() const;
|
||||||
|
|
||||||
|
virtual Checksum getCRC();
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#ifndef _SHARED_UTIL_RANDOM_H_
|
#ifndef _SHARED_UTIL_RANDOM_H_
|
||||||
#define _SHARED_UTIL_RANDOM_H_
|
#define _SHARED_UTIL_RANDOM_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
namespace Shared { namespace Util {
|
namespace Shared { namespace Util {
|
||||||
|
@ -29,20 +31,25 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int lastNumber;
|
int lastNumber;
|
||||||
|
std::vector<std::string> lastCaller;
|
||||||
//#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
// streflop::RandomState randomState;
|
// streflop::RandomState randomState;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
|
int rand(std::string lastCaller);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RandomGen();
|
RandomGen();
|
||||||
void init(int seed);
|
void init(int seed);
|
||||||
|
|
||||||
int rand();
|
int randRange(int min, int max,std::string lastCaller="");
|
||||||
int randRange(int min, int max);
|
float randRange(float min, float max,std::string lastCaller="");
|
||||||
float randRange(float min, float max);
|
|
||||||
|
|
||||||
int getLastNumber() const { return lastNumber; }
|
int getLastNumber() const { return lastNumber; }
|
||||||
void setLastNumber(int value) { lastNumber = value; }
|
void setLastNumber(int value) { lastNumber = value; }
|
||||||
|
|
||||||
|
std::string getLastCaller() const;
|
||||||
|
void clearLastCaller() { lastCaller.clear(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -122,6 +122,8 @@ ParticleSystem::ParticleSystem(int particleCount) {
|
||||||
teamcolorEnergy= false;
|
teamcolorEnergy= false;
|
||||||
alternations= 0;
|
alternations= 0;
|
||||||
particleSystemStartDelay= 0;
|
particleSystemStartDelay= 0;
|
||||||
|
|
||||||
|
this->particleOwner = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleSystem::~ParticleSystem() {
|
ParticleSystem::~ParticleSystem() {
|
||||||
|
@ -138,6 +140,49 @@ ParticleSystem::~ParticleSystem(){
|
||||||
particleObserver = NULL;
|
particleObserver = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ParticleSystem::callParticleOwnerEnd(ParticleSystem *particleSystem) {
|
||||||
|
if(this->particleOwner != NULL) {
|
||||||
|
this->particleOwner->end(particleSystem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Checksum ParticleSystem::getCRC() {
|
||||||
|
Checksum crcForParticleSystem;
|
||||||
|
|
||||||
|
//std::vector<Particle> particles;
|
||||||
|
|
||||||
|
crcForParticleSystem.addInt(random.getLastNumber());
|
||||||
|
crcForParticleSystem.addInt(blendMode);
|
||||||
|
crcForParticleSystem.addInt(state);
|
||||||
|
crcForParticleSystem.addInt(active);
|
||||||
|
crcForParticleSystem.addInt(visible);
|
||||||
|
crcForParticleSystem.addInt(aliveParticleCount);
|
||||||
|
crcForParticleSystem.addInt(particleCount);
|
||||||
|
|
||||||
|
//string textureFileLoadDeferred;
|
||||||
|
//int textureFileLoadDeferredSystemId;
|
||||||
|
//Texture::Format textureFileLoadDeferredFormat;
|
||||||
|
//int textureFileLoadDeferredComponents;
|
||||||
|
|
||||||
|
//Texture *texture;
|
||||||
|
//Vec3f pos;
|
||||||
|
//Vec4f color;
|
||||||
|
//Vec4f colorNoEnergy;
|
||||||
|
//float emissionRate;
|
||||||
|
//float emissionState;
|
||||||
|
crcForParticleSystem.addInt(maxParticleEnergy);
|
||||||
|
crcForParticleSystem.addInt(varParticleEnergy);
|
||||||
|
//float particleSize;
|
||||||
|
//float speed;
|
||||||
|
//Vec3f factionColor;
|
||||||
|
crcForParticleSystem.addInt(teamcolorNoEnergy);
|
||||||
|
crcForParticleSystem.addInt(teamcolorEnergy);
|
||||||
|
crcForParticleSystem.addInt(alternations);
|
||||||
|
crcForParticleSystem.addInt(particleSystemStartDelay);
|
||||||
|
//ParticleObserver *particleObserver;
|
||||||
|
|
||||||
|
return crcForParticleSystem;
|
||||||
|
}
|
||||||
|
|
||||||
// =============== VIRTUAL ======================
|
// =============== VIRTUAL ======================
|
||||||
|
|
||||||
//updates all living particles and creates new ones
|
//updates all living particles and creates new ones
|
||||||
|
@ -261,7 +306,7 @@ void ParticleSystem::setVisible(bool visible){
|
||||||
}
|
}
|
||||||
|
|
||||||
string ParticleSystem::toString() const {
|
string ParticleSystem::toString() const {
|
||||||
string result = "";
|
string result = "ParticleSystem ";
|
||||||
|
|
||||||
result += "particles = " + intToStr(particles.size());
|
result += "particles = " + intToStr(particles.size());
|
||||||
|
|
||||||
|
@ -478,24 +523,29 @@ void ParticleSystem::loadGame(const XmlNode *rootNode) {
|
||||||
void ParticleSystem::fade(){
|
void ParticleSystem::fade(){
|
||||||
//printf("**************Fading particle System:\n[%s]\n",this->toString().c_str());
|
//printf("**************Fading particle System:\n[%s]\n",this->toString().c_str());
|
||||||
|
|
||||||
|
bool alreadyFading = (state == sFade);
|
||||||
if(particleObserver != NULL){
|
if(particleObserver != NULL){
|
||||||
if(state != sPlay) {
|
if(state != sPlay) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"state != sPlay, state = [%d]",state);
|
snprintf(szBuf,8096,"state != sPlay, state = [%d]\n",state);
|
||||||
//throw megaglest_runtime_error(szBuf);
|
//throw megaglest_runtime_error(szBuf);
|
||||||
//printf(szBuf);
|
//printf(szBuf);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,"%s",szBuf);
|
SystemFlags::OutputDebug(SystemFlags::debugError,"%s",szBuf);
|
||||||
}
|
}
|
||||||
assert(state == sPlay);
|
//assert(state == sPlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
state= sFade;
|
state= sFade;
|
||||||
|
if(alreadyFading == false) {
|
||||||
if(particleObserver != NULL){
|
if(particleObserver != NULL){
|
||||||
particleObserver->update(this);
|
particleObserver->update(this);
|
||||||
particleObserver=NULL;
|
particleObserver=NULL;
|
||||||
}
|
}
|
||||||
for(int i=getChildCount()-1; i>=0; i--)
|
for(int i=getChildCount()-1; i>=0; i--) {
|
||||||
getChild(i)->fade();
|
getChild(i)->fade();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int ParticleSystem::isEmpty() const{
|
int ParticleSystem::isEmpty() const{
|
||||||
assert(aliveParticleCount>=0);
|
assert(aliveParticleCount>=0);
|
||||||
|
@ -648,6 +698,15 @@ void FireParticleSystem::updateParticle(Particle *p){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string FireParticleSystem::toString() const {
|
||||||
|
string result = ParticleSystem::toString();
|
||||||
|
|
||||||
|
result += "\nFireParticleSystem ";
|
||||||
|
result += "\nradius = " + floatToStr(radius);
|
||||||
|
result += "\nwindSpeed = " + windSpeed.getString();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
// ================= SET PARAMS ====================
|
// ================= SET PARAMS ====================
|
||||||
|
|
||||||
void FireParticleSystem::setRadius(float radius){
|
void FireParticleSystem::setRadius(float radius){
|
||||||
|
@ -688,6 +747,15 @@ void FireParticleSystem::loadGame(const XmlNode *rootNode) {
|
||||||
windSpeed = Vec3f::strToVec3(fireParticleSystemNode->getAttribute("windSpeed")->getValue());
|
windSpeed = Vec3f::strToVec3(fireParticleSystemNode->getAttribute("windSpeed")->getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Checksum FireParticleSystem::getCRC() {
|
||||||
|
Checksum crcForParticleSystem = ParticleSystem::getCRC();
|
||||||
|
|
||||||
|
//float radius;
|
||||||
|
//Vec3f windSpeed;
|
||||||
|
|
||||||
|
return crcForParticleSystem;
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// GameParticleSystem
|
// GameParticleSystem
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
@ -863,6 +931,7 @@ void GameParticleSystem::loadGame(const XmlNode *rootNode) {
|
||||||
XmlNode *node = childrenNodeList[i];
|
XmlNode *node = childrenNodeList[i];
|
||||||
|
|
||||||
UnitParticleSystem *ups = new UnitParticleSystem();
|
UnitParticleSystem *ups = new UnitParticleSystem();
|
||||||
|
//ups->setParticleOwner(!!!);
|
||||||
ups->loadGame(node);
|
ups->loadGame(node);
|
||||||
|
|
||||||
//children.push_back(ups);
|
//children.push_back(ups);
|
||||||
|
@ -890,6 +959,29 @@ void GameParticleSystem::loadGame(const XmlNode *rootNode) {
|
||||||
tween = gameParticleSystemNode->getAttribute("tween")->getFloatValue();
|
tween = gameParticleSystemNode->getAttribute("tween")->getFloatValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Checksum GameParticleSystem::getCRC() {
|
||||||
|
Checksum crcForParticleSystem = ParticleSystem::getCRC();
|
||||||
|
|
||||||
|
return crcForParticleSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
string GameParticleSystem::toString() const {
|
||||||
|
string result = ParticleSystem::toString();
|
||||||
|
|
||||||
|
result += "\nGameParticleSystem ";
|
||||||
|
result += "\nchildren = " + intToStr(children.size());
|
||||||
|
result += "\nprimitive = " + intToStr(primitive);
|
||||||
|
|
||||||
|
//string modelFileLoadDeferred;
|
||||||
|
//Model *model;
|
||||||
|
result += "\nmodelCycle = " + floatToStr(modelCycle);
|
||||||
|
result += "\noffset = " + offset.getString();
|
||||||
|
result += "\ndirection = " + direction.getString();
|
||||||
|
result += "\ntween = " + floatToStr(tween);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// UnitParticleSystem
|
// UnitParticleSystem
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
@ -1291,11 +1383,50 @@ void UnitParticleSystem::loadGame(const XmlNode *rootNode) {
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Checksum UnitParticleSystem::getCRC() {
|
||||||
|
Checksum crcForParticleSystem = ParticleSystem::getCRC();
|
||||||
|
|
||||||
|
return crcForParticleSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
string UnitParticleSystem::toString() const {
|
||||||
|
string result = ParticleSystem::toString();
|
||||||
|
|
||||||
|
result += "\nUnitParticleSystem ";
|
||||||
|
result += "\nradius = " + floatToStr(radius);
|
||||||
|
result += "\nminRadius = " + floatToStr(minRadius);
|
||||||
|
result += "\nwindSpeed = " + windSpeed.getString();
|
||||||
|
result += "\ncRotation = " + cRotation.getString();
|
||||||
|
result += "\nfixedAddition = " + fixedAddition.getString();
|
||||||
|
result += "\noldPosition = " + oldPosition.getString();
|
||||||
|
result += "\nenergyUp = " + intToStr(energyUp);
|
||||||
|
result += "\nstartTime = " + floatToStr(startTime);
|
||||||
|
result += "\nendTime = " + floatToStr(endTime);
|
||||||
|
result += "\nrelative = " + intToStr(relative);
|
||||||
|
result += "\nrelativeDirection = " + intToStr(relativeDirection);
|
||||||
|
result += "\nfixed = " + intToStr(fixed);
|
||||||
|
result += "\nshape = " + intToStr(shape);
|
||||||
|
|
||||||
|
result += "\nangle = " + floatToStr(angle);
|
||||||
|
result += "\nsizeNoEnergy = " + floatToStr(sizeNoEnergy);
|
||||||
|
result += "\ngravity = " + floatToStr(gravity);
|
||||||
|
result += "\nrotation = " + floatToStr(rotation);
|
||||||
|
result += "\nisVisibleAtNight = " + intToStr(isVisibleAtNight);
|
||||||
|
result += "\nisVisibleAtDay = " + intToStr(isVisibleAtDay);
|
||||||
|
result += "\nisDaylightAffected = " + intToStr(isDaylightAffected);
|
||||||
|
result += "\nradiusBasedStartenergy = " + intToStr(radiusBasedStartenergy);
|
||||||
|
result += "\nstaticParticleCount = " + intToStr(staticParticleCount);
|
||||||
|
result += "\ndelay = " + intToStr(delay);
|
||||||
|
result += "\nlifetime = " + intToStr(lifetime);
|
||||||
|
result += "\nemissionRateFade = " + floatToStr(emissionRateFade);
|
||||||
|
//GameParticleSystem* parent;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// RainParticleSystem
|
// RainParticleSystem
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
|
|
||||||
RainParticleSystem::RainParticleSystem(int particleCount) :
|
RainParticleSystem::RainParticleSystem(int particleCount) :
|
||||||
ParticleSystem(particleCount){
|
ParticleSystem(particleCount){
|
||||||
setWind(0.0f, 0.0f);
|
setWind(0.0f, 0.0f);
|
||||||
|
@ -1346,6 +1477,22 @@ void RainParticleSystem::setWind(float windAngle, float windSpeed){
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Checksum RainParticleSystem::getCRC() {
|
||||||
|
Checksum crcForParticleSystem = ParticleSystem::getCRC();
|
||||||
|
|
||||||
|
return crcForParticleSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
string RainParticleSystem::toString() const {
|
||||||
|
string result = ParticleSystem::toString();
|
||||||
|
|
||||||
|
result += "\nRainParticleSystem ";
|
||||||
|
result += "\nwindSpeed = " + windSpeed.getString();
|
||||||
|
result += "\nradius = " + floatToStr(radius);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// SnowParticleSystem
|
// SnowParticleSystem
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
@ -1397,6 +1544,22 @@ void SnowParticleSystem::setWind(float windAngle, float windSpeed){
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Checksum SnowParticleSystem::getCRC() {
|
||||||
|
Checksum crcForParticleSystem = ParticleSystem::getCRC();
|
||||||
|
|
||||||
|
return crcForParticleSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
string SnowParticleSystem::toString() const {
|
||||||
|
string result = ParticleSystem::toString();
|
||||||
|
|
||||||
|
result += "\nSnowParticleSystem ";
|
||||||
|
result += "\nwindSpeed = " + windSpeed.getString();
|
||||||
|
result += "\nradius = " + floatToStr(radius);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// AttackParticleSystem
|
// AttackParticleSystem
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
@ -1431,6 +1594,22 @@ void AttackParticleSystem::loadGame(const XmlNode *rootNode) {
|
||||||
gravity = attackParticleSystemNode->getAttribute("gravity")->getFloatValue();
|
gravity = attackParticleSystemNode->getAttribute("gravity")->getFloatValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Checksum AttackParticleSystem::getCRC() {
|
||||||
|
Checksum crcForParticleSystem = ParticleSystem::getCRC();
|
||||||
|
|
||||||
|
return crcForParticleSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
string AttackParticleSystem::toString() const {
|
||||||
|
string result = ParticleSystem::toString();
|
||||||
|
|
||||||
|
result += "\nAttackParticleSystem ";
|
||||||
|
result += "\nsizeNoEnergy = " + floatToStr(sizeNoEnergy);
|
||||||
|
result += "\ngravity = " + floatToStr(gravity);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// ProjectileParticleSystem
|
// ProjectileParticleSystem
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
@ -1452,7 +1631,7 @@ ProjectileParticleSystem::ProjectileParticleSystem(int particleCount) :
|
||||||
modelCycle=0.0f;
|
modelCycle=0.0f;
|
||||||
|
|
||||||
nextParticleSystem= NULL;
|
nextParticleSystem= NULL;
|
||||||
|
arriveDestinationDistance = 0.0f;
|
||||||
//printf("#aXX trajectorySpeed = %f\n",trajectorySpeed);
|
//printf("#aXX trajectorySpeed = %f\n",trajectorySpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1474,12 +1653,24 @@ void ProjectileParticleSystem::update(){
|
||||||
if(state == sPlay){
|
if(state == sPlay){
|
||||||
|
|
||||||
lastPos = pos;
|
lastPos = pos;
|
||||||
flatPos+= zVector * trajectorySpeed;
|
flatPos += zVector * truncateDecimal<double>(trajectorySpeed);
|
||||||
|
flatPos.x = truncateDecimal<double>(flatPos.x);
|
||||||
|
flatPos.y = truncateDecimal<double>(flatPos.y);
|
||||||
|
flatPos.z = truncateDecimal<double>(flatPos.z);
|
||||||
|
|
||||||
Vec3f targetVector = endPos - startPos;
|
Vec3f targetVector = endPos - startPos;
|
||||||
|
targetVector.x = truncateDecimal<double>(targetVector.x);
|
||||||
|
targetVector.y = truncateDecimal<double>(targetVector.y);
|
||||||
|
targetVector.z = truncateDecimal<double>(targetVector.z);
|
||||||
|
|
||||||
Vec3f currentVector = flatPos - startPos;
|
Vec3f currentVector = flatPos - startPos;
|
||||||
|
currentVector.x = truncateDecimal<double>(currentVector.x);
|
||||||
|
currentVector.y = truncateDecimal<double>(currentVector.y);
|
||||||
|
currentVector.z = truncateDecimal<double>(currentVector.z);
|
||||||
|
|
||||||
// ratio
|
// ratio
|
||||||
float relative= clamp(currentVector.length() / targetVector.length(), 0.0f, 1.0f);
|
double relative= clamp(currentVector.length() / targetVector.length(), 0.0f, 1.0f);
|
||||||
|
relative = truncateDecimal<double>(relative);
|
||||||
|
|
||||||
//printf("Update particle targetVector [%s][%f] currentVector [%s][%f] relative = %f\n",targetVector.getString().c_str(),targetVector.length(),currentVector.getString().c_str(),currentVector.length(),relative);
|
//printf("Update particle targetVector [%s][%f] currentVector [%s][%f] relative = %f\n",targetVector.getString().c_str(),targetVector.length(),currentVector.getString().c_str(),currentVector.length(),relative);
|
||||||
|
|
||||||
|
@ -1502,11 +1693,12 @@ void ProjectileParticleSystem::update(){
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case tParabolic: {
|
case tParabolic: {
|
||||||
float scaledT= 2.0f * (relative - 0.5f);
|
double scaledT = truncateDecimal<double>(2.0f * (relative - 0.5f));
|
||||||
float paraboleY= (1.0f - scaledT * scaledT) * trajectoryScale;
|
double paraboleY = truncateDecimal<double>((1.0f - scaledT * scaledT) * trajectoryScale);
|
||||||
|
|
||||||
pos= flatPos;
|
pos= flatPos;
|
||||||
pos.y += paraboleY;
|
pos.y += paraboleY;
|
||||||
|
pos.y = truncateDecimal<double>(pos.y);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1519,6 +1711,9 @@ void ProjectileParticleSystem::update(){
|
||||||
pos+= xVector * cos(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale;
|
pos+= xVector * cos(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale;
|
||||||
pos+= yVector * sin(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale;
|
pos+= yVector * sin(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale;
|
||||||
#endif
|
#endif
|
||||||
|
pos.x = truncateDecimal<double>(pos.x);
|
||||||
|
pos.y = truncateDecimal<double>(pos.y);
|
||||||
|
pos.z = truncateDecimal<double>(pos.z);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1529,12 +1724,17 @@ void ProjectileParticleSystem::update(){
|
||||||
|
|
||||||
direction= pos - lastPos;
|
direction= pos - lastPos;
|
||||||
direction.normalize();
|
direction.normalize();
|
||||||
|
direction.x = truncateDecimal<double>(direction.x);
|
||||||
|
direction.y = truncateDecimal<double>(direction.y);
|
||||||
|
direction.z = truncateDecimal<double>(direction.z);
|
||||||
|
|
||||||
// trigger update of child particles
|
// trigger update of child particles
|
||||||
positionChildren();
|
positionChildren();
|
||||||
rotateChildren();
|
rotateChildren();
|
||||||
|
|
||||||
//arrive destination
|
//arrive destination
|
||||||
if(flatPos.dist(endPos) < 0.5f){
|
arriveDestinationDistance = truncateDecimal<double>(flatPos.dist(endPos));
|
||||||
|
if(arriveDestinationDistance < 0.5f) {
|
||||||
fade();
|
fade();
|
||||||
model= NULL;
|
model= NULL;
|
||||||
|
|
||||||
|
@ -1557,11 +1757,11 @@ void ProjectileParticleSystem::update(){
|
||||||
void ProjectileParticleSystem::rotateChildren() {
|
void ProjectileParticleSystem::rotateChildren() {
|
||||||
//### only on horizontal plane :(
|
//### only on horizontal plane :(
|
||||||
#ifdef USE_STREFLOP
|
#ifdef USE_STREFLOP
|
||||||
float rotation = streflop::atan2(static_cast<streflop::Simple>(direction.x), static_cast<streflop::Simple>(direction.z));
|
double rotation = truncateDecimal<double>(streflop::atan2(static_cast<streflop::Simple>(direction.x), static_cast<streflop::Simple>(direction.z)));
|
||||||
#else
|
#else
|
||||||
float rotation = atan2(direction.x, direction.z);
|
double rotation = truncateDecimal<double>(atan2(direction.x, direction.z));
|
||||||
#endif
|
#endif
|
||||||
rotation = radToDeg(rotation);
|
rotation = truncateDecimal<double>(radToDeg(rotation));
|
||||||
for(Children::iterator it = children.begin(); it != children.end(); ++it)
|
for(Children::iterator it = children.begin(); it != children.end(); ++it)
|
||||||
(*it)->setRotation(rotation);
|
(*it)->setRotation(rotation);
|
||||||
}
|
}
|
||||||
|
@ -1570,7 +1770,8 @@ void ProjectileParticleSystem::initParticle(Particle *p, int particleIndex){
|
||||||
|
|
||||||
ParticleSystem::initParticle(p, particleIndex);
|
ParticleSystem::initParticle(p, particleIndex);
|
||||||
|
|
||||||
float t= static_cast<float> (particleIndex) / emissionRate;
|
double t= static_cast<double> (particleIndex) / emissionRate;
|
||||||
|
t = truncateDecimal<double>(t);
|
||||||
|
|
||||||
p->pos= pos + (lastPos - pos) * t;
|
p->pos= pos + (lastPos - pos) * t;
|
||||||
p->lastPos= lastPos;
|
p->lastPos= lastPos;
|
||||||
|
@ -1582,7 +1783,8 @@ void ProjectileParticleSystem::initParticle(Particle *p, int particleIndex){
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectileParticleSystem::updateParticle(Particle *p){
|
void ProjectileParticleSystem::updateParticle(Particle *p){
|
||||||
float energyRatio= clamp(static_cast<float> (p->energy) / maxParticleEnergy, 0.f, 1.f);
|
double energyRatio= clamp(static_cast<double> (p->energy) / maxParticleEnergy, 0.f, 1.f);
|
||||||
|
energyRatio = truncateDecimal<double>(energyRatio);
|
||||||
|
|
||||||
p->lastPos+= p->speed;
|
p->lastPos+= p->speed;
|
||||||
p->pos+= p->speed;
|
p->pos+= p->speed;
|
||||||
|
@ -1688,6 +1890,7 @@ void ProjectileParticleSystem::loadGame(const XmlNode *rootNode) {
|
||||||
if(projectileParticleSystemNode->hasChild("SplashParticleSystem") == true) {
|
if(projectileParticleSystemNode->hasChild("SplashParticleSystem") == true) {
|
||||||
XmlNode *splashParticleSystemNode = projectileParticleSystemNode->getChild("SplashParticleSystem");
|
XmlNode *splashParticleSystemNode = projectileParticleSystemNode->getChild("SplashParticleSystem");
|
||||||
nextParticleSystem = new SplashParticleSystem();
|
nextParticleSystem = new SplashParticleSystem();
|
||||||
|
nextParticleSystem->setParticleOwner(this->getParticleOwner());
|
||||||
nextParticleSystem->loadGame(splashParticleSystemNode);
|
nextParticleSystem->loadGame(splashParticleSystemNode);
|
||||||
}
|
}
|
||||||
// Vec3f lastPos;
|
// Vec3f lastPos;
|
||||||
|
@ -1716,6 +1919,39 @@ void ProjectileParticleSystem::loadGame(const XmlNode *rootNode) {
|
||||||
trajectoryFrequency = projectileParticleSystemNode->getAttribute("trajectoryFrequency")->getFloatValue();
|
trajectoryFrequency = projectileParticleSystemNode->getAttribute("trajectoryFrequency")->getFloatValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Checksum ProjectileParticleSystem::getCRC() {
|
||||||
|
Checksum crcForParticleSystem = ParticleSystem::getCRC();
|
||||||
|
|
||||||
|
return crcForParticleSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
string ProjectileParticleSystem::toString() const {
|
||||||
|
string result = ParticleSystem::toString();
|
||||||
|
|
||||||
|
result += "\nProjectileParticleSystem ";
|
||||||
|
if(nextParticleSystem != NULL) {
|
||||||
|
//result += "\nnextParticleSystem = " + nextParticleSystem->toString() + "\n";
|
||||||
|
result += "\nnextParticleSystem = NOT NULL\n";
|
||||||
|
}
|
||||||
|
result += "\nlastPos = " + lastPos.getString();
|
||||||
|
result += "\nstartPos = " + startPos.getString();
|
||||||
|
result += "\nendPos = " + endPos.getString();
|
||||||
|
result += "\nflatPos = " + flatPos.getString();
|
||||||
|
|
||||||
|
result += "\nxVector = " + xVector.getString();
|
||||||
|
result += "\nyVector = " + yVector.getString();
|
||||||
|
result += "\nzVector = " + zVector.getString();
|
||||||
|
|
||||||
|
result += "\ntrajectory = " + intToStr(trajectory);
|
||||||
|
result += "\ntrajectorySpeed = " + doubleToStr(trajectorySpeed);
|
||||||
|
result += "\ntrajectoryScale = " + doubleToStr(trajectoryScale);
|
||||||
|
result += "\ntrajectoryFrequency = " + doubleToStr(trajectoryFrequency);
|
||||||
|
|
||||||
|
result += "\narriveDestinationDistance = " + doubleToStr(arriveDestinationDistance);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// SplashParticleSystem
|
// SplashParticleSystem
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
@ -1730,7 +1966,7 @@ SplashParticleSystem::SplashParticleSystem(int particleCount) :
|
||||||
|
|
||||||
prevParticleSystem= NULL;
|
prevParticleSystem= NULL;
|
||||||
|
|
||||||
emissionRateFade= 1;
|
emissionRateFade= 1.0f;
|
||||||
verticalSpreadA= 1.0f;
|
verticalSpreadA= 1.0f;
|
||||||
verticalSpreadB= 0.0f;
|
verticalSpreadB= 0.0f;
|
||||||
horizontalSpreadA= 1.0f;
|
horizontalSpreadA= 1.0f;
|
||||||
|
@ -1753,7 +1989,9 @@ void SplashParticleSystem::update() {
|
||||||
if(state != sPause) {
|
if(state != sPause) {
|
||||||
emissionRate -= emissionRateFade;
|
emissionRate -= emissionRateFade;
|
||||||
|
|
||||||
float t= 1.0f - ((emissionRate + startEmissionRate) / (startEmissionRate * 2.0f));
|
double t = 1.0f - ((emissionRate + startEmissionRate) / (startEmissionRate * 2.0f));
|
||||||
|
t = truncateDecimal<double>(t);
|
||||||
|
|
||||||
t= clamp(t, 0.0f, 1.0f);
|
t= clamp(t, 0.0f, 1.0f);
|
||||||
setTween(t,t);
|
setTween(t,t);
|
||||||
|
|
||||||
|
@ -1802,18 +2040,18 @@ void SplashParticleSystem::saveGame(XmlNode *rootNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// float emissionRateFade;
|
// float emissionRateFade;
|
||||||
splashParticleSystemNode->addAttribute("emissionRateFade",floatToStr(emissionRateFade,16), mapTagReplacements);
|
splashParticleSystemNode->addAttribute("emissionRateFade",doubleToStr(emissionRateFade,16), mapTagReplacements);
|
||||||
// float verticalSpreadA;
|
// float verticalSpreadA;
|
||||||
splashParticleSystemNode->addAttribute("verticalSpreadA",floatToStr(verticalSpreadA,16), mapTagReplacements);
|
splashParticleSystemNode->addAttribute("verticalSpreadA",doubleToStr(verticalSpreadA,16), mapTagReplacements);
|
||||||
// float verticalSpreadB;
|
// float verticalSpreadB;
|
||||||
splashParticleSystemNode->addAttribute("verticalSpreadB",floatToStr(verticalSpreadB,16), mapTagReplacements);
|
splashParticleSystemNode->addAttribute("verticalSpreadB",doubleToStr(verticalSpreadB,16), mapTagReplacements);
|
||||||
// float horizontalSpreadA;
|
// float horizontalSpreadA;
|
||||||
splashParticleSystemNode->addAttribute("horizontalSpreadA",floatToStr(horizontalSpreadA,16), mapTagReplacements);
|
splashParticleSystemNode->addAttribute("horizontalSpreadA",doubleToStr(horizontalSpreadA,16), mapTagReplacements);
|
||||||
// float horizontalSpreadB;
|
// float horizontalSpreadB;
|
||||||
splashParticleSystemNode->addAttribute("horizontalSpreadB",floatToStr(horizontalSpreadB,16), mapTagReplacements);
|
splashParticleSystemNode->addAttribute("horizontalSpreadB",doubleToStr(horizontalSpreadB,16), mapTagReplacements);
|
||||||
//
|
//
|
||||||
// float startEmissionRate;
|
// float startEmissionRate;
|
||||||
splashParticleSystemNode->addAttribute("startEmissionRate",floatToStr(startEmissionRate,16), mapTagReplacements);
|
splashParticleSystemNode->addAttribute("startEmissionRate",doubleToStr(startEmissionRate,16), mapTagReplacements);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplashParticleSystem::loadGame(const XmlNode *rootNode) {
|
void SplashParticleSystem::loadGame(const XmlNode *rootNode) {
|
||||||
|
@ -1828,6 +2066,7 @@ void SplashParticleSystem::loadGame(const XmlNode *rootNode) {
|
||||||
if(splashParticleSystemNode->hasChild("ProjectileParticleSystem") == true) {
|
if(splashParticleSystemNode->hasChild("ProjectileParticleSystem") == true) {
|
||||||
XmlNode *projectileParticleSystemNode = splashParticleSystemNode->getChild("ProjectileParticleSystem");
|
XmlNode *projectileParticleSystemNode = splashParticleSystemNode->getChild("ProjectileParticleSystem");
|
||||||
prevParticleSystem = new ProjectileParticleSystem();
|
prevParticleSystem = new ProjectileParticleSystem();
|
||||||
|
prevParticleSystem->setParticleOwner(this->getParticleOwner());
|
||||||
prevParticleSystem->loadGame(projectileParticleSystemNode);
|
prevParticleSystem->loadGame(projectileParticleSystemNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1845,6 +2084,31 @@ void SplashParticleSystem::loadGame(const XmlNode *rootNode) {
|
||||||
startEmissionRate = splashParticleSystemNode->getAttribute("startEmissionRate")->getFloatValue();
|
startEmissionRate = splashParticleSystemNode->getAttribute("startEmissionRate")->getFloatValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Checksum SplashParticleSystem::getCRC() {
|
||||||
|
Checksum crcForParticleSystem = ParticleSystem::getCRC();
|
||||||
|
|
||||||
|
return crcForParticleSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
string SplashParticleSystem::toString() const {
|
||||||
|
string result = ParticleSystem::toString();
|
||||||
|
|
||||||
|
result += "\nSplashParticleSystem ";
|
||||||
|
if(prevParticleSystem != NULL) {
|
||||||
|
//result += "\nprevParticleSystem = " + prevParticleSystem->toString() + "\n";
|
||||||
|
result += "\nprevParticleSystem = NOT NULL\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
result += "\nemissionRateFade = " + doubleToStr(emissionRateFade);
|
||||||
|
result += "\nverticalSpreadA = " + doubleToStr(verticalSpreadA);
|
||||||
|
result += "\nverticalSpreadB = " + doubleToStr(verticalSpreadB);
|
||||||
|
result += "\nhorizontalSpreadA = " + doubleToStr(horizontalSpreadA);
|
||||||
|
result += "\nhorizontalSpreadB = " + doubleToStr(horizontalSpreadB);
|
||||||
|
result += "\nstartEmissionRate = " + doubleToStr(startEmissionRate);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// ParticleManager
|
// ParticleManager
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
@ -1910,14 +2174,13 @@ void ParticleManager::update(int renderFps){
|
||||||
currentParticleCount+= ps->getAliveParticleCount();
|
currentParticleCount+= ps->getAliveParticleCount();
|
||||||
|
|
||||||
bool showParticle= true;
|
bool showParticle= true;
|
||||||
if(dynamic_cast<UnitParticleSystem *> (ps) != NULL || dynamic_cast<FireParticleSystem *> (ps) != NULL){
|
if( dynamic_cast<UnitParticleSystem *> (ps) != NULL ||
|
||||||
|
dynamic_cast<FireParticleSystem *> (ps) != NULL) {
|
||||||
showParticle = ps->getVisible() || (ps->getState() == ParticleSystem::sFade);
|
showParticle = ps->getVisible() || (ps->getState() == ParticleSystem::sFade);
|
||||||
}
|
}
|
||||||
if(showParticle == true){
|
if(showParticle == true){
|
||||||
ps->update();
|
ps->update();
|
||||||
if(ps->isEmpty() && ps->getState() == ParticleSystem::sFade) {
|
if(ps->isEmpty() && ps->getState() == ParticleSystem::sFade) {
|
||||||
//delete ps;
|
|
||||||
//*it= NULL;
|
|
||||||
cleanupParticleSystemsList.push_back(ps);
|
cleanupParticleSystemsList.push_back(ps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1958,38 +2221,43 @@ void ParticleManager::cleanupParticleSystems(ParticleSystem *ps) {
|
||||||
// }
|
// }
|
||||||
// deleteList[ps]++;
|
// deleteList[ps]++;
|
||||||
|
|
||||||
|
if(ps != NULL) {
|
||||||
|
ps->callParticleOwnerEnd(ps);
|
||||||
|
}
|
||||||
|
|
||||||
delete ps;
|
delete ps;
|
||||||
this->particleSystems.erase(this->particleSystems.begin() + index);
|
this->particleSystems.erase(this->particleSystems.begin() + index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleManager::cleanupParticleSystems(vector<ParticleSystem *> &particleSystems){
|
void ParticleManager::cleanupParticleSystems(vector<ParticleSystem *> &cleanupParticleSystemsList){
|
||||||
|
if(cleanupParticleSystemsList.empty() == false) {
|
||||||
for(int i= particleSystems.size()-1; i >= 0; i--){
|
for(int i= cleanupParticleSystemsList.size()-1; i >= 0; i--) {
|
||||||
ParticleSystem *ps= particleSystems[i];
|
ParticleSystem *ps= cleanupParticleSystemsList[i];
|
||||||
cleanupParticleSystems(ps);
|
cleanupParticleSystems(ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
particleSystems.clear();
|
cleanupParticleSystemsList.clear();
|
||||||
//this->particleSystems.remove(NULL);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleManager::cleanupUnitParticleSystems(vector<UnitParticleSystem *> &particleSystems){
|
void ParticleManager::cleanupUnitParticleSystems(vector<UnitParticleSystem *> &cleanupParticleSystemsList){
|
||||||
|
if(cleanupParticleSystemsList.empty() == false) {
|
||||||
for(int i= particleSystems.size()-1; i >= 0; i--){
|
for(int i= cleanupParticleSystemsList.size()-1; i >= 0; i--) {
|
||||||
ParticleSystem *ps= particleSystems[i];
|
ParticleSystem *ps= cleanupParticleSystemsList[i];
|
||||||
cleanupParticleSystems(ps);
|
cleanupParticleSystems(ps);
|
||||||
}
|
}
|
||||||
particleSystems.clear();
|
cleanupParticleSystemsList.clear();
|
||||||
//this->particleSystems.remove(NULL);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleManager::manage(ParticleSystem *ps){
|
void ParticleManager::manage(ParticleSystem *ps){
|
||||||
assert((std::find(particleSystems.begin(),particleSystems.end(),ps) == particleSystems.end()) && "particle cannot be added twice");
|
assert((std::find(particleSystems.begin(),particleSystems.end(),ps) == particleSystems.end()) && "particle cannot be added twice");
|
||||||
particleSystems.push_back(ps);
|
particleSystems.push_back(ps);
|
||||||
for(int i=ps->getChildCount()-1; i>=0; i--)
|
for(int i = ps->getChildCount() - 1; i >= 0; i--) {
|
||||||
manage(ps->getChild(i));
|
manage(ps->getChild(i));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ParticleManager::end(){
|
void ParticleManager::end(){
|
||||||
while(particleSystems.empty() == false){
|
while(particleSystems.empty() == false){
|
||||||
|
@ -2002,6 +2270,9 @@ void ParticleManager::end(){
|
||||||
// }
|
// }
|
||||||
// deleteList[ps]++;
|
// deleteList[ps]++;
|
||||||
|
|
||||||
|
if(ps != NULL) {
|
||||||
|
ps->callParticleOwnerEnd(ps);
|
||||||
|
}
|
||||||
delete ps;
|
delete ps;
|
||||||
particleSystems.pop_back();
|
particleSystems.pop_back();
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,18 +52,26 @@ void RandomGen::init(int seed){
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] seed = %d, lastNumber = %d\n",__FILE__,__FUNCTION__,__LINE__,seed,lastNumber);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] seed = %d, lastNumber = %d\n",__FILE__,__FUNCTION__,__LINE__,seed,lastNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
int RandomGen::rand() {
|
int RandomGen::rand(string lastCaller) {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] lastNumber = %d\n",__FILE__,__FUNCTION__,__LINE__,lastNumber);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] lastNumber = %d\n",__FILE__,__FUNCTION__,__LINE__,lastNumber);
|
||||||
|
|
||||||
lastNumber= (a*lastNumber + b) % m;
|
this->lastNumber = (a*lastNumber + b) % m;
|
||||||
|
this->lastCaller.push_back(lastCaller);
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] lastNumber = %d\n",__FILE__,__FUNCTION__,__LINE__,lastNumber);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] lastNumber = %d\n",__FILE__,__FUNCTION__,__LINE__,lastNumber);
|
||||||
|
|
||||||
return lastNumber;
|
return lastNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RandomGen::randRange(int min, int max){
|
std::string RandomGen::getLastCaller() const {
|
||||||
assert(min<=max);
|
std::string result = "";
|
||||||
|
for(unsigned int index = 0; index < lastCaller.size(); ++index) {
|
||||||
|
result += lastCaller[index] + " ";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
int RandomGen::randRange(int min, int max,string lastCaller) {
|
||||||
|
//assert(min<=max);
|
||||||
if(min > max) {
|
if(min > max) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s Line: %d] min > max, min = %d, max = %d",__FILE__,__FUNCTION__,__LINE__,min,max);
|
snprintf(szBuf,8096,"In [%s::%s Line: %d] min > max, min = %d, max = %d",__FILE__,__FUNCTION__,__LINE__,min,max);
|
||||||
|
@ -74,9 +82,12 @@ int RandomGen::randRange(int min, int max){
|
||||||
// int res = streflop::Random<true, false, float>(min, max); // streflop
|
// int res = streflop::Random<true, false, float>(min, max); // streflop
|
||||||
//#else
|
//#else
|
||||||
int diff= max-min;
|
int diff= max-min;
|
||||||
int res= min + static_cast<int>(truncateDecimal<double>(static_cast<double>(diff+1),2)*RandomGen::rand() / m);
|
//int res= min + static_cast<int>(truncateDecimal<double>(static_cast<double>(diff+1),2)*RandomGen::rand() / m);
|
||||||
|
double numerator = static_cast<double>(diff + 1) * static_cast<double>(RandomGen::rand(lastCaller));
|
||||||
|
int res= min + static_cast<int>(truncateDecimal<double>(numerator / static_cast<double>(m)));
|
||||||
|
//int res= min + static_cast<int>(truncateDecimal<double>(static_cast<double>(diff+1 * RandomGen::rand()) / static_cast<double>(m)));
|
||||||
//#endif
|
//#endif
|
||||||
assert(res>=min && res<=max);
|
//assert(res>=min && res<=max);
|
||||||
if(res < min || res > max) {
|
if(res < min || res > max) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s Line: %d] res < min || res > max, min = %d, max = %d, res = %d",__FILE__,__FUNCTION__,__LINE__,min,max,res);
|
snprintf(szBuf,8096,"In [%s::%s Line: %d] res < min || res > max, min = %d, max = %d, res = %d",__FILE__,__FUNCTION__,__LINE__,min,max,res);
|
||||||
|
@ -88,8 +99,8 @@ int RandomGen::randRange(int min, int max){
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
float RandomGen::randRange(float min, float max){
|
float RandomGen::randRange(float min, float max,string lastCaller) {
|
||||||
assert(min<=max);
|
//assert(min<=max);
|
||||||
if(min > max) {
|
if(min > max) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s Line: %d] min > max, min = %f, max = %f",__FILE__,__FUNCTION__,__LINE__,min,max);
|
snprintf(szBuf,8096,"In [%s::%s Line: %d] min > max, min = %f, max = %f",__FILE__,__FUNCTION__,__LINE__,min,max);
|
||||||
|
@ -99,12 +110,12 @@ float RandomGen::randRange(float min, float max){
|
||||||
//#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
// float res = streflop::Random<true, false, float>(min, max, randomState); // streflop
|
// float res = streflop::Random<true, false, float>(min, max, randomState); // streflop
|
||||||
//#else
|
//#else
|
||||||
float rand01= static_cast<float>(RandomGen::rand())/(m-1);
|
float rand01= static_cast<float>(RandomGen::rand(lastCaller))/(m-1);
|
||||||
float res= min+(max-min)*rand01;
|
float res= min+(max-min)*rand01;
|
||||||
res = truncateDecimal<float>(res);
|
res = truncateDecimal<float>(res);
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
assert(res>=min && res<=max);
|
//assert(res>=min && res<=max);
|
||||||
if(res < min || res > max) {
|
if(res < min || res > max) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s Line: %d] res < min || res > max, min = %f, max = %f, res = %f",__FILE__,__FUNCTION__,__LINE__,min,max,res);
|
snprintf(szBuf,8096,"In [%s::%s Line: %d] res < min || res > max, min = %f, max = %f, res = %f",__FILE__,__FUNCTION__,__LINE__,min,max,res);
|
||||||
|
|
|
@ -27,6 +27,7 @@ IF(BUILD_MEGAGLEST_TESTS)
|
||||||
SET(DIRS_WITH_SRC
|
SET(DIRS_WITH_SRC
|
||||||
./
|
./
|
||||||
shared_lib/graphics
|
shared_lib/graphics
|
||||||
|
shared_lib/util
|
||||||
shared_lib/xml)
|
shared_lib/xml)
|
||||||
|
|
||||||
SET(MG_INCLUDES_ROOT "./")
|
SET(MG_INCLUDES_ROOT "./")
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
using namespace Shared::Graphics;
|
using namespace Shared::Graphics;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Tests for XmlIo
|
// Tests for math_util
|
||||||
//
|
//
|
||||||
class MathUtilTest : public CppUnit::TestFixture {
|
class MathUtilTest : public CppUnit::TestFixture {
|
||||||
// Register the suite of tests for this fixture
|
// Register the suite of tests for this fixture
|
||||||
|
|
Loading…
Reference in New Issue