Fixed block sync not activating for multiplayer

This commit is contained in:
Anuken
2018-01-26 18:59:56 -05:00
parent 8e6f628f5b
commit cfd62a010c
5 changed files with 8 additions and 7 deletions

View File

@ -395,7 +395,7 @@ public class NetServer extends Module{
if(Timers.get("serverBlockSync", blockSyncTime)){
Array<NetConnection> connections = new Array<>();
Array<NetConnection> connections = Net.getConnections();
for(int i = 0; i < connections.size; i ++){
int id = connections.get(i).id;
@ -453,6 +453,7 @@ public class NetServer extends Module{
}
packet.stream = new ByteArrayInputStream(bs.toByteArray());
//UCore.log("Sent block update stream to " + client + " / " + packet.stream.available());
Net.sendStream(client, packet);
}

View File

@ -78,8 +78,8 @@ public class Net{
}
/**Returns a list of all connections IDs.*/
public static Array<? extends NetConnection> getConnections(){
return serverProvider.getConnections();
public static Array<NetConnection> getConnections(){
return (Array<NetConnection>)serverProvider.getConnections();
}
/**Send an object to all connected clients, or to the server if this is a client.*/

View File

@ -95,7 +95,7 @@ public class HudFragment implements Fragment{
visible(() -> !GameState.is(State.menu));
Label fps = new Label(() -> (Settings.getBool("fps") ? (Gdx.graphics.getFramesPerSecond() + " FPS") +
(Net.active() && !Vars.gwt ? " / Ping: " + Net.getPing() : "") : ""));
(Net.active() && !Vars.gwt && !Net.server() ? " / Ping: " + Net.getPing() : "") : ""));
row();
add(fps).size(-1);

View File

@ -50,7 +50,7 @@ public class DefenseBlocks{
repairturret = new RepairTurret("repairturret"){
{
range = 30;
reload = 25f;
reload = 20f;
health = 60;
powerUsed = 0.08f;
}

View File

@ -15,7 +15,7 @@ import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Strings;
public class RepairTurret extends PowerTurret{
float repairPercent = 1f / 150f;
protected float repairFrac = 1f / 135f;
public RepairTurret(String name) {
super(name);
@ -59,7 +59,7 @@ public class RepairTurret extends PowerTurret{
int maxhealth = entity.blockTarget.tile.block().health;
if(entity.timer.get(timerReload, reload) && Angles.angleDist(target, entity.rotation) < shootCone){
entity.blockTarget.health += maxhealth * repairPercent;
entity.blockTarget.health += maxhealth * repairFrac;
if(entity.blockTarget.health > maxhealth)
entity.blockTarget.health = maxhealth;