Skip to content

Commit

Permalink
Improved host command
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Aug 9, 2018
1 parent 0cb8c60 commit 2aee72b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
3 changes: 0 additions & 3 deletions core/src/io/anuke/mindustry/ai/Pathfinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import io.anuke.ucore.core.Events;
import io.anuke.ucore.core.Timers;
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.world;
Expand Down Expand Up @@ -182,8 +181,6 @@ private void clear(){
}

state.spawner.checkAllQuadrants();

Log.info("Elapsed calculation time: {0}", Timers.elapsed());
}

class PathData{
Expand Down
43 changes: 21 additions & 22 deletions server/src/io/anuke/mindustry/server/ServerControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private void registerCommands(){
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)){
err("Already hosting. Type 'stop' to stop hosting first.");
return;
Expand All @@ -152,39 +152,38 @@ private void registerCommands(){
Map result = null;

if(arg.length > 0){
GameMode mode;
try{
mode = GameMode.valueOf(arg[0]);
}catch(IllegalArgumentException e){
err("No gamemode '{0}' found.", arg[0]);

String search = arg[0];
for(Map map : world.maps().all()){
if(map.name.equalsIgnoreCase(search)) result = map;
}

if(result == null){
err("No map with name &y'{0}'&lr found.", search);
return;
}


info("Loading map...");
state.mode = mode;

if(arg.length > 1){
String search = arg[1];
for(Map map : world.maps().all()){
if(map.name.equalsIgnoreCase(search))
result = map;
}

if(result == null){
err("No map with name &y'{0}'&lr found.", search);
GameMode mode;
try{
mode = GameMode.valueOf(arg[1]);
}catch(IllegalArgumentException e){
err("No gamemode '{0}' found.", arg[1]);
return;
}

logic.reset();
world.loadMap(result);
logic.play();
}else{
Log.info("&ly&fiNo map specified, so a procedural one was generated.");
playSectorMap();
state.mode = mode;
}

logic.reset();
world.loadMap(result);
logic.play();

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

Expand Down

0 comments on commit 2aee72b

Please sign in to comment.