- added a new validation for faction validation report AND game load for attack-var since a negative value will segfault the game
This commit is contained in:
parent
18a0a93a8e
commit
b201cebf3b
|
@ -361,6 +361,22 @@ std::vector<std::string> FactionType::validateFactionType() {
|
|||
sprintf(szBuf,"The Unit [%s] in Faction [%s] has no other units that can produce, build or morph into it in this faction!",unitType.getName().c_str(),this->getName().c_str());
|
||||
results.push_back(szBuf);
|
||||
}
|
||||
|
||||
// Ensure that all attack skill types have valid values
|
||||
if(unitType.hasSkillClass(scAttack) == true) {
|
||||
for(int j = 0; j < unitType.getSkillTypeCount(); ++j) {
|
||||
const SkillType *st = unitType.getSkillType(j);
|
||||
if(st != NULL && dynamic_cast<const AttackSkillType *>(st) != NULL) {
|
||||
const AttackSkillType *ast = dynamic_cast<const AttackSkillType *>(st);
|
||||
if(ast->getAttackVar() < 0) {
|
||||
char szBuf[4096]="";
|
||||
sprintf(szBuf,"The Unit [%s] in Faction [%s] has the skill [%s] with an INVALID attack var value which is < 0 [%d]!",unitType.getName().c_str(),this->getName().c_str(),ast->getName().c_str(),ast->getAttackVar());
|
||||
results.push_back(szBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// end
|
||||
}
|
||||
|
||||
return results;
|
||||
|
|
|
@ -155,7 +155,7 @@ int MoveSkillType::getTotalSpeed(const TotalUpgrade *totalUpgrade) const{
|
|||
// =====================================================
|
||||
|
||||
//varios
|
||||
AttackSkillType::AttackSkillType(){
|
||||
AttackSkillType::AttackSkillType() {
|
||||
skillClass= scAttack;
|
||||
attackType= NULL;
|
||||
projectile= false;
|
||||
|
@ -163,24 +163,34 @@ AttackSkillType::AttackSkillType(){
|
|||
splashRadius= 0;
|
||||
projectileParticleSystemType= NULL;
|
||||
splashParticleSystemType= NULL;
|
||||
for(int i=0; i<fieldCount; ++i){
|
||||
|
||||
for(int i = 0; i < fieldCount; ++i) {
|
||||
attackFields[i]= false;
|
||||
}
|
||||
}
|
||||
|
||||
AttackSkillType::~AttackSkillType(){
|
||||
AttackSkillType::~AttackSkillType() {
|
||||
delete projectileParticleSystemType;
|
||||
projectileParticleSystemType = NULL;
|
||||
|
||||
delete splashParticleSystemType;
|
||||
splashParticleSystemType = NULL;
|
||||
deleteValues(projSounds.getSounds().begin(), projSounds.getSounds().end());
|
||||
}
|
||||
|
||||
void AttackSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, const FactionType *ft){
|
||||
|
||||
SkillType::load(sn, dir, tt, ft);
|
||||
void AttackSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, const FactionType *ft) {
|
||||
SkillType::load(sn, dir, tt, ft);
|
||||
|
||||
//misc
|
||||
attackStrength= sn->getChild("attack-strenght")->getAttribute("value")->getIntValue();
|
||||
attackVar= sn->getChild("attack-var")->getAttribute("value")->getIntValue();
|
||||
|
||||
if(attackVar < 0) {
|
||||
char szBuf[4096]="";
|
||||
sprintf(szBuf,"The attack skill has an INVALID attack var value which is < 0 [%d] in file [%s]!",attackVar,dir.c_str());
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
attackRange= sn->getChild("attack-range")->getAttribute("value")->getIntValue();
|
||||
string attackTypeName= sn->getChild("attack-type")->getAttribute("value")->getRestrictedValue();
|
||||
attackType= tt->getAttackType(attackTypeName);
|
||||
|
|
Loading…
Reference in New Issue
Block a user