mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-02-23 15:38:29 +01:00
Only store first 4 bytes of map hashes (instead of the full 16byte md5sum)
* To keep savegame sizes smaller.
This commit is contained in:
@@ -49,6 +49,6 @@ public final class MapSection {
|
||||
}
|
||||
|
||||
public String calculateHash() {
|
||||
return ByteUtils.toHexString(layoutHash);
|
||||
return ByteUtils.toHexString(layoutHash, 4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user