Removed: Unused fields

This commit is contained in:
thedaneeffect committed 2023-01-07 20:15:22 -05:00
1 parent c9b271e884
commit ed6390f148
10 files changed
+1362 -1425

No files matched your search

+152 -156
View File
@@ -6,191 +6,187 @@ import java.io.IOException;
public class FloType {
public static int count;
public static FloType[] instances;
public static int count;
public static FloType[] instances;
public static void unpack(FileArchive archive) throws IOException {
Buffer buffer = new Buffer(archive.read("flo.dat"));
count = buffer.read16U();
if (instances == null) {
instances = new FloType[count];
}
for (int j = 0; j < count; j++) {
if (instances[j] == null) {
instances[j] = new FloType();
}
instances[j].method261(buffer);
}
}
public static void unpack(FileArchive archive) throws IOException {
Buffer buffer = new Buffer(archive.read("flo.dat"));
count = buffer.read16U();
if (instances == null) {
instances = new FloType[count];
}
for (int j = 0; j < count; j++) {
if (instances[j] == null) {
instances[j] = new FloType();
}
instances[j].read(buffer);
}
}
public String unusedString;
public int rgb;
public int textureID = -1;
public boolean unusedBool = false;
public boolean occludes = true;
public int hue;
public int saturation;
public int lightness;
public int chroma;
public int luminance;
public int hsl;
public int rgb;
public int textureID = -1;
public boolean occludes = true;
public int hue;
public int saturation;
public int lightness;
public int chroma;
public int luminance;
public int hsl;
public FloType() {
}
public FloType() {
}
public void method261(Buffer buffer) {
do {
int i = buffer.read8U();
if (i == 0) {
return;
}
if (i == 1) {
rgb = buffer.read24();
setColor(rgb);
} else if (i == 2) {
textureID = buffer.read8U();
} else if (i == 3) {
unusedBool = true;
} else if (i == 5) {
occludes = false;
} else if (i == 6) {
unusedString = buffer.readString();
} else if (i == 7) {
int hue = this.hue;
int saturation = this.saturation;
int lightness = this.lightness;
int chroma = this.chroma;
int rgb = buffer.read24();
setColor(rgb);
this.hue = hue;
this.saturation = saturation;
this.lightness = lightness;
this.chroma = chroma;
luminance = chroma;
} else {
System.out.println("Error unrecognised config code: " + i);
}
} while (true);
}
public void read(Buffer buffer) {
while (true) {
int code = buffer.read8U();
if (code == 0) {
return;
} else if (code == 1) {
rgb = buffer.read24();
setColor(rgb);
} else if (code == 2) {
textureID = buffer.read8U();
} else if (code == 3) {
} else if (code == 5) {
occludes = false;
} else if (code == 6) {
buffer.readString(); // name
} else if (code == 7) {
int hue = this.hue;
int saturation = this.saturation;
int lightness = this.lightness;
int chroma = this.chroma;
int rgb = buffer.read24();
setColor(rgb);
this.hue = hue;
this.saturation = saturation;
this.lightness = lightness;
this.chroma = chroma;
luminance = chroma;
} else {
System.out.println("Error unrecognised flo config code: " + code);
}
}
}
public void setColor(int rgb) {
double red = (double) ((rgb >> 16) & 0xff) / 256D;
double green = (double) ((rgb >> 8) & 0xff) / 256D;
double blue = (double) (rgb & 0xff) / 256D;
public void setColor(int rgb) {
double red = (double) ((rgb >> 16) & 0xff) / 256D;
double green = (double) ((rgb >> 8) & 0xff) / 256D;
double blue = (double) (rgb & 0xff) / 256D;
double min = red;
double min = red;
if (green < min) {
min = green;
}
if (green < min) {
min = green;
}
if (blue < min) {
min = blue;
}
if (blue < min) {
min = blue;
}
double max = red;
double max = red;
if (green > max) {
max = green;
}
if (green > max) {
max = green;
}
if (blue > max) {
max = blue;
}
if (blue > max) {
max = blue;
}
double h = 0.0D;
double s = 0.0D;
double l = (min + max) / 2D;
double h = 0.0D;
double s = 0.0D;
double l = (min + max) / 2D;
if (min != max) {
if (l < 0.5D) {
s = (max - min) / (max + min);
}
if (min != max) {
if (l < 0.5D) {
s = (max - min) / (max + min);
}
if (l >= 0.5D) {
s = (max - min) / (2D - max - min);
}
if (l >= 0.5D) {
s = (max - min) / (2D - max - min);
}
if (red == max) {
h = (green - blue) / (max - min);
} else if (green == max) {
h = 2D + ((blue - red) / (max - min));
} else if (blue == max) {
h = 4D + ((red - green) / (max - min));
}
}
if (red == max) {
h = (green - blue) / (max - min);
} else if (green == max) {
h = 2D + ((blue - red) / (max - min));
} else if (blue == max) {
h = 4D + ((red - green) / (max - min));
}
}
h /= 6D;
h /= 6D;
this.hue = (int) (h * 256D);
this.saturation = (int) (s * 256D);
this.lightness = (int) (l * 256D);
this.hue = (int) (h * 256D);
this.saturation = (int) (s * 256D);
this.lightness = (int) (l * 256D);
if (this.saturation < 0) {
this.saturation = 0;
} else if (this.saturation > 255) {
this.saturation = 255;
}
if (this.saturation < 0) {
this.saturation = 0;
} else if (this.saturation > 255) {
this.saturation = 255;
}
if (this.lightness < 0) {
this.lightness = 0;
} else if (this.lightness > 255) {
this.lightness = 255;
}
if (this.lightness < 0) {
this.lightness = 0;
} else if (this.lightness > 255) {
this.lightness = 255;
}
if (l > 0.5D) {
luminance = (int) ((1.0D - l) * s * 512D);
} else {
luminance = (int) (l * s * 512D);
}
if (l > 0.5D) {
luminance = (int) ((1.0D - l) * s * 512D);
} else {
luminance = (int) (l * s * 512D);
}
if (luminance < 1) {
luminance = 1;
}
if (luminance < 1) {
luminance = 1;
}
chroma = (int) (h * (double) luminance);
chroma = (int) (h * (double) luminance);
int hue = (this.hue + (int) (Math.random() * 16D)) - 8;
int hue = (this.hue + (int) (Math.random() * 16D)) - 8;
if (hue < 0) {
hue = 0;
} else if (hue > 255) {
hue = 255;
}
if (hue < 0) {
hue = 0;
} else if (hue > 255) {
hue = 255;
}
int saturation = (this.saturation + (int) (Math.random() * 48D)) - 24;
int saturation = (this.saturation + (int) (Math.random() * 48D)) - 24;
if (saturation < 0) {
saturation = 0;
} else if (saturation > 255) {
saturation = 255;
}
if (saturation < 0) {
saturation = 0;
} else if (saturation > 255) {
saturation = 255;
}
int lightness = (this.lightness + (int) (Math.random() * 48D)) - 24;
int lightness = (this.lightness + (int) (Math.random() * 48D)) - 24;
if (lightness < 0) {
lightness = 0;
} else if (lightness > 255) {
lightness = 255;
}
if (lightness < 0) {
lightness = 0;
} else if (lightness > 255) {
lightness = 255;
}
hsl = decimateHSL(hue, saturation, lightness);
}
hsl = decimateHSL(hue, saturation, lightness);
}
public int decimateHSL(int hue, int saturation, int lightness) {
if (lightness > 179) {
saturation /= 2;
}
if (lightness > 192) {
saturation /= 2;
}
if (lightness > 217) {
saturation /= 2;
}
if (lightness > 243) {
saturation /= 2;
}
return ((hue / 4) << 10) + ((saturation / 32) << 7) + (lightness / 2);
}
public int decimateHSL(int hue, int saturation, int lightness) {
if (lightness > 179) {
saturation /= 2;
}
if (lightness > 192) {
saturation /= 2;
}
if (lightness > 217) {
saturation /= 2;
}
if (lightness > 243) {
saturation /= 2;
}
return ((hue / 4) << 10) + ((saturation / 32) << 7) + (lightness / 2);
}
}
+26 -27
View File
@@ -1024,7 +1024,7 @@ public class Game extends GameShell {
if (!lowmem) {
drawProgress(90, "Unpacking sounds");
SoundTrack.method240(new Buffer(archiveSounds.read("sounds.dat")));
SoundTrack.unpack(new Buffer(archiveSounds.read("sounds.dat")));
}
drawProgress(95, "Unpacking interfaces");
@@ -9734,19 +9734,19 @@ public class Game extends GameShell {
int arith = 0;
do {
int opcode = script[pos++];
int code = script[pos++];
int register = 0;
byte nextArithmetic = 0;
if (opcode == 0) {
if (code == 0) {
return acc;
} else if (opcode == 1) { // load_skill_level {skill}
} else if (code == 1) { // load_skill_level {skill}
register = skillLevel[script[pos++]];
} else if (opcode == 2) { // load_skill_base_level {skill}
} else if (code == 2) { // load_skill_base_level {skill}
register = skillBaseLevel[script[pos++]];
} else if (opcode == 3) { // load_skill_exp {skill}
} else if (code == 3) { // load_skill_exp {skill}
register = skillExperience[script[pos++]];
} else if (opcode == 4) {// load_inv_count {interface id} {obj id}
} else if (code == 4) {// load_inv_count {interface id} {obj id}
IfType inventory = IfType.instances[script[pos++]];
int objID = script[pos++];
if ((objID >= 0) && (objID < ObjType.count) && (!ObjType.get(objID).members || members)) {
@@ -9756,21 +9756,21 @@ public class Game extends GameShell {
}
}
}
} else if (opcode == 5) { // load_var {id}
} else if (code == 5) { // load_var {id}
register = varps[script[pos++]];
} else if (opcode == 6) { // load_next_level_xp {skill}
} else if (code == 6) { // load_next_level_xp {skill}
register = levelExperience[skillBaseLevel[script[pos++]] - 1];
} else if (opcode == 7) {
} else if (code == 7) {
register = (varps[script[pos++]] * 100) / 46875;
} else if (opcode == 8) { // load_combat_level
} else if (code == 8) { // load_combat_level
register = localPlayer.combatLevel;
} else if (opcode == 9) { // load_total_level
} else if (code == 9) { // load_total_level
for (int skill = 0; skill < Skill.COUNT; skill++) {
if (Skill.ENABLED[skill]) {
register += skillBaseLevel[skill];
}
}
} else if (opcode == 10) {// load_inv_contains {interface id} {obj id}
} else if (code == 10) {// load_inv_contains {interface id} {obj id}
IfType c = IfType.instances[script[pos++]];
int objID = script[pos++] + 1;
if ((objID >= 0) && (objID < ObjType.count) && (!ObjType.get(objID).members || members)) {
@@ -9782,29 +9782,29 @@ public class Game extends GameShell {
break;
}
}
} else if (opcode == 11) { // load_energy
} else if (code == 11) { // load_energy
register = energy;
} else if (opcode == 12) { // load_weight
} else if (code == 12) { // load_weight
register = weightCarried;
} else if (opcode == 13) {// load_bool {varp} {bit: 0..31}
} else if (code == 13) {// load_bool {varp} {bit: 0..31}
int varp = varps[script[pos++]];
int bit = script[pos++];
register = ((varp & (1 << bit)) == 0) ? 0 : 1;
} else if (opcode == 14) {// load_varbit {varbit}
} else if (code == 14) {// load_varbit {varbit}
VarbitType varbit = VarbitType.instances[script[pos++]];
int lsb = varbit.lsb;
register = (varps[varbit.varp] >> lsb) & BITMASK[varbit.msb - lsb];
} else if (opcode == 15) { // sub
} else if (code == 15) { // sub
nextArithmetic = 1;
} else if (opcode == 16) { // div
} else if (code == 16) { // div
nextArithmetic = 2;
} else if (opcode == 17) { // mul
} else if (code == 17) { // mul
nextArithmetic = 3;
} else if (opcode == 18) { // load_world_x
} else if (code == 18) { // load_world_x
register = (localPlayer.x >> 7) + sceneBaseTileX;
} else if (opcode == 19) { // load_world_z
} else if (code == 19) { // load_world_z
register = (localPlayer.z >> 7) + sceneBaseTileZ;
} else if (opcode == 20) { // load {value}
} else if (code == 20) { // load {value}
register = script[pos++];
}
@@ -10452,8 +10452,8 @@ public class Game extends GameShell {
flameThread = false;
}
public void readZonePacket(int opcode) {
switch (opcode) {
public void readZonePacket(int code) {
switch (code) {
case PacketIn.OBJ_ADD:
readObjAdd();
break;
@@ -11909,8 +11909,7 @@ public class Game extends GameShell {
baseZ = in.read8U();
baseX = in.read8UC();
while (in.position < packetSize) {
int opcode = in.read8U();
readZonePacket(opcode);
readZonePacket(in.read8U());
}
}
+109 -111
View File
@@ -6,128 +6,126 @@ import java.io.IOException;
public class IdkType {
public static int count;
public static IdkType[] instances;
public static int count;
public static IdkType[] instances;
public static void unpack(FileArchive archive) throws IOException {
Buffer buffer = new Buffer(archive.read("idk.dat"));
count = buffer.read16U();
if (instances == null) {
instances = new IdkType[count];
}
for (int j = 0; j < count; j++) {
if (instances[j] == null) {
instances[j] = new IdkType();
}
instances[j].read(buffer);
}
}
public static void unpack(FileArchive archive) throws IOException {
Buffer buffer = new Buffer(archive.read("idk.dat"));
count = buffer.read16U();
if (instances == null) {
instances = new IdkType[count];
}
for (int j = 0; j < count; j++) {
if (instances[j] == null) {
instances[j] = new IdkType();
}
instances[j].read(buffer);
}
}
public final int[] colorSrc = new int[6];
public final int[] colorDst = new int[6];
public final int[] headModelIDs = {-1, -1, -1, -1, -1};
public int type = -1;
public int[] modelIDs;
public boolean selectable = false;
public final int[] colorSrc = new int[6];
public final int[] colorDst = new int[6];
public final int[] headModelIDs = {-1, -1, -1, -1, -1};
public int type = -1;
public int[] modelIDs;
public boolean selectable = false;
public IdkType() {
}
public IdkType() {
}
public void read(Buffer in) {
do {
int opcode = in.read8U();
if (opcode == 0) {
return;
}
public void read(Buffer in) {
while (true) {
int code = in.read8U();
if (code == 0) {
return;
} else if (code == 1) {
type = in.read8U();
} else if (code == 2) {
int j = in.read8U();
modelIDs = new int[j];
for (int k = 0; k < j; k++) {
modelIDs[k] = in.read16U();
}
} else if (code == 3) {
selectable = true;
} else if ((code >= 40) && (code < 50)) {
colorSrc[code - 40] = in.read16U();
} else if ((code >= 50) && (code < 60)) {
colorDst[code - 50] = in.read16U();
} else if ((code >= 60) && (code < 70)) {
headModelIDs[code - 60] = in.read16U();
} else {
System.out.println("Error unrecognised identikit config code: " + code);
}
}
}
if (opcode == 1) {
type = in.read8U();
} else if (opcode == 2) {
int j = in.read8U();
modelIDs = new int[j];
for (int k = 0; k < j; k++) {
modelIDs[k] = in.read16U();
}
} else if (opcode == 3) {
selectable = true;
} else if ((opcode >= 40) && (opcode < 50)) {
colorSrc[opcode - 40] = in.read16U();
} else if ((opcode >= 50) && (opcode < 60)) {
colorDst[opcode - 50] = in.read16U();
} else if ((opcode >= 60) && (opcode < 70)) {
headModelIDs[opcode - 60] = in.read16U();
} else {
System.out.println("Error unrecognised config code: " + opcode);
}
} while (true);
}
public boolean validateModel() {
if (modelIDs == null) {
return true;
}
boolean loaded = true;
for (int modelId : modelIDs) {
if (!Model.validate(modelId)) {
loaded = false;
}
}
return loaded;
}
public boolean validateModel() {
if (modelIDs == null) {
return true;
}
boolean loaded = true;
for (int modelId : modelIDs) {
if (!Model.validate(modelId)) {
loaded = false;
}
}
return loaded;
}
public Model getModel() {
if (modelIDs == null) {
return null;
}
Model[] models = new Model[modelIDs.length];
for (int i = 0; i < modelIDs.length; i++) {
models[i] = Model.tryGet(modelIDs[i]);
}
public Model getModel() {
if (modelIDs == null) {
return null;
}
Model[] models = new Model[modelIDs.length];
for (int i = 0; i < modelIDs.length; i++) {
models[i] = Model.tryGet(modelIDs[i]);
}
Model model;
Model model;
if (models.length == 1) {
model = models[0];
} else {
model = new Model(models.length, models);
}
if (models.length == 1) {
model = models[0];
} else {
model = new Model(models.length, models);
}
for (int i = 0; i < 6; i++) {
if (colorSrc[i] == 0) {
break;
}
model.recolor(colorSrc[i], colorDst[i]);
}
for (int i = 0; i < 6; i++) {
if (colorSrc[i] == 0) {
break;
}
model.recolor(colorSrc[i], colorDst[i]);
}
return model;
}
return model;
}
public boolean validateHeadModel() {
boolean loaded = true;
for (int i = 0; i < 5; i++) {
if ((headModelIDs[i] != -1) && !Model.validate(headModelIDs[i])) {
loaded = false;
}
}
return loaded;
}
public boolean validateHeadModel() {
boolean loaded = true;
for (int i = 0; i < 5; i++) {
if ((headModelIDs[i] != -1) && !Model.validate(headModelIDs[i])) {
loaded = false;
}
}
return loaded;
}
public Model getHeadModel() {
Model[] models = new Model[5];
int i = 0;
for (int j = 0; j < 5; j++) {
if (headModelIDs[j] != -1) {
models[i++] = Model.tryGet(headModelIDs[j]);
}
}
Model model = new Model(i, models);
for (int k = 0; k < 6; k++) {
if (colorSrc[k] == 0) {
break;
}
model.recolor(colorSrc[k], colorDst[k]);
}
return model;
}
public Model getHeadModel() {
Model[] models = new Model[5];
int i = 0;
for (int j = 0; j < 5; j++) {
if (headModelIDs[j] != -1) {
models[i++] = Model.tryGet(headModelIDs[j]);
}
}
Model model = new Model(i, models);
for (int k = 0; k < 6; k++) {
if (colorSrc[k] == 0) {
break;
}
model.recolor(colorSrc[k], colorDst[k]);
}
return model;
}
}
+279 -283
View File
@@ -8,332 +8,328 @@ import java.io.IOException;
public class NPCType {
private static int cachePosition;
private static Buffer dat;
public static int[] offsets;
private static NPCType[] cache;
public static Game game;
public static int count;
public static LRUMap<Long, Model> modelCache = new LRUMap<>(30);
private static int cachePosition;
private static Buffer dat;
public static int[] offsets;
private static NPCType[] cache;
public static Game game;
public static int count;
public static LRUMap<Long, Model> modelCache = new LRUMap<>(30);
public static NPCType get(int id) {
for (int j = 0; j < 20; j++) {
if (cache[j].uid == (long) id) {
return cache[j];
}
}
cachePosition = (cachePosition + 1) % 20;
NPCType type = cache[cachePosition] = new NPCType();
dat.position = offsets[id];
type.uid = id;
type.read(dat);
return type;
}
public static NPCType get(int id) {
for (int j = 0; j < 20; j++) {
if (cache[j].uid == (long) id) {
return cache[j];
}
}
cachePosition = (cachePosition + 1) % 20;
NPCType type = cache[cachePosition] = new NPCType();
dat.position = offsets[id];
type.uid = id;
type.read(dat);
return type;
}
public static void unpack(FileArchive archive) throws IOException {
dat = new Buffer(archive.read("npc.dat"));
Buffer buffer = new Buffer(archive.read("npc.idx"));
count = buffer.read16U();
offsets = new int[count];
public static void unpack(FileArchive archive) throws IOException {
dat = new Buffer(archive.read("npc.dat"));
Buffer buffer = new Buffer(archive.read("npc.idx"));
count = buffer.read16U();
offsets = new int[count];
int offset = 2;
for (int i = 0; i < count; i++) {
offsets[i] = offset;
offset += buffer.read16U();
}
int offset = 2;
for (int i = 0; i < count; i++) {
offsets[i] = offset;
offset += buffer.read16U();
}
cache = new NPCType[20];
cache = new NPCType[20];
for (int k = 0; k < 20; k++) {
cache[k] = new NPCType();
}
}
for (int k = 0; k < 20; k++) {
cache[k] = new NPCType();
}
}
public static void unload() {
modelCache = null;
offsets = null;
cache = null;
dat = null;
}
public static void unload() {
modelCache = null;
offsets = null;
cache = null;
dat = null;
}
public int seqTurnRightID = -1;
public int varbitID = -1;
public int seqTurnAroundID = -1;
public int varpID = -1;
public int level = -1;
public String name;
public String[] options;
public int seqWalkID = -1;
public byte size = 1;
public int[] colorDst;
public int unusedInt0 = -1;
public int[] headModelIDs;
public int headicon = -1;
public int[] colorSrc;
public int seqStandID = -1;
public long uid = -1L;
public int turnSpeed = 32;
public int seqTurnLeftID = -1;
public boolean interactable = true;
public int lightAmbient;
public int scaleZ = 128;
public boolean showOnMinimap = true;
public int[] overrides;
public byte[] desc;
public int unusedInt1 = -1;
public int scaleXY = 128;
public int lightAttenuation;
/**
* Causes the npc to render on top of other npcs.
*/
public boolean important = false;
public int[] modelIDs;
public int unusedInt2 = -1;
public int seqTurnRightID = -1;
public int varbitID = -1;
public int seqTurnAroundID = -1;
public int varpID = -1;
public int level = -1;
public String name;
public String[] options;
public int seqWalkID = -1;
public byte size = 1;
public int[] colorDst;
public int[] headModelIDs;
public int headicon = -1;
public int[] colorSrc;
public int seqStandID = -1;
public long uid = -1L;
public int turnSpeed = 32;
public int seqTurnLeftID = -1;
public boolean interactable = true;
public int lightAmbient;
public int scaleZ = 128;
public boolean showOnMinimap = true;
public int[] overrides;
public byte[] desc;
public int scaleXY = 128;
public int lightAttenuation;
/**
* Causes the npc to render on top of other npcs.
*/
public boolean important = false;
public int[] modelIDs;
public NPCType() {
}
public NPCType() {
}
public Model getHeadModel() {
if (overrides != null) {
NPCType type = getOverrideType();
if (type == null) {
return null;
} else {
return type.getHeadModel();
}
}
public Model getHeadModel() {
if (overrides != null) {
NPCType type = getOverrideType();
if (type == null) {
return null;
} else {
return type.getHeadModel();
}
}
if (headModelIDs == null) {
return null;
}
if (headModelIDs == null) {
return null;
}
boolean loaded = false;
boolean loaded = false;
for (int value : headModelIDs) {
if (!Model.validate(value)) {
loaded = true;
}
}
for (int value : headModelIDs) {
if (!Model.validate(value)) {
loaded = true;
}
}
if (loaded) {
return null;
}
if (loaded) {
return null;
}
Model[] models = new Model[headModelIDs.length];
Model[] models = new Model[headModelIDs.length];
for (int i = 0; i < headModelIDs.length; i++) {
models[i] = Model.tryGet(headModelIDs[i]);
}
for (int i = 0; i < headModelIDs.length; i++) {
models[i] = Model.tryGet(headModelIDs[i]);
}
Model model;
Model model;
if (models.length == 1) {
model = models[0];
} else {
model = new Model(models.length, models);
}
if (models.length == 1) {
model = models[0];
} else {
model = new Model(models.length, models);
}
if (colorSrc != null) {
for (int i = 0; i < colorSrc.length; i++) {
model.recolor(colorSrc[i], colorDst[i]);
}
}
return model;
}
if (colorSrc != null) {
for (int i = 0; i < colorSrc.length; i++) {
model.recolor(colorSrc[i], colorDst[i]);
}
}
return model;
}
public NPCType getOverrideType() {
int value = -1;
public NPCType getOverrideType() {
int value = -1;
if (varbitID != -1) {
VarbitType vb = VarbitType.instances[this.varbitID];
int varp = vb.varp;
int lsb = vb.lsb;
int msb = vb.msb;
int mask = Game.BITMASK[msb - lsb];
value = (game.varps[varp] >> lsb) & mask;
} else if (varpID != -1) {
value = game.varps[varpID];
}
if (varbitID != -1) {
VarbitType vb = VarbitType.instances[this.varbitID];
int varp = vb.varp;
int lsb = vb.lsb;
int msb = vb.msb;
int mask = Game.BITMASK[msb - lsb];
value = (game.varps[varp] >> lsb) & mask;
} else if (varpID != -1) {
value = game.varps[varpID];
}
if ((value < 0) || (value >= overrides.length) || (overrides[value] == -1)) {
return null;
} else {
return get(overrides[value]);
}
}
if ((value < 0) || (value >= overrides.length) || (overrides[value] == -1)) {
return null;
} else {
return get(overrides[value]);
}
}
public Model getSequencedModel(int secondaryTransformID, int primaryTransformID, int[] seqMask) {
if (overrides != null) {
NPCType override = getOverrideType();
if (override == null) {
return null;
} else {
return override.getSequencedModel(secondaryTransformID, primaryTransformID, seqMask);
}
}
public Model getSequencedModel(int secondaryTransformID, int primaryTransformID, int[] seqMask) {
if (overrides != null) {
NPCType override = getOverrideType();
if (override == null) {
return null;
} else {
return override.getSequencedModel(secondaryTransformID, primaryTransformID, seqMask);
}
}
Model model = modelCache.get(uid);
Model model = modelCache.get(uid);
if (model == null) {
boolean invalid = false;
if (model == null) {
boolean invalid = false;
for (int value : modelIDs) {
if (!Model.validate(value)) {
invalid = true;
}
}
for (int value : modelIDs) {
if (!Model.validate(value)) {
invalid = true;
}
}
if (invalid) {
return null;
}
if (invalid) {
return null;
}
Model[] models = new Model[modelIDs.length];
Model[] models = new Model[modelIDs.length];
for (int i = 0; i < modelIDs.length; i++) {
models[i] = Model.tryGet(modelIDs[i]);
}
for (int i = 0; i < modelIDs.length; i++) {
models[i] = Model.tryGet(modelIDs[i]);
}
if (models.length == 1) {
model = models[0];
} else {
model = new Model(models.length, models);
}
if (models.length == 1) {
model = models[0];
} else {
model = new Model(models.length, models);
}
if (colorSrc != null) {
for (int i = 0; i < colorSrc.length; i++) {
model.recolor(colorSrc[i], colorDst[i]);
}
}
if (colorSrc != null) {
for (int i = 0; i < colorSrc.length; i++) {
model.recolor(colorSrc[i], colorDst[i]);
}
}
model.createLabelReferences();
model.calculateNormals(64 + lightAmbient, 850 + lightAttenuation, -30, -50, -30, true);
modelCache.put(uid, model);
}
model.createLabelReferences();
model.calculateNormals(64 + lightAmbient, 850 + lightAttenuation, -30, -50, -30, true);
modelCache.put(uid, model);
}
Model tmp = Model.EMPTY;
tmp.set(model, SeqTransform.isNull(primaryTransformID) & SeqTransform.isNull(secondaryTransformID));
Model tmp = Model.EMPTY;
tmp.set(model, SeqTransform.isNull(primaryTransformID) & SeqTransform.isNull(secondaryTransformID));
if ((primaryTransformID != -1) && (secondaryTransformID != -1)) {
tmp.applyTransforms(primaryTransformID, secondaryTransformID, seqMask);
} else if (primaryTransformID != -1) {
tmp.applyTransform(primaryTransformID);
}
if ((primaryTransformID != -1) && (secondaryTransformID != -1)) {
tmp.applyTransforms(primaryTransformID, secondaryTransformID, seqMask);
} else if (primaryTransformID != -1) {
tmp.applyTransform(primaryTransformID);
}
if ((scaleXY != 128) || (scaleZ != 128)) {
tmp.scale(scaleXY, scaleXY, scaleZ);
}
if ((scaleXY != 128) || (scaleZ != 128)) {
tmp.scale(scaleXY, scaleXY, scaleZ);
}
tmp.calculateBoundsCylinder();
tmp.labelFaces = null;
tmp.labelVertices = null;
tmp.calculateBoundsCylinder();
tmp.labelFaces = null;
tmp.labelVertices = null;
if (size == 1) {
tmp.pickable = true;
}
if (size == 1) {
tmp.pickable = true;
}
return tmp;
}
return tmp;
}
public void read(Buffer buffer) {
do {
int opcode = buffer.read8U();
public void read(Buffer buffer) {
while (true) {
int code = buffer.read8U();
if (opcode == 0) {
return;
}
if (code == 0) {
return;
} else if (code == 1) {
int modelCount = buffer.read8U();
modelIDs = new int[modelCount];
for (int i = 0; i < modelCount; i++) {
modelIDs[i] = buffer.read16U();
}
} else if (code == 2) {
name = buffer.readString();
} else if (code == 3) {
desc = buffer.readStringRaw();
} else if (code == 12) {
size = buffer.read();
} else if (code == 13) {
seqStandID = buffer.read16U();
} else if (code == 14) {
seqWalkID = buffer.read16U();
} else if (code == 17) {
seqWalkID = buffer.read16U();
seqTurnAroundID = buffer.read16U();
seqTurnLeftID = buffer.read16U();
seqTurnRightID = buffer.read16U();
} else if ((code >= 30) && (code < 40)) {
if (options == null) {
options = new String[5];
}
if (opcode == 1) {
int modelCount = buffer.read8U();
modelIDs = new int[modelCount];
for (int i = 0; i < modelCount; i++) {
modelIDs[i] = buffer.read16U();
}
} else if (opcode == 2) {
name = buffer.readString();
} else if (opcode == 3) {
desc = buffer.readStringRaw();
} else if (opcode == 12) {
size = buffer.read();
} else if (opcode == 13) {
seqStandID = buffer.read16U();
} else if (opcode == 14) {
seqWalkID = buffer.read16U();
} else if (opcode == 17) {
seqWalkID = buffer.read16U();
seqTurnAroundID = buffer.read16U();
seqTurnLeftID = buffer.read16U();
seqTurnRightID = buffer.read16U();
} else if ((opcode >= 30) && (opcode < 40)) {
if (options == null) {
options = new String[5];
}
options[opcode - 30] = buffer.readString();
if (options[opcode - 30].equalsIgnoreCase("hidden")) {
options[opcode - 30] = null;
}
} else if (opcode == 40) {
int recolorCount = buffer.read8U();
colorSrc = new int[recolorCount];
colorDst = new int[recolorCount];
for (int i = 0; i < recolorCount; i++) {
colorSrc[i] = buffer.read16U();
colorDst[i] = buffer.read16U();
}
} else if (opcode == 60) {
int l = buffer.read8U();
headModelIDs = new int[l];
for (int l1 = 0; l1 < l; l1++) {
headModelIDs[l1] = buffer.read16U();
}
} else if (opcode == 90) {
unusedInt2 = buffer.read16U();
} else if (opcode == 91) {
unusedInt0 = buffer.read16U();
} else if (opcode == 92) {
unusedInt1 = buffer.read16U();
} else if (opcode == 93) {
showOnMinimap = false;
} else if (opcode == 95) {
level = buffer.read16U();
} else if (opcode == 97) {
scaleXY = buffer.read16U();
} else if (opcode == 98) {
scaleZ = buffer.read16U();
} else if (opcode == 99) {
important = true;
} else if (opcode == 100) {
lightAmbient = buffer.read();
} else if (opcode == 101) {
lightAttenuation = buffer.read() * 5;
} else if (opcode == 102) {
headicon = buffer.read16U();
} else if (opcode == 103) {
turnSpeed = buffer.read16U();
} else if (opcode == 106) {
varbitID = buffer.read16U();
options[code - 30] = buffer.readString();
if (varbitID == 65535) {
varbitID = -1;
}
varpID = buffer.read16U();
if (options[code - 30].equalsIgnoreCase("hidden")) {
options[code - 30] = null;
}
} else if (code == 40) {
int count = buffer.read8U();
colorSrc = new int[count];
colorDst = new int[count];
if (varpID == 65535) {
varpID = -1;
}
for (int i = 0; i < count; i++) {
colorSrc[i] = buffer.read16U();
colorDst[i] = buffer.read16U();
}
} else if (code == 60) {
int count = buffer.read8U();
headModelIDs = new int[count];
for (int l1 = 0; l1 < count; l1++) {
headModelIDs[l1] = buffer.read16U();
}
} else if ((code == 90) || (code == 91) || (code == 92)) {
buffer.read16U();
} else if (code == 93) {
showOnMinimap = false;
} else if (code == 95) {
level = buffer.read16U();
} else if (code == 97) {
scaleXY = buffer.read16U();
} else if (code == 98) {
scaleZ = buffer.read16U();
} else if (code == 99) {
important = true;
} else if (code == 100) {
lightAmbient = buffer.read();
} else if (code == 101) {
lightAttenuation = buffer.read() * 5;
} else if (code == 102) {
headicon = buffer.read16U();
} else if (code == 103) {
turnSpeed = buffer.read16U();
} else if (code == 106) {
varbitID = buffer.read16U();
int overrideCount = buffer.read8U();
overrides = new int[overrideCount + 1];
if (varbitID == 65535) {
varbitID = -1;
}
for (int i = 0; i <= overrideCount; i++) {
overrides[i] = buffer.read16U();
if (overrides[i] == 65535) {
overrides[i] = -1;
}
}
} else if (opcode == 107) {
interactable = false;
}
} while (true);
}
varpID = buffer.read16U();
if (varpID == 65535) {
varpID = -1;
}
int overrideCount = buffer.read8U();
overrides = new int[overrideCount + 1];
for (int i = 0; i <= overrideCount; i++) {
overrides[i] = buffer.read16U();
if (overrides[i] == 65535) {
overrides[i] = -1;
}
}
} else if (code == 107) {
interactable = false;
}
}
}
}
+640 -644
View File
File diff suppressed because it is too large. Load diff
+21 -21
View File
@@ -107,7 +107,6 @@ public class SeqType {
*/
public int replayStyle = 1;
public int unusedInt;
public SeqType() {
}
@@ -130,11 +129,12 @@ public class SeqType {
}
public void load(Buffer buffer) {
do {
int opcode = buffer.read8U();
if (opcode == 0) {
while (true) {
int code = buffer.read8U();
if (code == 0) {
break;
} else if (opcode == 1) {
} else if (code == 1) {
frameCount = buffer.read8U();
transformIDs = new int[frameCount];
auxiliaryTransformIDs = new int[frameCount];
@@ -147,37 +147,37 @@ public class SeqType {
}
frameDuration[f] = buffer.read16U();
}
} else if (opcode == 2) {
} else if (code == 2) {
loopFrameCount = buffer.read16U();
} else if (opcode == 3) {
} else if (code == 3) {
int count = buffer.read8U();
mask = new int[count + 1];
for (int l = 0; l < count; l++) {
mask[l] = buffer.read8U();
}
mask[count] = 9999999;
} else if (opcode == 4) {
} else if (code == 4) {
forwardRenderPadding = true;
} else if (opcode == 5) {
} else if (code == 5) {
priority = buffer.read8U();
} else if (opcode == 6) {
} else if (code == 6) {
rightHandOverride = buffer.read16U();
} else if (opcode == 7) {
} else if (code == 7) {
leftHandOverride = buffer.read16U();
} else if (opcode == 8) {
} else if (code == 8) {
loopCount = buffer.read8U();
} else if (opcode == 9) {
} else if (code == 9) {
moveStyle = buffer.read8U();
} else if (opcode == 10) {
} else if (code == 10) {
idleStyle = buffer.read8U();
} else if (opcode == 11) {
} else if (code == 11) {
replayStyle = buffer.read8U();
} else if (opcode == 12) {
unusedInt = buffer.read32();
} else if (code == 12) {
buffer.read32();
} else {
System.out.println("Error unrecognised seq config code: " + opcode);
System.out.println("Error unrecognised seq config code: " + code);
}
} while (true);
}
if (frameCount == 0) {
frameCount = 1;
@@ -200,9 +200,9 @@ public class SeqType {
if (idleStyle == -1) {
if (mask != null) {
idleStyle = 2;
return;
} else {
idleStyle = 0;
}
idleStyle = 0;
}
}
+28 -30
View File
@@ -2,23 +2,21 @@ public class SoundTrack {
public static final SoundTrack[] tracks = new SoundTrack[5000];
public static final int[] delays = new int[5000];
public static byte[] bbuf;
public static Buffer buffer;
public static byte[] waveBytes = new byte[441000];
public static Buffer waveBuffer = new Buffer(waveBytes);
public static void method240(Buffer src) {
bbuf = new byte[441000];
SoundTrack.buffer = new Buffer(bbuf);
public static void unpack(Buffer in) {
SoundTone.init();
do {
int id = src.read16U();
int id = in.read16U();
if (id == 65535) {
return;
}
tracks[id] = new SoundTrack();
tracks[id].read(src);
tracks[id].read(in);
delays[id] = tracks[id].trim();
} while (true);
}
@@ -26,7 +24,7 @@ public class SoundTrack {
public static Buffer generate(int loopCount, int id) {
if (tracks[id] != null) {
SoundTrack track = tracks[id];
return track.getWaveform(loopCount);
return track.getWave(loopCount);
} else {
return null;
}
@@ -85,24 +83,24 @@ public class SoundTrack {
* @param loopCount the loop count.
* @return the {@link Buffer} containing the waveform data.
*/
public Buffer getWaveform(int loopCount) {
public Buffer getWave(int loopCount) {
int length = generate(loopCount);
buffer.position = 0;
buffer.write32(0x52494646); // "RIFF" ChunkID
buffer.write32LE(36 + length); // ChunkSize
buffer.write32(0x57415645); // "WAVE" format
buffer.write32(0x666d7420); // "fmt " chunk id
buffer.write32LE(16); // chunk size
buffer.write16LE(1); // audio format
buffer.write16LE(1); // num channels
buffer.write32LE(22050); // sample rate
buffer.write32LE(22050); // byte rate
buffer.write16LE(1); // block align
buffer.write16LE(8); // bits per sample
buffer.write32(0x64617461); // "data"
buffer.write32LE(length);
buffer.position += length;
return buffer;
waveBuffer.position = 0;
waveBuffer.write32(0x52494646); // "RIFF" ChunkID
waveBuffer.write32LE(36 + length); // ChunkSize
waveBuffer.write32(0x57415645); // "WAVE" format
waveBuffer.write32(0x666d7420); // "fmt " chunk id
waveBuffer.write32LE(16); // chunk size
waveBuffer.write16LE(1); // audio format
waveBuffer.write16LE(1); // num channels
waveBuffer.write32LE(22050); // sample rate
waveBuffer.write32LE(22050); // byte rate
waveBuffer.write16LE(1); // block align
waveBuffer.write16LE(8); // bits per sample
waveBuffer.write32(0x64617461); // "data"
waveBuffer.write32LE(length);
waveBuffer.position += length;
return waveBuffer;
}
public int generate(int loopCount) {
@@ -129,7 +127,7 @@ public class SoundTrack {
int totalSampleCount = sampleCount + ((loopStop - loopStart) * (loopCount - 1));
for (int sample = 44; sample < (totalSampleCount + 44); sample++) {
bbuf[sample] = -128;
waveBytes[sample] = -128;
}
for (int tone = 0; tone < 10; tone++) {
@@ -142,7 +140,7 @@ public class SoundTrack {
int[] samples = tones[tone].generate(toneSampleCount, tones[tone].length);
for (int sample = 0; sample < toneSampleCount; sample++) {
bbuf[sample + start + 44] += (byte) (samples[sample] >> 8);
waveBytes[sample + start + 44] += (byte) (samples[sample] >> 8);
}
}
@@ -155,14 +153,14 @@ public class SoundTrack {
// Moves the end of the sound (after the loops) to the true end of the buffer.
int endOffset = (totalSampleCount += 44) - sampleCount;
for (int sample = sampleCount - 1; sample >= loopStop; sample--) {
bbuf[sample + endOffset] = bbuf[sample];
waveBytes[sample + endOffset] = waveBytes[sample];
}
// Duplicates loop area.
for (int loop = 1; loop < loopCount; loop++) {
int offset = (loopStop - loopStart) * loop;
for (int sample = loopStart; sample < loopStop; sample++) {
bbuf[sample + offset] = bbuf[sample];
waveBytes[sample + offset] = waveBytes[sample];
}
}
+78 -79
View File
@@ -8,96 +8,95 @@ import java.io.IOException;
public class SpotAnimType {
public static int count;
public static SpotAnimType[] instances;
public static LRUMap<Integer, Model> modelCache = new LRUMap<>(30);
public static int count;
public static SpotAnimType[] instances;
public static LRUMap<Integer, Model> modelCache = new LRUMap<>(30);
public static void unpack(FileArchive archive) throws IOException {
Buffer buffer = new Buffer(archive.read("spotanim.dat"));
count = buffer.read16U();
public static void unpack(FileArchive archive) throws IOException {
Buffer buffer = new Buffer(archive.read("spotanim.dat"));
count = buffer.read16U();
if (instances == null) {
instances = new SpotAnimType[count];
}
if (instances == null) {
instances = new SpotAnimType[count];
}
for (int i = 0; i < count; i++) {
if (instances[i] == null) {
instances[i] = new SpotAnimType();
}
instances[i].index = i;
instances[i].read(buffer);
}
}
for (int i = 0; i < count; i++) {
if (instances[i] == null) {
instances[i] = new SpotAnimType();
}
instances[i].index = i;
instances[i].read(buffer);
}
}
public final int[] colorSrc = new int[6];
public final int[] colorDst = new int[6];
public int index;
public int modelID;
public int seqID = -1;
public SeqType seq;
public int scaleXY = 128;
public int scaleZ = 128;
public int rotation;
public int lightAmbient;
public int lightAttenuation;
public final int[] colorSrc = new int[6];
public final int[] colorDst = new int[6];
public int index;
public int modelID;
public int seqID = -1;
public SeqType seq;
public int scaleXY = 128;
public int scaleZ = 128;
public int rotation;
public int lightAmbient;
public int lightAttenuation;
public SpotAnimType() {
}
public SpotAnimType() {
}
public void read(Buffer buffer) {
do {
int i = buffer.read8U();
if (i == 0) {
return;
}
if (i == 1) {
modelID = buffer.read16U();
} else if (i == 2) {
seqID = buffer.read16U();
if (SeqType.instances != null) {
seq = SeqType.instances[seqID];
}
} else if (i == 4) {
scaleXY = buffer.read16U();
} else if (i == 5) {
scaleZ = buffer.read16U();
} else if (i == 6) {
rotation = buffer.read16U();
} else if (i == 7) {
lightAmbient = buffer.read8U();
} else if (i == 8) {
lightAttenuation = buffer.read8U();
} else if ((i >= 40) && (i < 50)) {
colorSrc[i - 40] = buffer.read16U();
} else if ((i >= 50) && (i < 60)) {
colorDst[i - 50] = buffer.read16U();
} else {
System.out.println("Error unrecognised spotanim config code: " + i);
}
} while (true);
}
public void read(Buffer buffer) {
while (true) {
int code = buffer.read8U();
if (code == 0) {
return;
} else if (code == 1) {
modelID = buffer.read16U();
} else if (code == 2) {
seqID = buffer.read16U();
if (SeqType.instances != null) {
seq = SeqType.instances[seqID];
}
} else if (code == 4) {
scaleXY = buffer.read16U();
} else if (code == 5) {
scaleZ = buffer.read16U();
} else if (code == 6) {
rotation = buffer.read16U();
} else if (code == 7) {
lightAmbient = buffer.read8U();
} else if (code == 8) {
lightAttenuation = buffer.read8U();
} else if ((code >= 40) && (code < 50)) {
colorSrc[code - 40] = buffer.read16U();
} else if ((code >= 50) && (code < 60)) {
colorDst[code - 50] = buffer.read16U();
} else {
System.out.println("Error unrecognised spotanim config code: " + code);
}
}
}
public Model getModel() {
Model model = modelCache.get(index);
public Model getModel() {
Model model = modelCache.get(index);
if (model != null) {
return model;
}
if (model != null) {
return model;
}
model = Model.tryGet(modelID);
model = Model.tryGet(modelID);
if (model == null) {
return null;
}
if (model == null) {
return null;
}
for (int i = 0; i < 6; i++) {
if (colorSrc[0] != 0) {
model.recolor(colorSrc[i], colorDst[i]);
}
}
for (int i = 0; i < 6; i++) {
if (colorSrc[0] != 0) {
model.recolor(colorSrc[i], colorDst[i]);
}
}
modelCache.put(index, model);
return model;
}
modelCache.put(index, model);
return model;
}
}
+8 -19
View File
@@ -21,16 +21,12 @@ public class VarbitType {
instances[j] = new VarbitType();
}
instances[j].read(buffer);
if (instances[j].unusedBool) {
VarpType.instances[instances[j].varp].unusedBool3 = true;
}
}
if (buffer.position != buffer.data.length) {
System.out.println("varbit load mismatch");
}
}
public String unusedString;
public int varp;
/**
* The least significant bit.
@@ -40,32 +36,25 @@ public class VarbitType {
* The most significant bit.
*/
public int msb;
public boolean unusedBool = false;
public int unusedInt0 = -1;
public int unusedInt1;
public VarbitType() {
}
public void read(Buffer buffer) {
do {
int opcode = buffer.read8U();
if (opcode == 0) {
int code = buffer.read8U();
if (code == 0) {
return;
} else if (opcode == 1) {
} else if (code == 1) {
varp = buffer.read16U();
lsb = buffer.read8U();
msb = buffer.read8U();
} else if (opcode == 10) {
unusedString = buffer.readString();
} else if (opcode == 2) {
unusedBool = true;
} else if (opcode == 3) {
unusedInt0 = buffer.read32();
} else if (opcode == 4) {
unusedInt1 = buffer.read32();
} else if (code == 10) {
buffer.readString();
} else if (code == 3 || code == 4) {
buffer.read32();
} else {
System.out.println("Error unrecognised config code: " + opcode);
System.out.println("Error unrecognised varbit config code: " + code);
}
} while (true);
}
+21 -55
View File
@@ -6,82 +6,48 @@ import java.io.IOException;
public class VarpType {
public static int anInt700;
public static int count;
public static VarpType[] instances;
public static int anInt702;
public static int[] anIntArray703;
public static void unpack(FileArchive archive) throws IOException {
Buffer buffer = new Buffer(archive.read("varp.dat"));
anInt702 = 0;
anInt700 = buffer.read16U();
count = buffer.read16U();
if (instances == null) {
instances = new VarpType[anInt700];
instances = new VarpType[count];
}
if (anIntArray703 == null) {
anIntArray703 = new int[anInt700];
}
for (int j = 0; j < anInt700; j++) {
if (instances[j] == null) {
instances[j] = new VarpType();
for (int i = 0; i < count; i++) {
if (instances[i] == null) {
instances[i] = new VarpType();
}
instances[j].read(buffer, j);
instances[i].read(buffer);
}
if (buffer.position != buffer.data.length) {
System.out.println("varptype load mismatch");
}
}
public String unusedString;
public int unusedInt0;
public int unusedInt1;
public boolean unusedBool0 = false;
public boolean unusedBool1 = true;
public int type;
public boolean unusedBool2 = false;
public int unusedInt2;
public int unusedInt3;
public boolean unusedBool3 = false;
public int unusedInt4 = -1;
public VarpType() {
}
public void read(Buffer buffer, int i) {
do {
int opcode = buffer.read8U();
if (opcode == 0) {
public void read(Buffer in) {
while (true) {
int code = in.read8U();
if (code == 0) {
return;
} else if (opcode == 1) {
unusedInt0 = buffer.read8U();
} else if (opcode == 2) {
unusedInt1 = buffer.read8U();
} else if (opcode == 3) {
unusedBool0 = true;
anIntArray703[anInt702++] = i;
} else if (opcode == 4) {
unusedBool1 = false;
} else if (opcode == 5) {
type = buffer.read16U();
} else if (opcode == 6) {
unusedBool2 = true;
} else if (opcode == 7) {
unusedInt2 = buffer.read32();
} else if (opcode == 8) {
unusedInt3 = 1;
unusedBool3 = true;
} else if (opcode == 10) {
unusedString = buffer.readString();
} else if (opcode == 11) {
unusedBool3 = true;
} else if (opcode == 12) {
unusedInt4 = buffer.read32();
} else if (opcode == 13) {
unusedInt3 = 2;
} else if (code == 1 || code == 2) {
in.read8U();
} else if (code == 5) {
type = in.read16U();
} else if (code == 7 || code == 12) {
in.read32();
} else if (code == 10) {
in.readString();
} else {
System.out.println("Error unrecognised config code: " + opcode);
System.out.println("Error unrecognised varp config code: " + code);
}
} while (true);
}
}
}