Many various network fixes
This commit is contained in:
@@ -315,7 +315,7 @@ public class NetServer extends Module{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!player.timer.get(Player.timerSync, serverSyncTime)) continue;
|
||||
if(!player.timer.get(Player.timerSync, serverSyncTime) || !connection.hasConnected) continue;
|
||||
|
||||
//if the player hasn't acknowledged that it has recieved the packet, send the same thing again
|
||||
if(connection.lastSentSnapshotID > connection.lastSnapshotID){
|
||||
@@ -454,6 +454,7 @@ public class NetServer extends Module{
|
||||
@Remote(targets = Loc.client)
|
||||
public static void connectConfirm(Player player){
|
||||
player.add();
|
||||
Net.getConnection(player.clientid).hasConnected = true;
|
||||
Call.sendMessage("[accent]" + player.name + " has connected.");
|
||||
Log.info("&y{0} has connected.", player.name);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ItemDrop extends SolidEntity implements SaveTrait, SyncTrait, DrawT
|
||||
drop.item = item;
|
||||
drop.amount = amount;
|
||||
drop.velocity.set(4f, 0f).rotate(angle);
|
||||
drop.set(x, y);
|
||||
drop.setNet(x, y);
|
||||
drop.add();
|
||||
|
||||
return drop;
|
||||
@@ -162,6 +162,9 @@ public class ItemDrop extends SolidEntity implements SaveTrait, SyncTrait, DrawT
|
||||
}else{
|
||||
updateVelocity(0.2f);
|
||||
updateTime();
|
||||
if(time >= lifetime()){
|
||||
CallEntity.onPickup(getID());
|
||||
}
|
||||
}
|
||||
|
||||
Tile tile = world.tileWorld(x, y);
|
||||
|
||||
@@ -125,9 +125,9 @@ public interface BuilderTrait {
|
||||
|
||||
if (!(tile.block() instanceof BreakBlock)) { //check if haven't started placing
|
||||
if(Build.validBreak(unit.getTeam(), current.x, current.y)){
|
||||
|
||||
//if it's valid, place it
|
||||
//FIXME a player instance is required here, but the the builder may not be a player
|
||||
if(!current.requested){
|
||||
if(!current.requested && unit instanceof Player){
|
||||
CallBlocks.breakBlock((Player)unit, unit.getTeam(), current.x, current.y);
|
||||
current.requested = true;
|
||||
}
|
||||
@@ -154,10 +154,9 @@ public interface BuilderTrait {
|
||||
}else{
|
||||
if (!(tile.block() instanceof BuildBlock)) { //check if haven't started placing
|
||||
if(Build.validPlace(unit.getTeam(), current.x, current.y, current.recipe.result, current.rotation)){
|
||||
//if it's valid, place it
|
||||
//FIXME a player instance is required here, but the the builder may not be a player
|
||||
|
||||
if(!current.requested){
|
||||
//if it's valid, place it
|
||||
if(!current.requested && unit instanceof Player){
|
||||
CallBlocks.placeBlock((Player)unit, unit.getTeam(), current.x, current.y, current.recipe, current.rotation);
|
||||
current.requested = true;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,9 @@ package io.anuke.mindustry.entities.units.types;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
import com.badlogic.gdx.utils.Queue;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.entities.effect.ItemDrop;
|
||||
import io.anuke.mindustry.entities.traits.BuilderTrait;
|
||||
@@ -17,7 +15,6 @@ import io.anuke.mindustry.entities.units.UnitState;
|
||||
import io.anuke.mindustry.game.EventType.BlockBuildEvent;
|
||||
import io.anuke.mindustry.gen.CallEntity;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.net.In;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
@@ -84,7 +81,7 @@ public class Drone extends FlyingUnit implements BuilderTrait {
|
||||
float dist = Math.min(entity.distanceTo(x, y) - placeDistance, 0);
|
||||
|
||||
if(dist / type.maxVelocity < timeToBuild * 0.9f){
|
||||
CallEntity.onDroneBeginBuild(this, entity.tile, entity.recipe);
|
||||
//CallEntity.onDroneBeginBuild(this, entity.tile, entity.recipe);
|
||||
target = entity;
|
||||
setState(build);
|
||||
}
|
||||
@@ -207,24 +204,26 @@ public class Drone extends FlyingUnit implements BuilderTrait {
|
||||
public void write(DataOutput data) throws IOException {
|
||||
super.write(data);
|
||||
data.writeInt(mineTile == null ? -1 : mineTile.packedPosition());
|
||||
data.writeInt(placeQueue.size == 0 ? -1 : world.tile(placeQueue.last().x, placeQueue.last().y).packedPosition());
|
||||
data.writeByte(placeQueue.size == 0 ? -1 : placeQueue.last().recipe.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInput data, long time) throws IOException {
|
||||
super.read(data, time);
|
||||
int mined = data.readInt();
|
||||
int pp = data.readInt();
|
||||
byte rid = data.readByte();
|
||||
|
||||
if(mined != -1){
|
||||
mineTile = world.tile(mined);
|
||||
}
|
||||
}
|
||||
|
||||
@Remote(in = In.entities)
|
||||
public static void onDroneBeginBuild(Unit unit, Tile tile, Recipe recipe){
|
||||
if(unit == null) return;
|
||||
|
||||
Drone drone = (Drone)unit;
|
||||
|
||||
drone.getPlaceQueue().addLast(new BuildRequest(tile.x, tile.y, tile.getRotation(), recipe));
|
||||
if(pp != -1){
|
||||
Tile tile = world.tile(pp);
|
||||
placeQueue.clear();
|
||||
placeQueue.addLast(new BuildRequest(tile.x, tile.y, tile.getRotation(), Recipe.getByID(rid)));
|
||||
}
|
||||
}
|
||||
|
||||
public final UnitState
|
||||
|
||||
@@ -21,6 +21,8 @@ public abstract class NetConnection {
|
||||
/**Timestamp of last recieved snapshot.*/
|
||||
public long lastRecievedTime;
|
||||
|
||||
public boolean hasConnected = false;
|
||||
|
||||
public NetConnection(int id, String address){
|
||||
this.id = id;
|
||||
this.address = address;
|
||||
|
||||
Reference in New Issue
Block a user