Merged with master

This commit is contained in:
Anuken
2018-04-08 10:46:48 -04:00
27 changed files with 180 additions and 109 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ allprojects {
version = 'release' version = 'release'
ext { ext {
versionNumber = '3.4' versionNumber = '3.5'
versionType = 'release' versionType = 'release'
appName = 'Mindustry' appName = 'Mindustry'
gdxVersion = '1.9.8' gdxVersion = '1.9.8'
+2
View File
@@ -42,6 +42,8 @@ text.server.kicked.recentKick=You have been kicked recently.\nWait before connec
text.server.connected={0} has joined. text.server.connected={0} has joined.
text.server.disconnected={0} has disconnected. text.server.disconnected={0} has disconnected.
text.nohost=Can't host server on a custom map! text.nohost=Can't host server on a custom map!
text.host.info=The [accent]host[] button hosts a server on ports [scarlet]6567[] and [scarlet]6568.[]\nAnybody on the same [LIGHT_GRAY]wifi or local network[] should be able to see your server in their server list.\n\nIf you want people to be able to connect from anywhere by IP, [accent]port forwarding[] is required.\n\n[LIGHT_GRAY]Note: If someone is experiencing trouble connecting to your LAN game, make sure you have allowed Mindustry access to your local network in your firewall settings.
text.join.info=Here, you can enter a [accent]server IP[] to connect to, or discover [accent]local network[] servers to connect to.\nBoth LAN and WAN multiplayer is supported.\n\n[LIGHT_GRAY]Note: There is no automatic global server list; if you want to connect to someone by IP, you would need to ask the host for their IP.
text.hostserver=Host Server text.hostserver=Host Server
text.host=Host text.host=Host
text.hosting=[accent]Opening server... text.hosting=[accent]Opening server...
+3 -3
View File
@@ -64,11 +64,11 @@ void main() {
if(i >= u_hitamount) break; if(i >= u_hitamount) break;
vec3 hit = u_hits[i]; vec3 hit = u_hits[i];
float rad = hit.z * HIT_RADIUS; float rad = hit.z * HIT_RADIUS;
float fract = 1.0 - hit.z; float fin = 1.0 - hit.z;
if(abs(distance(vec2(hit.x, hit.y), coords - u_texsize/2.0) - rad) < 1.0){ if(abs(distance(vec2(hit.x, hit.y), coords - u_texsize/2.0) - rad) < 1.0){
color = mix(color, u_color* vec4(si, si, si, 1.0), (1.0 * fract)); color = mix(color, u_color* vec4(si, si, si, 1.0), (1.0 * fin));
color.a = ALPHA + 0.82 *fract; color.a = ALPHA + 0.82 *fin;
} }
} }
} }
@@ -3,6 +3,7 @@ package io.anuke.mindustry.core;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.IntMap; import com.badlogic.gdx.utils.IntMap;
import com.badlogic.gdx.utils.IntSet; import com.badlogic.gdx.utils.IntSet;
import io.anuke.mindustry.content.UpgradeRecipes;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.BulletType; import io.anuke.mindustry.entities.BulletType;
import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.Player;
@@ -13,9 +14,12 @@ import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.Net.SendMode; import io.anuke.mindustry.net.Net.SendMode;
import io.anuke.mindustry.net.NetworkIO; import io.anuke.mindustry.net.NetworkIO;
import io.anuke.mindustry.net.Packets.*; import io.anuke.mindustry.net.Packets.*;
import io.anuke.mindustry.resource.Upgrade;
import io.anuke.mindustry.resource.Weapon;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Placement; import io.anuke.mindustry.world.Placement;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.BaseBulletType; import io.anuke.ucore.entities.BaseBulletType;
import io.anuke.ucore.entities.Entities; import io.anuke.ucore.entities.Entities;
@@ -261,6 +265,15 @@ public class NetClient extends Module {
Player player = playerGroup.getByID(packet.info.playerid); Player player = playerGroup.getByID(packet.info.playerid);
ui.traces.show(player, packet.info); ui.traces.show(player, packet.info);
}); });
Net.handleClient(UpgradePacket.class, packet -> {
Weapon weapon = Upgrade.getByID(packet.id);
state.inventory.removeItems(UpgradeRecipes.get(weapon));
control.upgrades().addWeapon(weapon);
ui.hudfrag.updateWeapons();
Effects.sound("purchase");
});
} }
@Override @Override
+26 -15
View File
@@ -68,6 +68,8 @@ public class NetServer extends Module{
TraceInfo trace = admins.getTrace(Net.getConnection(id).address); TraceInfo trace = admins.getTrace(Net.getConnection(id).address);
PlayerInfo info = admins.getInfo(uuid); PlayerInfo info = admins.getInfo(uuid);
trace.uuid = uuid;
trace.android = packet.android;
if(admins.isIDBanned(uuid)){ if(admins.isIDBanned(uuid)){
kick(id, KickReason.banned); kick(id, KickReason.banned);
@@ -82,8 +84,6 @@ public class NetServer extends Module{
String ip = Net.getConnection(id).address; String ip = Net.getConnection(id).address;
admins.updatePlayerJoined(uuid, ip, packet.name); admins.updatePlayerJoined(uuid, ip, packet.name);
trace.uuid = uuid;
trace.android = packet.android;
if(packet.version != Version.build && Version.build != -1 && packet.version != -1){ if(packet.version != Version.build && Version.build != -1 && packet.version != -1){
kick(id, packet.version > Version.build ? KickReason.serverOutdated : KickReason.clientOutdated); kick(id, packet.version > Version.build ? KickReason.serverOutdated : KickReason.clientOutdated);
@@ -111,7 +111,7 @@ public class NetServer extends Module{
//TODO try DeflaterOutputStream //TODO try DeflaterOutputStream
ByteArrayOutputStream stream = new ByteArrayOutputStream(); 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(); WorldData data = new WorldData();
data.stream = new ByteArrayInputStream(stream.toByteArray()); data.stream = new ByteArrayInputStream(stream.toByteArray());
Net.sendStream(id, data); Net.sendStream(id, data);
@@ -165,17 +165,16 @@ public class NetServer extends Module{
TraceInfo info = admins.getTrace(Net.getConnection(id).address); TraceInfo info = admins.getTrace(Net.getConnection(id).address);
Weapon weapon = Upgrade.getByID((byte)packet.data); Weapon weapon = Upgrade.getByID((byte)packet.data);
float wtrc = 40f; float wtrc = 60;
if(!Timers.get(info.ip + "-weapontrace", wtrc)){ if(!Timers.get("fastshoot-" + id + "-" + weapon.id, wtrc)){
info.fastShots ++; info.fastShots.getAndIncrement(weapon.id, 0, 1);
}else{
if(info.fastShots - 2 > (int)(wtrc / (weapon.getReload() / 2f))){ if(info.fastShots.get(weapon.id, 0) > (int)(wtrc / (weapon.getReload() / 2f)) + 2){
kick(id, KickReason.kick); kick(id, KickReason.kick);
} }
}else{
info.fastShots = 0; info.fastShots.put(weapon.id, 0);
} }
packet.entityid = connections.get(id).id; packet.entityid = connections.get(id).id;
@@ -241,14 +240,27 @@ public class NetServer extends Module{
Player player = connections.get(id); Player player = connections.get(id);
Weapon weapon = Upgrade.getByID(packet.id); 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(!state.inventory.hasItems(UpgradeRecipes.get(weapon))){
if (!weapons.get(player.name).contains(weapon.id)) weapons.get(player.name).add(weapon.id); 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)); state.inventory.removeItems(UpgradeRecipes.get(weapon));
Net.sendTo(id, packet, SendMode.tcp);
}); });
Net.handleServer(WeaponSwitchPacket.class, (id, packet) -> { Net.handleServer(WeaponSwitchPacket.class, (id, packet) -> {
TraceInfo info = admins.getTrace(Net.getConnection(id).address);
packet.playerid = connections.get(id).id; packet.playerid = connections.get(id).id;
Net.sendExcept(id, packet, SendMode.tcp); Net.sendExcept(id, packet, SendMode.tcp);
}); });
@@ -344,9 +356,8 @@ public class NetServer extends Module{
Log.info("Kicking connection #{0} / IP: {1}. Reason: {2}", connection, con.address, reason); 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) && admins.getTrace(con.address).uuid != null){
PlayerInfo info = admins.getInfo(admins.getTrace(con.address).uuid);
if(reason == KickReason.kick || reason == KickReason.banned){
info.timesKicked ++; info.timesKicked ++;
info.lastKicked = TimeUtils.millis(); info.lastKicked = TimeUtils.millis();
} }
@@ -566,14 +566,14 @@ public class Renderer extends RendererModule{
} }
//TODO optimize! //TODO optimize!
public void drawBar(Color color, float x, float y, float fraction){ public void drawBar(Color color, float x, float y, float finion){
fraction = Mathf.clamp(fraction); finion = Mathf.clamp(finion);
if(fraction > 0) fraction = Mathf.clamp(fraction + 0.2f, 0.24f, 1f); if(finion > 0) finion = Mathf.clamp(finion + 0.2f, 0.24f, 1f);
float len = 3; float len = 3;
float w = (int) (len * 2 * fraction) + 0.5f; float w = (int) (len * 2 * finion) + 0.5f;
x -= 0.5f; x -= 0.5f;
y += 0.5f; y += 0.5f;
+2 -2
View File
@@ -223,8 +223,8 @@ public class UI extends SceneModule{
public void showInfo(String info){ public void showInfo(String info){
new Dialog("$text.info.title", "dialog"){{ new Dialog("$text.info.title", "dialog"){{
content().margin(15).add(info); content().margin(15).add(info).width(600f).get().setWrap(true);
buttons().addButton("$text.ok", this::hide).size(90, 50).pad(4).get().getLabelCell().width(400f).get().setWrap(true); buttons().addButton("$text.ok", this::hide).size(90, 50).pad(4);
}}.show(); }}.show();
} }
+1 -1
View File
@@ -180,7 +180,7 @@ public class World extends Module{
Array<Tile> removals = target.getLinkedTiles(tempTiles); Array<Tile> removals = target.getLinkedTiles(tempTiles);
for(Tile toremove : removals){ for(Tile toremove : removals){
//note that setting a new block automatically unlinks it //note that setting a new block automatically unlinks it
toremove.setBlock(Blocks.air); if(toremove != null) toremove.setBlock(Blocks.air);
} }
} }
} }
@@ -45,7 +45,6 @@ public class Player extends Unit{
public Mech mech = Mechs.standard; public Mech mech = Mechs.standard;
public float targetAngle = 0f; public float targetAngle = 0f;
public float stucktime = 0f;
public boolean dashing = false; public boolean dashing = false;
public int clientid = -1; public int clientid = -1;
@@ -58,7 +57,7 @@ public class Player extends Unit{
public Player(){ public Player(){
hitbox.setSize(5); hitbox.setSize(5);
hitboxTile.setSize(5f); hitboxTile.setSize(4f);
maxhealth = 200; maxhealth = 200;
heal(); heal();
@@ -215,15 +214,8 @@ public class Player extends Unit{
Tile tile = world.tileWorld(x, y); Tile tile = world.tileWorld(x, y);
//if player is in solid block //if player is in solid block
if(tile != null && tile.solid()){ if(tile != null && tile.solid())) {
stucktime += Timers.delta(); damage(health + 1); //die instantly
}else{
stucktime = 0f;
}
if(stucktime > 15f){
damage(health+1); //die instantly
stucktime = 0f;
} }
if(ui.chatfrag.chatOpen()) return; if(ui.chatfrag.chatOpen()) return;
@@ -26,8 +26,9 @@ public class DefaultKeybinds {
"block_info", Input.CONTROL_LEFT, "block_info", Input.CONTROL_LEFT,
"player_list", Input.TAB, "player_list", Input.TAB,
"chat", Input.ENTER, "chat", Input.ENTER,
"chat_scroll_up", Input.UP, "chat_history_prev", Input.UP,
"chat_scroll_down", Input.DOWN, "chat_history_next", Input.DOWN,
"chat_scroll", new Axis(Input.SCROLL),
"console", Input.GRAVE, "console", Input.GRAVE,
"weapon_1", Input.NUM_1, "weapon_1", Input.NUM_1,
"weapon_2", Input.NUM_2, "weapon_2", Input.NUM_2,
@@ -55,8 +56,9 @@ public class DefaultKeybinds {
"rotate", new Axis(Input.CONTROLLER_A, Input.CONTROLLER_B), "rotate", new Axis(Input.CONTROLLER_A, Input.CONTROLLER_B),
"player_list", Input.CONTROLLER_START, "player_list", Input.CONTROLLER_START,
"chat", Input.ENTER, "chat", Input.ENTER,
"chat_scroll_up", Input.UP, "chat_history_prev", Input.UP,
"chat_scroll_down", Input.DOWN, "chat_history_next", Input.DOWN,
"chat_scroll", new Axis(Input.SCROLL),
"console", Input.GRAVE, "console", Input.GRAVE,
"weapon_1", Input.NUM_1, "weapon_1", Input.NUM_1,
"weapon_2", Input.NUM_2, "weapon_2", Input.NUM_2,
@@ -85,11 +85,11 @@ public enum PlaceMode{
if(tile != null && control.input().validBreak(tilex, tiley)){ if(tile != null && control.input().validBreak(tilex, tiley)){
if(tile.isLinked()) if(tile.isLinked())
tile = tile.getLinked(); tile = tile.getLinked();
float fract = control.input().breaktime / tile.getBreakTime(); float fin = control.input().breaktime / tile.getBreakTime();
if(android && control.input().breaktime > 0){ if(android && control.input().breaktime > 0){
Draw.color(Colors.get("breakStart"), Colors.get("break"), fract); Draw.color(Colors.get("breakStart"), Colors.get("break"), fin);
Lines.poly(tile.drawx(), tile.drawy(), 25, 4 + (1f - fract) * 26); Lines.poly(tile.drawx(), tile.drawy(), 25, 4 + (1f - fin) * 26);
} }
Draw.reset(); Draw.reset();
} }
@@ -172,6 +172,18 @@ public class Administration {
return info.admin && ip.equals(info.validAdminIP); return info.admin && ip.equals(info.validAdminIP);
} }
public Array<PlayerInfo> findByName(String name, boolean last){
Array<PlayerInfo> result = new Array<>();
for(PlayerInfo info : playerInfo.values()){
if(info.lastName.toLowerCase().equals(name.toLowerCase()) || (last && info.names.contains(name, false))){
result.add(info);
}
}
return result;
}
public PlayerInfo getInfo(String id){ public PlayerInfo getInfo(String id){
return getCreateInfo(id); return getCreateInfo(id);
} }
@@ -78,9 +78,13 @@ public class NetEvents {
public static void handleSendMessage(String message){ public static void handleSendMessage(String message){
ChatPacket packet = new ChatPacket(); ChatPacket packet = new ChatPacket();
packet.text = message; packet.text = message;
packet.name = Vars.player.name; packet.name = player.name;
packet.id = Vars.player.id; packet.id = player.id;
Net.send(packet, SendMode.tcp); Net.send(packet, SendMode.tcp);
if(Net.server() && !headless){
ui.chatfrag.addMessage(message, netCommon.colorizeName(player.id, player.name));
}
} }
public static void handleShoot(SyncEntity entity, float x, float y, float angle, short data){ public static void handleShoot(SyncEntity entity, float x, float y, float angle, short data){
@@ -1,5 +1,6 @@
package io.anuke.mindustry.net; package io.anuke.mindustry.net;
import com.badlogic.gdx.utils.IntIntMap;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.content.blocks.Blocks; import io.anuke.mindustry.content.blocks.Blocks;
@@ -9,7 +10,7 @@ public class TraceInfo {
public boolean modclient; public boolean modclient;
public boolean android; public boolean android;
public int fastShots; public IntIntMap fastShots = new IntIntMap();
public int totalBlocksBroken; public int totalBlocksBroken;
public int structureBlocksBroken; public int structureBlocksBroken;
@@ -1,5 +1,6 @@
package io.anuke.mindustry.ui.dialogs; package io.anuke.mindustry.ui.dialogs;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import io.anuke.ucore.function.Consumer; import io.anuke.ucore.function.Consumer;
import io.anuke.ucore.scene.ui.Dialog; import io.anuke.ucore.scene.ui.Dialog;
@@ -35,6 +36,12 @@ public class ColorPickDialog extends Dialog{
table.row(); table.row();
} }
} }
keyDown(key->{
if(key == Keys.ESCAPE || key == Keys.BACK)
hide();
});
} }
public void show(Consumer<Color> cons){ public void show(Consumer<Color> cons){
@@ -160,7 +160,7 @@ public class FileChooser extends FloatingDialog {
Arrays.sort(handles, (a, b) ->{ Arrays.sort(handles, (a, b) ->{
if(a.isDirectory() && !b.isDirectory()) return -1; if(a.isDirectory() && !b.isDirectory()) return -1;
if( !a.isDirectory() && b.isDirectory()) return 1; if( !a.isDirectory() && b.isDirectory()) return 1;
return a.name().compareTo(b.name()); return a.name().toUpperCase().compareTo(b.name().toUpperCase());
}); });
return handles; return handles;
} }
@@ -3,8 +3,6 @@ package io.anuke.mindustry.ui.dialogs;
import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.Colors; import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Align;
import io.anuke.ucore.core.Inputs;
import io.anuke.ucore.scene.ui.Dialog; import io.anuke.ucore.scene.ui.Dialog;
public class FloatingDialog extends Dialog{ public class FloatingDialog extends Dialog{
@@ -26,11 +24,5 @@ public class FloatingDialog extends Dialog{
if(key == Keys.ESCAPE || key == Keys.BACK) if(key == Keys.ESCAPE || key == Keys.BACK)
hide(); hide();
}); });
update(() -> {
if(Inputs.keyTap("menu")){
hide();
}
});
} }
} }
@@ -40,10 +40,12 @@ public class HostDialog extends FloatingDialog{
}); });
}).size(50f, 54f).get(); }).size(50f, 54f).get();
button.update(() -> button.getStyle().imageUpColor = player.getColor()); button.update(() -> button.getStyle().imageUpColor = player.getColor());
}).width(w).height(70f).pad(4); }).width(w).height(70f).pad(4).colspan(3);
content().row(); content().row();
content().add().width(65f);
content().addButton("$text.host", () -> { content().addButton("$text.host", () -> {
ui.loadfrag.show("$text.hosting"); ui.loadfrag.show("$text.hosting");
Timers.runTask(5f, () -> { Timers.runTask(5f, () -> {
@@ -57,5 +59,7 @@ public class HostDialog extends FloatingDialog{
hide(); hide();
}); });
}).width(w).height(70f); }).width(w).height(70f);
content().addButton("?", () -> ui.showInfo("$text.host.info")).size(65f, 70f).padLeft(6f);
} }
} }
@@ -38,8 +38,14 @@ public class JoinDialog extends FloatingDialog {
loadServers(); loadServers();
buttons().add().width(60f);
buttons().add().growX();
addCloseButton(); addCloseButton();
buttons().add().growX();
buttons().addButton("?", () -> ui.showInfo("$text.join.info")).size(60f, 64f);
add = new FloatingDialog("$text.joingame.title"); add = new FloatingDialog("$text.joingame.title");
add.content().add("$text.joingame.ip").padRight(5f).left(); add.content().add("$text.joingame.ip").padRight(5f).left();
@@ -18,7 +18,7 @@ public class BackgroundFragment implements Fragment {
Draw.color(); Draw.color();
TextureRegion back = Draw.region("background"); 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); Draw.alpha(0.5f);
Core.batch.draw(back, w/2 - back.getRegionWidth()*backscl/2, h/2 - back.getRegionHeight()*backscl/2, 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; float logoh = logo.getRegionHeight()*logoscl;
Draw.color(); 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(); }).visible(() -> state.is(State.menu)).grow();
} }
} }
@@ -19,8 +19,7 @@ import io.anuke.ucore.scene.ui.Label.LabelStyle;
import io.anuke.ucore.scene.ui.TextField; import io.anuke.ucore.scene.ui.TextField;
import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit; import io.anuke.ucore.scene.ui.layout.Unit;
import io.anuke.ucore.util.Log; import io.anuke.ucore.util.Mathf;
import java.util.Arrays;
import static io.anuke.mindustry.Vars.state; import static io.anuke.mindustry.Vars.state;
import static io.anuke.ucore.core.Core.scene; import static io.anuke.ucore.core.Core.scene;
@@ -30,7 +29,7 @@ public class ChatFragment extends Table implements Fragment{
private final static int messagesShown = 10; private final static int messagesShown = 10;
private final static int maxLength = 150; private final static int maxLength = 150;
private Array<ChatMessage> messages = new Array<>(); private Array<ChatMessage> messages = new Array<>();
private float fadetime, lastfade; private float fadetime;
private boolean chatOpen = false; private boolean chatOpen = false;
private TextField chatfield; private TextField chatfield;
private Label fieldlabel = new Label(">"); private Label fieldlabel = new Label(">");
@@ -42,6 +41,7 @@ public class ChatFragment extends Table implements Fragment{
private float textspacing = Unit.dp.scl(10); private float textspacing = Unit.dp.scl(10);
private Array<String> history = new Array<String>(); private Array<String> history = new Array<String>();
private int historyPos = 0; private int historyPos = 0;
private int scrollPos = 0;
public ChatFragment(){ public ChatFragment(){
super(); super();
@@ -62,15 +62,16 @@ public class ChatFragment extends Table implements Fragment{
} }
if (chatOpen) { if (chatOpen) {
if (Inputs.keyTap("chat_scroll_up") && historyPos < history.size - 1) { if (Inputs.keyTap("chat_history_prev") && historyPos < history.size - 1) {
if (historyPos == 0) history.set(0, chatfield.getText()); if (historyPos == 0) history.set(0, chatfield.getText());
historyPos++; historyPos++;
updateChat(); updateChat();
} }
if (Inputs.keyTap("chat_scroll_down") && historyPos > 0) { if (Inputs.keyTap("chat_history_next") && historyPos > 0) {
historyPos--; historyPos--;
updateChat(); updateChat();
} }
scrollPos = (int)Mathf.clamp(scrollPos + Inputs.getAxis("chat_scroll"), 0, Math.max(0, messages.size - messagesShown));
} }
}); });
@@ -134,16 +135,16 @@ public class ChatFragment extends Table implements Fragment{
batch.setColor(shadowColor); batch.setColor(shadowColor);
float theight = offsety + spacing + getMarginBottom(); float theight = offsety + spacing + getMarginBottom();
for(int i = 0; i < messagesShown && i < messages.size && i < fadetime; i ++){ for(int i = scrollPos; i < messages.size && i < messagesShown + scrollPos && (i < fadetime || chatOpen); i++){
layout.setText(font, messages.get(i).formattedMessage, Color.WHITE, textWidth, Align.bottomLeft, true); layout.setText(font, messages.get(i).formattedMessage, Color.WHITE, textWidth, Align.bottomLeft, true);
theight += layout.height+textspacing; theight += layout.height+textspacing;
if(i == 0) theight -= textspacing+1; if(i - scrollPos == 0) theight -= textspacing+1;
font.getCache().clear(); font.getCache().clear();
font.getCache().addText(messages.get(i).formattedMessage, fontoffsetx + offsetx, offsety + theight, textWidth, Align.bottomLeft, true); font.getCache().addText(messages.get(i).formattedMessage, fontoffsetx + offsetx, offsety + theight, textWidth, Align.bottomLeft, true);
if(fadetime-i < 1f && fadetime-i >= 0f){ if(!chatOpen && fadetime-i < 1f && fadetime-i >= 0f){
font.getCache().setAlphas(fadetime-i); font.getCache().setAlphas(fadetime-i);
batch.setColor(0, 0, 0, shadowColor.a*(fadetime-i)); batch.setColor(0, 0, 0, shadowColor.a*(fadetime-i));
} }
@@ -163,10 +164,10 @@ public class ChatFragment extends Table implements Fragment{
private void sendMessage(){ private void sendMessage(){
String message = chatfield.getText(); String message = chatfield.getText();
clearChatInput(); clearChatInput();
history.insert(1, message);
if(message.replaceAll(" ", "").isEmpty()) return; if(message.replaceAll(" ", "").isEmpty()) return;
history.insert(1, message);
NetEvents.handleSendMessage(message); NetEvents.handleSendMessage(message);
} }
@@ -176,12 +177,10 @@ public class ChatFragment extends Table implements Fragment{
scene.setKeyboardFocus(chatfield); scene.setKeyboardFocus(chatfield);
chatfield.fireClick(); chatfield.fireClick();
chatOpen = !chatOpen; chatOpen = !chatOpen;
lastfade = fadetime;
fadetime = messagesShown + 1;
}else{ }else{
scene.setKeyboardFocus(null); scene.setKeyboardFocus(null);
chatOpen = !chatOpen; chatOpen = !chatOpen;
fadetime = lastfade; scrollPos = 0;
sendMessage(); sendMessage();
} }
} }
@@ -102,19 +102,24 @@ public class Placement {
if(type.solid || type.solidifes) if(type.solid || type.solidifes)
synchronized (Entities.entityLock) { synchronized (Entities.entityLock) {
rect.setSize(tilesize*2f).setCenter(x*tilesize + type.getPlaceOffset().x, y*tilesize + type.getPlaceOffset().y); try {
boolean[] result = {false};
Units.getNearby(rect, e -> { rect.setSize(tilesize * 2f).setCenter(x * tilesize + type.getPlaceOffset().x, y * tilesize + type.getPlaceOffset().y);
if (e == null) return; //not sure why this happens? boolean[] result = {false};
Rectangle rect = e.hitbox.getRect(e.x, e.y);
if (Placement.rect.overlaps(rect) && !e.isFlying()) { Units.getNearby(rect, e -> {
result[0] = true; if (e == null) return; //not sure why this happens?
} Rectangle rect = e.hitbox.getRect(e.x, e.y);
});
if(result[0]) return false; if (Placement.rect.overlaps(rect) && !e.isFlying()) {
result[0] = true;
}
});
if (result[0]) return false;
}catch (Exception e){
return false;
}
} }
Tile tile = world.tile(x, y); Tile tile = world.tile(x, y);
@@ -1,12 +1,11 @@
package io.anuke.mindustry.world.blocks.types.distribution; package io.anuke.mindustry.world.blocks.types.distribution;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.NumberUtils; import com.badlogic.gdx.utils.NumberUtils;
import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.BlockGroup;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Bits; import io.anuke.ucore.util.Bits;
@@ -22,6 +21,7 @@ public class TunnelConveyor extends Block{
solid = true; solid = true;
health = 70; health = 70;
instantTransfer = true; instantTransfer = true;
bars.add(new BlockBar(BarType.inventory, true, tile -> (float)tile.<TunnelEntity>entity().index/capacity));
group = BlockGroup.transportation; group = BlockGroup.transportation;
} }
@@ -31,11 +31,6 @@ public class TunnelConveyor extends Block{
if(entity.index >= entity.buffer.length) return; if(entity.index >= entity.buffer.length) return;
Tile tunnel = getDestTunnel(tile, item);
if(tunnel == null) return;
Tile to = tunnel.getNearby(tunnel.getRotation());
if(to == null) return;
entity.buffer[entity.index ++] = Bits.packLong(NumberUtils.floatToIntBits(Timers.time()), item.id); entity.buffer[entity.index ++] = Bits.packLong(NumberUtils.floatToIntBits(Timers.time()), item.id);
} }
@@ -68,19 +63,9 @@ public class TunnelConveyor extends Block{
@Override @Override
public boolean acceptItem(Item item, Tile tile, Tile source){ public boolean acceptItem(Item item, Tile tile, Tile source){
TunnelEntity entity = tile.entity(); TunnelEntity entity = tile.entity();
if(entity.index >= entity.buffer.length - 1) return false;
int rot = source.relativeTo(tile.x, tile.y); int rot = source.relativeTo(tile.x, tile.y);
if(rot != (tile.getRotation() + 2)%4) return false; if(rot != (tile.getRotation() + 2)%4) return false;
Tile tunnel = getDestTunnel(tile, item); return entity.index < entity.buffer.length - 1;
if(tunnel != null){
Tile to = tunnel.getNearby(tunnel.getRotation());
return to != null && to.block().acceptItem(item, to, tunnel);
}else{
return false;
}
} }
@Override @Override
@@ -108,14 +108,15 @@ public class WeaponFactory extends Block{
tip.setInstant(true); tip.setInstant(true);
ImageButton button = content.addImageButton("white", 8*4, () -> { 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()){ if(Net.client()){
NetEvents.handleUpgrade(weapon); 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(); }).size(49f, 54f).padBottom(-5).get();
+7 -1
View File
@@ -423,7 +423,13 @@ public class KryoServer implements ServerProvider {
byte[] out = Base64Coder.decode(message); byte[] out = Base64Coder.decode(message);
ByteBuffer buffer = ByteBuffer.wrap(out); ByteBuffer buffer = ByteBuffer.wrap(out);
Object o = serializer.read(buffer); Object o = serializer.read(buffer);
Gdx.app.postRunnable(() -> Net.handleServerReceived(id, o)); Gdx.app.postRunnable(() -> {
try {
Net.handleServerReceived(id, o);
}catch (Exception e){
e.printStackTrace();
}
});
} }
}catch (Exception e){ }catch (Exception e){
Log.err(e); Log.err(e);
@@ -146,9 +146,10 @@ public class ServerControl extends Module {
} }
}else{ }else{
result = world.maps().all().random(); result = world.maps().all().random();
Log.info("&ly&fiNo map specified, so &lb{0}&ly was chosen randomly.", result.name);
} }
GameMode mode = null; GameMode mode;
try{ try{
mode = arg.length < 2 ? GameMode.waves : GameMode.valueOf(arg[1]); mode = arg.length < 2 ? GameMode.waves : GameMode.valueOf(arg[1]);
}catch (IllegalArgumentException e){ }catch (IllegalArgumentException e){
@@ -438,7 +439,7 @@ public class ServerControl extends Module {
}else{ }else{
Log.info("&lyAdmins:"); Log.info("&lyAdmins:");
for(PlayerInfo info : admins){ 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);
} }
} }
}); });
@@ -534,6 +535,33 @@ public class ServerControl extends Module {
} }
}); });
handler.register("find", "<name> [check-all-names]", "Find player info(s) by name. Can optionally check for all names a player has had.", arg -> {
boolean checkAll = arg.length == 2 && arg[1].equals("true");
Array<PlayerInfo> infos = netServer.admins.findByName(arg[0], checkAll);
if(infos.size == 1) {
PlayerInfo info = infos.peek();
Log.info("&lcTrace info for player '{0}' / UUID {1}:", info.lastName, info.id);
Log.info(" &lyall names used: {0}", info.names);
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);
}else if(infos.size > 1){
Log.info("&lcMultiple people have been found with that name:");
for(PlayerInfo info : infos){
Log.info(" &ly{0}", info.id);
}
Log.info("&lcUse the info command to examine each person individually.");
}else{
info("Nobody with that name could be found.");
}
});
handler.register("info", "<UUID>", "Get global info for a player's UUID.", arg -> { handler.register("info", "<UUID>", "Get global info for a player's UUID.", arg -> {
PlayerInfo info = netServer.admins.getInfoOptional(arg[0]); PlayerInfo info = netServer.admins.getInfoOptional(arg[0]);
@@ -543,6 +571,7 @@ public class ServerControl extends Module {
Log.info(" &lyIP: {0}", info.lastIP); Log.info(" &lyIP: {0}", info.lastIP);
Log.info(" &lyall IPs used: {0}", info.ips); Log.info(" &lyall IPs used: {0}", info.ips);
Log.info(" &lytimes joined: {0}", info.timesJoined); Log.info(" &lytimes joined: {0}", info.timesJoined);
Log.info(" &lytimes kicked: {0}", info.timesKicked);
Log.info(""); Log.info("");
Log.info(" &lytotal blocks broken: {0}", info.totalBlocksBroken); Log.info(" &lytotal blocks broken: {0}", info.totalBlocksBroken);
Log.info(" &lytotal blocks placed: {0}", info.totalBlockPlaced); Log.info(" &lytotal blocks placed: {0}", info.totalBlockPlaced);