How to count buildings
From OPU Wiki
How do you count how many buildings of a certain type exist ?
int CountBuildings(int player,map_id type)
{
int cnt=0;
Unit u;
PlayerBuildingEnum enum1(player,type);
while (enum1.GetNext(u)!=0)
if (u.GetType()==type) ++cnt;
return cnt;
}
I have submitted a request for this function to be included into the next SDK version. For now, you can add it to your source code, and just call it:
int tokamaks=CountBuildings(1,mapTokamak);
