Compare commits

..
17 Commits
15 changed files with 97 additions and 61 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ allprojects {
appName = 'Mindustry'
gdxVersion = '1.9.8'
aiVersion = '1.8.1'
uCoreVersion = '238babe'
uCoreVersion = 'c5d47cc'
getVersionString = {
String buildVersion = getBuildVersion()
+3 -3
View File
@@ -1,7 +1,7 @@
#Autogenerated file. Do not modify.
#Sat Mar 24 14:20:21 EDT 2018
#Mon Apr 02 14:29:45 EDT 2018
version=release
androidBuildCode=473
androidBuildCode=494
name=Mindustry
code=3.5
build=35
build=37
@@ -172,7 +172,7 @@ public class Control extends Module{
Events.on(WaveEvent.class, () -> {
Sounds.play("spawn");
int last = Settings.getInt("hiscore" + world.getMap().name);
int last = Settings.getInt("hiscore" + world.getMap().name, 0);
if(state.wave > last && !state.mode.infiniteResources && !state.mode.disableWaveTimer){
Settings.putInt("hiscore" + world.getMap().name, state.wave);
@@ -172,17 +172,17 @@ public class NetServer extends Module{
TraceInfo info = admins.getTrace(Net.getConnection(id).address);
Weapon weapon = (Weapon)Upgrade.getByID(packet.weaponid);
float wtrc = 40f;
float wtrc = 60;
if(!Timers.get(info.ip + "-weapontrace", wtrc)){
if(TimeUtils.millis() < info.lastFastShot + (int)(wtrc/60f*1000)){
info.fastShots ++;
}else{
if(info.fastShots - 1 > (int)(wtrc / (weapon.getReload() / 2f))){
if(info.fastShots - 6 > (int)(wtrc / (weapon.getReload() / 2f))){
kick(id, KickReason.kick);
}
}else{
info.fastShots = 0;
info.lastFastShot = TimeUtils.millis();
}
packet.playerid = connections.get(id).id;
@@ -265,6 +265,10 @@ public class NetServer extends Module{
});
Net.handleServer(WeaponSwitchPacket.class, (id, packet) -> {
TraceInfo info = admins.getTrace(Net.getConnection(id).address);
info.fastShots = 0;
info.lastFastShot = TimeUtils.millis();
packet.playerid = connections.get(id).id;
Net.sendExcept(id, packet, SendMode.tcp);
});
+1 -1
View File
@@ -244,7 +244,7 @@ public class World extends Module{
Array<Tile> removals = target.getLinkedTiles();
for(Tile toremove : removals){
//note that setting a new block automatically unlinks it
toremove.setBlock(Blocks.air);
if(toremove != null) toremove.setBlock(Blocks.air);
}
}
}
@@ -42,7 +42,6 @@ public class Player extends SyncEntity{
public Mech mech = Mech.standard;
public float targetAngle = 0f;
public float stucktime = 0f;
public boolean dashing = false;
public int clientid = -1;
@@ -54,7 +53,7 @@ public class Player extends SyncEntity{
public Player(){
hitbox.setSize(5);
hitboxTile.setSize(5f);
hitboxTile.setSize(4f);
maxhealth = 200;
heal();
@@ -161,15 +160,8 @@ public class Player extends SyncEntity{
Tile tile = world.tileWorld(x, y);
//if player is in solid block
if(tile != null && ((tile.floor().liquid && tile.block() == Blocks.air) || tile.solid())){
stucktime += Timers.delta();
}else{
stucktime = 0f;
}
if(stucktime > 15f){
damage(health+1); //die instantly
stucktime = 0f;
if(tile != null && ((tile.floor().liquid && tile.block() == Blocks.air) || tile.solid())) {
damage(health + 1); //die instantly
}
if(ui.chatfrag.chatOpen()) return;
@@ -26,8 +26,9 @@ public class DefaultKeybinds {
"block_info", Input.CONTROL_LEFT,
"player_list", Input.TAB,
"chat", Input.ENTER,
"chat_scroll_up", Input.UP,
"chat_scroll_down", Input.DOWN,
"chat_history_prev", Input.UP,
"chat_history_next", Input.DOWN,
"chat_scroll", new Axis(Input.SCROLL),
"console", Input.GRAVE,
"weapon_1", Input.NUM_1,
"weapon_2", Input.NUM_2,
@@ -55,8 +56,9 @@ public class DefaultKeybinds {
"rotate", new Axis(Input.CONTROLLER_A, Input.CONTROLLER_B),
"player_list", Input.CONTROLLER_START,
"chat", Input.ENTER,
"chat_scroll_up", Input.UP,
"chat_scroll_down", Input.DOWN,
"chat_history_prev", Input.UP,
"chat_history_next", Input.DOWN,
"chat_scroll", new Axis(Input.SCROLL),
"console", Input.GRAVE,
"weapon_1", Input.NUM_1,
"weapon_2", Input.NUM_2,
@@ -172,6 +172,18 @@ public class Administration {
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){
return getCreateInfo(id);
}
@@ -10,6 +10,7 @@ public class TraceInfo {
public boolean android;
public int fastShots;
public long lastFastShot;
public int totalBlocksBroken;
public int structureBlocksBroken;
@@ -159,7 +159,7 @@ public class FileChooser extends FloatingDialog {
Arrays.sort(handles, (a, b) ->{
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;
}
@@ -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.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
import io.anuke.ucore.util.Log;
import java.util.Arrays;
import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.state;
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 maxLength = 150;
private Array<ChatMessage> messages = new Array<>();
private float fadetime, lastfade;
private float fadetime;
private boolean chatOpen = false;
private TextField chatfield;
private Label fieldlabel = new Label(">");
@@ -42,6 +41,7 @@ public class ChatFragment extends Table implements Fragment{
private float textspacing = Unit.dp.scl(10);
private Array<String> history = new Array<String>();
private int historyPos = 0;
private int scrollPos = 0;
public ChatFragment(){
super();
@@ -62,15 +62,16 @@ public class ChatFragment extends Table implements Fragment{
}
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());
historyPos++;
updateChat();
}
if (Inputs.keyTap("chat_scroll_down") && historyPos > 0) {
if (Inputs.keyTap("chat_history_next") && historyPos > 0) {
historyPos--;
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);
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);
theight += layout.height+textspacing;
if(i == 0) theight -= textspacing+1;
if(i - scrollPos == 0) theight -= textspacing+1;
font.getCache().clear();
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);
batch.setColor(0, 0, 0, shadowColor.a*(fadetime-i));
}
@@ -163,10 +164,10 @@ public class ChatFragment extends Table implements Fragment{
private void sendMessage(){
String message = chatfield.getText();
clearChatInput();
history.insert(1, message);
if(message.replaceAll(" ", "").isEmpty()) return;
history.insert(1, message);
NetEvents.handleSendMessage(message);
}
@@ -176,12 +177,10 @@ public class ChatFragment extends Table implements Fragment{
scene.setKeyboardFocus(chatfield);
chatfield.fireClick();
chatOpen = !chatOpen;
lastfade = fadetime;
fadetime = messagesShown + 1;
}else{
scene.setKeyboardFocus(null);
chatOpen = !chatOpen;
fadetime = lastfade;
scrollPos = 0;
sendMessage();
}
}
@@ -106,13 +106,18 @@ public class Placement {
rect.setCenter(offset.x + x * tilesize, offset.y + y * tilesize);
synchronized (Entities.entityLock) {
for (SolidEntity e : Entities.getNearby(enemyGroup, x * tilesize, y * tilesize, tilesize * 2f)) {
if (e == null) continue; //not sure why this happens?
Rectangle rect = e.hitbox.getRect(e.x, e.y);
//exception sometimes thrown due to multithreading, not sure what else to try at this point
try {
for (SolidEntity e : Entities.getNearby(enemyGroup, x * tilesize, y * tilesize, tilesize * 2f)) {
if (e == null) continue; //not sure why this happens?
Rectangle rect = e.hitbox.getRect(e.x, e.y);
if (Placement.rect.overlaps(rect)) {
return false;
if (Placement.rect.overlaps(rect)) {
return false;
}
}
}catch (Exception e){
return false;
}
}
@@ -1,10 +1,12 @@
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.NumberUtils;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.BlockBar;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Bits;
@@ -21,6 +23,7 @@ public class TunnelConveyor extends Block{
solid = true;
health = 70;
instantTransfer = true;
bars.add(new BlockBar(Color.GREEN, true, tile -> (float)tile.<TunnelEntity>entity().index/capacity));
}
@Override
@@ -34,11 +37,6 @@ public class TunnelConveyor extends Block{
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);
}
@@ -71,19 +69,9 @@ public class TunnelConveyor extends Block{
@Override
public boolean acceptItem(Item item, Tile tile, Tile source){
TunnelEntity entity = tile.entity();
if(entity.index >= entity.buffer.length - 1) return false;
int rot = source.relativeTo(tile.x, tile.y);
if(rot != (tile.getRotation() + 2)%4) return false;
Tile tunnel = getDestTunnel(tile, item);
if(tunnel != null){
Tile to = tunnel.getNearby(tunnel.getRotation());
return to != null && to.block().acceptItem(item, to, tunnel);
}else{
return false;
}
return entity.index < entity.buffer.length - 1;
}
@Override
+7 -1
View File
@@ -423,7 +423,13 @@ public class KryoServer implements ServerProvider {
byte[] out = Base64Coder.decode(message);
ByteBuffer buffer = ByteBuffer.wrap(out);
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){
Log.err(e);
@@ -537,6 +537,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 -> {
PlayerInfo info = netServer.admins.getInfoOptional(arg[0]);