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?)
table.push_back(b);
}
}
- sort(table.begin(), table.end());
+ sort(table.begin(), table.end(), bucket::lessThan);
}
void
return (altitude_ft < b.altitude_ft);
}
+bool
+FGInterpolateEnvironmentCtrl::bucket::lessThan(bucket *a, bucket *b)
+{
+ return (a->altitude_ft) < (b->altitude_ft);
+}
\f
////////////////////////////////////////////////////////////////////////
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);