1
0
Fork 0

Fix for weather interpolation problem from Anders Gidenstam

Anders said:
With Stuart's help I've looked closer at this and I think I've tracked
down the cause of the problem:
At least on my computer the sort() call on line 234 in
Environment/environment_ctrl.cxx sorts the vector entries by memory
address instead of altitude, i.e. the custom comparison predicate is not
used. This causes the tables of environment conditions to be reordered
into a wrong order at some weather updates, depending, basically,
on where the memory allocator places the objects. (Btw. why are they are
freshly allocated for each update?)
This commit is contained in:
timoore 2007-08-15 15:22:44 +00:00
parent 3bf9ab1098
commit e23f731ef7
2 changed files with 8 additions and 1 deletions

View file

@ -231,7 +231,7 @@ FGInterpolateEnvironmentCtrl::read_table (const SGPropertyNode * node,
table.push_back(b);
}
}
sort(table.begin(), table.end());
sort(table.begin(), table.end(), bucket::lessThan);
}
void
@ -312,6 +312,11 @@ FGInterpolateEnvironmentCtrl::bucket::operator< (const bucket &b) const
return (altitude_ft < b.altitude_ft);
}
bool
FGInterpolateEnvironmentCtrl::bucket::lessThan(bucket *a, bucket *b)
{
return (a->altitude_ft) < (b->altitude_ft);
}
////////////////////////////////////////////////////////////////////////

View file

@ -134,6 +134,8 @@ private:
double altitude_ft;
FGEnvironment environment;
bool operator< (const bucket &b) const;
// LessThan predicate for bucket pointers.
static bool lessThan(bucket *a, bucket *b);
};
void read_table (const SGPropertyNode * node, vector<bucket *> &table);