Code: Select all
// Header
class UnitInfo
{
UnitInfo();
~UnitInfo();
int priority;
friend operator<(UnitInfo &A, UnitInfo &B);
};
operator<(UnitInfo &A, UnitInfo &B);
// CPP File
operator<(UnitInfo &A, UnitInfo &B)
{
return A.priority < B.priority;
}
[code]
And then you can have a set of this class. If you don't care how they are sorted, just have the operator function return false.
BTW, forget about the priority_queue I was talking about. It was removed in the 2003 Microsoft STL. I've been using the above method, but with the set container instead, and pulling off the front with begin().
I have decided to use your command limiting idea, and it has been working quite well at reducing lag, even when a unit is stuck in a factory and can't get out. However, spring has been crashing really bad every now and then, so I'm going to have to figure out why before I can release a new version.