fix divide by zero in the engine svc

This commit is contained in:
Julian Krings 2025-06-09 19:19:00 +02:00
parent f9dac8a3a1
commit 172e234514
No known key found for this signature in database
GPG Key ID: 208C6E08C3B718D2

View File

@ -187,7 +187,7 @@ public class IrisEngineSVC implements IrisService {
return;
try {
engine.getMantle().trim(tectonicLimit.get() / worlds.size());
engine.getMantle().trim(tectonicLimit());
} catch (Throwable e) {
Iris.reportError(e);
Iris.error("EngineSVC: Failed to trim for " + name);
@ -204,7 +204,7 @@ public class IrisEngineSVC implements IrisService {
try {
long unloadStart = System.currentTimeMillis();
int count = engine.getMantle().unloadTectonicPlate(tectonicLimit.get() / worlds.size());
int count = engine.getMantle().unloadTectonicPlate(tectonicLimit());
if (count > 0) {
Iris.debug(C.GOLD + "Unloaded " + C.YELLOW + count + " TectonicPlates in " + C.RED + Form.duration(System.currentTimeMillis() - unloadStart, 2));
}
@ -217,6 +217,10 @@ public class IrisEngineSVC implements IrisService {
}
}
private int tectonicLimit() {
return tectonicLimit.get() / Math.max(worlds.size(), 1);
}
@Synchronized
private void close() {
if (closed) return;