mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-11-11 03:31:19 +03:00
Server crash fix / Disabled logic config sync / Faster logic parsing
This commit is contained in:
parent
96607ef753
commit
150aab3530
@ -33,6 +33,7 @@ import mindustry.world.*;
|
||||
import mindustry.world.blocks.ConstructBlock.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
import mindustry.world.blocks.logic.LogicBlock.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
import mindustry.world.blocks.power.*;
|
||||
import mindustry.world.consumers.*;
|
||||
@ -940,7 +941,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
/** Called when arbitrary configuration is applied to a tile. */
|
||||
public void configured(@Nullable Unit builder, @Nullable Object value){
|
||||
//null is of type void.class; anonymous classes use their superclass.
|
||||
Class<?> type = value == null ? void.class : value.getClass().isAnonymousClass() || value.getClass().getSimpleName().startsWith("adapter") ? value.getClass().getSuperclass() : value.getClass();
|
||||
Class<?> type = value == null ? void.class : value.getClass().isAnonymousClass() ? value.getClass().getSuperclass() : value.getClass();
|
||||
|
||||
if(value instanceof Item) type = Item.class;
|
||||
if(value instanceof Block) type = Block.class;
|
||||
@ -1360,12 +1361,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
|
||||
@Override
|
||||
public void control(LAccess type, Object p1, double p2, double p3, double p4){
|
||||
//don't execute configure instructions as the client
|
||||
if(type == LAccess.configure && block.logicConfigurable && !net.client()){
|
||||
//don't execute configure instructions that copy logic building configures; this can cause extreme lag
|
||||
if(type == LAccess.configure && block.logicConfigurable && !(p1 instanceof LogicBuild)){
|
||||
//change config only if it's new
|
||||
Object prev = senseObject(LAccess.config);
|
||||
if(prev != p1){
|
||||
configureAny(p1);
|
||||
if(senseObject(LAccess.config) != p1){
|
||||
configured(null, p1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,13 +50,11 @@ public enum LAccess{
|
||||
enabled("to"), //"to" is standard for single parameter access
|
||||
shoot("x", "y", "shoot"),
|
||||
shootp(true, "unit", "shoot"),
|
||||
configure(true, 30, "to"),
|
||||
configure(true, "to"),
|
||||
color("r", "g", "b");
|
||||
|
||||
public final String[] params;
|
||||
public final boolean isObj;
|
||||
/** Tick cooldown between invocations. */
|
||||
public float cooldown = -1;
|
||||
|
||||
public static final LAccess[]
|
||||
all = values(),
|
||||
@ -73,9 +71,4 @@ public enum LAccess{
|
||||
isObj = obj;
|
||||
}
|
||||
|
||||
LAccess(boolean obj, float cooldown, String... params){
|
||||
this.params = params;
|
||||
this.cooldown = cooldown;
|
||||
isObj = obj;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import mindustry.logic.LExecutor.*;
|
||||
public class LAssembler{
|
||||
public static ObjectMap<String, Func<String[], LStatement>> customParsers = new ObjectMap<>();
|
||||
public static final int maxTokenLength = 36;
|
||||
private static final int invalidNum = Integer.MIN_VALUE;
|
||||
|
||||
private static final StringMap opNameChanges = StringMap.of(
|
||||
"atan2", "angle",
|
||||
@ -77,23 +78,22 @@ public class LAssembler{
|
||||
//remove spaces for non-strings
|
||||
symbol = symbol.replace(' ', '_');
|
||||
|
||||
try{
|
||||
double value = parseDouble(symbol);
|
||||
if(Double.isNaN(value) || Double.isInfinite(value)) value = 0;
|
||||
double value = parseDouble(symbol);
|
||||
|
||||
if(value == invalidNum){
|
||||
return putVar(symbol).id;
|
||||
}else{
|
||||
//this creates a hidden const variable with the specified value
|
||||
return putConst("___" + value, value).id;
|
||||
}catch(NumberFormatException e){
|
||||
return putVar(symbol).id;
|
||||
}
|
||||
}
|
||||
|
||||
double parseDouble(String symbol) throws NumberFormatException{
|
||||
double parseDouble(String symbol){
|
||||
//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);
|
||||
if(symbol.startsWith("0b")) return Strings.parseLong(symbol, 2, 2, symbol.length(), invalidNum);
|
||||
if(symbol.startsWith("0x")) return Strings.parseLong(symbol, 16, 2, symbol.length(), invalidNum);
|
||||
|
||||
return Double.parseDouble(symbol);
|
||||
return Strings.parseDouble(symbol, invalidNum);
|
||||
}
|
||||
|
||||
/** Adds a constant value by name. */
|
||||
|
@ -523,7 +523,6 @@ public class LExecutor{
|
||||
public int target;
|
||||
public LAccess type = LAccess.enabled;
|
||||
public int p1, p2, p3, p4;
|
||||
public Interval timer = new Interval(1);
|
||||
|
||||
public ControlI(LAccess type, int target, int p1, int p2, int p3, int p4){
|
||||
this.type = type;
|
||||
@ -539,7 +538,7 @@ public class LExecutor{
|
||||
@Override
|
||||
public void run(LExecutor exec){
|
||||
Object obj = exec.obj(target);
|
||||
if(obj instanceof Building b && b.team == exec.team && exec.linkIds.contains(b.id) && (type.cooldown <= 0 || timer.get(type.cooldown))){
|
||||
if(obj instanceof Building b && b.team == exec.team && exec.linkIds.contains(b.id)){
|
||||
if(type.isObj){
|
||||
b.control(type, exec.obj(p1), exec.num(p2), exec.num(p3), exec.num(p4));
|
||||
}else{
|
||||
|
@ -143,7 +143,7 @@ public class PowerNode extends PowerBlock{
|
||||
Draw.color(Pal.placing);
|
||||
Drawf.circles(x * tilesize + offset, y * tilesize + offset, laserRange * tilesize);
|
||||
|
||||
getPotentialLinks(tile, other -> {
|
||||
getPotentialLinks(tile, player.team(), other -> {
|
||||
Draw.color(laserColor1, Renderer.laserOpacity * 0.5f);
|
||||
drawLaser(tile.team(), x * tilesize + offset, y * tilesize + offset, other.x, other.y, size, other.block.size);
|
||||
|
||||
@ -193,10 +193,10 @@ public class PowerNode extends PowerBlock{
|
||||
return Intersector.overlaps(Tmp.cr1.set(src.worldx() + offset, src.worldy() + offset, laserRange * tilesize), Tmp.r1.setSize(size * tilesize).setCenter(other.worldx() + offset, other.worldy() + offset));
|
||||
}
|
||||
|
||||
protected void getPotentialLinks(Tile tile, Cons<Building> others){
|
||||
protected void getPotentialLinks(Tile tile, Team team, Cons<Building> others){
|
||||
Boolf<Building> valid = other -> other != null && other.tile() != tile && other.power != null &&
|
||||
(other.block.outputsPower || other.block.consumesPower || other.block instanceof PowerNode) &&
|
||||
overlaps(tile.x * tilesize + offset, tile.y * tilesize + offset, other.tile(), laserRange * tilesize) && other.team == player.team() &&
|
||||
overlaps(tile.x * tilesize + offset, tile.y * tilesize + offset, other.tile(), laserRange * tilesize) && other.team == team &&
|
||||
!graphs.contains(other.power.graph) &&
|
||||
!PowerNode.insulated(tile, other.tile) &&
|
||||
!(other instanceof PowerNodeBuild obuild && obuild.power.links.size >= ((PowerNode)obuild.block).maxNodes) &&
|
||||
@ -211,7 +211,7 @@ public class PowerNode extends PowerBlock{
|
||||
//add conducting graphs to prevent double link
|
||||
for(var p : Edges.getEdges(size)){
|
||||
Tile other = tile.nearby(p);
|
||||
if(other != null && other.team() == player.team() && other.build != null && other.build.power != null){
|
||||
if(other != null && other.team() == team && other.build != null && other.build.power != null){
|
||||
graphs.add(other.build.power.graph);
|
||||
}
|
||||
}
|
||||
@ -351,7 +351,7 @@ public class PowerNode extends PowerBlock{
|
||||
public void placed(){
|
||||
if(net.client()) return;
|
||||
|
||||
getPotentialLinks(tile, other -> {
|
||||
getPotentialLinks(tile, team, other -> {
|
||||
if(!power.links.contains(other.pos())){
|
||||
configureAny(other.pos());
|
||||
}
|
||||
@ -382,7 +382,7 @@ public class PowerNode extends PowerBlock{
|
||||
if(this == other){
|
||||
if(other.power.links.size == 0){
|
||||
int[] total = {0};
|
||||
getPotentialLinks(tile, link -> {
|
||||
getPotentialLinks(tile, team, link -> {
|
||||
if(!insulated(this, link) && total[0]++ < maxNodes){
|
||||
configure(link.pos());
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=50fe096a7d26e76abc9be1ee5b18172d18e1b930
|
||||
archash=f57850f3e251bf14804cbbea536a9f01cf61c22d
|
||||
|
Loading…
Reference in New Issue
Block a user