int Get_Team_Player_Count(int Team) seemed to always crash for me, it says it's tested, but I wasn't able to use it. here is the stock version of it:
int Get_Team_Player_Count(int Team)
{
int Total = 0;
GenericSLNode *x = BaseGameObjList->HeadNode;
while (x)
{
GameObject *o = As_SoldierGameObj((GameObject *)x->NodeData);
if (o && Get_Object_Type(o) == Team)
{
Total++;
}
x = x->NodeNext;
}
return Total;
}
I altered it so that the while loop doesn't try to do Get_Object_Type on the GameObject *, because this is where it seemed to crash. I think you can only use that function on buildings and players, so I'm sure that's why it was crashing...
I changed it to this:
int Get_Team_Player_Count(int Team)
{
int Total = 0;
GenericSLNode *x = BaseGameObjList->HeadNode;
while (x)
{
GameObject *o = (GameObject *)x->NodeData;
if (o && Commands->Is_A_Star(o))
{
if (Get_Team(Get_Player_ID(o)) == Team)
{
Total++;
}
}
x = x->NodeNext;
}
return Total;
}
And I havn't had a crash yet, maybe you'll look into it for 4.0?