Compare commits

...

15 Commits
v35 ... v36

Author SHA1 Message Date
Anuken
9db7b1385d Updated uCore / Fixed behind-UI swipe bug 2018-04-01 12:07:30 -04:00
Anuken
528cb6bf40 Fixed possible wave crash 2018-04-01 11:39:50 -04:00
Anuken
0936fc6550 Multithreading crash fixes / Server 'find' command added 2018-04-01 11:33:30 -04:00
Anuken
537e25af9f Fixed server crash / Added graphics blending methods 2018-03-31 14:04:55 -04:00
Anuken
ed276ac79e Fixed random collision deaths 2018-03-30 19:18:33 -04:00
Anuken
84548187f5 Changed tunnel acceptance algorithm 2018-03-30 18:05:58 -04:00
Anuken
f0302ca7dc Changed file sorting comparator to ignore case 2018-03-28 09:39:29 -04:00
Anuken
795464e737 Updated uCore 2018-03-28 00:22:39 -04:00
Anuken
2a1110c358 Merge remote-tracking branch 'origin/master' 2018-03-28 00:22:25 -04:00
Anuken
c54df7cbd1 Fixed host bug, server failing to kick people firing too fast 2018-03-28 00:22:07 -04:00
Anuken
46e6b839b9 Merge pull request #108 from valoran-labs/scrollable-chat
Make chat scrollable, other chat fixes
2018-03-26 17:27:18 -04:00
iczero
30fc96e4da Make chat scrollable, other chat fixes 2018-03-26 00:45:42 -07:00
Anuken
e0c1bb8da1 Final kick revision (?) 2018-03-24 19:30:16 -04:00
Anuken
fd352f4ab1 Changed kicking again 2018-03-24 19:19:24 -04:00
Anuken
7f40247b89 Fixed overly sensitive shoot-kicking 2018-03-24 19:10:17 -04:00
15 changed files with 94 additions and 58 deletions

View File

@@ -25,7 +25,7 @@ allprojects {
appName = 'Mindustry' appName = 'Mindustry'
gdxVersion = '1.9.8' gdxVersion = '1.9.8'
aiVersion = '1.8.1' aiVersion = '1.8.1'
uCoreVersion = '238babe' uCoreVersion = 'c5d47cc'
getVersionString = { getVersionString = {
String buildVersion = getBuildVersion() String buildVersion = getBuildVersion()

View File

@@ -1,7 +1,7 @@
#Autogenerated file. Do not modify. #Autogenerated file. Do not modify.
#Sat Mar 24 14:20:21 EDT 2018 #Sun Apr 01 12:07:12 EDT 2018
version=release version=release
androidBuildCode=473 androidBuildCode=492
name=Mindustry name=Mindustry
code=3.5 code=3.5
build=35 build=custom build

View File

@@ -172,7 +172,7 @@ public class Control extends Module{
Events.on(WaveEvent.class, () -> { Events.on(WaveEvent.class, () -> {
Sounds.play("spawn"); 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){ if(state.wave > last && !state.mode.infiniteResources && !state.mode.disableWaveTimer){
Settings.putInt("hiscore" + world.getMap().name, state.wave); Settings.putInt("hiscore" + world.getMap().name, state.wave);

View File

@@ -172,17 +172,17 @@ public class NetServer extends Module{
TraceInfo info = admins.getTrace(Net.getConnection(id).address); TraceInfo info = admins.getTrace(Net.getConnection(id).address);
Weapon weapon = (Weapon)Upgrade.getByID(packet.weaponid); 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 ++; 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); kick(id, KickReason.kick);
} }
}else{
info.fastShots = 0; info.fastShots = 0;
info.lastFastShot = TimeUtils.millis();
} }
packet.playerid = connections.get(id).id; packet.playerid = connections.get(id).id;
@@ -265,6 +265,10 @@ public class NetServer extends Module{
}); });
Net.handleServer(WeaponSwitchPacket.class, (id, packet) -> { 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; packet.playerid = connections.get(id).id;
Net.sendExcept(id, packet, SendMode.tcp); Net.sendExcept(id, packet, SendMode.tcp);
}); });

View File

@@ -244,7 +244,7 @@ public class World extends Module{
Array<Tile> removals = target.getLinkedTiles(); Array<Tile> removals = target.getLinkedTiles();
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);
} }
} }
} }

View File

@@ -42,7 +42,6 @@ public class Player extends SyncEntity{
public Mech mech = Mech.standard; public Mech mech = Mech.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;
@@ -54,7 +53,7 @@ public class Player extends SyncEntity{
public Player(){ public Player(){
hitbox.setSize(5); hitbox.setSize(5);
hitboxTile.setSize(5f); hitboxTile.setSize(4f);
maxhealth = 200; maxhealth = 200;
heal(); heal();
@@ -161,15 +160,8 @@ public class Player extends SyncEntity{
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.floor().liquid && tile.block() == Blocks.air) || tile.solid())){ if(tile != null && ((tile.floor().liquid && tile.block() == Blocks.air) || 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;

View File

@@ -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,

View File

@@ -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);
} }

View File

@@ -10,6 +10,7 @@ public class TraceInfo {
public boolean android; public boolean android;
public int fastShots; public int fastShots;
public long lastFastShot;
public int totalBlocksBroken; public int totalBlocksBroken;
public int structureBlocksBroken; public int structureBlocksBroken;

View File

@@ -159,7 +159,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;
} }

View File

@@ -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();
} }
} }

View File

@@ -106,13 +106,18 @@ public class Placement {
rect.setCenter(offset.x + x * tilesize, offset.y + y * tilesize); rect.setCenter(offset.x + x * tilesize, offset.y + y * tilesize);
synchronized (Entities.entityLock) { synchronized (Entities.entityLock) {
for (SolidEntity e : Entities.getNearby(enemyGroup, x * tilesize, y * tilesize, tilesize * 2f)) { //exception sometimes thrown due to multithreading, not sure what else to try at this point
if (e == null) continue; //not sure why this happens? try {
Rectangle rect = e.hitbox.getRect(e.x, e.y); 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)) { if (Placement.rect.overlaps(rect)) {
return false; return false;
}
} }
}catch (Exception e){
return false;
} }
} }

View File

@@ -71,19 +71,7 @@ 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();
return entity.index < entity.buffer.length - 1;
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;
}
} }
@Override @Override

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);

View File

@@ -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 -> { 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]);