mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-05 18:30:22 -08:00
Closes Anuken/Mindustry-Suggestions/issues/5742
This commit is contained in:
parent
fdae9a14fe
commit
17a5b2f387
5 changed files with 65 additions and 56 deletions
|
|
@ -89,6 +89,8 @@ public class Vars implements Loadable{
|
|||
public static final String reportIssueURL = "https://github.com/Anuken/Mindustry/issues/new?labels=bug&template=bug_report.md";
|
||||
/** list of built-in servers.*/
|
||||
public static final Seq<ServerGroup> defaultServers = Seq.with();
|
||||
/** cached server list - only used if defaultServers have not been fetched*/
|
||||
public static final Seq<ServerGroup> cachedServers = Seq.with();
|
||||
/** maximum openGL errors logged */
|
||||
public static final int maxGlErrors = 100;
|
||||
/** maximum size of any block, do not change unless you know what you're doing */
|
||||
|
|
@ -206,6 +208,10 @@ public class Vars implements Loadable{
|
|||
public static boolean drawDebugHitboxes = false;
|
||||
/** Whether to draw avoidance fields. */
|
||||
public static boolean debugDrawAvoidance = false;
|
||||
/** Whether the on-disk server file cache has been loaded. */
|
||||
public static boolean loadedServerCache = false;
|
||||
/** Whether the server list has been fetched from Github. */
|
||||
public static boolean fetchedServers = false;
|
||||
/** application data directory, equivalent to {@link Settings#getDataDirectory()} */
|
||||
public static Fi dataDirectory;
|
||||
/** data subdirectory used for screenshots */
|
||||
|
|
@ -226,6 +232,8 @@ public class Vars implements Loadable{
|
|||
public static Fi bebuildDirectory;
|
||||
/** file used to store launch ID */
|
||||
public static Fi launchIDFile;
|
||||
/** local cache of server list */
|
||||
public static Fi serverCacheFile;
|
||||
/** empty map, indicates no current map */
|
||||
public static Map emptyMap;
|
||||
/** empty tile for payloads */
|
||||
|
|
@ -322,6 +330,7 @@ public class Vars implements Loadable{
|
|||
modDirectory = dataDirectory.child("mods/");
|
||||
schematicDirectory = dataDirectory.child("schematics/");
|
||||
bebuildDirectory = dataDirectory.child("be_builds/");
|
||||
serverCacheFile = dataDirectory.child("server_list.json");
|
||||
emptyMap = new Map(new StringMap());
|
||||
|
||||
if(tree == null) tree = new FileTree();
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import arc.util.*;
|
|||
import mindustry.content.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
|
|
@ -36,6 +37,16 @@ public class EditorRenderer implements Disposable{
|
|||
packWidth = width * tilesize + packPad * 2;
|
||||
packHeight = height * tilesize + packPad * 2;
|
||||
|
||||
//clear darkness
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
Tile tile = world.tile(x, y);
|
||||
if(tile.block() instanceof StaticWall){
|
||||
tile.data = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recache();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@ package mindustry.io.versions;
|
|||
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.ui.dialogs.JoinDialog.*;
|
||||
|
||||
import java.io.*;
|
||||
|
|
@ -50,35 +47,4 @@ public class LegacyIO{
|
|||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static void readResearch(){
|
||||
try{
|
||||
byte[] bytes = Core.settings.getBytes("unlocks");
|
||||
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(bytes));
|
||||
|
||||
int length = stream.readInt();
|
||||
if(length > 0){
|
||||
stream.readUTF(); //name of key type
|
||||
stream.readUTF(); //name of value type
|
||||
|
||||
//each element is an array list
|
||||
for(int i = 0; i < length; i++){
|
||||
ContentType type = ContentType.all[stream.readInt()];
|
||||
int arrLength = stream.readInt();
|
||||
if(arrLength > 0){
|
||||
stream.readUTF(); //type of contents (String)
|
||||
for(int j = 0; j < arrLength; j++){
|
||||
String name = stream.readUTF();
|
||||
Content out = Vars.content.getByName(type, name);
|
||||
if(out instanceof UnlockableContent u){
|
||||
u.quietUnlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
Log.err(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import mindustry.ui.*;
|
|||
import static mindustry.Vars.*;
|
||||
|
||||
public class JoinDialog extends BaseDialog{
|
||||
Seq<ServerGroup> tmpServers = new Seq<>();
|
||||
Seq<Server> servers = new Seq<>();
|
||||
Dialog add;
|
||||
Server renaming;
|
||||
|
|
@ -110,10 +111,6 @@ public class JoinDialog extends BaseDialog{
|
|||
keyDown(KeyCode.f5, this::refreshAll);
|
||||
|
||||
shown(() -> {
|
||||
if(defaultServers.isEmpty()){
|
||||
fetchServers();
|
||||
}
|
||||
|
||||
setup();
|
||||
refreshAll();
|
||||
|
||||
|
|
@ -394,7 +391,7 @@ public class JoinDialog extends BaseDialog{
|
|||
global.clear();
|
||||
global.background(null);
|
||||
|
||||
if(defaultServers.isEmpty()){
|
||||
if(!fetchedServers){
|
||||
fetchServers();
|
||||
}
|
||||
|
||||
|
|
@ -406,8 +403,12 @@ public class JoinDialog extends BaseDialog{
|
|||
t.button(Icon.zoom, Styles.emptyi, this::refreshCommunity).size(54f);
|
||||
}).width((targetWidth() + 5f) * columns()).height(70f).pad(4).row();
|
||||
|
||||
for(int i = 0; i < defaultServers.size; i ++){
|
||||
ServerGroup group = defaultServers.get((i + defaultServers.size/2) % defaultServers.size);
|
||||
//if the servers have been fetched, use the fetched list
|
||||
//otherwise use the cached list + the extra servers that may have been included by mods
|
||||
var servers = fetchedServers ? defaultServers : tmpServers.clear().addAll(cachedServers).addAll(defaultServers);
|
||||
|
||||
for(int i = 0; i < servers.size; i ++){
|
||||
ServerGroup group = servers.get((i + servers.size/2) % servers.size);
|
||||
boolean hidden = group.hidden();
|
||||
if(hidden && !showHidden){
|
||||
continue;
|
||||
|
|
@ -661,6 +662,15 @@ public class JoinDialog extends BaseDialog{
|
|||
var urls = Version.type.equals("bleeding-edge") || Vars.forceBeServers ? serverJsonBeURLs : serverJsonURLs;
|
||||
|
||||
if(Core.settings.getBool("communityservers", true)){
|
||||
try{
|
||||
if(!loadedServerCache && serverCacheFile.exists()){
|
||||
loadedServerCache = true;
|
||||
cachedServers.addAll(parseServerString(serverCacheFile.readString()));
|
||||
}
|
||||
}catch(Exception e){
|
||||
Log.err("Failed to load cached server file", e);
|
||||
}
|
||||
|
||||
fetchServers(urls, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -678,7 +688,25 @@ public class JoinDialog extends BaseDialog{
|
|||
}
|
||||
})
|
||||
.submit(result -> {
|
||||
Jval val = Jval.read(result.getResultAsString());
|
||||
String text = result.getResultAsString();
|
||||
Seq<ServerGroup> servers = parseServerString(text);
|
||||
//modify default servers on main thread
|
||||
Core.app.post(() -> {
|
||||
//cache the server list to a file, so it can be loaded in case of an outage later
|
||||
try{
|
||||
serverCacheFile.writeString(text);
|
||||
}catch(Exception e){
|
||||
Log.err("Failed to write server cache", e);
|
||||
}
|
||||
defaultServers.addAll(servers);
|
||||
fetchedServers = true;
|
||||
Log.info("Fetched @ community servers.", defaultServers.sum(s -> s.addresses.length));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private static Seq<ServerGroup> parseServerString(String str){
|
||||
Jval val = Jval.read(str);
|
||||
Seq<ServerGroup> servers = new Seq<>();
|
||||
val.asArray().each(child -> {
|
||||
String name = child.getString("name", "");
|
||||
|
|
@ -691,13 +719,8 @@ public class JoinDialog extends BaseDialog{
|
|||
}
|
||||
servers.add(new ServerGroup(name, addresses, prioritized));
|
||||
});
|
||||
//modify default servers on main thread
|
||||
Core.app.post(() -> {
|
||||
servers.sort(s -> s.name == null ? Integer.MAX_VALUE : s.name.hashCode());
|
||||
defaultServers.addAll(servers);
|
||||
Log.info("Fetched @ community servers.", defaultServers.sum(s -> s.addresses.length));
|
||||
});
|
||||
});
|
||||
return servers;
|
||||
}
|
||||
|
||||
private void saveServers(){
|
||||
|
|
|
|||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue