Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Tiberian Technologies / Blackhand Studios » Tiberian Technologies Forum » int Get_Team_Player_Count(int Team)
int Get_Team_Player_Count(int Team) [message #339927] Wed, 09 July 2008 08:08 Go to previous message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma:
General (3 Stars)
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? Smile



 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Sooooo...
Next Topic: EA
Goto Forum:
  


Current Time: Sun Feb 02 07:43:46 MST 2025

Total time taken to generate the page: 0.00751 seconds