diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index e722afb8f1..6af657678f 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -357,7 +357,8 @@ public class Logic implements ApplicationListener{ //map is over, no more world processor objective stuff state.rules.disableWorldProcessors = true; - state.rules.objectives.clear(); + + Call.clearObjectives(); //save, just in case if(!headless && !net.client()){ @@ -460,9 +461,6 @@ public class Logic implements ApplicationListener{ if(!state.isEditor()){ state.rules.objectives.update(); - if(state.rules.objectives.checkChanged() && net.server()){ - Call.setObjectives(state.rules.objectives); - } } if(state.rules.waves && state.rules.waveTimer && !state.gameOver){ diff --git a/core/src/mindustry/core/NetClient.java b/core/src/mindustry/core/NetClient.java index 914e8eb003..8171a89797 100644 --- a/core/src/mindustry/core/NetClient.java +++ b/core/src/mindustry/core/NetClient.java @@ -340,15 +340,23 @@ public class NetClient implements ApplicationListener{ state.rules = rules; } + //NOTE: avoid using this, runs into packet/buffer size limitations @Remote(variants = Variant.both) public static void setObjectives(MapObjectives executor){ state.rules.objectives = executor; } - @Remote(called = Loc.server) - public static void objectiveCompleted(String[] flagsRemoved, String[] flagsAdded){ - state.rules.objectiveFlags.removeAll(flagsRemoved); - state.rules.objectiveFlags.addAll(flagsAdded); + @Remote(variants = Variant.both, called = Loc.server) + public static void clearObjectives(){ + state.rules.objectives.clear(); + } + + @Remote(variants = Variant.both, called = Loc.server) + public static void completeObjective(int index){ + var obj = state.rules.objectives.get(index); + if(obj != null){ + obj.done(); + } } @Remote(variants = Variant.both) diff --git a/core/src/mindustry/game/MapObjectives.java b/core/src/mindustry/game/MapObjectives.java index 94b57d4d59..fe7a3b235d 100644 --- a/core/src/mindustry/game/MapObjectives.java +++ b/core/src/mindustry/game/MapObjectives.java @@ -39,8 +39,6 @@ public class MapObjectives implements Iterable, Eachable all = new Seq<>(4); - /** @see #checkChanged() */ - protected transient boolean changed; static{ registerObjective( @@ -126,21 +124,13 @@ public class MapObjectives implements Iterable, Eachable { //objectives cannot get completed on the client, but they do try to update for timers and such if(obj.update() && !net.client()){ - obj.completed = true; - obj.done(); + Call.completeObjective(all.indexOf(obj)); } - - changed |= obj.changed; - obj.changed = false; }); } - /** @return True if map rules should be synced. Reserved for {@link Vars#logic}; do not invoke directly! */ - public boolean checkChanged(){ - boolean has = changed; - changed = false; - - return has; + public @Nullable MapObjective get(int index){ + return index < 0 || index >= all.size ? null : all.get(index); } /** @return Whether there are any qualified objectives at all. */ @@ -149,7 +139,6 @@ public class MapObjectives implements Iterable, Eachable 0) changed = true; all.clear(); } @@ -191,7 +180,7 @@ public class MapObjectives implements Iterable, Eachable, Eachable