From 598049265a8d4732a1719bde8fb15a79d38f40eb Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 13 Jan 2023 09:59:01 -0500 Subject: [PATCH] Complete revert of #8019 --- core/src/mindustry/world/meta/Env.java | 75 ++++---------------------- 1 file changed, 9 insertions(+), 66 deletions(-) diff --git a/core/src/mindustry/world/meta/Env.java b/core/src/mindustry/world/meta/Env.java index 7ea5010a54..4cb7bf7676 100644 --- a/core/src/mindustry/world/meta/Env.java +++ b/core/src/mindustry/world/meta/Env.java @@ -1,83 +1,26 @@ package mindustry.world.meta; -import arc.struct.*; -import arc.util.*; - /** Environmental flags for different types of locations. */ public class Env{ public static final int //is on a planet - terrestrial, + terrestrial = 1, //is in space, no atmosphere - space, + space = 1 << 1, //is underwater, on a planet - underwater, + underwater = 1 << 2, //has a spores - spores, + spores = 1 << 3, //has a scorching env effect - scorching, + scorching = 1 << 4, //has oil reservoirs - groundOil, + groundOil = 1 << 5, //has water reservoirs - groundWater, + groundWater = 1 << 6, //has oxygen in the atmosphere - oxygen, + oxygen = 1 << 7, //all attributes combined, only used for bitmasking purposes any = 0xffffffff, //no attributes (0) none = 0; - - //do NOT modify directly! - public static final ObjectIntMap nameToId; - public static final IntMap idToName; - - static{ - //last time i didn't use a static initializer i got a null pointer. - //i can probably just move the fields around, but i don't trust java enough for that - nameToId = new ObjectIntMap<>(); - idToName = new IntMap<>(); - - terrestrial = add("terrestrial"); - space = add("space"); - underwater = add("underwater"); - spores = add("spores"); - scorching = add("scorching"); - groundOil = add("groundOil"); - groundWater = add("groundWater"); - oxygen = add("oxygen"); - } - - public static int add(String key){ - if(nameToId.containsKey(key)) throw new IllegalArgumentException("'" + key + "' env already exists."); - if(nameToId.size >= 32) throw new IllegalStateException("Max env count 32 exceeded."); - - int id = 1 << nameToId.size; - nameToId.put(key, id); - idToName.put(id, key); - return id; - } - - public static int remap(int mask, IntMap idToName){ - int out = 0; - for(int i = 0; i < 32; i++){ - int key = 1 << i; - if((mask & key) == key){ - String name = idToName.get(key); - if(name == null){ - //if it's unmapped it's probably just some mods using constant value - out |= key; - continue; - } - - int id = nameToId.get(name, -1); - if(id == -1){ - Log.warn("Ignoring '@' env key.", name); - }else{ - out |= id; - } - } - } - - return out; - } -} +} \ No newline at end of file