-- attempt to fix another oos issue detected

This commit is contained in:
Mark Vejvoda
2013-10-26 07:02:32 +00:00
parent 7f97d94983
commit 539df3a854
2 changed files with 48 additions and 3 deletions

View File

@@ -1478,6 +1478,10 @@ Vec3f Unit::getCurrVector() const{
} }
Vec3f result = getCurrVectorFlat() + Vec3f(0.f, type->getHeight() / 2.f, 0.f); Vec3f result = getCurrVectorFlat() + Vec3f(0.f, type->getHeight() / 2.f, 0.f);
result.x = truncateDecimal<float>(result.x,6);
result.y = truncateDecimal<float>(result.y,6);
result.z = truncateDecimal<float>(result.z,6);
return result; return result;
} }
@@ -1503,15 +1507,26 @@ Vec3f Unit::getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) c
v.x = lastPosValue.x + progressAsFloat * (curPosValue.x - lastPosValue.x); v.x = lastPosValue.x + progressAsFloat * (curPosValue.x - lastPosValue.x);
v.z = lastPosValue.y + progressAsFloat * (curPosValue.y - lastPosValue.y); v.z = lastPosValue.y + progressAsFloat * (curPosValue.y - lastPosValue.y);
v.y = y1 + progressAsFloat * (y2-y1); v.y = y1 + progressAsFloat * (y2-y1);
v.x = truncateDecimal<float>(v.x,6);
v.y = truncateDecimal<float>(v.y,6);
v.z = truncateDecimal<float>(v.z,6);
} }
else { else {
v.x = static_cast<float>(curPosValue.x); v.x = static_cast<float>(curPosValue.x);
v.z = static_cast<float>(curPosValue.y); v.z = static_cast<float>(curPosValue.y);
v.y = y2; v.y = y2;
v.x = truncateDecimal<float>(v.x,6);
v.y = truncateDecimal<float>(v.y,6);
v.z = truncateDecimal<float>(v.z,6);
} }
v.x += type->getSize() / 2.f - 0.5f; v.x += type->getSize() / 2.f - 0.5f;
v.z += type->getSize() / 2.f - 0.5f; v.z += type->getSize() / 2.f - 0.5f;
v.x = truncateDecimal<float>(v.x,6);
v.z = truncateDecimal<float>(v.z,6);
return v; return v;
} }
@@ -3405,7 +3420,8 @@ float Unit::computeHeight(const Vec2i &pos) const {
float height= map->getCell(pos)->getHeight(); float height= map->getCell(pos)->getHeight();
if(currField == fAir) { if(currField == fAir) {
const float airHeight=game->getWorld()->getTileset()->getAirHeight(); float airHeight = game->getWorld()->getTileset()->getAirHeight();
airHeight = truncateDecimal<float>(airHeight,6);
height += airHeight; height += airHeight;
height = truncateDecimal<float>(height,6); height = truncateDecimal<float>(height,6);
@@ -4311,6 +4327,8 @@ std::string Unit::toString(bool crcMode) const {
} }
result += "pathFindRefreshCellCount = " + intToStr(pathFindRefreshCellCount) + "\n"; result += "pathFindRefreshCellCount = " + intToStr(pathFindRefreshCellCount) + "\n";
result += "currentPathFinderDesiredFinalPos = " + currentPathFinderDesiredFinalPos.getString() + "\n";
result += "lastStuckFrame = " + uIntToStr(lastStuckFrame) + "\n"; result += "lastStuckFrame = " + uIntToStr(lastStuckFrame) + "\n";
result += "lastStuckPos = " + lastStuckPos.getString() + "\n"; result += "lastStuckPos = " + lastStuckPos.getString() + "\n";
@@ -5292,7 +5310,7 @@ Checksum Unit::getCRC() {
//CauseOfDeathType causeOfDeath; //CauseOfDeathType causeOfDeath;
//uint32 pathfindFailedConsecutiveFrameCount; //uint32 pathfindFailedConsecutiveFrameCount;
//Vec2i currentPathFinderDesiredFinalPos; crcForUnit.addString(this->currentPathFinderDesiredFinalPos.getString());
crcForUnit.addInt(random.getLastNumber()); crcForUnit.addInt(random.getLastNumber());
if(this->random.getLastCaller() != "") { if(this->random.getLastCaller() != "") {

View File

@@ -1788,9 +1788,17 @@ void ProjectileParticleSystem::update(){
pos= flatPos; pos= flatPos;
#ifdef USE_STREFLOP #ifdef USE_STREFLOP
pos+= xVector * streflop::cos(static_cast<streflop::Simple>(relative * trajectoryFrequency * targetVector.length())) * trajectoryScale; pos+= xVector * streflop::cos(static_cast<streflop::Simple>(relative * trajectoryFrequency * targetVector.length())) * trajectoryScale;
pos.x = truncateDecimal<float>(pos.x,6);
pos.y = truncateDecimal<float>(pos.y,6);
pos.z = truncateDecimal<float>(pos.z,6);
pos+= yVector * streflop::sin(static_cast<streflop::Simple>(relative * trajectoryFrequency * targetVector.length())) * trajectoryScale; pos+= yVector * streflop::sin(static_cast<streflop::Simple>(relative * trajectoryFrequency * targetVector.length())) * trajectoryScale;
#else #else
pos+= xVector * cos(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale; pos+= xVector * cos(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale;
pos.x = truncateDecimal<float>(pos.x,6);
pos.y = truncateDecimal<float>(pos.y,6);
pos.z = truncateDecimal<float>(pos.z,6);
pos+= yVector * sin(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale; pos+= yVector * sin(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale;
#endif #endif
pos.x = truncateDecimal<float>(pos.x,6); pos.x = truncateDecimal<float>(pos.x,6);
@@ -1804,7 +1812,11 @@ void ProjectileParticleSystem::update(){
break; break;
} }
direction= pos - lastPos; direction= (pos - lastPos);
direction.x = truncateDecimal<float>(direction.x,6);
direction.y = truncateDecimal<float>(direction.y,6);
direction.z = truncateDecimal<float>(direction.z,6);
direction.normalize(); direction.normalize();
direction.x = truncateDecimal<float>(direction.x,6); direction.x = truncateDecimal<float>(direction.x,6);
direction.y = truncateDecimal<float>(direction.y,6); direction.y = truncateDecimal<float>(direction.y,6);
@@ -1908,6 +1920,13 @@ void ProjectileParticleSystem::updateParticle(Particle *p){
} }
void ProjectileParticleSystem::setPath(Vec3f startPos, Vec3f endPos) { void ProjectileParticleSystem::setPath(Vec3f startPos, Vec3f endPos) {
startPos.x = truncateDecimal<float>(startPos.x,6);
startPos.y = truncateDecimal<float>(startPos.y,6);
startPos.z = truncateDecimal<float>(startPos.z,6);
endPos.x = truncateDecimal<float>(endPos.x,6);
endPos.y = truncateDecimal<float>(endPos.y,6);
endPos.z = truncateDecimal<float>(endPos.z,6);
//compute axis //compute axis
zVector= endPos - startPos; zVector= endPos - startPos;
@@ -2172,7 +2191,15 @@ void SplashParticleSystem::initParticle(Particle *p, int particleIndex){
p->speed= Vec3f(horizontalSpreadA * random.randRange(-1.0f, 1.0f) + horizontalSpreadB, verticalSpreadA p->speed= Vec3f(horizontalSpreadA * random.randRange(-1.0f, 1.0f) + horizontalSpreadB, verticalSpreadA
* random.randRange(-1.0f, 1.0f) + verticalSpreadB, horizontalSpreadA * random.randRange(-1.0f, 1.0f) * random.randRange(-1.0f, 1.0f) + verticalSpreadB, horizontalSpreadA * random.randRange(-1.0f, 1.0f)
+ horizontalSpreadB); + horizontalSpreadB);
p->speed.x = truncateDecimal<float>(p->speed.x,6);
p->speed.y = truncateDecimal<float>(p->speed.y,6);
p->speed.z = truncateDecimal<float>(p->speed.z,6);
p->speed.normalize(); p->speed.normalize();
p->speed.x = truncateDecimal<float>(p->speed.x,6);
p->speed.y = truncateDecimal<float>(p->speed.y,6);
p->speed.z = truncateDecimal<float>(p->speed.z,6);
p->speed= p->speed * speed; p->speed= p->speed * speed;
p->speed.x = truncateDecimal<float>(p->speed.x,6); p->speed.x = truncateDecimal<float>(p->speed.x,6);
p->speed.y = truncateDecimal<float>(p->speed.y,6); p->speed.y = truncateDecimal<float>(p->speed.y,6);