Improved host command

This commit is contained in:
Anuken
2018-08-08 20:57:24 -04:00
parent 0cb8c600b7
commit 2aee72b47b
2 changed files with 21 additions and 25 deletions

View File

@@ -16,7 +16,6 @@ import io.anuke.mindustry.world.meta.BlockFlag;
import io.anuke.ucore.core.Events; import io.anuke.ucore.core.Events;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Geometry; import io.anuke.ucore.util.Geometry;
import io.anuke.ucore.util.Log;
import static io.anuke.mindustry.Vars.state; import static io.anuke.mindustry.Vars.state;
import static io.anuke.mindustry.Vars.world; import static io.anuke.mindustry.Vars.world;
@@ -182,8 +181,6 @@ public class Pathfinder{
} }
state.spawner.checkAllQuadrants(); state.spawner.checkAllQuadrants();
Log.info("Elapsed calculation time: {0}", Timers.elapsed());
} }
class PathData{ class PathData{

View File

@@ -143,7 +143,7 @@ public class ServerControl extends Module{
Log.info("Stopped server."); Log.info("Stopped server.");
}); });
handler.register("host", "[mode] [mapname]", "Open the server with a specific map.", arg -> { handler.register("host", "[mapname] [mode]", "Open the server with a specific map.", arg -> {
if(state.is(State.playing)){ if(state.is(State.playing)){
err("Already hosting. Type 'stop' to stop hosting first."); err("Already hosting. Type 'stop' to stop hosting first.");
return; return;
@@ -152,22 +152,10 @@ public class ServerControl extends Module{
Map result = null; Map result = null;
if(arg.length > 0){ if(arg.length > 0){
GameMode mode;
try{
mode = GameMode.valueOf(arg[0]);
}catch(IllegalArgumentException e){
err("No gamemode '{0}' found.", arg[0]);
return;
}
info("Loading map..."); String search = arg[0];
state.mode = mode;
if(arg.length > 1){
String search = arg[1];
for(Map map : world.maps().all()){ for(Map map : world.maps().all()){
if(map.name.equalsIgnoreCase(search)) if(map.name.equalsIgnoreCase(search)) result = map;
result = map;
} }
if(result == null){ if(result == null){
@@ -175,16 +163,27 @@ public class ServerControl extends Module{
return; return;
} }
info("Loading map...");
if(arg.length > 1){
GameMode mode;
try{
mode = GameMode.valueOf(arg[1]);
}catch(IllegalArgumentException e){
err("No gamemode '{0}' found.", arg[1]);
return;
}
state.mode = mode;
}
logic.reset(); logic.reset();
world.loadMap(result); world.loadMap(result);
logic.play(); logic.play();
}else{
Log.info("&ly&fiNo map specified, so a procedural one was generated.");
playSectorMap();
}
}else{ }else{
Log.info("&ly&fiNo map specified, so a procedural one was generated."); Log.info("&ly&fiNo map specified. Loading sector {0}, {1}.", Settings.getInt("sectorid"), 0);
playSectorMap(); playSectorMap();
} }