fixed bug in known spells
This commit is contained in:
parent
d71cabb754
commit
b19e89d7cf
|
@ -26,6 +26,10 @@ public abstract class Character extends AbstractFile
|
|||
public int characterLevel;
|
||||
public int possessionsCount;
|
||||
|
||||
public boolean mysteryBit; // first bit in spellsKnown
|
||||
public final boolean[] spellsKnown = new boolean[50];
|
||||
public final int[][] spellAllowance = new int[2][7];
|
||||
|
||||
public enum Race
|
||||
{
|
||||
NORACE, HUMAN, ELF, DWARF, GNOME, HOBBIT
|
||||
|
@ -70,6 +74,25 @@ public abstract class Character extends AbstractFile
|
|||
attributes[ptr + 1] = (value & 0x03E0) >>> 5;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
protected void checkKnownSpells (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int bit = 1; // skip first bit
|
||||
int val = buffer[ptr];
|
||||
mysteryBit = (val & 0x01) == 1;
|
||||
|
||||
for (int i = 0; i < spellsKnown.length; i++)
|
||||
{
|
||||
if (bit == 8)
|
||||
{
|
||||
val = buffer[++ptr];
|
||||
bit = 0;
|
||||
}
|
||||
spellsKnown[i] = ((val >>> bit++) & 0x01) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public String getAwardString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -78,6 +78,8 @@ class CharacterV1 extends Character
|
|||
hpLeft = Utility.getShort (buffer, 134);
|
||||
hpMax = Utility.getShort (buffer, 136);
|
||||
|
||||
checkKnownSpells (buffer, 138);
|
||||
|
||||
for (int i = 0; i < 7; i++)
|
||||
mageSpells[i] = buffer[146 + i * 2];
|
||||
|
||||
|
@ -98,16 +100,9 @@ class CharacterV1 extends Character
|
|||
assetValue += baggage.item.getCost ();
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for (int i = 138; i < 145; i++)
|
||||
for (int bit = 0; bit < 8; bit++)
|
||||
{
|
||||
if (((buffer[i] >>> bit) & 0x01) != 0)
|
||||
spellBook.add (spellList.get (index));
|
||||
|
||||
if (++index >= spellList.size ())
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < spellsKnown.length; i++)
|
||||
if (spellsKnown[i])
|
||||
spellBook.add (spellList.get (i));
|
||||
|
||||
nextLevel = experienceLevels.get (typeInt).getExperiencePoints (characterLevel + 1);
|
||||
}
|
||||
|
|
|
@ -33,10 +33,6 @@ public class CharacterV4 extends Character
|
|||
public final long experience;
|
||||
public final int maxlevac; // max level armour class?
|
||||
|
||||
public final boolean mysteryBit; // first bit in spellsKnown
|
||||
public final boolean[] spellsKnown = new boolean[50];
|
||||
public final int[][] spellAllowance = new int[2][7];
|
||||
|
||||
public final int hpCalCmd;
|
||||
public final int healPts;
|
||||
|
||||
|
@ -101,18 +97,7 @@ public class CharacterV4 extends Character
|
|||
hpLeft = Utility.getShort (buffer, 135);
|
||||
hpMax = Utility.getShort (buffer, 137);
|
||||
|
||||
mysteryBit = (buffer[139] & 0x01) == 1;
|
||||
int index = -1; // skip mystery bit
|
||||
for (int i = 139; i < 146; i++)
|
||||
for (int bit = 0; bit < 8; bit++)
|
||||
{
|
||||
if (((buffer[i] >>> bit) & 0x01) != 0)
|
||||
if (index >= 0)
|
||||
spellsKnown[index] = true;
|
||||
|
||||
if (++index >= MAX_SPELLS)
|
||||
break;
|
||||
}
|
||||
checkKnownSpells (buffer, 139);
|
||||
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue