diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index d4d20529e8..0bb62bbc96 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -263,7 +263,7 @@ text.mapeditor = Map Editor text.donate = Donate text.connectfail = [crimson]Failed to connect to server\:\n\n[accent]{0} -text.error.unreachable = Server unreachable. +text.error.unreachable = Server unreachable.\nIs the address spelled correctly? text.error.invalidaddress = Invalid address. text.error.timedout = Timed out!\nMake sure the host has port forwarding set up, and that the address is correct! text.error.mismatch = Packet error:\npossible client/server version mismatch.\nMake sure you and the host have the latest version of Mindustry! diff --git a/core/src/io/anuke/mindustry/ai/BlockIndexer.java b/core/src/io/anuke/mindustry/ai/BlockIndexer.java index 1213bd2721..04c5c04cb8 100644 --- a/core/src/io/anuke/mindustry/ai/BlockIndexer.java +++ b/core/src/io/anuke/mindustry/ai/BlockIndexer.java @@ -247,7 +247,7 @@ public class BlockIndexer{ for(int x = quadrantX * structQuadrantSize; x < world.width() && x < (quadrantX + 1) * structQuadrantSize; x++){ for(int y = quadrantY * structQuadrantSize; y < world.height() && y < (quadrantY + 1) * structQuadrantSize; y++){ Tile result = world.tile(x, y); - if(result.block().drops == null || !scanOres.contains(result.block().drops.item)) continue; + if( result == null || result.block().drops == null || !scanOres.contains(result.block().drops.item)) continue; itemSet.add(result.block().drops.item); } diff --git a/core/src/io/anuke/mindustry/core/UI.java b/core/src/io/anuke/mindustry/core/UI.java index 8120e2212a..1fb684cdb2 100644 --- a/core/src/io/anuke/mindustry/core/UI.java +++ b/core/src/io/anuke/mindustry/core/UI.java @@ -155,6 +155,7 @@ public class UI extends SceneModule{ load = new LoadDialog(); levels = new CustomGameDialog(); language = new LanguageDialog(); + unlocks = new UnlocksDialog(); settings = new SettingsMenuDialog(); host = new HostDialog(); paused = new PausedDialog(); @@ -165,7 +166,6 @@ public class UI extends SceneModule{ traces = new TraceDialog(); maps = new MapsDialog(); localplayers = new LocalPlayerDialog(); - unlocks = new UnlocksDialog(); content = new ContentInfoDialog(); sectors = new SectorsDialog(); missions = new MissionDialog(); diff --git a/core/src/io/anuke/mindustry/maps/SectorPresets.java b/core/src/io/anuke/mindustry/maps/SectorPresets.java index 29540e1d5b..08fa7f1b19 100644 --- a/core/src/io/anuke/mindustry/maps/SectorPresets.java +++ b/core/src/io/anuke/mindustry/maps/SectorPresets.java @@ -56,7 +56,8 @@ public class SectorPresets{ Missions.blockRecipe(ProductionBlocks.waterExtractor), new ContentMission(Items.biomatter), Missions.blockRecipe(CraftingBlocks.biomatterCompressor), - new ContentMission(Liquids.oil) + new ContentMission(Liquids.oil), + new BattleMission() ), Array.with(Items.copper, Items.lead, Items.coal, Items.titanium))); } @@ -69,6 +70,8 @@ public class SectorPresets{ return presets.get(x, y); } + public GridMap getPresets() { return presets; } + private void add(SectorPreset preset){ presets.put(preset.x, preset.y, preset); orePresets.put(preset.x, preset.y, preset.ores); diff --git a/core/src/io/anuke/mindustry/net/Net.java b/core/src/io/anuke/mindustry/net/Net.java index 78941f012f..4bd10f57fd 100644 --- a/core/src/io/anuke/mindustry/net/Net.java +++ b/core/src/io/anuke/mindustry/net/Net.java @@ -59,7 +59,7 @@ public class Net{ } String error = t.getMessage() == null ? "" : t.getMessage().toLowerCase(); - String type = error.getClass().toString().toLowerCase(); + String type = t.getClass().toString().toLowerCase(); if(error.equals("mismatch")){ error = Bundles.get("text.error.mismatch"); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java index 26a90e46bc..728e94bae1 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java @@ -57,6 +57,9 @@ public class PausedDialog extends FloatingDialog{ hide(); }); + content().row(); + content().addButton("$text.unlocks", ui.unlocks::show); + content().row(); content().addButton("$text.settings", ui.settings::show); diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 0341a51de1..7206e82db0 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -107,7 +107,7 @@ public class HudFragment extends Fragment{ Stack stack = new Stack(); TextButton waves = new TextButton(""); - Table btable = new Table().margin(14); + Table btable = new Table().margin(0); stack.add(waves); stack.add(btable); @@ -375,7 +375,7 @@ public class HudFragment extends Fragment{ (!state.mode.disableWaveTimer ? Bundles.format("text.wave.waiting", (int)(state.wavetime/60)) : Bundles.get("text.waiting"))) : - Bundles.format("text.mission.display", world.getSector().currentMission().displayString())).growX(); + Bundles.format("text.mission.display", world.getSector().currentMission().displayString())).growX().pad(8f); table.clicked(() -> { if(world.getSector() != null && world.getSector().currentMission().hasMessage()){ diff --git a/tests/src/test/java/SectorTests.java b/tests/src/test/java/SectorTests.java new file mode 100644 index 0000000000..3aae6cb305 --- /dev/null +++ b/tests/src/test/java/SectorTests.java @@ -0,0 +1,54 @@ +import com.badlogic.gdx.utils.Array; +import io.anuke.mindustry.Vars; +import io.anuke.mindustry.core.ContentLoader; +import io.anuke.mindustry.maps.SectorPresets; +import io.anuke.mindustry.maps.generation.Generation; +import io.anuke.mindustry.maps.missions.Mission; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** This class is responsible for testing predefined sectors. */ +public class SectorTests{ + + private SectorPresets presets; + private Generation fakeGen; + + @BeforeAll + static void initializeDependencies(){ + Vars.content = new ContentLoader(); + Vars.content.load(); + } + + @BeforeEach + void initTest(){ + this.presets = new SectorPresets(); + + // Fake away the Generation dependency + this.fakeGen = new Generation(null, null, 250, 250, null); + } + + /** Returns true if at least one mission provides a spawn point. */ + private boolean spawnPointIsDefined(Array missions){ + for(Mission mission : missions){ + if(mission.getSpawnPoints(this.fakeGen).size > 0){ + return true; + } + } + // No spawn point provided + return false; + } + + /** + * Makes sure that every predefined sector has a position for the player core defined. + * This is achieved by adding at least one mission which defines a spawn point. + */ + @Test + void test_sectorHasACore(){ + for(SectorPresets.SectorPreset preset : this.presets.getPresets().values()){ + assertTrue(spawnPointIsDefined(preset.missions), "Sector at (" + preset.x + "|" + preset.y + ") contains no missions which define a spawn point. Add a battle or wave mission."); + } + } +}