Skip to content

Commit

Permalink
Attempt to fix a rare yet critical crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Slotterleet committed Apr 27, 2024
1 parent 7ac2fb5 commit c0238f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/fos/core/FOSMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import fos.ui.*;
import fos.ui.menus.*;
import mindustry.ai.Pathfinder;
import mindustry.core.GameState;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.mod.Mod;
Expand Down Expand Up @@ -157,6 +158,10 @@ public void init() {
Reflect.invoke(pathfinder, "preloadPath", new Object[]{pt}, Pathfinder.Flowfield.class);
}
});
Events.on(EventType.StateChangeEvent.class, e -> {
// reset the flowfield's vector on exit.
if (e.to == GameState.State.menu) FOSVars.fposVector.setZero();
});

//anything after this should not be initialized on dedicated servers.
if (headless) return;
Expand Down
4 changes: 3 additions & 1 deletion src/fos/core/FOSVars.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ public class FOSVars {
/** Capsules creator **/
public static CapsulesController capsulesController;

/** Internal. */
public static Vec2 fposVector = new Vec2();
/** A flowfield used in certain custom AIs. */
public static Pathfinder.Flowfield fpos = new Pathfinder.PositionTarget(new Vec2());
public static Pathfinder.Flowfield fpos = new Pathfinder.PositionTarget(fposVector);

/** Enabling debug mode debug **/
public static final boolean debug = Core.settings.getBool("fos-debugmode");
Expand Down

0 comments on commit c0238f7

Please sign in to comment.