Fix support of 20-digit numeric seeds

Minetest 64 bit seeds were being listed signed instead of unsigned in some places.
E.g. with seed 14105561135541706857, "Copy Seed" used to put -4341182938167844759 in the clipboard
master
Treer 2018-06-17 02:28:01 +10:00
parent dffe29e2d1
commit 049a030144
4 changed files with 12 additions and 6 deletions

View File

@ -248,7 +248,7 @@ public class Actions {
public void copySeedToClipboard() {
ViewerFacade viewerFacade = viewerFacadeSupplier.get();
if (viewerFacade != null) {
String seed = "" + viewerFacade.getWorldSeed().getLong();
String seed = viewerFacade.getWorldSeed().getLongAsString();
StringSelection selection = new StringSelection(seed);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection);
}
@ -260,7 +260,7 @@ public class Actions {
if (viewerFacade != null) {
BufferedImage image = viewerFacade.createScreenshot();
String suggestedFilename = "screenshot_" + viewerFacade.getWorldType().getFilenameText() + "_"
+ viewerFacade.getWorldSeed().getLong() + ".png";
+ viewerFacade.getWorldSeed().getLongAsString() + ".png";
File file = dialogs.askForScreenshotSaveFile(suggestedFilename);
if (file != null) {
file = appendPNGFileExtensionIfNecessary(file);

View File

@ -72,9 +72,9 @@ public class SeedHistoryLogger {
private String getSeedString(WorldSeed worldSeed) {
String text = worldSeed.getText();
if (text != null) {
return worldSeed.getLong() + ", " + text;
return worldSeed.getLongAsString() + ", " + text;
} else {
return worldSeed.getLong() + "";
return worldSeed.getLongAsString();
}
}

View File

@ -72,17 +72,23 @@ public class WorldSeed {
private final String text;
private final WorldSeedType type;
private final String label;
private final GameEngineType gameEngineType;
private WorldSeed(long seed, String text, WorldSeedType type, GameEngineType game_engine_type) {
this.seed = seed;
this.text = text;
this.type = type;
this.gameEngineType = game_engine_type;
this.label = type.getLabel(seed, text, game_engine_type);
}
public long getLong() {
return seed;
}
public String getLongAsString() {
return (gameEngineType == GameEngineType.MINETEST) ? Long.toUnsignedString(seed) : Long.toString(seed);
}
public String getText() {
return text;

View File

@ -93,8 +93,8 @@ public enum TestWorldDeclaration {
"testworld",
"storage",
recognisedVersion.getName(),
"" + worldSeed.getLong()).toFile();
this.directoryString = RESOURCE_PREFIX + recognisedVersion.getName() + "/" + worldSeed.getLong() + "/";
worldSeed.getLongAsString()).toFile();
this.directoryString = RESOURCE_PREFIX + recognisedVersion.getName() + "/" + worldSeed.getLongAsString() + "/";
}
public RecognisedVersion getRecognisedVersion() {