diff --git a/build.gradle b/build.gradle index 0e44959044..47bbaa9dfd 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ allprojects { appName = 'Mindustry' gdxVersion = '1.9.8' aiVersion = '1.8.1' - uCoreVersion = '9503bcb' + uCoreVersion = '238babe' getVersionString = { String buildVersion = getBuildVersion() diff --git a/core/assets/version.properties b/core/assets/version.properties index 2db0c0a4c1..255d51b647 100644 --- a/core/assets/version.properties +++ b/core/assets/version.properties @@ -1,7 +1,7 @@ #Autogenerated file. Do not modify. -#Sat Mar 24 12:13:33 EDT 2018 +#Sat Mar 24 14:04:34 EDT 2018 version=release -androidBuildCode=459 +androidBuildCode=470 name=Mindustry code=3.4 build=custom build diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index b0ad4a281c..a8cebfdbb3 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -16,11 +16,15 @@ import io.anuke.mindustry.net.Net.SendMode; import io.anuke.mindustry.net.NetworkIO; import io.anuke.mindustry.net.Packets.*; import io.anuke.mindustry.resource.Item; +import io.anuke.mindustry.resource.Upgrade; +import io.anuke.mindustry.resource.UpgradeRecipes; +import io.anuke.mindustry.resource.Weapon; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Map; import io.anuke.mindustry.world.Placement; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.ProductionBlocks; +import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Timers; import io.anuke.ucore.entities.BaseBulletType; import io.anuke.ucore.entities.Entities; @@ -298,6 +302,15 @@ public class NetClient extends Module { Player player = playerGroup.getByID(packet.info.playerid); ui.traces.show(player, packet.info); }); + + Net.handleClient(UpgradePacket.class, packet -> { + Weapon weapon = (Weapon) Upgrade.getByID(packet.id); + + state.inventory.removeItems(UpgradeRecipes.get(weapon)); + control.upgrades().addWeapon(weapon); + ui.hudfrag.updateWeapons(); + Effects.sound("purchase"); + }); } @Override diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index 312208a0e3..152237017e 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -60,6 +60,8 @@ public class NetServer extends Module{ TraceInfo trace = admins.getTrace(Net.getConnection(id).address); PlayerInfo info = admins.getInfo(uuid); + trace.uuid = uuid; + trace.android = packet.android; if(admins.isIDBanned(uuid)){ kick(id, KickReason.banned); @@ -74,8 +76,6 @@ public class NetServer extends Module{ String ip = Net.getConnection(id).address; admins.updatePlayerJoined(uuid, ip, packet.name); - trace.uuid = uuid; - trace.android = packet.android; if(packet.version != Version.build && Version.build != -1 && packet.version != -1){ kick(id, packet.version > Version.build ? KickReason.serverOutdated : KickReason.clientOutdated); @@ -121,7 +121,7 @@ public class NetServer extends Module{ Player player = connections.get(id); ByteArrayOutputStream stream = new ByteArrayOutputStream(); - NetworkIO.writeWorld(player, weapons.get(player.name, new ByteArray()), stream); + NetworkIO.writeWorld(player, weapons.get(admins.getTrace(Net.getConnection(id).address).uuid, new ByteArray()), stream); WorldData data = new WorldData(); data.stream = new ByteArrayInputStream(stream.toByteArray()); Net.sendStream(id, data); @@ -178,7 +178,7 @@ public class NetServer extends Module{ info.fastShots ++; }else{ - if(info.fastShots - 2 > (int)(wtrc / (weapon.getReload() / 2f))){ + if(info.fastShots - 1 > (int)(wtrc / (weapon.getReload() / 2f))){ kick(id, KickReason.kick); } @@ -246,11 +246,22 @@ public class NetServer extends Module{ Player player = connections.get(id); Weapon weapon = (Weapon) Upgrade.getByID(packet.id); + String uuid = admins.getTrace(Net.getConnection(id).address).uuid; - if (!weapons.containsKey(player.name)) weapons.put(player.name, new ByteArray()); - if (!weapons.get(player.name).contains(weapon.id)) weapons.get(player.name).add(weapon.id); + if(!state.inventory.hasItems(UpgradeRecipes.get(weapon))){ + return; + } + + if (!weapons.containsKey(uuid)) weapons.put(uuid, new ByteArray()); + + if (!weapons.get(uuid).contains(weapon.id)){ + weapons.get(uuid).add(weapon.id); + }else{ + return; + } state.inventory.removeItems(UpgradeRecipes.get(weapon)); + Net.sendTo(id, packet, SendMode.tcp); }); Net.handleServer(WeaponSwitchPacket.class, (id, packet) -> { @@ -348,9 +359,8 @@ public class NetServer extends Module{ Log.info("Kicking connection #{0} / IP: {1}. Reason: {2}", connection, con.address, reason); } - PlayerInfo info = admins.getInfo(admins.getTrace(con.address).uuid); - - if(reason == KickReason.kick || reason == KickReason.banned){ + if((reason == KickReason.kick || reason == KickReason.banned) && admins.getTrace(con.address).uuid != null){ + PlayerInfo info = admins.getInfo(admins.getTrace(con.address).uuid); info.timesKicked ++; info.lastKicked = TimeUtils.millis(); } diff --git a/core/src/io/anuke/mindustry/io/SaveIO.java b/core/src/io/anuke/mindustry/io/SaveIO.java index e5ed643607..662f71ea7c 100644 --- a/core/src/io/anuke/mindustry/io/SaveIO.java +++ b/core/src/io/anuke/mindustry/io/SaveIO.java @@ -12,9 +12,7 @@ import io.anuke.ucore.core.Settings; import java.io.*; -import static io.anuke.mindustry.Vars.gwt; -import static io.anuke.mindustry.Vars.logic; -import static io.anuke.mindustry.Vars.saveDirectory; +import static io.anuke.mindustry.Vars.*; public class SaveIO{ public static final IntMap versions = new IntMap<>(); diff --git a/core/src/io/anuke/mindustry/net/NetEvents.java b/core/src/io/anuke/mindustry/net/NetEvents.java index 8b75515d9f..ccb59f36a1 100644 --- a/core/src/io/anuke/mindustry/net/NetEvents.java +++ b/core/src/io/anuke/mindustry/net/NetEvents.java @@ -96,9 +96,13 @@ public class NetEvents { public static void handleSendMessage(String message){ ChatPacket packet = new ChatPacket(); packet.text = message; - packet.name = Vars.player.name; - packet.id = Vars.player.id; + packet.name = player.name; + packet.id = player.id; Net.send(packet, SendMode.tcp); + + if(Net.server() && !headless){ + ui.chatfrag.addMessage(message, netCommon.colorizeName(player.id, player.name)); + } } public static void handleShoot(Weapon weapon, float x, float y, float angle){ diff --git a/core/src/io/anuke/mindustry/ui/fragments/BackgroundFragment.java b/core/src/io/anuke/mindustry/ui/fragments/BackgroundFragment.java index a786df7686..e920593899 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/BackgroundFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/BackgroundFragment.java @@ -18,7 +18,7 @@ public class BackgroundFragment implements Fragment { Draw.color(); TextureRegion back = Draw.region("background"); - float backscl = Math.max(Gdx.graphics.getWidth() / (float)back.getRegionWidth() * 1.5f, Unit.dp.scl(5f)); + float backscl = (int)Math.max(Gdx.graphics.getWidth() / (float)back.getRegionWidth() * 1.5f, Unit.dp.scl(5f)); Draw.alpha(0.5f); Core.batch.draw(back, w/2 - back.getRegionWidth()*backscl/2, h/2 - back.getRegionHeight()*backscl/2, @@ -31,7 +31,7 @@ public class BackgroundFragment implements Fragment { float logoh = logo.getRegionHeight()*logoscl; Draw.color(); - Core.batch.draw(logo, w/2 - logow/2, h - logoh + 15 - Unit.dp.scl(portrait ? 30f : 0), logow, logoh); + Core.batch.draw(logo, (int)(w/2 - logow/2), (int)(h - logoh + 15 - Unit.dp.scl(portrait ? 30f : 0)), logow, logoh); }).visible(() -> state.is(State.menu)).grow(); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/WeaponFactory.java b/core/src/io/anuke/mindustry/world/blocks/types/production/WeaponFactory.java index 11b55a631c..062288cc6c 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/WeaponFactory.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/WeaponFactory.java @@ -89,14 +89,15 @@ public class WeaponFactory extends Block{ tip.setInstant(true); ImageButton button = content.addImageButton("white", 8*4, () -> { - state.inventory.removeItems(requirements); - control.upgrades().addWeapon(weapon); - ui.hudfrag.updateWeapons(); - run.listen(); - Effects.sound("purchase"); if(Net.client()){ NetEvents.handleUpgrade(weapon); + }else{ + state.inventory.removeItems(requirements); + control.upgrades().addWeapon(weapon); + ui.hudfrag.updateWeapons(); + run.listen(); + Effects.sound("purchase"); } }).size(49f, 54f).padBottom(-5).get(); diff --git a/server/src/io/anuke/mindustry/server/ServerControl.java b/server/src/io/anuke/mindustry/server/ServerControl.java index 4404ab6b46..39b91c3f6d 100644 --- a/server/src/io/anuke/mindustry/server/ServerControl.java +++ b/server/src/io/anuke/mindustry/server/ServerControl.java @@ -147,11 +147,12 @@ public class ServerControl extends Module { return; } }else{ - while(result == null || result.visible) + while(result == null || !result.visible) result = world.maps().getAllMaps().random(); + Log.info("&ly&fiNo map specified, so &lb{0}&ly was chosen randomly.", result.name); } - GameMode mode = null; + GameMode mode; try{ mode = arg.length < 2 ? GameMode.waves : GameMode.valueOf(arg[1]); }catch (IllegalArgumentException e){ @@ -441,7 +442,7 @@ public class ServerControl extends Module { }else{ Log.info("&lyAdmins:"); for(PlayerInfo info : admins){ - Log.info(" &luy {0} / ID: '{1}' / IP: '{2}'", info.lastName, info.id, info.lastIP); + Log.info(" &lm {0} / ID: '{1}' / IP: '{2}'", info.lastName, info.id, info.lastIP); } } }); @@ -545,6 +546,7 @@ public class ServerControl extends Module { Log.info(" &lyIP: {0}", info.lastIP); Log.info(" &lyall IPs used: {0}", info.ips); Log.info(" &lytimes joined: {0}", info.timesJoined); + Log.info(" &lytimes kicked: {0}", info.timesKicked); Log.info(""); Log.info(" &lytotal blocks broken: {0}", info.totalBlocksBroken); Log.info(" &lytotal blocks placed: {0}", info.totalBlockPlaced);