Added D2S#getTownsString() and implemented it into D2S Reader logging

This commit is contained in:
Collin Smith 2020-08-16 01:18:21 -07:00
parent c85f1b9e44
commit 2eb773633a
2 changed files with 17 additions and 1 deletions

View File

@ -127,6 +127,22 @@ public class D2S {
return "";
}
public String getTownsString() {
final int DIFF_ACT_MASK = 0x7;
final int DIFF_FLAG_ACTIVE = 1 << 7;
StringBuilder sb = new StringBuilder();
sb.append("[");
for (byte town : towns) {
sb.append('A').append((town & DIFF_ACT_MASK) + 1);
if ((town & DIFF_FLAG_ACTIVE) == DIFF_FLAG_ACTIVE) sb.append('*');
sb.append(", ");
}
sb.setLength(sb.length() - 2);
sb.append("]");
return sb.toString();
}
public static class MercData {
int flags;
int seed;

View File

@ -105,7 +105,7 @@ public class D2SReader96 {
d2s.colors = in.readBytes(COF.Component.NUM_COMPONENTS);
if (log.isDebugEnabled()) log.debug("colors: {}", ByteBufUtil.hexDump(d2s.colors));
d2s.towns = in.readBytes(Riiablo.MAX_DIFFS);
if (log.isDebugEnabled()) log.debug("towns: {}", ByteBufUtil.hexDump(d2s.towns));
if (log.isDebugEnabled()) log.debug("towns: {} ({})", ByteBufUtil.hexDump(d2s.towns), d2s.getTownsString());
d2s.mapSeed = in.read32();
Log.debugf(log, "mapSeed: 0x%08X", d2s.mapSeed);
try {