mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-10 23:28:52 +07:00
Hex/bin logic number support
This commit is contained in:
parent
563e99aded
commit
00d6997b5a
@ -1912,7 +1912,7 @@ public class Blocks implements ContentList{
|
||||
new UnitType[]{UnitTypes.antumbra, UnitTypes.eclipse},
|
||||
new UnitType[]{UnitTypes.arkyid, UnitTypes.toxopid},
|
||||
new UnitType[]{UnitTypes.scepter, UnitTypes.reign},
|
||||
new UnitType[] {UnitTypes.sei, UnitTypes.omura},
|
||||
new UnitType[]{UnitTypes.sei, UnitTypes.omura},
|
||||
new UnitType[]{UnitTypes.quad, UnitTypes.oct},
|
||||
new UnitType[]{UnitTypes.vela, UnitTypes.corvus}
|
||||
);
|
||||
|
@ -189,17 +189,28 @@ public class LAssembler{
|
||||
return putConst("___" + symbol, symbol.substring(1, symbol.length() - 1).replace("\\n", "\n")).id;
|
||||
}
|
||||
|
||||
//remove spaces for non-strings
|
||||
symbol = symbol.replace(' ', '_');
|
||||
|
||||
try{
|
||||
double value = Double.parseDouble(symbol);
|
||||
double value = parseDouble(symbol);
|
||||
if(Double.isNaN(value) || Double.isInfinite(value)) value = 0;
|
||||
|
||||
//this creates a hidden const variable with the specified value
|
||||
String key = "___" + value;
|
||||
return putConst(key, value).id;
|
||||
return putConst("___" + value, value).id;
|
||||
}catch(NumberFormatException e){
|
||||
return putVar(symbol).id;
|
||||
}
|
||||
}
|
||||
|
||||
double parseDouble(String symbol) throws NumberFormatException{
|
||||
//parse hex/binary syntax
|
||||
if(symbol.startsWith("0b")) return Long.parseLong(symbol.substring(2), 2);
|
||||
if(symbol.startsWith("0x")) return Long.parseLong(symbol.substring(2), 16);
|
||||
|
||||
return Double.parseDouble(symbol);
|
||||
}
|
||||
|
||||
/** Adds a constant value by name. */
|
||||
public BVar putConst(String name, Object value){
|
||||
BVar var = putVar(name);
|
||||
|
@ -491,7 +491,6 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
selected = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user