From 68b06fdea695603b759c255759af684f6bee42c1 Mon Sep 17 00:00:00 2001 From: BalaM314 <71201189+BalaM314@users.noreply.github.com> Date: Tue, 12 Dec 2023 19:17:40 +0530 Subject: [PATCH] Allow fetching unitCount by type, and buildCount without type (#9374) * Allow fetching unitCount by type, and buildCount without type * show in processor ui --- core/src/mindustry/logic/LExecutor.java | 11 +++++++++-- core/src/mindustry/logic/LStatements.java | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/logic/LExecutor.java b/core/src/mindustry/logic/LExecutor.java index 01e5266fea..16dfe01bf2 100644 --- a/core/src/mindustry/logic/LExecutor.java +++ b/core/src/mindustry/logic/LExecutor.java @@ -1360,13 +1360,20 @@ public class LExecutor{ exec.setobj(result, i < 0 || i >= builds.size ? null : builds.get(i)); } } - case unitCount -> exec.setnum(result, data.units.size); + case unitCount -> { + UnitType type = exec.obj(extra) instanceof UnitType u ? u : null; + if(type == null){ + exec.setnum(result, data.units.size); + }else{ + exec.setnum(result, data.unitsByType[type.id].size); + } + } case coreCount -> exec.setnum(result, data.cores.size); case playerCount -> exec.setnum(result, data.players.size); case buildCount -> { Block block = exec.obj(extra) instanceof Block b ? b : null; if(block == null){ - exec.setobj(result, null); + exec.setnum(result, data.buildings.size); }else{ exec.setnum(result, data.getBuildings(block).size); } diff --git a/core/src/mindustry/logic/LStatements.java b/core/src/mindustry/logic/LStatements.java index 1a9e0473d8..30b7b52b56 100644 --- a/core/src/mindustry/logic/LStatements.java +++ b/core/src/mindustry/logic/LStatements.java @@ -1748,7 +1748,7 @@ public class LStatements{ fields(table, index, i -> index = i); } - if(type == FetchType.buildCount || type == FetchType.build){ + if(type == FetchType.buildCount || type == FetchType.build || type == FetchType.unitCount){ row(table); fields(table, "block", extra, i -> extra = i);