Skip to content

Commit

Permalink
Revert "Remove need to iterate through list every frame"
Browse files Browse the repository at this point in the history
This reverts commit 0d6234e.
  • Loading branch information
7003Mars committed Dec 30, 2023
1 parent f5ff822 commit 4e43d28
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 15 deletions.
1 change: 0 additions & 1 deletion core/src/mindustry/entities/comp/BuilderComp.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ void addBuild(BuildPlan place, boolean tail){
planSeq.clear();
}
if(replace != null){
replace.removed = true;
plans.remove(replace);
if(isLocalPlayer) control.input.playerPlanTree.remove(replace);
}
Expand Down
2 changes: 0 additions & 2 deletions core/src/mindustry/entities/units/BuildPlan.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public class BuildPlan implements Position, Pool.Poolable, QuadTreeObject{
public boolean initialized, stuck, cachedValid;
/** If true, this plan is in the world. If false, it is being rendered in a schematic. */
public boolean worldContext = true;
/** Has the plan been removed from the world? */
public boolean removed = false;

/** Visual scale. Used only for rendering. */
public float animScale = 0f;
Expand Down
13 changes: 2 additions & 11 deletions core/src/mindustry/input/InputHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,6 @@ protected void removeSelection(int x1, int y1, int x2, int y2, boolean flush, in
while(it.hasNext()){
var plan = it.next();
if(!plan.breaking && plan.bounds(Tmp.r2).overlaps(Tmp.r1)){
plan.removed = true;
it.remove();
}
}
Expand All @@ -1532,7 +1531,6 @@ protected void removeSelection(int x1, int y1, int x2, int y2, boolean flush, in
while(it.hasNext()){
var plan = it.next();
if(!plan.breaking && plan.bounds(Tmp.r2).overlaps(Tmp.r1)){
plan.removed = true;
it.remove();
}
}
Expand All @@ -1541,10 +1539,7 @@ protected void removeSelection(int x1, int y1, int x2, int y2, boolean flush, in
it = frozenPlans.iterator();
while (it.hasNext()) {
BuildPlan plan = it.next();
if (!plan.breaking && plan.bounds(Tmp.r2).overlaps(Tmp.r1)) {
plan.removed = true;
it.remove();
}
if (!plan.breaking && plan.bounds(Tmp.r2).overlaps(Tmp.r1)) it.remove();
}
}

Expand Down Expand Up @@ -1577,7 +1572,6 @@ protected void removeSelectionPlans(int x1, int y1, int x2, int y2, int maxLengt
while(it.hasNext()){
BuildPlan plan = it.next();
if(plan.bounds(Tmp.r2, true).overlaps(Tmp.r1)){
plan.removed = true;
it.remove();
}
}
Expand All @@ -1586,7 +1580,6 @@ protected void removeSelectionPlans(int x1, int y1, int x2, int y2, int maxLengt
while(it.hasNext()){
BuildPlan plan = it.next();
if(plan.bounds(Tmp.r2, true).overlaps(Tmp.r1)){
plan.removed = true;
it.remove();
}
}
Expand All @@ -1595,9 +1588,7 @@ protected void removeSelectionPlans(int x1, int y1, int x2, int y2, int maxLengt
it = frozenPlans.iterator();
while (it.hasNext()) {
BuildPlan plan = it.next();
if (plan.bounds(Tmp.r2, true).overlaps(Tmp.r1)) {
it.remove();
}
if (plan.bounds(Tmp.r2, true).overlaps(Tmp.r1)) it.remove();
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/mindustry/ui/fragments/PlanConfigFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public void showConfig(BuildPlan plan) {
this.hide();
return;
}
if (plan.removed) {
boolean planExists = control.input.selectPlans.contains(plan) || player.unit().plans.contains(plan);
if (!planExists) {
this.hide();
return;
}
Expand Down

0 comments on commit 4e43d28

Please sign in to comment.