removed protected from AbstractFile.name

This commit is contained in:
Denis Molony 2021-07-24 18:08:40 +10:00
parent 7f2e963689
commit 5f29cfcd09
10 changed files with 214 additions and 209 deletions

View File

@ -15,7 +15,7 @@ public abstract class AbstractFile implements DataSource
{
static boolean showDebugText;
protected String name;
String name;
public byte[] buffer;
AssemblerProgram assembler;
protected BufferedImage image;
@ -30,6 +30,13 @@ public abstract class AbstractFile implements DataSource
this.buffer = buffer;
}
// ---------------------------------------------------------------------------------//
public void setName (String name)
// ---------------------------------------------------------------------------------//
{
this.name = name; // Infocom ZObject uses this - but it sucks
}
// ---------------------------------------------------------------------------------//
@Override
public String getText () // Override this to get a tailored text representation

View File

@ -139,7 +139,7 @@ public class AppleworksWPFile extends AbstractFile
break;
default:
System.out.printf ("Unknown value in %s: %02X %02X%n", name, b1, b2);
System.out.printf ("Unknown value in %s: %02X %02X%n", getName (), b1, b2);
}
ptr += 2;
}

View File

@ -13,6 +13,7 @@ import com.bytezone.diskbrowser.disk.Disk;
import com.bytezone.diskbrowser.disk.DiskAddress;
import com.bytezone.diskbrowser.disk.SectorType;
import com.bytezone.diskbrowser.gui.DataSource;
import com.bytezone.diskbrowser.utilities.HexFormatter;
// -----------------------------------------------------------------------------------//
public class CPMDisk extends AbstractFormattedDisk
@ -228,6 +229,7 @@ public class CPMDisk extends AbstractFormattedDisk
for (int sector = 0; sector < 8; sector++)
{
byte[] buffer = disk.readBlock (3, sector);
System.out.println (HexFormatter.format (buffer));
// check if entire sector is empty (everything == 0xE5)
if (bufferContainsAll (buffer, (byte) EMPTY_BYTE_VALUE))

View File

@ -556,9 +556,6 @@ public class DiskFactory
if (disk == null)
disk = checkPascalDisk (appleDisk512);
if (disk == null)
disk = checkCPMDisk (appleDisk256);
if (disk == null)
{
disk2 = checkInfocomDisk (appleDisk256);
@ -566,6 +563,9 @@ public class DiskFactory
disk = disk2;
}
if (disk == null)
disk = checkCPMDisk (appleDisk256); // checks almost nothing
if (disk == null)
disk = new DataDisk (appleDisk256);

View File

@ -57,7 +57,9 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
propertyTablePtr = header.getWord (offset + 7);
int ptr = propertyTablePtr;
int nameLength = header.getByte (ptr) * 2;
this.name = nameLength == 0 ? "<<" + id + ">>" : new ZString (header, ++ptr).value;
System.out.printf ("was %s%n", this.getName ());
setName (nameLength == 0 ? "<<" + id + ">>" : new ZString (header, ++ptr).value);
System.out.printf ("now %s%n", this.getName ());
ptr += nameLength;
// read each property
@ -84,11 +86,11 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
{
StringBuilder text = new StringBuilder ();
text.append (String.format ("ID : %02X (%<3d) %s%n%n", id, name));
text.append (String.format ("ID : %02X (%<3d) %s%n%n", id, getName ()));
String obj1 = parent == 0 ? "" : header.getObject (parent - 1).name;
String obj2 = sibling == 0 ? "" : header.getObject (sibling - 1).name;
String obj3 = child == 0 ? "" : header.getObject (child - 1).name;
String obj1 = parent == 0 ? "" : header.getObject (parent - 1).getName ();
String obj2 = sibling == 0 ? "" : header.getObject (sibling - 1).getName ();
String obj3 = child == 0 ? "" : header.getObject (child - 1).getName ();
text.append (String.format ("Parent : %02X (%<3d) %s%n", parent, obj1));
text.append (String.format ("Sibling : %02X (%<3d) %s%n", sibling, obj2));
@ -132,7 +134,7 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
public String toString ()
// ---------------------------------------------------------------------------------//
{
return HexFormatter.getHexString (buffer, startPtr, HEADER_SIZE) + " " + name;
return HexFormatter.getHexString (buffer, startPtr, HEADER_SIZE) + " " + getName ();
}
// ---------------------------------------------------------------------------------//
@ -200,7 +202,7 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
if (propertyNumber >= 19) // directions
{
ZObject object = getObject ();
String objectName = object == null ? "no object" : object.name;
String objectName = object == null ? "no object" : object.getName ();
switch (length)
{
@ -271,8 +273,8 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
for (int i = 0; i < length; i++)
{
int objectId = header.getByte (ptr + i + 1);
text.append (
String.format ("%s%s", (i == 0 ? "" : ", "), getObject (objectId).name));
text.append (String.format ("%s%s", (i == 0 ? "" : ", "),
getObject (objectId).getName ()));
}
}
// else
@ -296,6 +298,6 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
public int compareTo (ZObject o)
// ---------------------------------------------------------------------------------//
{
return this.name.compareTo (o.name);
return this.getName ().compareTo (o.getName ());
}
}

View File

@ -104,7 +104,7 @@ class Character extends AbstractFile
item.partyOwns++;
}
else
System.out.println (name + " ItemID : " + itemID + " is outside range 0:"
System.out.println (getName () + " ItemID : " + itemID + " is outside range 0:"
+ (itemList.size () - 1));
}
}
@ -121,7 +121,7 @@ class Character extends AbstractFile
if (index > 0 && index <= spellList.size ())
spellBook.add (spellList.get (index - 1));
else
System.out.println ("LinkSpell: " + name + " SpellID : " + index
System.out.println ("LinkSpell: " + getName () + " SpellID : " + index
+ " is outside range 1:" + spellList.size ());
}
}
@ -133,7 +133,7 @@ class Character extends AbstractFile
{
StringBuilder text = new StringBuilder ();
text.append ("Character name ..... " + name);
text.append ("Character name ..... " + getName ());
text.append ("\n\nRace ............... " + stats.race);
text.append ("\nType ............... " + stats.type);
text.append ("\nAlignment .......... " + stats.alignment);
@ -301,7 +301,7 @@ class Character extends AbstractFile
public String toString ()
// ---------------------------------------------------------------------------------//
{
return name;
return getName ();
}
// ---------------------------------------------------------------------------------//

View File

@ -40,7 +40,7 @@ class Item extends AbstractFile implements Comparable<Item>
{
StringBuilder text = new StringBuilder ();
text.append ("Name ......... : " + name);
text.append ("Name ......... : " + getName ());
// int length = HexFormatter.intValue (buffer[16]);
text.append ("\nGeneric name . : " + genericName);
text.append ("\nType ......... : " + type);
@ -112,7 +112,7 @@ class Item extends AbstractFile implements Comparable<Item>
// ---------------------------------------------------------------------------------//
{
StringBuilder line = new StringBuilder ();
line.append (String.format ("%-16s", name));
line.append (String.format ("%-16s", getName ()));
if (buffer[36] == -1)
line.append ("(c) ");
else
@ -142,7 +142,8 @@ class Item extends AbstractFile implements Comparable<Item>
public String getDump (int block)
// ---------------------------------------------------------------------------------//
{
StringBuilder line = new StringBuilder (String.format ("%3d %-16s", itemID, name));
StringBuilder line =
new StringBuilder (String.format ("%3d %-16s", itemID, getName ()));
int lo = block == 0 ? 32 : block == 1 ? 46 : 70;
int hi = lo + 24;
if (hi > buffer.length)

View File

@ -75,7 +75,8 @@ class MessageDataBlock extends AbstractFile
}
else
lastMessageNo = firstMessageNo;
this.name += " - " + lastMessageNo;
// this.name += " - " + lastMessageNo;
setName (getName () + " - " + lastMessageNo);
}
// ---------------------------------------------------------------------------------//

View File

@ -151,7 +151,7 @@ class Monster extends AbstractFile
text.append ("\n\nPartner ID ...... " + partnerID);
if (partnerOdds > 0)
text.append (" " + monsters.get (partnerID).name);
text.append (" " + monsters.get (partnerID).getName ());
text.append ("\nPartner odds .... " + partnerOdds + "%");
text.append ("\n\nMage level ...... " + mageSpellLevel);

View File

@ -76,7 +76,7 @@ class Spell extends AbstractFile
public String getName ()
// ---------------------------------------------------------------------------------//
{
return name;
return getName ();
}
// ---------------------------------------------------------------------------------//
@ -165,7 +165,7 @@ class Spell extends AbstractFile
text.append (" width=\"100%\">\n");
text.append (" <tr>\n <td width=\"110\">Spell name</td>\n");
text.append (" <td>" + name + "</td>\n </tr>\n");
text.append (" <td>" + getName () + "</td>\n </tr>\n");
text.append (" <tr>\n <td>Translation</td>\n");
text.append (" <td>" + translation + "</td>\n </tr>\n");
@ -191,7 +191,7 @@ class Spell extends AbstractFile
public String toString ()
// ---------------------------------------------------------------------------------//
{
StringBuilder text = new StringBuilder (name);
StringBuilder text = new StringBuilder (getName ());
while (text.length () < 14)
text.append (" ");
if (spellType == SpellType.PRIEST)
@ -211,39 +211,35 @@ class Spell extends AbstractFile
return text.toString ();
}
private static String[] spellNames =
{ "KALKI", "DIOS", "BADIOS", "MILWA", "PORFIC", "MATU", "CALFO", "MANIFO",
"MONTINO", "LOMILWA", "DIALKO", "LATUMAPIC", "BAMATU", "DIAL", "BADIAL",
"LATUMOFIS", "MAPORFIC", "DIALMA", "BADIALMA", "LITOKAN", "KANDI", "DI", "BADI",
"LORTO", "MADI", "MABADI", "LOKTOFEIT", "MALIKTO", "KADORTO",
private static String[] spellNames = { "KALKI", "DIOS", "BADIOS", "MILWA", "PORFIC",
"MATU", "CALFO", "MANIFO", "MONTINO", "LOMILWA", "DIALKO", "LATUMAPIC", "BAMATU",
"DIAL", "BADIAL", "LATUMOFIS", "MAPORFIC", "DIALMA", "BADIALMA", "LITOKAN", "KANDI",
"DI", "BADI", "LORTO", "MADI", "MABADI", "LOKTOFEIT", "MALIKTO", "KADORTO",
"HALITO", "MOGREF", "KATINO", "DUMAPIC", "DILTO", "SOPIC", "MAHALITO", "MOLITO",
"MORLIS", "DALTO", "LAHALITO", "MAMORLIS", "MAKANITO", "MADALTO", "LAKANITO",
"ZILWAN", "MASOPIC", "HAMAN", "MALOR", "MAHAMAN", "TILTOWAIT" };
private static String[] translations =
{ "Blessings", "Heal", "Harm", "Light", "Shield", "Blessing & zeal", "X-ray vision",
"Statue", "Still air", "More light", "Softness/supple", "Identification",
"Prayer", "Heal (more)", "Hurt (more)", "Cure poison", "Shield (big)",
"Heal (greatly)", "Hurt (greatly)", "Flame tower", "Location", "Life", "Death",
"Blades", "Healing", "Harm (incredibly)", "Recall", "The Word of Death",
"Resurrection",
private static String[] translations = { "Blessings", "Heal", "Harm", "Light", "Shield",
"Blessing & zeal", "X-ray vision", "Statue", "Still air", "More light",
"Softness/supple", "Identification", "Prayer", "Heal (more)", "Hurt (more)",
"Cure poison", "Shield (big)", "Heal (greatly)", "Hurt (greatly)", "Flame tower",
"Location", "Life", "Death", "Blades", "Healing", "Harm (incredibly)", "Recall",
"The Word of Death", "Resurrection",
"Little Fire", "Body Iron", "Bad Air", "Clarity", "Darkness", "Glass", "Big fire",
"Spark storm", "Fear", "Blizzard blast", "Flame storm", "Terror", "Deadly air",
"Frost", "Suffocation", "Dispell", "Big glass", "Change", "Apport",
"Great change", "(untranslatable)" };
"Frost", "Suffocation", "Dispell", "Big glass", "Change", "Apport", "Great change",
"(untranslatable)" };
private static SpellThrown[] when =
{ SpellThrown.COMBAT, SpellThrown.ANY_TIME, SpellThrown.COMBAT,
SpellThrown.ANY_TIME, SpellThrown.COMBAT, SpellThrown.COMBAT, SpellThrown.LOOTING,
SpellThrown.COMBAT, SpellThrown.COMBAT, SpellThrown.ANY_TIME,
SpellThrown.ANY_TIME, SpellThrown.COMBAT, SpellThrown.COMBAT,
SpellThrown.ANY_TIME, SpellThrown.COMBAT, SpellThrown.ANY_TIME,
SpellThrown.ANY_TIME, SpellThrown.ANY_TIME, SpellThrown.COMBAT,
SpellThrown.COMBAT, SpellThrown.CAMP, SpellThrown.CAMP, SpellThrown.COMBAT,
private static SpellThrown[] when = { SpellThrown.COMBAT, SpellThrown.ANY_TIME,
SpellThrown.COMBAT, SpellThrown.ANY_TIME, SpellThrown.COMBAT, SpellThrown.COMBAT,
SpellThrown.COMBAT, SpellThrown.ANY_TIME,
SpellThrown.LOOTING, SpellThrown.COMBAT, SpellThrown.COMBAT, SpellThrown.ANY_TIME,
SpellThrown.ANY_TIME, SpellThrown.COMBAT, SpellThrown.COMBAT, SpellThrown.ANY_TIME,
SpellThrown.COMBAT, SpellThrown.ANY_TIME, SpellThrown.ANY_TIME,
SpellThrown.ANY_TIME, SpellThrown.COMBAT, SpellThrown.COMBAT, SpellThrown.CAMP,
SpellThrown.CAMP, SpellThrown.COMBAT, SpellThrown.COMBAT, SpellThrown.ANY_TIME,
SpellThrown.COMBAT, SpellThrown.COMBAT, SpellThrown.COMBAT, SpellThrown.ANY_TIME,
SpellThrown.COMBAT, SpellThrown.COMBAT, SpellThrown.COMBAT, SpellThrown.CAMP,
SpellThrown.COMBAT, SpellThrown.COMBAT, SpellThrown.COMBAT, SpellThrown.COMBAT,
@ -252,16 +248,15 @@ class Spell extends AbstractFile
SpellThrown.COMBAT, SpellThrown.COMBAT, SpellThrown.COMBAT_OR_CAMP,
SpellThrown.COMBAT, SpellThrown.COMBAT, };
private static SpellTarget[] affects =
{ SpellTarget.PARTY, SpellTarget.PERSON, SpellTarget.MONSTER, SpellTarget.PARTY,
SpellTarget.CASTER, SpellTarget.PARTY, SpellTarget.CASTER,
SpellTarget.MONSTER_GROUP, SpellTarget.MONSTER_GROUP, SpellTarget.PARTY,
SpellTarget.PERSON, SpellTarget.PARTY, SpellTarget.PARTY, SpellTarget.PERSON,
SpellTarget.MONSTER, SpellTarget.PERSON, SpellTarget.PARTY, SpellTarget.PERSON,
SpellTarget.MONSTER, SpellTarget.PARTY, SpellTarget.PERSON, SpellTarget.PERSON,
SpellTarget.MONSTER, SpellTarget.MONSTER_GROUP, SpellTarget.PERSON,
SpellTarget.MONSTER, SpellTarget.PARTY, SpellTarget.MONSTER_GROUP,
SpellTarget.PERSON,
private static SpellTarget[] affects = { SpellTarget.PARTY, SpellTarget.PERSON,
SpellTarget.MONSTER, SpellTarget.PARTY, SpellTarget.CASTER, SpellTarget.PARTY,
SpellTarget.CASTER, SpellTarget.MONSTER_GROUP, SpellTarget.MONSTER_GROUP,
SpellTarget.PARTY, SpellTarget.PERSON, SpellTarget.PARTY, SpellTarget.PARTY,
SpellTarget.PERSON, SpellTarget.MONSTER, SpellTarget.PERSON, SpellTarget.PARTY,
SpellTarget.PERSON, SpellTarget.MONSTER, SpellTarget.PARTY, SpellTarget.PERSON,
SpellTarget.PERSON, SpellTarget.MONSTER, SpellTarget.MONSTER_GROUP,
SpellTarget.PERSON, SpellTarget.MONSTER, SpellTarget.PARTY,
SpellTarget.MONSTER_GROUP, SpellTarget.PERSON,
SpellTarget.MONSTER, SpellTarget.CASTER, SpellTarget.MONSTER_GROUP,
SpellTarget.NONE, SpellTarget.MONSTER_GROUP, SpellTarget.CASTER,
@ -271,8 +266,8 @@ class Spell extends AbstractFile
SpellTarget.MONSTER, SpellTarget.PARTY, SpellTarget.VARIABLE, SpellTarget.PARTY,
SpellTarget.PARTY, SpellTarget.ALL_MONSTERS };
private static String[] descriptions =
{ "KALKI reduces the AC of all party members by one, and thus makes"
private static String[] descriptions = {
"KALKI reduces the AC of all party members by one, and thus makes"
+ " them harder to hit.",
"DIOS restores from one to eight hit points of damage from a party"
+ "member. It will not bring dead back to life.",
@ -332,10 +327,8 @@ class Spell extends AbstractFile
+ " not cause death to occur.",
"LORTO causes sharp blades to slice through a group, causing six to"
+ " 36 points of damage.",
"MADI causes all hit points to be restored and cures any condition"
+ " but death.",
"MABADI causes all but one to eight hit points to be removed from"
+ " the target.",
"MADI causes all hit points to be restored and cures any condition" + " but death.",
"MABADI causes all but one to eight hit points to be removed from" + " the target.",
"LOKTOFEIT causes all party members to be teleported back to the"
+ " castle, minus all their equipment and most of their gold. There"
+ " is also a good chance this spell will not function.",
@ -375,8 +368,7 @@ class Spell extends AbstractFile
"DALTO is similar to MAHALITO except that cold replaces flames."
+ " Also, six to 36 hit points of damage are done.",
"LAHALITO is an improved MAHALITO, doing the same damage as DALTO.",
"MAMORLIS is similar to MORLIS, except that all monster groups are"
+ " affected.",
"MAMORLIS is similar to MORLIS, except that all monster groups are" + " affected.",
"Any monsters of less than eigth level (i.e. about 35-40 hit points)"
+ " are killed by this spell outright.",
"An improved DALTO causing eight to 64 hit points of damage.",