mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-13 01:07:30 +07:00
Auto-play server sectors / Difficulty decrease / Improved d/c messages
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -21,6 +21,7 @@
|
|||||||
/core/assets/gifexport/
|
/core/assets/gifexport/
|
||||||
/core/assets/version.properties
|
/core/assets/version.properties
|
||||||
/core/assets/locales.json
|
/core/assets/locales.json
|
||||||
|
/ios/src/io/anuke/mindustry/gen/
|
||||||
*.gif
|
*.gif
|
||||||
|
|
||||||
version.properties
|
version.properties
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
android:name="io.anuke.mindustry.AndroidLauncher"
|
android:name="io.anuke.mindustry.AndroidLauncher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:screenOrientation="user"
|
android:screenOrientation="user"
|
||||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
@ -79,7 +79,9 @@ text.server.mismatch=Packet error: possible client/server version mismatch.\nMak
|
|||||||
text.server.closing=[accent]Closing server...
|
text.server.closing=[accent]Closing server...
|
||||||
text.server.kicked.kick=You have been kicked from the server!
|
text.server.kicked.kick=You have been kicked from the server!
|
||||||
text.server.kicked.fastShoot=You are shooting too quickly.
|
text.server.kicked.fastShoot=You are shooting too quickly.
|
||||||
text.server.kicked.invalidPassword=Invalid password!
|
text.server.kicked.serverClose=Server closed.
|
||||||
|
text.server.kicked.sectorComplete=Sector completed.
|
||||||
|
text.server.kicked.sectorComplete.text=Your mission is complete.\nThe server will now continue at the next sector.
|
||||||
text.server.kicked.clientOutdated=Outdated client! Update your game!
|
text.server.kicked.clientOutdated=Outdated client! Update your game!
|
||||||
text.server.kicked.serverOutdated=Outdated server! Ask the host to update!
|
text.server.kicked.serverOutdated=Outdated server! Ask the host to update!
|
||||||
text.server.kicked.banned=You are banned on this server.
|
text.server.kicked.banned=You are banned on this server.
|
||||||
|
@ -149,7 +149,13 @@ public class NetClient extends Module{
|
|||||||
public static void onKick(KickReason reason){
|
public static void onKick(KickReason reason){
|
||||||
netClient.disconnectQuietly();
|
netClient.disconnectQuietly();
|
||||||
state.set(State.menu);
|
state.set(State.menu);
|
||||||
if(!reason.quiet) ui.showError("$text.server.kicked." + reason.name());
|
if(!reason.quiet){
|
||||||
|
if(reason.extraText() != null){
|
||||||
|
ui.showText(reason.toString(), reason.extraText());
|
||||||
|
}else{
|
||||||
|
ui.showText("$text.disconnect", reason.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
ui.loadfrag.hide();
|
ui.loadfrag.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,6 +363,12 @@ public class NetServer extends Module{
|
|||||||
admins.clearTraces();
|
admins.clearTraces();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void kickAll(KickReason reason){
|
||||||
|
for(NetConnection con : Net.getConnections()){
|
||||||
|
kick(con.id, reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void kick(int connection, KickReason reason){
|
public void kick(int connection, KickReason reason){
|
||||||
NetConnection con = Net.getConnection(connection);
|
NetConnection con = Net.getConnection(connection);
|
||||||
if(con == null){
|
if(con == null){
|
||||||
|
@ -283,6 +283,13 @@ public class UI extends SceneModule{
|
|||||||
}}.show();
|
}}.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showText(String title, String text){
|
||||||
|
new Dialog(title, "dialog"){{
|
||||||
|
content().margin(15).add(text).width(400f).wrap().get().setAlignment(Align.center, Align.center);
|
||||||
|
buttons().addButton("$text.ok", this::hide).size(90, 50).pad(4);
|
||||||
|
}}.show();
|
||||||
|
}
|
||||||
|
|
||||||
public void showConfirm(String title, String text, Runnable confirmed){
|
public void showConfirm(String title, String text, Runnable confirmed){
|
||||||
FloatingDialog dialog = new FloatingDialog(title);
|
FloatingDialog dialog = new FloatingDialog(title);
|
||||||
dialog.content().add(text).width(400f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
|
dialog.content().add(text).width(400f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
|
||||||
|
@ -10,6 +10,8 @@ import com.badlogic.gdx.utils.IntMap;
|
|||||||
import com.badlogic.gdx.utils.ObjectMap;
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||||
import io.anuke.mindustry.core.Platform;
|
import io.anuke.mindustry.core.Platform;
|
||||||
|
import io.anuke.mindustry.gen.Call;
|
||||||
|
import io.anuke.mindustry.net.Packets.KickReason;
|
||||||
import io.anuke.mindustry.net.Packets.StreamBegin;
|
import io.anuke.mindustry.net.Packets.StreamBegin;
|
||||||
import io.anuke.mindustry.net.Packets.StreamChunk;
|
import io.anuke.mindustry.net.Packets.StreamChunk;
|
||||||
import io.anuke.mindustry.net.Streamable.StreamBuilder;
|
import io.anuke.mindustry.net.Streamable.StreamBuilder;
|
||||||
@ -88,7 +90,7 @@ public class Net{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Host a server at an address
|
* Host a server at an address.
|
||||||
*/
|
*/
|
||||||
public static void host(int port) throws IOException{
|
public static void host(int port) throws IOException{
|
||||||
serverProvider.host(port);
|
serverProvider.host(port);
|
||||||
@ -102,6 +104,10 @@ public class Net{
|
|||||||
* Closes the server.
|
* Closes the server.
|
||||||
*/
|
*/
|
||||||
public static void closeServer(){
|
public static void closeServer(){
|
||||||
|
for(NetConnection con : getConnections()){
|
||||||
|
Call.onKick(con.id, KickReason.serverClose);
|
||||||
|
}
|
||||||
|
|
||||||
serverProvider.close();
|
serverProvider.close();
|
||||||
server = false;
|
server = false;
|
||||||
active = false;
|
active = false;
|
||||||
|
@ -10,6 +10,7 @@ import io.anuke.mindustry.game.Version;
|
|||||||
import io.anuke.mindustry.type.Recipe;
|
import io.anuke.mindustry.type.Recipe;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.io.IOUtils;
|
import io.anuke.ucore.io.IOUtils;
|
||||||
|
import io.anuke.ucore.util.Bundles;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@ -22,16 +23,27 @@ import static io.anuke.mindustry.Vars.world;
|
|||||||
public class Packets{
|
public class Packets{
|
||||||
|
|
||||||
public enum KickReason{
|
public enum KickReason{
|
||||||
kick, invalidPassword, clientOutdated, serverOutdated, banned, gameover(true), recentKick, nameInUse, idInUse, fastShoot, nameEmpty, customClient, sectorComplete(true);
|
kick, clientOutdated, serverOutdated, banned, gameover(true), recentKick,
|
||||||
|
nameInUse, idInUse, nameEmpty, customClient, sectorComplete, serverClose;
|
||||||
|
|
||||||
public final boolean quiet;
|
public final boolean quiet;
|
||||||
|
|
||||||
KickReason(){
|
KickReason(){
|
||||||
quiet = false;
|
this(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
KickReason(boolean quiet){
|
KickReason(boolean quiet){
|
||||||
this.quiet = quiet;
|
this.quiet = quiet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(){
|
||||||
|
return Bundles.get("text.server.kicked." + name());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String extraText(){
|
||||||
|
return Bundles.getOrNull("text.server.kicked." + name() + ".text");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum AdminAction{
|
public enum AdminAction{
|
||||||
|
@ -8,6 +8,7 @@ import io.anuke.mindustry.content.fx.BlockFx;
|
|||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.graphics.Layer;
|
import io.anuke.mindustry.graphics.Layer;
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
|
import io.anuke.mindustry.type.ItemStack;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.consumers.ConsumeLiquid;
|
import io.anuke.mindustry.world.consumers.ConsumeLiquid;
|
||||||
@ -233,7 +234,8 @@ public class Drill extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isValid(Tile tile){
|
protected boolean isValid(Tile tile){
|
||||||
return tile.floor().drops != null && tile.floor().drops.item.hardness <= tier;
|
ItemStack drops = tile.floor().drops;
|
||||||
|
return drops != null && drops.item.hardness <= tier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DrillEntity extends TileEntity{
|
public static class DrillEntity extends TileEntity{
|
||||||
|
@ -38,7 +38,7 @@ import java.io.DataOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class UnitPad extends Block{
|
public class UnitPad extends Block{
|
||||||
protected float gracePeriodMultiplier = 22f;
|
protected float gracePeriodMultiplier = 23f;
|
||||||
protected float speedupTime = 60f * 60f * 20;
|
protected float speedupTime = 60f * 60f * 20;
|
||||||
protected float maxSpeedup = 7f;
|
protected float maxSpeedup = 7f;
|
||||||
|
|
||||||
|
@ -53,23 +53,25 @@ public class ServerControl extends Module{
|
|||||||
Effects.setEffectProvider((a, b, c, d, e, f) -> {});
|
Effects.setEffectProvider((a, b, c, d, e, f) -> {});
|
||||||
Sounds.setHeadless(true);
|
Sounds.setHeadless(true);
|
||||||
|
|
||||||
String[] commands = {};
|
|
||||||
|
|
||||||
if(args.length > 0){
|
|
||||||
commands = String.join(" ", args).split(",");
|
|
||||||
Log.info("&lmFound {0} command-line arguments to parse. {1}", commands.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
registerCommands();
|
registerCommands();
|
||||||
|
|
||||||
for(String s : commands){
|
Gdx.app.postRunnable(() -> {
|
||||||
Response response = handler.handleMessage(s);
|
String[] commands = {};
|
||||||
if(response.type != ResponseType.valid){
|
|
||||||
Log.err("Invalid command argument sent: '{0}': {1}", s, response.type.name());
|
if(args.length > 0){
|
||||||
Log.err("Argument usage: &lc<command-1> <command1-args...>,<command-2> <command-2-args2...>");
|
commands = String.join(" ", args).split(",");
|
||||||
System.exit(1);
|
Log.info("&lmFound {0} command-line arguments to parse. {1}", commands.length);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
for(String s : commands){
|
||||||
|
Response response = handler.handleMessage(s);
|
||||||
|
if(response.type != ResponseType.valid){
|
||||||
|
Log.err("Invalid command argument sent: '{0}': {1}", s, response.type.name());
|
||||||
|
Log.err("Argument usage: &lc<command-1> <command1-args...>,<command-2> <command-2-args2...>");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Thread thread = new Thread(this::readCommands, "Server Controls");
|
Thread thread = new Thread(this::readCommands, "Server Controls");
|
||||||
thread.setDaemon(true);
|
thread.setDaemon(true);
|
||||||
@ -82,33 +84,28 @@ public class ServerControl extends Module{
|
|||||||
|
|
||||||
Events.on(GameOverEvent.class, () -> {
|
Events.on(GameOverEvent.class, () -> {
|
||||||
info("Game over!");
|
info("Game over!");
|
||||||
|
netServer.kickAll(KickReason.gameover);
|
||||||
for(NetConnection connection : Net.getConnections()){
|
|
||||||
netServer.kick(connection.id, KickReason.gameover);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mode != ShuffleMode.off){
|
if(mode != ShuffleMode.off){
|
||||||
if(world.maps().all().size > 0){
|
if(world.getSector() == null){
|
||||||
Array<Map> maps = mode == ShuffleMode.both ? world.maps().all() :
|
if(world.maps().all().size > 0){
|
||||||
mode == ShuffleMode.normal ? world.maps().defaultMaps() : world.maps().customMaps();
|
Array<Map> maps = mode == ShuffleMode.both ? world.maps().all() :
|
||||||
|
mode == ShuffleMode.normal ? world.maps().defaultMaps() : world.maps().customMaps();
|
||||||
|
|
||||||
Map previous = world.getMap();
|
Map previous = world.getMap();
|
||||||
Map map = previous;
|
Map map = previous;
|
||||||
while(map == previous) map = maps.random();
|
if(maps.size > 1){
|
||||||
|
while(map == previous) map = maps.random();
|
||||||
if(map != null){
|
}
|
||||||
|
|
||||||
info("Selected next map to be {0}.", map.name);
|
info("Selected next map to be {0}.", map.name);
|
||||||
state.set(State.playing);
|
|
||||||
|
|
||||||
logic.reset();
|
logic.reset();
|
||||||
world.loadMap(map);
|
world.loadMap(map);
|
||||||
}else{
|
state.set(State.playing);
|
||||||
info("Selected a procedural map.");
|
|
||||||
playSectorMap();
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
info("Selected a procedural map.");
|
info("Re-trying sector map.");
|
||||||
playSectorMap();
|
playSectorMap();
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@ -290,7 +287,7 @@ public class ServerControl extends Module{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.register("debugmode", "<on/off>", "Disables or enables debug ode", arg -> {
|
handler.register("debug", "<on/off>", "Disables or enables debug ode", arg -> {
|
||||||
boolean value = arg[0].equalsIgnoreCase("on");
|
boolean value = arg[0].equalsIgnoreCase("on");
|
||||||
debug = value;
|
debug = value;
|
||||||
info("Debug mode is now {0}.", value ? "on" : "off");
|
info("Debug mode is now {0}.", value ? "on" : "off");
|
||||||
@ -632,7 +629,7 @@ public class ServerControl extends Module{
|
|||||||
info("Core destroyed.");
|
info("Core destroyed.");
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.register("debug", "Print debug info", arg -> {
|
handler.register("debuginfo", "Print debug info", arg -> {
|
||||||
info(DebugFragment.debugInfo());
|
info(DebugFragment.debugInfo());
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -829,7 +826,7 @@ public class ServerControl extends Module{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void playSectorMap(){
|
private void playSectorMap(){
|
||||||
world.loadSector(world.sectors().get(0, 0));
|
world.loadSector(world.sectors().get(Settings.getInt("sectorid"), 0));
|
||||||
logic.play();
|
logic.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -842,6 +839,27 @@ public class ServerControl extends Module{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(){
|
||||||
|
|
||||||
|
if(state.is(State.playing) && world.getSector() != null){
|
||||||
|
//all assigned missions are complete
|
||||||
|
if(world.getSector().completedMissions >= world.getSector().missions.size){
|
||||||
|
world.sectors().completeSector(world.getSector().x, world.getSector().y);
|
||||||
|
world.sectors().save();
|
||||||
|
Settings.putInt("sectorid", world.getSector().x + 1);
|
||||||
|
Settings.save();
|
||||||
|
|
||||||
|
netServer.kickAll(KickReason.sectorComplete);
|
||||||
|
logic.reset();
|
||||||
|
playSectorMap();
|
||||||
|
}else if(world.getSector().currentMission().isComplete()){
|
||||||
|
//increment completed missions, check next index next frame
|
||||||
|
world.getSector().completedMissions ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum ShuffleMode{
|
enum ShuffleMode{
|
||||||
normal, custom, both, off
|
normal, custom, both, off
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user