From b33dd7e91c75a94f0d189b0c8089146f8d56ca79 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 9 Jun 2018 14:20:08 -0400 Subject: [PATCH] Fixed ammo resupply and shooting not working clientside --- .../io/anuke/annotations/RemoteWriteGenerator.java | 11 +++++++++++ core/src/io/anuke/mindustry/io/TypeIO.java | 1 - core/src/io/anuke/mindustry/net/NetworkIO.java | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/annotations/src/io/anuke/annotations/RemoteWriteGenerator.java b/annotations/src/io/anuke/annotations/RemoteWriteGenerator.java index 07edbb2752..3ab0d2c3bb 100644 --- a/annotations/src/io/anuke/annotations/RemoteWriteGenerator.java +++ b/annotations/src/io/anuke/annotations/RemoteWriteGenerator.java @@ -150,6 +150,13 @@ public class RemoteWriteGenerator { String typeName = var.asType().toString(); //captialized version of type name for writing primitives String capName = typeName.equals("byte") ? "" : Character.toUpperCase(typeName.charAt(0)) + typeName.substring(1); + //special case: method can be called from anywhere to anywhere + //thus, only write the player when the SERVER is writing data, since the client is the only one who reads that + boolean writePlayerSkipCheck = methodEntry.where == Loc.both && methodEntry.local == Loc.both && i == 0; + + if(writePlayerSkipCheck){ //write begin check + method.beginControlFlow("if(io.anuke.mindustry.net.Net.server())"); + } if(Utils.isPrimitive(typeName)) { //check if it's a primitive, and if so write it if(typeName.equals("boolean")){ //booleans are special @@ -170,6 +177,10 @@ public class RemoteWriteGenerator { //add statement for writing it method.addStatement(ser.writeMethod + "(TEMP_BUFFER, " + varName +")"); } + + if(writePlayerSkipCheck){ //write end check + method.endControlFlow(); + } } //assign packet length diff --git a/core/src/io/anuke/mindustry/io/TypeIO.java b/core/src/io/anuke/mindustry/io/TypeIO.java index a3b89d7ad1..95309c4611 100644 --- a/core/src/io/anuke/mindustry/io/TypeIO.java +++ b/core/src/io/anuke/mindustry/io/TypeIO.java @@ -11,7 +11,6 @@ import io.anuke.mindustry.type.Upgrade; import io.anuke.mindustry.type.Weapon; import io.anuke.mindustry.world.Tile; - import java.nio.ByteBuffer; import static io.anuke.mindustry.Vars.playerGroup; diff --git a/core/src/io/anuke/mindustry/net/NetworkIO.java b/core/src/io/anuke/mindustry/net/NetworkIO.java index 3bd8e6a3e9..3a13960d3a 100644 --- a/core/src/io/anuke/mindustry/net/NetworkIO.java +++ b/core/src/io/anuke/mindustry/net/NetworkIO.java @@ -15,6 +15,7 @@ import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.BlockPart; import io.anuke.ucore.core.Timers; import io.anuke.ucore.entities.Entities; +import io.anuke.ucore.entities.EntityPhysics; import io.anuke.ucore.util.Bits; import java.io.*; @@ -169,6 +170,8 @@ public class NetworkIO { } } + EntityPhysics.resizeTree(0, 0, width * tilesize, height * tilesize); + player.reset(); state.teams = new TeamInfo();