Skip to content

Commit

Permalink
do not exist for unexpected exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
soloturn authored and Cervator committed Dec 17, 2024
1 parent 4e12a75 commit ec9adf8
Showing 1 changed file with 39 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -486,52 +486,57 @@ public boolean tick() {
return false;
}

if (assetTypeManager instanceof AutoReloadAssetTypeManager) {
try {
((AutoReloadAssetTypeManager) assetTypeManager).reloadChangedAssets();
} catch (IllegalStateException ignore) {
// ignore: This can happen if a module environment switch is happening in a different thread.
return true;
try {
if (assetTypeManager instanceof AutoReloadAssetTypeManager) {
try {
((AutoReloadAssetTypeManager) assetTypeManager).reloadChangedAssets();
} catch (IllegalStateException ignore) {
// ignore: This can happen if a module environment switch is happening in a different thread.
return true;
}
}
}

processPendingState();
processPendingState();

if (currentState == null) {
shutdown();
return false;
}
if (currentState == null) {
shutdown();
return false;
}

Iterator<Float> updateCycles = timeSubsystem.getEngineTime().tick();
CoreRegistry.setContext(currentState.getContext());
rootContext.get(NetworkSystem.class).setContext(currentState.getContext());
Iterator<Float> updateCycles = timeSubsystem.getEngineTime().tick();
CoreRegistry.setContext(currentState.getContext());
rootContext.get(NetworkSystem.class).setContext(currentState.getContext());

for (EngineSubsystem subsystem : allSubsystems) {
try (Activity ignored = PerformanceMonitor.startActivity(subsystem.getName() + " PreUpdate")) {
subsystem.preUpdate(currentState, timeSubsystem.getEngineTime().getRealDelta());
for (EngineSubsystem subsystem : allSubsystems) {
try (Activity ignored = PerformanceMonitor.startActivity(subsystem.getName() + " PreUpdate")) {
subsystem.preUpdate(currentState, timeSubsystem.getEngineTime().getRealDelta());
}
}
}

while (updateCycles.hasNext()) {
float updateDelta = updateCycles.next(); // gameTime gets updated here!
try (Activity ignored = PerformanceMonitor.startActivity("Main Update")) {
currentState.update(updateDelta);
while (updateCycles.hasNext()) {
float updateDelta = updateCycles.next(); // gameTime gets updated here!
try (Activity ignored = PerformanceMonitor.startActivity("Main Update")) {
currentState.update(updateDelta);
}
}
}

// Waiting processes are set by modules via GameThread.a/synch() methods.
GameThread.processWaitingProcesses();
// Waiting processes are set by modules via GameThread.a/synch() methods.
GameThread.processWaitingProcesses();

for (EngineSubsystem subsystem : getSubsystems()) {
try (Activity ignored = PerformanceMonitor.startActivity(subsystem.getName() + " Subsystem postUpdate")) {
subsystem.postUpdate(currentState, timeSubsystem.getEngineTime().getRealDelta());
for (EngineSubsystem subsystem : getSubsystems()) {
try (Activity ignored = PerformanceMonitor.startActivity(subsystem.getName() + " Subsystem postUpdate")) {
subsystem.postUpdate(currentState, timeSubsystem.getEngineTime().getRealDelta());
}
}
assetTypeManager.disposedUnusedAssets();

PerformanceMonitor.rollCycle();
PerformanceMonitor.startActivity("Other");
return true;
} catch (Exception ignore) {
ignore.printStackTrace();

Check warning on line 537 in engine/src/main/java/org/terasology/engine/core/TerasologyEngine.java

View check run for this annotation

Terasology Jenkins.io / PMD

AvoidPrintStackTrace

NORMAL: Avoid printStackTrace(); use a logger call instead.
Raw output
Avoid printStackTrace(); use a logger call instead. <pre> <code> class Foo { void bar() { try { // do something } catch (Exception e) { e.printStackTrace(); } } } </code> </pre> <a href="https://pmd.github.io/pmd-6.55.0/pmd_rules_java_bestpractices.html#avoidprintstacktrace"> See PMD documentation. </a>
return true;
}
assetTypeManager.disposedUnusedAssets();

PerformanceMonitor.rollCycle();
PerformanceMonitor.startActivity("Other");
return true;
}

public void cleanup() {
Expand Down

0 comments on commit ec9adf8

Please sign in to comment.