Only store first 4 bytes of map hashes (instead of the full 16byte md5sum)

* To keep savegame sizes smaller.
This commit is contained in:
Oskar Wiksten
2013-06-22 16:31:39 +02:00
parent 6c03b40262
commit 95c4ba9396
2 changed files with 4 additions and 3 deletions

View File

@@ -49,6 +49,6 @@ public final class MapSection {
}
public String calculateHash() {
return ByteUtils.toHexString(layoutHash);
return ByteUtils.toHexString(layoutHash, 4);
}
}

View File

@@ -1,11 +1,12 @@
package com.gpl.rpg.AndorsTrail.util;
public final class ByteUtils {
public static String toHexString(byte[] bytes) {
public static String toHexString(byte[] bytes) { return toHexString(bytes, bytes.length); }
public static String toHexString(byte[] bytes, int numBytes) {
if (bytes == null) return "";
if (bytes.length == 0) return "";
StringBuffer result = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
for (int i = 0; i < Math.min(numBytes, bytes.length); i++) {
String h = Integer.toHexString(0xFF & bytes[i]);
if (h.length() < 2) result.append('0');
result.append(h);