diff --git a/build.gradle b/build.gradle index 7adb39d517..90e50b2227 100644 --- a/build.gradle +++ b/build.gradle @@ -142,18 +142,13 @@ project(":ios") { compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion" compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios" } - - robovm { - iosSignIdentity = "a" - iosProvisioningProfile = "" - } } project(":core") { apply plugin: "java" dependencies { - boolean comp = System.properties["release"] == null || System.properties["release"] == "false" + boolean comp = true//System.properties["release"] == null || System.properties["release"] == "false" if(!comp){ println("NOTICE: Compiling release build.") @@ -161,7 +156,7 @@ project(":core") { println("Compiling DEBUG build.") } - if(new File('../uCore').exists() && comp){ + if(new File(projectDir.parent, '../uCore').exists() && comp){ compile project(":uCore") }else{ compile "com.github.anuken:ucore:$uCoreVersion" diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index f39511b080..75730d6277 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -106,22 +106,22 @@ public class Vars{ new Locale("de"), new Locale("pt", "BR"), new Locale("ko"), new Locale("in", "ID"), new Locale("ita"), new Locale("es")}; public static final Color[] playerColors = { - Color.valueOf("82759a"), - Color.valueOf("c0c1c5"), - Color.valueOf("fff0e7"), - Color.valueOf("7d2953"), - Color.valueOf("ff074e"), - Color.valueOf("ff072a"), - Color.valueOf("ff76a6"), - Color.valueOf("a95238"), - Color.valueOf("ffa108"), - Color.valueOf("feeb2c"), - Color.valueOf("ffcaa8"), - Color.valueOf("008551"), - Color.valueOf("00e339"), - Color.valueOf("423c7b"), - Color.valueOf("4b5ef1"), - Color.valueOf("2cabfe"), + Color.valueOf("82759a"), + Color.valueOf("c0c1c5"), + Color.valueOf("fff0e7"), + Color.valueOf("7d2953"), + Color.valueOf("ff074e"), + Color.valueOf("ff072a"), + Color.valueOf("ff76a6"), + Color.valueOf("a95238"), + Color.valueOf("ffa108"), + Color.valueOf("feeb2c"), + Color.valueOf("ffcaa8"), + Color.valueOf("008551"), + Color.valueOf("00e339"), + Color.valueOf("423c7b"), + Color.valueOf("4b5ef1"), + Color.valueOf("2cabfe"), }; //server port diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index 8038c3f1cf..768304e2b2 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -258,19 +258,11 @@ public class NetClient extends Module { ui.restart.show(); }); - Net.handleClient(FriendlyFireChangePacket.class, packet -> state.friendlyFire = packet.enabled); - Net.handleClient(NetErrorPacket.class, packet -> { ui.showError(packet.message); disconnectQuietly(); }); - Net.handleClient(PlayerAdminPacket.class, packet -> { - Player player = playerGroup.getByID(packet.id); - player.isAdmin = packet.admin; - ui.listfrag.rebuild(); - }); - Net.handleClient(TracePacket.class, packet -> { Player player = playerGroup.getByID(packet.info.playerid); ui.traces.show(player, packet.info); diff --git a/core/src/io/anuke/mindustry/entities/Bullet.java b/core/src/io/anuke/mindustry/entities/Bullet.java index 87d2f84e78..58c4b07e0c 100644 --- a/core/src/io/anuke/mindustry/entities/Bullet.java +++ b/core/src/io/anuke/mindustry/entities/Bullet.java @@ -107,7 +107,7 @@ public class Bullet extends BulletEntity{ } @Override - public int getDamage(){ + public float getDamage(){ return damage == -1 ? type.damage : damage; } diff --git a/core/src/io/anuke/mindustry/entities/BulletType.java b/core/src/io/anuke/mindustry/entities/BulletType.java index 61e7172ac0..1c94cad697 100644 --- a/core/src/io/anuke/mindustry/entities/BulletType.java +++ b/core/src/io/anuke/mindustry/entities/BulletType.java @@ -11,8 +11,7 @@ public abstract class BulletType extends BaseBulletType{ public StatusEffect status = StatusEffects.none; public float statusIntensity = 0.5f; - //TODO use float damage - public BulletType(float speed, int damage){ + public BulletType(float speed, float damage){ this.speed = speed; this.damage = damage; lifetime = 40f; diff --git a/core/src/io/anuke/mindustry/entities/effect/Lightning.java b/core/src/io/anuke/mindustry/entities/effect/Lightning.java index cd2b8b0286..df7500f5f4 100644 --- a/core/src/io/anuke/mindustry/entities/effect/Lightning.java +++ b/core/src/io/anuke/mindustry/entities/effect/Lightning.java @@ -31,7 +31,7 @@ public class Lightning extends TimedEntity implements Poolable{ public Color color = Palette.lancerLaser; - public static void create(Team team, Effect effect, Color color, int damage, float x, float y, float targetAngle, int length){ + public static void create(Team team, Effect effect, Color color, float damage, float x, float y, float targetAngle, int length){ Lightning l = Pools.obtain(Lightning.class); l.x = x; @@ -68,10 +68,10 @@ public class Lightning extends TimedEntity implements Poolable{ Rectangle hitbox = entity.hitbox.getRect(entity.x, entity.y, range); if(hitbox.contains(x2, y2) || hitbox.contains(fx, fy)){ - int result = damage; + float result = damage; if(entity.status.current() == StatusEffects.wet) - result = (int)(result * wetDamageMultiplier); + result = (result * wetDamageMultiplier); entity.damage(result); Effects.effect(effect, x2, y2, fangle); diff --git a/core/src/io/anuke/mindustry/net/Invoke.java b/core/src/io/anuke/mindustry/net/Invoke.java index 36a0bc7d4e..1dedc24206 100644 --- a/core/src/io/anuke/mindustry/net/Invoke.java +++ b/core/src/io/anuke/mindustry/net/Invoke.java @@ -5,6 +5,7 @@ import com.badlogic.gdx.utils.reflect.ClassReflection; import com.badlogic.gdx.utils.reflect.Method; import com.badlogic.gdx.utils.reflect.ReflectionException; import io.anuke.mindustry.Vars; +import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.net.Net.SendMode; import io.anuke.mindustry.net.Packets.InvokePacket; @@ -17,6 +18,8 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.nio.ByteBuffer; +import static io.anuke.mindustry.Vars.playerGroup; + /**Class for invoking static methods of other classes remotely.*/ public class Invoke { private static ObjectMap> methods = new ObjectMap<>(); @@ -52,6 +55,10 @@ public class Invoke { on(NetEvents.class, methodName, args); } + public static void eventRemote(String methodName, Object... args){ + on(NetEvents.class, methodName, args); + } + //TODO refactor to serializer map! static void writeObjects(ByteBuffer buffer, Object[] objects){ for(Object o : objects){ @@ -76,6 +83,8 @@ public class Invoke { }else if(type == Entity.class){ buffer.put((byte)((Entity)o).getGroup().getID()); buffer.putInt(((Entity)o).id); + }else if(type == Player.class){ + buffer.putInt(((Player)o).id); }else if(type == Team.class){ buffer.put((byte)((Team)o).ordinal()); }else if(type == String.class){ @@ -110,6 +119,9 @@ public class Invoke { byte group = buffer.get(); int id = buffer.getInt(); obj = Entities.getGroup(group).getByID(id); + }else if(type == Player.class){ + int id = buffer.getInt(); + obj = playerGroup.getByID(id); }else if(type == Team.class){ obj = Team.values()[buffer.get()]; }else if(type == String.class){ diff --git a/core/src/io/anuke/mindustry/net/NetEvents.java b/core/src/io/anuke/mindustry/net/NetEvents.java index 36c4d75701..2cddfbeddf 100644 --- a/core/src/io/anuke/mindustry/net/NetEvents.java +++ b/core/src/io/anuke/mindustry/net/NetEvents.java @@ -18,13 +18,10 @@ import static io.anuke.mindustry.Vars.*; public class NetEvents { - public static void handleFriendlyFireChange(boolean enabled){ - FriendlyFireChangePacket packet = Pools.obtain(FriendlyFireChangePacket.class); - packet.enabled = enabled; + public static void friendlyFireChange(boolean enabled){ + state.friendlyFire = enabled; - netCommon.sendMessage(enabled ? "[accent]Friendly fire enabled." : "[accent]Friendly fire disabled."); - - Net.send(packet, SendMode.tcp); + if(Net.server()) netCommon.sendMessage(enabled ? "[accent]Friendly fire enabled." : "[accent]Friendly fire disabled."); } public static void handleGameOver(){ @@ -117,12 +114,12 @@ public class NetEvents { Net.send(packet, SendMode.tcp); } - public static void handleAdminSet(Player player, boolean admin){ - PlayerAdminPacket packet = Pools.obtain(PlayerAdminPacket.class); - packet.admin = admin; - packet.id = player.id; + public static void adminSet(Player player, boolean admin){ player.isAdmin = admin; - Net.send(packet, SendMode.tcp); + + if(Net.client()){ + ui.listfrag.rebuild(); + } } public static void handleAdministerRequest(Player target, AdminAction action){ diff --git a/core/src/io/anuke/mindustry/net/Packets.java b/core/src/io/anuke/mindustry/net/Packets.java index 596f22ae8e..97ba244375 100644 --- a/core/src/io/anuke/mindustry/net/Packets.java +++ b/core/src/io/anuke/mindustry/net/Packets.java @@ -477,24 +477,6 @@ public class Packets { public void read(ByteBuffer buffer) { } } - public static class FriendlyFireChangePacket implements Packet{ - public boolean enabled; - - @Override - public void write(ByteBuffer buffer) { - buffer.put(enabled ? 1 : (byte)0); - } - - @Override - public void read(ByteBuffer buffer) { - enabled = buffer.get() == 1; - } - } - - public static class CustomMapPacket extends Streamable{ - - } - public static class MapAckPacket implements Packet{ @Override public void write(ByteBuffer buffer) { } @@ -517,23 +499,6 @@ public class Packets { } } - public static class PlayerAdminPacket implements Packet{ - public boolean admin; - public int id; - - @Override - public void write(ByteBuffer buffer) { - buffer.put(admin ? (byte)1 : 0); - buffer.putInt(id); - } - - @Override - public void read(ByteBuffer buffer) { - admin = buffer.get() == 1; - id = buffer.getInt(); - } - } - public static class AdministerRequestPacket implements Packet{ public AdminAction action; public int id; diff --git a/core/src/io/anuke/mindustry/net/Registrator.java b/core/src/io/anuke/mindustry/net/Registrator.java index 36960edd23..0997cdc84a 100644 --- a/core/src/io/anuke/mindustry/net/Registrator.java +++ b/core/src/io/anuke/mindustry/net/Registrator.java @@ -32,12 +32,9 @@ public class Registrator { EntityRequestPacket.class, ConnectConfirmPacket.class, GameOverPacket.class, - FriendlyFireChangePacket.class, - CustomMapPacket.class, MapAckPacket.class, EntitySpawnPacket.class, NetErrorPacket.class, - PlayerAdminPacket.class, AdministerRequestPacket.class, TracePacket.class, InvokePacket.class, diff --git a/core/src/io/anuke/mindustry/ui/dialogs/AdminsDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/AdminsDialog.java index b1986af887..3715c755dd 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/AdminsDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/AdminsDialog.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.ui.dialogs; import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.net.Administration.PlayerInfo; +import io.anuke.mindustry.net.Invoke; import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.NetConnection; import io.anuke.mindustry.net.NetEvents; @@ -49,7 +50,7 @@ public class AdminsDialog extends FloatingDialog { for(Player player : playerGroup.all()){ NetConnection c = Net.getConnection(player.clientid); if(c != null){ - NetEvents.handleAdminSet(player, false); + Invoke.event("adminSet", player, false); break; } } diff --git a/core/src/io/anuke/mindustry/ui/fragments/PlayerListFragment.java b/core/src/io/anuke/mindustry/ui/fragments/PlayerListFragment.java index 47f4359c3f..c2a8dc68d0 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/PlayerListFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/PlayerListFragment.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.ui.fragments; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.Player; +import io.anuke.mindustry.net.Invoke; import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.NetConnection; import io.anuke.mindustry.net.NetEvents; @@ -48,7 +49,7 @@ public class PlayerListFragment implements Fragment{ get().addCheck("$text.server.friendlyfire", b -> { state.friendlyFire = b; - NetEvents.handleFriendlyFireChange(b); + Invoke.event("friendlyFireChange", b); }).growX().update(i -> i.setChecked(state.friendlyFire)).disabled(b -> Net.client()).padRight(5); new button("$text.server.bans", () -> { @@ -155,12 +156,12 @@ public class PlayerListFragment implements Fragment{ if(netServer.admins.isAdmin(id, connection.address)){ ui.showConfirm("$text.confirm", "$text.confirmunadmin", () -> { netServer.admins.unAdminPlayer(id); - NetEvents.handleAdminSet(player, false); + Invoke.event("adminSet", player, false); }); }else{ ui.showConfirm("$text.confirm", "$text.confirmadmin", () -> { netServer.admins.adminPlayer(id, connection.address); - NetEvents.handleAdminSet(player, true); + Invoke.event("adminSet", player, true); }); } }).update(b ->{ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index a5fe1cb94b..f6b961fd5a 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5a02e80bc2..bf3de21830 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed May 02 11:26:02 EDT 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip