int arnaUpdateCountryBalance(arnaCOUNTRY_BALANCE * CountryBalance)
{
int BadGuyID;
arnaCOUNTRY_BALANCE NewBalance;
pcUSER_RECORD * pcUserRecord;
bgUSER_RECORD * bgUserRecord;
const arnaSETTINGS * Settings;
int Country;
double Least;
memset(&NewBalance,0,sizeof(arnaCOUNTRY_BALANCE));
Settings = arnaservGetSettings();
for(BadGuyID = udGetNextOnlineUserFd(-1);
BadGuyID >= 0;
BadGuyID = udGetNextOnlineUserFd(BadGuyID))
{
pcUserRecord = udGetpcUserRecord(BadGuyID);
bgUserRecord = udGetbgUserRecord(BadGuyID);
Country = bgUserRecord->UserInfo.Country;
++NewBalance.TotalPlayerCnt;
++NewBalance.PlayerCnt[Country];
if(pcUserRecord->Permisions & cmdCP_IN_FLIGHT)
{
++NewBalance.InFlightCnt[Country];
}
}
if(NewBalance.TotalPlayerCnt > 0 )
{
Least = 2.0;
for(Country=0;Country
{
NewBalance.CountryPer[Country] = (double)NewBalance.PlayerCnt[Country] / (double)NewBalance.TotalPlayerCnt;
if(NewBalance.CountryPer[Country] < Least)
{
Least = NewBalance.CountryPer[Country];
}
}
if(Least != 0)
{
for(Country=0;Country
{
NewBalance.MinEnyValue[Country] =
(NewBalance.CountryPer[Country] - (Least + Settings->BaseCountryPer)) * Settings->CountryBalanceScale * 100;
if(NewBalance.MinEnyValue[Country] < 0)
{
NewBalance.MinEnyValue[Country] = 0;
}
if(NewBalance.MinEnyValue[Country] > 49)
{
NewBalance.MinEnyValue[Country] = 49;
}
}
}
}
if(NewBalance.TotalPlayerCnt < Settings->MinBalanceTotal)
{
for(Country=0;Country
{
NewBalance.MinEnyValue[Country] = 0;
}
}
*CountryBalance = NewBalance;
return 0;
}