v0.4.1a: fixed problems with rankings ids, implemented UUIDs for them as well

This commit is contained in:
Evan Debenham 2016-08-09 20:00:00 -04:00
parent 7dc2f24eda
commit cdb13146eb
2 changed files with 20 additions and 14 deletions

View File

@ -48,7 +48,6 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton;
import com.watabou.noosa.Game; import com.watabou.noosa.Game;
import com.watabou.utils.Bundlable; import com.watabou.utils.Bundlable;
import com.watabou.utils.Bundle; import com.watabou.utils.Bundle;
import com.watabou.utils.SystemTime;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -57,6 +56,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Locale; import java.util.Locale;
import java.util.UUID;
public enum Rankings { public enum Rankings {
@ -87,7 +87,7 @@ public enum Rankings {
INSTANCE.saveGameData(rec); INSTANCE.saveGameData(rec);
rec.gameID = String.valueOf(SystemTime.now); rec.gameID = UUID.randomUUID().toString();
records.add( rec ); records.add( rec );

View File

@ -36,6 +36,8 @@ import com.watabou.noosa.Image;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
import javax.microedition.khronos.opengles.GL10; import javax.microedition.khronos.opengles.GL10;
import java.util.ArrayList;
import java.util.UUID;
public class WelcomeScene extends PixelScene { public class WelcomeScene extends PixelScene {
@ -148,9 +150,10 @@ public class WelcomeScene extends PixelScene {
private void updateVersion(int previousVersion){ private void updateVersion(int previousVersion){
//rankings conversion //rankings conversion
if (previousVersion < 108){ if (previousVersion <= 114){
Rankings.INSTANCE.load(); Rankings.INSTANCE.load();
for (Rankings.Record rec : Rankings.INSTANCE.records){ for (Rankings.Record rec : Rankings.INSTANCE.records){
if (rec.gameFile != null) {
try { try {
Dungeon.loadGame(rec.gameFile, false); Dungeon.loadGame(rec.gameFile, false);
rec.gameID = rec.gameFile.replaceAll("\\D", ""); rec.gameID = rec.gameFile.replaceAll("\\D", "");
@ -164,6 +167,9 @@ public class WelcomeScene extends PixelScene {
String file = rec.gameFile; String file = rec.gameFile;
rec.gameFile = ""; rec.gameFile = "";
Game.instance.deleteFile(file); Game.instance.deleteFile(file);
} else if (rec.gameID == null){
rec.gameID = UUID.randomUUID().toString();
}
} }
Rankings.INSTANCE.save(); Rankings.INSTANCE.save();
} }