Fixed some multiplayer bugs

This commit is contained in:
Anuken
2022-02-11 14:07:36 -05:00
parent 3728d137cd
commit ba3e2f6f67
5 changed files with 27 additions and 16 deletions
+11 -4
View File
@@ -3320,7 +3320,7 @@ public class Blocks{
ammo(Items.scrap, new BasicBulletType(){{ ammo(Items.scrap, new BasicBulletType(){{
damage = 40; damage = 40;
speed = 8f; speed = 8.5f;
width = 11f; width = 11f;
height = 16f; height = 16f;
trailColor = Pal.bulletYellowBack; trailColor = Pal.bulletYellowBack;
@@ -3329,13 +3329,20 @@ public class Blocks{
collidesTiles = false; collidesTiles = false;
shootEffect = Fx.shootBig2; shootEffect = Fx.shootBig2;
smokeEffect = Fx.shootBigSmoke2; smokeEffect = Fx.shootBigSmoke2;
frontColor = Color.white;
backColor = Color.valueOf("869cbe");
lifetime = 34f;
//controversial
homingDelay = 10f;
homingPower = 0.01f;
}}); }});
//TODO bullet. //TODO bullet.
//recoilAmount = 1f; //recoilAmount = 1f;
reloadTime = 8f; reloadTime = 8f;
shootLength = 15f; shootLength = 14f;
rotateSpeed = 5f; rotateSpeed = 5f;
coolantUsage = 30f / 60f; coolantUsage = 30f / 60f;
@@ -3350,7 +3357,7 @@ public class Blocks{
widthSpread = true; widthSpread = true;
targetGround = false; targetGround = false;
spread = 4.6f; spread = 4.6f;
inaccuracy = 8f; inaccuracy = 9f;
restitution = 0.1f; restitution = 0.1f;
shootWarmupSpeed = 0.08f; shootWarmupSpeed = 0.08f;
@@ -3359,7 +3366,7 @@ public class Blocks{
acceptCoolant = false; acceptCoolant = false;
scaledHealth = 340; scaledHealth = 340;
range = 250f; range = 270f;
size = 4; size = 4;
}}; }};
+2 -1
View File
@@ -34,7 +34,8 @@ import static mindustry.Vars.*;
public class NetClient implements ApplicationListener{ public class NetClient implements ApplicationListener{
private static final float dataTimeout = 60 * 20; private static final float dataTimeout = 60 * 20;
private static final float playerSyncTime = 5; /** ticks between syncs, e.g. 5 means 60/5 = 12 syncs/sec*/
private static final float playerSyncTime = 4;
private static final Reads dataReads = new Reads(null); private static final Reads dataReads = new Reads(null);
private long ping; private long ping;
@@ -728,12 +728,9 @@ public class DesktopInput extends InputHandler{
} }
Call.commandUnits(player, ids, attack instanceof Building b ? b : null, attack instanceof Unit u ? u : null, target); Call.commandUnits(player, ids, attack instanceof Building b ? b : null, attack instanceof Unit u ? u : null, target);
} }
} }
return super.tap(x, y, count, button); return super.tap(x, y, count, button);
} }
@@ -194,6 +194,9 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
public static void commandUnits(Player player, int[] unitIds, @Nullable Building buildTarget, @Nullable Unit unitTarget, @Nullable Vec2 posTarget){ public static void commandUnits(Player player, int[] unitIds, @Nullable Building buildTarget, @Nullable Unit unitTarget, @Nullable Vec2 posTarget){
if(player == null || unitIds == null) return; if(player == null || unitIds == null) return;
//why did I ever think this was a good idea
if(unitTarget != null && unitTarget.isNull()) unitTarget = null;
if(net.server() && !netServer.admins.allowAction(player, ActionType.commandUnits, event -> { if(net.server() && !netServer.admins.allowAction(player, ActionType.commandUnits, event -> {
event.unitIDs = unitIds; event.unitIDs = unitIds;
})){ })){
+11 -8
View File
@@ -443,15 +443,18 @@ public class Weapon implements Cloneable{
if(unitSpawned == null){ if(unitSpawned == null){
return bullet.create(unit, unit.team, x, y, angle, (1f - velocityRnd) + Mathf.random(velocityRnd), lifescl); return bullet.create(unit, unit.team, x, y, angle, (1f - velocityRnd) + Mathf.random(velocityRnd), lifescl);
}else{ }else{
Unit spawned = unitSpawned.create(unit.team); //don't spawn units clientside!
spawned.set(x, y); if(!net.client()){
spawned.rotation = angle; Unit spawned = unitSpawned.create(unit.team);
//immediately spawn at top speed, since it was launched spawned.set(x, y);
spawned.vel.trns(angle, unitSpawned.speed); spawned.rotation = angle;
if(spawned.controller() instanceof MissileAI ai){ //immediately spawn at top speed, since it was launched
ai.shooter = unit; spawned.vel.trns(angle, unitSpawned.speed);
if(spawned.controller() instanceof MissileAI ai){
ai.shooter = unit;
}
spawned.add();
} }
spawned.add();
//TODO assign AI target here? //TODO assign AI target here?
return null; return null;
} }