mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-10-21 11:03:13 -04:00
Current amount of online players is now correctly displayed at character creation and population status is calculated relatively to GALAXY-MAX-ONLINE
This commit is contained in:
@@ -37,7 +37,7 @@ import resources.Galaxy;
|
||||
|
||||
public class LoginClusterStatus extends SWGPacket {
|
||||
|
||||
public static final int CRC = 0x3436AEB6;
|
||||
public static final int CRC = getCrc("LoginClusterStatus");
|
||||
|
||||
private Vector <Galaxy> galaxies;
|
||||
|
||||
@@ -100,20 +100,4 @@ public class LoginClusterStatus extends SWGPacket {
|
||||
return galaxies;
|
||||
}
|
||||
|
||||
private int getPopulationStatus(int pop) {
|
||||
if (pop < 300)
|
||||
return 0; // Very Light
|
||||
if (pop < 600)
|
||||
return 1; // Light
|
||||
if (pop < 900)
|
||||
return 2; // Medium
|
||||
if (pop < 1200)
|
||||
return 3; // Heavy
|
||||
if (pop < 1500)
|
||||
return 4; // Very Heavy
|
||||
if (pop < 3000)
|
||||
return 5; // Extremely Heavy
|
||||
return 6; // Full
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -306,21 +306,29 @@ public class LoginService extends Service {
|
||||
Config c = getConfig(ConfigFile.PRIMARY);
|
||||
ResultSet set = getGalaxies.executeQuery();
|
||||
List <Galaxy> galaxies = new ArrayList<Galaxy>();
|
||||
int maxPopulation = c.getInt("GALAXY-MAX-ONLINE", 3000);
|
||||
double consumed;
|
||||
int population;
|
||||
|
||||
try {
|
||||
while (set.next()) {
|
||||
Galaxy g = new Galaxy();
|
||||
population = set.getInt("population");
|
||||
consumed = ((double) population / maxPopulation) * 100;
|
||||
|
||||
g.setId(set.getInt("id"));
|
||||
g.setName(set.getString("name"));
|
||||
g.setAddress(set.getString("address"));
|
||||
g.setPopulation(set.getInt("population"));
|
||||
g.setPopulation(population);
|
||||
g.setTimeZone(set.getInt("timezone"));
|
||||
g.setZonePort(set.getInt("zone_port"));
|
||||
g.setPingPort(set.getInt("ping_port"));
|
||||
g.setStatus(set.getInt("status"));
|
||||
g.setMaxCharacters(c.getInt("GALAXY-MAX-CHARACTERS", 2));
|
||||
g.setOnlinePlayerLimit(c.getInt("GALAXY-MAX-ONLINE", 3000));
|
||||
g.setOnlineFreeTrialLimit(c.getInt("GALAXY-MAX-ONLINE", 3000));
|
||||
g.setOnlinePlayerLimit(maxPopulation);
|
||||
g.setOnlineFreeTrialLimit(maxPopulation);
|
||||
g.setRecommended(true);
|
||||
g.setPopulationStatus(populationStatus(consumed));
|
||||
// If locked, restricted, or full
|
||||
if (p.getAccessLevel() == AccessLevel.ADMIN && g.getStatus() != GalaxyStatus.UP)
|
||||
g.setStatus(GalaxyStatus.UP);
|
||||
@@ -366,4 +374,31 @@ public class LoginService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
private int populationStatus(double consumed) {
|
||||
double veryLight = 10; // 10%
|
||||
double light = 20; // 20%
|
||||
double medium = 30; // 30%
|
||||
double heavy = 40; // 40%
|
||||
double veryHeavy = 50; // 50%
|
||||
double extremelyHeavy = 100; // 100%
|
||||
int popStatus;
|
||||
|
||||
if(consumed < veryLight)
|
||||
popStatus = 0;
|
||||
else if(consumed < light)
|
||||
popStatus = 1;
|
||||
else if(consumed < medium)
|
||||
popStatus = 2;
|
||||
else if(consumed < heavy)
|
||||
popStatus = 3;
|
||||
else if(consumed < veryHeavy)
|
||||
popStatus = 4;
|
||||
else if(consumed < extremelyHeavy)
|
||||
popStatus = 5;
|
||||
else
|
||||
popStatus = 6;
|
||||
|
||||
return popStatus;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user