This commit is contained in:
Anuken
2020-08-18 16:56:30 -04:00
parent e96fcb3cb7
commit 26acf7cbbc
8 changed files with 27 additions and 29 deletions

View File

@@ -843,8 +843,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
} }
} }
/** Called when the block is tapped.*/ /** Called when the block is tapped by the local player. */
public void tapped(Player player){ public void tapped(){
} }

View File

@@ -166,17 +166,6 @@ public class EventType{
} }
} }
/** Called when the player taps a block. */
public static class TapEvent{
public final Building tile;
public final Player player;
public TapEvent(Building tile, Player player){
this.tile = tile;
this.player = player;
}
}
/** Called when the player sets a specific block. */ /** Called when the player sets a specific block. */
public static class TapConfigEvent{ public static class TapConfigEvent{
public final Building tile; public final Building tile;

View File

@@ -206,15 +206,6 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
); );
} }
@Remote(targets = Loc.both, called = Loc.server, forward = true)
public static void tileTapped(Player player, Building tile){
if(tile == null || player == null) return;
if(net.server() && (!Units.canInteract(player, tile) ||
!netServer.admins.allowAction(player, ActionType.tapTile, tile.tile(), action -> {}))) throw new ValidateException(player, "Player cannot tap a tile.");
tile.tapped(player);
Core.app.post(() -> Events.fire(new TapEvent(tile, player)));
}
@Remote(targets = Loc.both, called = Loc.both, forward = true) @Remote(targets = Loc.both, called = Loc.both, forward = true)
public static void tileConfig(Player player, Building tile, @Nullable Object value){ public static void tileConfig(Player player, Building tile, @Nullable Object value){
if(tile == null) return; if(tile == null) return;
@@ -778,7 +769,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
//call tapped event //call tapped event
if(!consumed && tile.interactable(player.team())){ if(!consumed && tile.interactable(player.team())){
Call.tileTapped(player, tile); tile.tapped();
} }
//consume tap event if necessary //consume tap event if necessary

View File

@@ -75,7 +75,6 @@ public class Administration{
addActionFilter(action -> { addActionFilter(action -> {
if(action.type != ActionType.breakBlock && if(action.type != ActionType.breakBlock &&
action.type != ActionType.placeBlock && action.type != ActionType.placeBlock &&
action.type != ActionType.tapTile &&
Config.antiSpam.bool() && Config.antiSpam.bool() &&
//make sure players can configure their own stuff, e.g. in schematics //make sure players can configure their own stuff, e.g. in schematics
lastPlaced.get(action.tile.pos(), -1) != action.player.id()){ lastPlaced.get(action.tile.pos(), -1) != action.player.id()){
@@ -720,7 +719,7 @@ public class Administration{
} }
public enum ActionType{ public enum ActionType{
breakBlock, placeBlock, rotate, configure, tapTile, withdrawItem, depositItem breakBlock, placeBlock, rotate, configure, withdrawItem, depositItem
} }
} }

View File

@@ -10,6 +10,7 @@ import arc.util.serialization.*;
import mindustry.core.*; import mindustry.core.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
import mindustry.io.*;
import mindustry.net.Administration.*; import mindustry.net.Administration.*;
import mindustry.net.Packets.*; import mindustry.net.Packets.*;
import mindustry.ui.*; import mindustry.ui.*;
@@ -129,6 +130,9 @@ public class BeControl{
progress -> {}, progress -> {},
() -> false, () -> false,
() -> Core.app.post(() -> { () -> Core.app.post(() -> {
Log.info("&lcSaving...");
SaveIO.save(saveDirectory.child("autosavebe." + saveExtension));
netServer.kickAll(KickReason.serverRestarting); netServer.kickAll(KickReason.serverRestarting);
Threads.sleep(32); Threads.sleep(32);

View File

@@ -148,9 +148,9 @@ public class BuildBlock extends Block{
} }
@Override @Override
public void tapped(Player player){ public void tapped(){
//if the target is constructible, begin constructing //if the target is constructible, begin constructing
if(!headless && cblock != null){ if(cblock != null){
if(control.input.buildWasAutoPaused && !control.input.isBuilding && player.isBuilder()){ if(control.input.buildWasAutoPaused && !control.input.isBuilding && player.isBuilder()){
control.input.isBuilding = true; control.input.isBuilding = true;
} }

View File

@@ -84,7 +84,7 @@ public class Door extends Wall{
if(type == LAccess.enabled){ if(type == LAccess.enabled){
boolean shouldOpen = !Mathf.zero(p1); boolean shouldOpen = !Mathf.zero(p1);
if(open == shouldOpen || (Units.anyEntities(tile) && !shouldOpen) || !origin().timer(timerToggle, 60f)){ if(net.client() || open == shouldOpen || (Units.anyEntities(tile) && !shouldOpen) || !origin().timer(timerToggle, 60f)){
return; return;
} }
@@ -133,7 +133,7 @@ public class Door extends Wall{
} }
@Override @Override
public void tapped(Player player){ public void tapped(){
if((Units.anyEntities(tile) && open) || !origin().timer(timerToggle, 50f)){ if((Units.anyEntities(tile) && open) || !origin().timer(timerToggle, 50f)){
return; return;
} }

View File

@@ -86,6 +86,21 @@ public class ServerControl implements ApplicationListener{
registerCommands(); registerCommands();
Core.app.post(() -> { Core.app.post(() -> {
//try to load auto-update save if possible
if(Config.autoUpdate.bool()){
Fi fi = saveDirectory.child("autosavebe." + saveExtension);
if(fi.exists()){
try{
SaveIO.load(fi);
info("Auto-save loaded.");
state.set(State.playing);
netServer.openServer();
}catch(Throwable e){
Log.err(e);
}
}
}
Seq<String> commands = new Seq<>(); Seq<String> commands = new Seq<>();
if(args.length > 0){ if(args.length > 0){