From ba3e2f6f6762812cb1860c3a3949a482e9a2ba43 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 11 Feb 2022 14:07:36 -0500 Subject: [PATCH] Fixed some multiplayer bugs --- core/src/mindustry/content/Blocks.java | 15 +++++++++++---- core/src/mindustry/core/NetClient.java | 3 ++- core/src/mindustry/input/DesktopInput.java | 3 --- core/src/mindustry/input/InputHandler.java | 3 +++ core/src/mindustry/type/Weapon.java | 19 +++++++++++-------- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 9bc5336edc..40fa50920f 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -3320,7 +3320,7 @@ public class Blocks{ ammo(Items.scrap, new BasicBulletType(){{ damage = 40; - speed = 8f; + speed = 8.5f; width = 11f; height = 16f; trailColor = Pal.bulletYellowBack; @@ -3329,13 +3329,20 @@ public class Blocks{ collidesTiles = false; shootEffect = Fx.shootBig2; smokeEffect = Fx.shootBigSmoke2; + frontColor = Color.white; + backColor = Color.valueOf("869cbe"); + + lifetime = 34f; + //controversial + homingDelay = 10f; + homingPower = 0.01f; }}); //TODO bullet. //recoilAmount = 1f; reloadTime = 8f; - shootLength = 15f; + shootLength = 14f; rotateSpeed = 5f; coolantUsage = 30f / 60f; @@ -3350,7 +3357,7 @@ public class Blocks{ widthSpread = true; targetGround = false; spread = 4.6f; - inaccuracy = 8f; + inaccuracy = 9f; restitution = 0.1f; shootWarmupSpeed = 0.08f; @@ -3359,7 +3366,7 @@ public class Blocks{ acceptCoolant = false; scaledHealth = 340; - range = 250f; + range = 270f; size = 4; }}; diff --git a/core/src/mindustry/core/NetClient.java b/core/src/mindustry/core/NetClient.java index 5533425b12..d5e2a3e3a7 100644 --- a/core/src/mindustry/core/NetClient.java +++ b/core/src/mindustry/core/NetClient.java @@ -34,7 +34,8 @@ import static mindustry.Vars.*; public class NetClient implements ApplicationListener{ 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 long ping; diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index 2097ad842e..ddcd3b26d3 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -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); - } } - - return super.tap(x, y, count, button); } diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index aa2fa6d297..e9826d8e83 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -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){ 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 -> { event.unitIDs = unitIds; })){ diff --git a/core/src/mindustry/type/Weapon.java b/core/src/mindustry/type/Weapon.java index 3c1b1a7e1e..9ff3cef80d 100644 --- a/core/src/mindustry/type/Weapon.java +++ b/core/src/mindustry/type/Weapon.java @@ -443,15 +443,18 @@ public class Weapon implements Cloneable{ if(unitSpawned == null){ return bullet.create(unit, unit.team, x, y, angle, (1f - velocityRnd) + Mathf.random(velocityRnd), lifescl); }else{ - Unit spawned = unitSpawned.create(unit.team); - spawned.set(x, y); - spawned.rotation = angle; - //immediately spawn at top speed, since it was launched - spawned.vel.trns(angle, unitSpawned.speed); - if(spawned.controller() instanceof MissileAI ai){ - ai.shooter = unit; + //don't spawn units clientside! + if(!net.client()){ + Unit spawned = unitSpawned.create(unit.team); + spawned.set(x, y); + spawned.rotation = angle; + //immediately spawn at top speed, since it was launched + spawned.vel.trns(angle, unitSpawned.speed); + if(spawned.controller() instanceof MissileAI ai){ + ai.shooter = unit; + } + spawned.add(); } - spawned.add(); //TODO assign AI target here? return null; }