Fixed ammo resupply and shooting not working clientside

This commit is contained in:
Anuken 2018-06-09 14:20:08 -04:00
parent 30e13259b3
commit b33dd7e91c
3 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -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;

View File

@ -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();