From e627008fbc25049bd9ec63b33107d25e17cfcdf3 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 8 Jun 2022 08:33:01 -0400 Subject: [PATCH] Slightly different implementation of #6910 --- core/src/mindustry/logic/GlobalVars.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/src/mindustry/logic/GlobalVars.java b/core/src/mindustry/logic/GlobalVars.java index 46ba1c1969..e24a15152c 100644 --- a/core/src/mindustry/logic/GlobalVars.java +++ b/core/src/mindustry/logic/GlobalVars.java @@ -68,12 +68,14 @@ public class GlobalVars{ } for(Block block : Vars.content.blocks()){ - put("@" + block.name, block); + //only register blocks that have no item equivalent (this skips sand) + if(content.item(block.name) == null){ + put("@" + block.name, block); + } } //used as a special value for any environmental solid block put("@solid", Blocks.stoneWall); - put("@air", Blocks.air); for(UnitType type : Vars.content.units()){ put("@" + type.name, type); @@ -161,6 +163,12 @@ public class GlobalVars{ /** Adds a constant value by name. */ public int put(String name, Object value){ + int existingIdx = namesToIds.get(name, -1); + if(existingIdx != -1){ //don't overwrite existing vars (see #6910) + Log.debug("Failed to add global logic variable '@', as it already exists.", name); + return existingIdx; + } + Var var = new Var(name); var.constant = true; if(value instanceof Number num){