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,39 +152,38 @@ public class ServerControl extends Module{
Map result = null; Map result = null;
if(arg.length > 0){ if(arg.length > 0){
GameMode mode;
try{ String search = arg[0];
mode = GameMode.valueOf(arg[0]); for(Map map : world.maps().all()){
}catch(IllegalArgumentException e){ if(map.name.equalsIgnoreCase(search)) result = map;
err("No gamemode '{0}' found.", arg[0]); }
if(result == null){
err("No map with name &y'{0}'&lr found.", search);
return; return;
} }
info("Loading map..."); info("Loading map...");
state.mode = mode;
if(arg.length > 1){ if(arg.length > 1){
String search = arg[1]; GameMode mode;
for(Map map : world.maps().all()){ try{
if(map.name.equalsIgnoreCase(search)) mode = GameMode.valueOf(arg[1]);
result = map; }catch(IllegalArgumentException e){
} err("No gamemode '{0}' found.", arg[1]);
if(result == null){
err("No map with name &y'{0}'&lr found.", search);
return; return;
} }
logic.reset(); state.mode = mode;
world.loadMap(result);
logic.play();
}else{
Log.info("&ly&fiNo map specified, so a procedural one was generated.");
playSectorMap();
} }
logic.reset();
world.loadMap(result);
logic.play();
}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();
} }