Renamed: Component->Interface

Constants: IfType#OPTION_TYPE_*
Constants: IfType#TYPE_*
Renamed: Model.Header fields
Renamed: Model#unpack
Renamed: SceneObjStack
This commit is contained in:
thedaneeffect committed 2023-01-05 20:59:52 -05:00
1 parent 9d8c7da0ce
commit 6bb096a79f
7 files changed
+872 -780

No files matched your search

+715 -646
View File
File diff suppressed because it is too large. Load diff
+57 -42
View File
@@ -12,6 +12,22 @@ public class IfType {
public static LRUMap<Long, Image24> imageCache;
public static IfType[] instances;
public static final int TYPE_PARENT = 0;
public static final int TYPE_UNUSED = 1;
public static final int TYPE_INVENTORY = 2;
public static final int TYPE_RECT = 3;
public static final int TYPE_TEXT = 4;
public static final int TYPE_IMAGE = 5;
public static final int TYPE_MODEL = 6;
public static final int TYPE_INVENTORY_TEXT = 7;
public static final int OPTION_TYPE_STANDARD = 1;
public static final int OPTION_TYPE_SPELL = 2;
public static final int OPTION_TYPE_CLOSE = 3;
public static final int OPTION_TYPE_TOGGLE = 4;
public static final int OPTION_TYPE_SELECT = 5;
public static final int OPTION_TYPE_CONTINUE = 6;
public static void unpack(FileArchive config, BitmapFont[] fonts, FileArchive media) throws IOException {
imageCache = new LRUMap<>(500);
Buffer in = new Buffer(config.read("data"));
@@ -68,26 +84,26 @@ public class IfType {
}
}
if (iface.type == 0) {
if (iface.type == TYPE_PARENT) {
iface.scrollableHeight = in.read16U();
iface.hide = in.read8U() == 1;
int childCount = in.read16U();
iface.children = new int[childCount];
iface.childID = new int[childCount];
iface.childX = new int[childCount];
iface.childY = new int[childCount];
for (int i = 0; i < childCount; i++) {
iface.children[i] = in.read16U();
iface.childID[i] = in.read16U();
iface.childX[i] = in.read16();
iface.childY[i] = in.read16();
}
}
if (iface.type == 1) {
if (iface.type == TYPE_UNUSED) {
iface.unusedInt = in.read16U();
iface.unusedBool = in.read8U() == 1;
}
if (iface.type == 2) {
if (iface.type == TYPE_INVENTORY) {
iface.inventorySlotObjID = new int[iface.width * iface.height];
iface.inventorySlotObjCount = new int[iface.width * iface.height];
iface.inventoryDraggable = in.read8U() == 1;
@@ -99,19 +115,22 @@ public class IfType {
iface.inventorySlotOffsetX = new int[20];
iface.inventorySlotOffsetY = new int[20];
iface.inventorySlotImage = new Image24[20];
for (int j2 = 0; j2 < 20; j2++) {
int k3 = in.read8U();
if (k3 == 1) {
iface.inventorySlotOffsetX[j2] = in.read16();
iface.inventorySlotOffsetY[j2] = in.read16();
String s1 = in.readString();
if ((media != null) && (s1.length() > 0)) {
int i5 = s1.lastIndexOf(",");
iface.inventorySlotImage[j2] = getImage(Integer.parseInt(s1.substring(i5 + 1)), media, s1.substring(0, i5));
for (int slot = 0; slot < 20; slot++) {
if (in.read8U() == 1) {
iface.inventorySlotOffsetX[slot] = in.read16();
iface.inventorySlotOffsetY[slot] = in.read16();
String imageName = in.readString();
if ((media != null) && (imageName.length() > 0)) {
int imageID = imageName.lastIndexOf(",");
iface.inventorySlotImage[slot] = getImage(Integer.parseInt(imageName.substring(imageID + 1)), media, imageName.substring(0, imageID));
}
}
}
iface.inventoryOptions = new String[5];
for (int i = 0; i < 5; i++) {
iface.inventoryOptions[i] = in.readString();
if (iface.inventoryOptions[i].length() == 0) {
@@ -120,11 +139,11 @@ public class IfType {
}
}
if (iface.type == 3) {
if (iface.type == TYPE_RECT) {
iface.fill = in.read8U() == 1;
}
if ((iface.type == 4) || (iface.type == 1)) {
if ((iface.type == TYPE_TEXT) || (iface.type == TYPE_UNUSED)) {
iface.center = in.read8U() == 1;
int fontID = in.read8U();
if (fonts != null) {
@@ -133,22 +152,22 @@ public class IfType {
iface.shadow = in.read8U() == 1;
}
if (iface.type == 4) {
if (iface.type == TYPE_TEXT) {
iface.text = in.readString();
iface.activeText = in.readString();
}
if ((iface.type == 1) || (iface.type == 3) || (iface.type == 4)) {
if ((iface.type == TYPE_UNUSED) || (iface.type == TYPE_RECT) || (iface.type == TYPE_TEXT)) {
iface.color = in.read32();
}
if ((iface.type == 3) || (iface.type == 4)) {
if ((iface.type == TYPE_RECT) || (iface.type == TYPE_TEXT)) {
iface.activeColor = in.read32();
iface.hoverColor = in.read32();
iface.activeHoverColor = in.read32();
}
if (iface.type == 5) {
if (iface.type == TYPE_IMAGE) {
String s = in.readString();
if ((media != null) && (s.length() > 0)) {
int comma = s.lastIndexOf(",");
@@ -161,7 +180,7 @@ public class IfType {
}
}
if (iface.type == 6) {
if (iface.type == TYPE_MODEL) {
int tmp = in.read8U();
if (tmp != 0) {
iface.modelCategory = 1;
@@ -193,7 +212,7 @@ public class IfType {
iface.modelYaw = in.read16U();
}
if (iface.type == 7) {
if (iface.type == TYPE_INVENTORY_TEXT) {
iface.inventorySlotObjID = new int[iface.width * iface.height];
iface.inventorySlotObjCount = new int[iface.width * iface.height];
iface.center = in.read8U() == 1;
@@ -207,10 +226,10 @@ public class IfType {
iface.inventoryMarginY = in.read16();
iface.inventoryInteractable = in.read8U() == 1;
iface.inventoryOptions = new String[5];
for (int k4 = 0; k4 < 5; k4++) {
iface.inventoryOptions[k4] = in.readString();
if (iface.inventoryOptions[k4].length() == 0) {
iface.inventoryOptions[k4] = null;
for (int option = 0; option < 5; option++) {
iface.inventoryOptions[option] = in.readString();
if (iface.inventoryOptions[option].length() == 0) {
iface.inventoryOptions[option] = null;
}
}
}
@@ -219,22 +238,23 @@ public class IfType {
iface.spellAction = in.readString();
}
if ((iface.optionType == 2) || (iface.type == 2)) {
if ((iface.optionType == OPTION_TYPE_SPELL) || (iface.type == TYPE_INVENTORY)) {
iface.spellAction = in.readString();
iface.spellName = in.readString();
iface.spellFlags = in.read16U();
}
if ((iface.optionType == 1) || (iface.optionType == 4) || (iface.optionType == 5) || (iface.optionType == 6)) {
if (iface.optionType == OPTION_TYPE_STANDARD || iface.optionType == OPTION_TYPE_TOGGLE || iface.optionType == OPTION_TYPE_SELECT || iface.optionType == OPTION_TYPE_CONTINUE) {
iface.option = in.readString();
if (iface.option.length() == 0) {
if (iface.optionType == 1) {
if (iface.optionType == OPTION_TYPE_STANDARD) {
iface.option = "Ok";
} else if (iface.optionType == 4) {
} else if (iface.optionType == OPTION_TYPE_TOGGLE) {
iface.option = "Select";
} else if (iface.optionType == 5) {
} else if (iface.optionType == OPTION_TYPE_SELECT) {
iface.option = "Select";
} else if (iface.optionType == 6) {
} else if (iface.optionType == OPTION_TYPE_CONTINUE) {
iface.option = "Continue";
}
}
@@ -246,9 +266,11 @@ public class IfType {
public static Image24 getImage(int id, FileArchive media, String name) {
long uid = (StringUtil.hashCode(name) << 8) + (long) id;
Image24 image = imageCache.get(uid);
if (image != null) {
return image;
}
try {
image = new Image24(media, name, id);
imageCache.put(uid, image);
@@ -274,7 +296,7 @@ public class IfType {
public int activeSeqID;
public String activeText;
public boolean center;
public int[] children;
public int[] childID;
public int[] childX;
public int[] childY;
public int color;
@@ -285,7 +307,7 @@ public class IfType {
public int height;
/**
* Hides this component. Only works for parent components by default.
* @see Game#drawParentComponent(IfType, int, int, int)
* @see Game#drawParentInterface(IfType, int, int, int)
*/
public boolean hide;
public int hoverColor;
@@ -308,20 +330,13 @@ public class IfType {
public int modelYaw;
public int modelZoom;
public String option;
public static final int OPTION_TYPE_STANDARD = 1;
public static final int OPTION_TYPE_SPELL = 2;
public static final int OPTION_TYPE_CLOSE = 3;
public static final int OPTION_TYPE_TOGGLE = 4;
public static final int OPTION_TYPE_SELECT = 5;
public static final int OPTION_TYPE_CONTINUE = 6;
public int optionType;
public int parentID;
public int[] scriptComparator;
public int[] scriptOperand;
public int[][] scripts;
public int scrollableHeight;
public int scrollPos;
public int scrollPosition;
public int seqCycle;
public int seqFrame;
public int seqID;
+84 -76
View File
@@ -17,13 +17,10 @@ public class Model extends Entity {
public static int[] tmpVertexY = new int[2000];
public static int[] tmpVertexZ = new int[2000];
public static int[] tmpFaceAlpha = new int[2000];
public static Header[] headers;
public static OnDemand ondemand;
public static boolean[] faceClippedX = new boolean[4096];
public static boolean[] faceNearClipped = new boolean[4096];
public static int[] vertexScreenX = new int[4096];
public static int[] vertexScreenY = new int[4096];
public static int[] vertexScreenZ = new int[4096];
@@ -38,7 +35,6 @@ public class Model extends Entity {
public static int[] tmpPriority10FaceDepth = new int[2000];
public static int[] tmpPriority11FaceDepth = new int[2000];
public static int[] tmpPriorityDepthSum = new int[12];
public static int baseX;
public static int baseY;
public static int baseZ;
@@ -51,25 +47,24 @@ public class Model extends Entity {
public static int[] palette = Draw3D.palette;
public static int[] reciprical16 = Draw3D.reciprocal16;
public static class Header {
public static final class Header {
public byte[] data;
public int vertexCount;
public int faceCount;
public int texturedFaceCount;
public int obPoint1Position;
public int obPoint2Position;
public int obPoint3Position;
public int obPoint4Position;
public int obPoint5Position;
public int obVertex1Position;
public int obVertex2Position;
public int obFace1Position;
public int obFace2Position;
public int obFace3Position;
public int obFace4Position;
public int obFace5Position;
public int obAxisPosition;
public int vertexFlagsOffset;
public int vertexXOffset;
public int vertexYOffset;
public int vertexZOffset;
public int vertexLabelsOffset;
public int faceVerticesOffset;
public int faceOrientationsOffset;
public int faceColorsOffset;
public int faceInfosOffset;
public int facePrioritiesOffset;
public int faceAlphasOffset;
public int faceLabelsOffset;
public int faceTextureAxisOffset;
}
@@ -116,62 +111,75 @@ public class Model extends Entity {
header.vertexCount = buffer.read16U();
header.faceCount = buffer.read16U();
header.texturedFaceCount = buffer.read8U();
int k = buffer.read8U();
int l = buffer.read8U();
int i1 = buffer.read8U();
int j1 = buffer.read8U();
int k1 = buffer.read8U();
int l1 = buffer.read16U();
int i2 = buffer.read16U();
//noinspection unused
int j2 = buffer.read16U();
int k2 = buffer.read16U();
int hasInfo = buffer.read8U();
int priority = buffer.read8U();
int hasAlpha = buffer.read8U();
int hasFaceLabels = buffer.read8U();
int hasVertexLabels = buffer.read8U();
int dataLengthX = buffer.read16U();
int dataLengthY = buffer.read16U();
int dataLengthZ = buffer.read16U();
int dataLengthFaceOrientations = buffer.read16U();
int offset = 0;
header.obPoint1Position = offset;
header.vertexFlagsOffset = offset;
offset += header.vertexCount;
header.obVertex2Position = offset;
header.faceOrientationsOffset = offset;
offset += header.faceCount;
header.obFace3Position = offset;
if (l == 255) {
header.facePrioritiesOffset = offset;
if (priority == 255) {
offset += header.faceCount;
} else {
header.obFace3Position = -l - 1;
header.facePrioritiesOffset = -priority - 1;
}
header.obFace5Position = offset;
if (j1 == 1) {
header.faceLabelsOffset = offset;
if (hasFaceLabels == 1) {
offset += header.faceCount;
} else {
header.obFace5Position = -1;
header.faceLabelsOffset = -1;
}
header.obFace2Position = offset;
if (k == 1) {
header.faceInfosOffset = offset;
if (hasInfo == 1) {
offset += header.faceCount;
} else {
header.obFace2Position = -1;
header.faceInfosOffset = -1;
}
header.obPoint5Position = offset;
if (k1 == 1) {
header.vertexLabelsOffset = offset;
if (hasVertexLabels == 1) {
offset += header.vertexCount;
} else {
header.obPoint5Position = -1;
header.vertexLabelsOffset = -1;
}
header.obFace4Position = offset;
if (i1 == 1) {
header.faceAlphasOffset = offset;
if (hasAlpha == 1) {
offset += header.faceCount;
} else {
header.obFace4Position = -1;
header.faceAlphasOffset = -1;
}
header.obVertex1Position = offset;
offset += k2;
header.obFace1Position = offset;
header.faceVerticesOffset = offset;
offset += dataLengthFaceOrientations;
header.faceColorsOffset = offset;
offset += header.faceCount * 2;
header.obAxisPosition = offset;
header.faceTextureAxisOffset = offset;
offset += header.texturedFaceCount * 6;
header.obPoint2Position = offset;
offset += l1;
header.obPoint3Position = offset;
offset += i2;
header.obPoint4Position = offset;
header.vertexXOffset = offset;
offset += dataLengthX;
header.vertexYOffset = offset;
offset += dataLengthY;
header.vertexZOffset = offset;
offset += dataLengthZ;
}
public static void unload(int id) {
@@ -346,44 +354,44 @@ public class Model extends Entity {
texturedVertexB = new int[texturedFaceCount];
texturedVertexC = new int[texturedFaceCount];
if (header.obPoint5Position >= 0) {
if (header.vertexLabelsOffset >= 0) {
vertexLabel = new int[vertexCount];
}
if (header.obFace2Position >= 0) {
if (header.faceInfosOffset >= 0) {
faceInfo = new int[faceCount];
}
if (header.obFace3Position >= 0) {
if (header.facePrioritiesOffset >= 0) {
facePriority = new int[faceCount];
} else {
priority = -header.obFace3Position - 1;
priority = -header.facePrioritiesOffset - 1;
}
if (header.obFace4Position >= 0) {
if (header.faceAlphasOffset >= 0) {
faceAlpha = new int[faceCount];
}
if (header.obFace5Position >= 0) {
if (header.faceLabelsOffset >= 0) {
faceLabel = new int[faceCount];
}
faceColor = new int[faceCount];
Buffer buf0 = new Buffer(header.data);
buf0.position = header.obPoint1Position;
buf0.position = header.vertexFlagsOffset;
Buffer buf1 = new Buffer(header.data);
buf1.position = header.obPoint2Position;
buf1.position = header.vertexXOffset;
Buffer buf2 = new Buffer(header.data);
buf2.position = header.obPoint3Position;
buf2.position = header.vertexYOffset;
Buffer buf3 = new Buffer(header.data);
buf3.position = header.obPoint4Position;
buf3.position = header.vertexZOffset;
Buffer buf4 = new Buffer(header.data);
buf4.position = header.obPoint5Position;
buf4.position = header.vertexLabelsOffset;
int x = 0;
int y = 0;
@@ -421,11 +429,11 @@ public class Model extends Entity {
}
}
buf0.position = header.obFace1Position;
buf1.position = header.obFace2Position;
buf2.position = header.obFace3Position;
buf3.position = header.obFace4Position;
buf4.position = header.obFace5Position;
buf0.position = header.faceColorsOffset;
buf1.position = header.faceInfosOffset;
buf2.position = header.facePrioritiesOffset;
buf3.position = header.faceAlphasOffset;
buf4.position = header.faceLabelsOffset;
for (int face = 0; face < faceCount; face++) {
faceColor[face] = buf0.read16U();
@@ -447,8 +455,8 @@ public class Model extends Entity {
}
}
buf0.position = header.obVertex1Position;
buf1.position = header.obVertex2Position;
buf0.position = header.faceVerticesOffset;
buf1.position = header.faceOrientationsOffset;
int a = 0;
int b = 0;
@@ -497,9 +505,9 @@ public class Model extends Entity {
// reuse b, a, new c
if (orientation == 4) {
int a_ = a;
int tmp = a;
a = b;
b = a_;
b = tmp;
c = buf0.readSmart() + last;
last = c;
faceVertexA[face] = a;
@@ -508,7 +516,7 @@ public class Model extends Entity {
}
}
buf0.position = header.obAxisPosition;
buf0.position = header.faceTextureAxisOffset;
for (int face = 0; face < texturedFaceCount; face++) {
texturedVertexA[face] = buf0.read16U();
+2 -2
View File
@@ -8,7 +8,7 @@ public final class PacketIn {
public static final int CAM_SETPOS = 166;
public static final int CAM_SHAKE = 35;
public static final int IF_CHAT = 164;
public static final int CHAT_COMPONENT_STICKY = 218;
public static final int IF_CHAT_STICKY = 218;
public static final int CHAT_FILTER_SETTINGS = 206;
public static final int CLEAR_MAP_FLAG = 78;
public static final int FRIENDLIST_LOADED = 221;
@@ -134,7 +134,7 @@ public final class PacketIn {
SIZE[IF_VIEWPORT_OVERLAY] = 2;
SIZE[IGNORE_LIST] = -2;
SIZE[OBJ_REVEAL] = 7;
SIZE[CHAT_COMPONENT_STICKY] = 2;
SIZE[IF_CHAT_STICKY] = 2;
SIZE[FRIENDLIST_LOADED] = 1;
SIZE[IF_SETANGLE] = 8;
SIZE[UPDATE_RUNWEIGHT] = 2;
+10 -10
View File
@@ -413,15 +413,15 @@ public class Scene {
levelTiles[tileLevel][tileX][tileZ].groundDecoration = decor;
}
public void addObjStack(Entity obj0, Entity obj1, Entity obj2, int level, int stx, int stz, int y, int bitset) {
public void addObjStack(Entity topObj, Entity bottomObj, Entity middleObj, int level, int stx, int stz, int y, int bitset) {
SceneObjStack stack = new SceneObjStack();
stack.x = (stx * 128) + 64;
stack.z = (stz * 128) + 64;
stack.y = y;
stack.bitset = bitset;
stack.obj0 = obj0;
stack.obj1 = obj1;
stack.obj2 = obj2;
stack.topObj = topObj;
stack.bottomObj = bottomObj;
stack.middleObj = middleObj;
int stackOffset = 0;
@@ -1763,14 +1763,14 @@ public class Scene {
}
private static void drawObjStack(SceneObjStack stack, int offset) {
if (stack.obj1 != null) {
stack.obj1.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, stack.x - eyeX, stack.y - eyeY - offset, stack.z - eyeZ, stack.bitset);
if (stack.bottomObj != null) {
stack.bottomObj.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, stack.x - eyeX, stack.y - eyeY - offset, stack.z - eyeZ, stack.bitset);
}
if (stack.obj2 != null) {
stack.obj2.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, stack.x - eyeX, stack.y - eyeY - offset, stack.z - eyeZ, stack.bitset);
if (stack.middleObj != null) {
stack.middleObj.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, stack.x - eyeX, stack.y - eyeY - offset, stack.z - eyeZ, stack.bitset);
}
if (stack.obj0 != null) {
stack.obj0.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, stack.x - eyeX, stack.y - eyeY - offset, stack.z - eyeZ, stack.bitset);
if (stack.topObj != null) {
stack.topObj.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, stack.x - eyeX, stack.y - eyeY - offset, stack.z - eyeZ, stack.bitset);
}
}
+3 -3
View File
@@ -7,9 +7,9 @@ public class SceneObjStack {
public int y;
public int x;
public int z;
public Entity obj0;
public Entity obj1;
public Entity obj2;
public Entity topObj;
public Entity bottomObj;
public Entity middleObj;
public int bitset;
public int offset;
+1 -1
View File
@@ -36,7 +36,7 @@ public class SeqType {
public int[] transformIDs;
/**
* Auxiliary transform indices appear to only be used by a {@link IfType} of type <code>6</code> as seen in {@link Game#drawParentComponent(IfType, int, int, int)}.
* Auxiliary transform indices appear to only be used by a {@link IfType} of type <code>6</code> as seen in {@link Game#drawParentInterface(IfType, int, int, int)}.
*/
public int[] auxiliaryTransformIDs;