Organized incoming packets

Organized menu options
Added additional debug info
Increased maximum occluders from 500 to 1000
Made occluders generate more often
This commit is contained in:
thedaneeffect committed 2023-01-04 22:13:03 -05:00
1 parent e5072ee11a
commit d6ddc1dd6c
8 files changed
+2803 -2430

No files matched your search

+2663 -2316
View File
File diff suppressed because it is too large. Load diff
+7
View File
@@ -10,6 +10,7 @@ import java.io.IOException;
public abstract class GameShell extends JComponent implements Runnable, MouseListener, MouseMotionListener, KeyListener, FocusListener, WindowListener {
public final long[] otim = new long[10];
public final double[] frameTime = new double[100];
public final int[] actionKey = new int[128];
public final int[] keyQueue = new int[128];
public int state;
@@ -72,6 +73,7 @@ public abstract class GameShell extends JComponent implements Runnable, MouseLis
load();
int opos = 0;
int fpos = 0;
int ratio = 256;
int delta = 1;
int count = 0;
@@ -139,6 +141,8 @@ public abstract class GameShell extends JComponent implements Runnable, MouseLis
intex++;
}
long time = System.nanoTime();
for (; count < 256; count += ratio) {
mouseClickButton = lastMouseClickButton;
mouseClickX = lastMouseClickX;
@@ -157,6 +161,9 @@ public abstract class GameShell extends JComponent implements Runnable, MouseLis
draw();
frameTime[fpos] = (double)(System.nanoTime() - time) / 1_000_000.0;
fpos = (fpos + 1) % frameTime.length;
if (debug) {
System.out.println("ntime:" + ntime);
for (int i = 0; i < 10; i++) {
+2 -2
View File
@@ -103,9 +103,9 @@ public class LocEntity extends Entity {
int low = varbit.lsb;
int high = varbit.msb;
int mask = Game.BITMASK[high - low];
value = (game.variables[varp] >> low) & mask;
value = (game.varps[varp] >> low) & mask;
} else if (varp != -1) {
value = game.variables[varp];
value = game.varps[varp];
}
if ((value < 0) || (value >= overrideTypeIDs.length) || (overrideTypeIDs[value] == -1)) {
+2 -2
View File
@@ -230,9 +230,9 @@ public class LocType {
int low = varbit.lsb;
int high = varbit.msb;
int mask = Game.BITMASK[high - low];
value = (game.variables[varp] >> low) & mask;
value = (game.varps[varp] >> low) & mask;
} else if (varp != -1) {
value = game.variables[varp];
value = game.varps[varp];
}
if ((value < 0) || (value >= overrideTypeIDs.length) || (overrideTypeIDs[value] == -1)) {
+2 -2
View File
@@ -147,9 +147,9 @@ public class NPCType {
int lsb = vb.lsb;
int msb = vb.msb;
int mask = Game.BITMASK[msb - lsb];
value = (game.variables[varp] >> lsb) & mask;
value = (game.varps[varp] >> lsb) & mask;
} else if (varpID != -1) {
value = game.variables[varpID];
value = game.varps[varpID];
}
if ((value < 0) || (value >= overrides.length) || (overrides[value] == -1)) {
+78 -67
View File
@@ -5,7 +5,7 @@ public final class PacketIn {
public static final int CAMERA_DISABLE_CINEMATIC = 107;
public static final int CAMERA_EFFECT = 35;
public static final int CAMERA_LOOK_AT = 177;
public static final int CAMERA_SET_POSITION = 166;
public static final int CAMERA_POSITION = 166;
public static final int CHAT_COMPONENT = 164;
public static final int CHAT_COMPONENT_STICKY = 218;
public static final int CHAT_MESSAGE = 196;
@@ -36,19 +36,30 @@ public final class PacketIn {
public static final int INVENTORY_UPDATE = 34;
public static final int JINGLE = 121;
public static final int LOCAL_PLAYER = 249;
public static final int LOC_PLACE = 151;
public static final int LOC_REMOVE = 101;
public static final int LOC_UPDATE = 160;
public static final int LOGIN_INFO = 176;
public static final int MESSAGE = 253;
public static final int MINIMAP_STATE = 99;
public static final int MULTIZONE = 61;
public static final int OBJ_PLACE = 44;
public static final int OBJ_REMOVE = 156;
public static final int OBJ_REVEAL = 215;
public static final int OBJ_UPDATE = 84;
public static final int PLAYER_LOC = 147;
public static final int PLAYER_OPTION = 104;
public static final int PRIVACY_SETTINGS = 206;
public static final int RESTORE_VARS = 68;
public static final int PROJECTILE = 117;
public static final int RESTORE_VARPS = 68;
public static final int SCENE_LOAD = 73;
public static final int SCENE_LOAD_INSTANCED = 241;
public static final int SCENE_RESET_SEQ = 1;
public static final int SKILL = 134;
public static final int SONG = 74;
public static final int SOUND = 174;
public static final int SPATIAL_SOUND = 105;
public static final int SPOTANIM = 4;
public static final int SYNC_NPCS = 65;
public static final int SYNC_PLAYERS = 81;
public static final int SYSTEM_UPDATE = 114;
@@ -66,72 +77,72 @@ public final class PacketIn {
public static final int ZONE_UPDATE = 60;
static {
SIZE[4] = 6;
SIZE[8] = 4;
SIZE[24] = 1;
SIZE[34] = -2;
SIZE[35] = 4;
SIZE[36] = 3;
SIZE[44] = 5;
SIZE[SPOTANIM] = 6;
SIZE[COMPONENT_MODEL] = 4;
SIZE[TAB_HINT] = 1;
SIZE[INVENTORY_UPDATE] = -2;
SIZE[CAMERA_EFFECT] = 4;
SIZE[VARP_BYTE] = 3;
SIZE[OBJ_PLACE] = 5;
SIZE[47] = 6;
SIZE[50] = 9;
SIZE[53] = -2;
SIZE[60] = -2;
SIZE[61] = 1;
SIZE[64] = 2;
SIZE[65] = -2;
SIZE[70] = 6;
SIZE[71] = 3;
SIZE[72] = 2;
SIZE[73] = 4;
SIZE[74] = 2;
SIZE[75] = 4;
SIZE[79] = 4;
SIZE[81] = -2;
SIZE[84] = 7;
SIZE[85] = 2;
SIZE[87] = 6;
SIZE[97] = 2;
SIZE[99] = 1;
SIZE[101] = 2;
SIZE[104] = -1;
SIZE[105] = 4;
SIZE[106] = 1;
SIZE[110] = 1;
SIZE[114] = 2;
SIZE[117] = 15;
SIZE[121] = 4;
SIZE[122] = 4;
SIZE[126] = -2;
SIZE[134] = 6;
SIZE[142] = 2;
SIZE[147] = 14;
SIZE[151] = 4;
SIZE[156] = 3;
SIZE[160] = 4;
SIZE[164] = 2;
SIZE[166] = 6;
SIZE[171] = 3;
SIZE[174] = 5;
SIZE[176] = 10;
SIZE[177] = 6;
SIZE[185] = 2;
SIZE[196] = -1;
SIZE[200] = 4;
SIZE[206] = 3;
SIZE[208] = 2;
SIZE[214] = -2;
SIZE[215] = 7;
SIZE[218] = 2;
SIZE[221] = 1;
SIZE[230] = 8;
SIZE[240] = 2;
SIZE[241] = -2;
SIZE[246] = 6;
SIZE[248] = 4;
SIZE[249] = 3;
SIZE[253] = -1;
SIZE[254] = 6;
SIZE[FRIEND_STATUS] = 9;
SIZE[INVENTORY] = -2;
SIZE[ZONE_UPDATE] = -2;
SIZE[MULTIZONE] = 1;
SIZE[ZONE_CLEAR] = 2;
SIZE[SYNC_NPCS] = -2;
SIZE[COMPONENT_POSITION] = 6;
SIZE[TAB_COMPONENT] = 3;
SIZE[INVENTORY_CLEAR] = 2;
SIZE[SCENE_LOAD] = 4;
SIZE[SONG] = 2;
SIZE[COMPONENT_MODEL_NPC] = 4;
SIZE[COMPONENT_SCROLL_Y] = 4;
SIZE[SYNC_PLAYERS] = -2;
SIZE[OBJ_UPDATE] = 7;
SIZE[ZONE_BASE] = 2;
SIZE[VARP_INT] = 6;
SIZE[VIEWPORT_COMPONENT] = 2;
SIZE[MINIMAP_STATE] = 1;
SIZE[LOC_REMOVE] = 2;
SIZE[PLAYER_OPTION] = -1;
SIZE[SPATIAL_SOUND] = 4;
SIZE[TAB_SELECTED] = 1;
SIZE[ENERGY] = 1;
SIZE[SYSTEM_UPDATE] = 2;
SIZE[PROJECTILE] = 15;
SIZE[JINGLE] = 4;
SIZE[COMPONENT_COLOR] = 4;
SIZE[COMPONENT_TEXT] = -2;
SIZE[SKILL] = 6;
SIZE[COMPONENT_RESET_SEQ] = 2;
SIZE[PLAYER_LOC] = 14;
SIZE[LOC_PLACE] = 4;
SIZE[OBJ_REMOVE] = 3;
SIZE[LOC_UPDATE] = 4;
SIZE[CHAT_COMPONENT] = 2;
SIZE[CAMERA_POSITION] = 6;
SIZE[COMPONENT_HIDDEN] = 3;
SIZE[SOUND] = 5;
SIZE[LOGIN_INFO] = 10;
SIZE[CAMERA_LOOK_AT] = 6;
SIZE[COMPONENT_MODEL_PLAYER] = 2;
SIZE[CHAT_MESSAGE] = -1;
SIZE[COMPONENT_SEQ] = 4;
SIZE[PRIVACY_SETTINGS] = 3;
SIZE[VIEWPORT_OVERLAY_COMPONENT] = 2;
SIZE[IGNORE_LIST] = -2;
SIZE[OBJ_REVEAL] = 7;
SIZE[CHAT_COMPONENT_STICKY] = 2;
SIZE[FRIENDSERVER_STATUS] = 1;
SIZE[COMPONENT_MODEL_ROTATION] = 8;
SIZE[WEIGHT] = 2;
SIZE[SCENE_LOAD_INSTANCED] = -2;
SIZE[COMPONENT_MODEL_OBJ] = 6;
SIZE[VIEWPORT_AND_SIDEBAR_COMPONENTS] = 4;
SIZE[LOCAL_PLAYER] = 3;
SIZE[MESSAGE] = -1;
SIZE[HINT] = 6;
}
private PacketIn() {
+47 -39
View File
@@ -102,10 +102,12 @@ public class Scene {
public static int clickTileX = -1;
public static int clickTileZ = -1;
public static int[] levelOccluderCount = new int[LEVEL_COUNT];
public static SceneOccluder[][] levelOccluders = new SceneOccluder[LEVEL_COUNT][500];
public static SceneOccluder[][] levelOccluders = new SceneOccluder[LEVEL_COUNT][1000];
public static boolean disableOccluders;
public static int activeOccluderCount;
public static int activeWallOccluderCount;
public static int activeGroundOccluderCount;
public static int tilesCulled;
public static DoublyLinkedList drawTileQueue = new DoublyLinkedList();
public static boolean[][][][] visibilityMatrix = new boolean[8][32][51][51];
public static boolean[][] visibilityMap;
@@ -1057,10 +1059,10 @@ public class Scene {
}
}
public void method312(int i, int j) {
public void click(int mouseY, int mouseX) {
takingInput = true;
mouseX = j;
mouseY = i;
Scene.mouseX = mouseX;
Scene.mouseY = mouseY;
clickTileX = -1;
clickTileZ = -1;
}
@@ -1995,12 +1997,17 @@ public class Scene {
}
public void updateActiveOccluders() {
int count = levelOccluderCount[topLevel];
SceneOccluder[] occluders = levelOccluders[topLevel];
activeOccluderCount = 0;
activeGroundOccluderCount = 0;
activeWallOccluderCount = 0;
tilesCulled=0;
if (disableOccluders) {
return;
}
int count = levelOccluderCount[topLevel];
SceneOccluder[] occluders = levelOccluders[topLevel];
for (int i = 0; i < count; i++) {
SceneOccluder occluder = occluders[i];
@@ -2051,10 +2058,10 @@ public class Scene {
deltaMinX = -deltaMinX;
}
occluder.minDeltaZ = ((occluder.minZ - eyeZ) << 8) / deltaMinX;
occluder.maxDeltaZ = ((occluder.maxZ - eyeZ) << 8) / deltaMinX;
occluder.minDeltaY = ((occluder.minY - eyeY) << 8) / deltaMinX;
occluder.maxDeltaY = ((occluder.maxY - eyeY) << 8) / deltaMinX;
occluder.minDeltaZ = ((occluder.minZ - eyeZ) << 10) / deltaMinX;
occluder.maxDeltaZ = ((occluder.maxZ - eyeZ) << 10) / deltaMinX;
occluder.minDeltaY = ((occluder.minY - eyeY) << 10) / deltaMinX;
occluder.maxDeltaY = ((occluder.maxY - eyeY) << 10) / deltaMinX;
activeOccluders[activeOccluderCount++] = occluder;
activeWallOccluderCount++;
continue;
@@ -2104,10 +2111,10 @@ public class Scene {
deltaMinZ = -deltaMinZ;
}
occluder.minDeltaX = ((occluder.minX - eyeX) << 8) / deltaMinZ;
occluder.maxDeltaX = ((occluder.maxX - eyeX) << 8) / deltaMinZ;
occluder.minDeltaY = ((occluder.minY - eyeY) << 8) / deltaMinZ;
occluder.maxDeltaY = ((occluder.maxY - eyeY) << 8) / deltaMinZ;
occluder.minDeltaX = ((occluder.minX - eyeX) << 10) / deltaMinZ;
occluder.maxDeltaX = ((occluder.maxX - eyeX) << 10) / deltaMinZ;
occluder.minDeltaY = ((occluder.minY - eyeY) << 10) / deltaMinZ;
occluder.maxDeltaY = ((occluder.maxY - eyeY) << 10) / deltaMinZ;
activeOccluders[activeOccluderCount++] = occluder;
activeWallOccluderCount++;
} else if (occluder.type == 4) {
@@ -2156,10 +2163,10 @@ public class Scene {
if (ok) {
occluder.mode = 5;
occluder.minDeltaX = ((occluder.minX - eyeX) << 8) / deltaMaxY;
occluder.maxDeltaX = ((occluder.maxX - eyeX) << 8) / deltaMaxY;
occluder.minDeltaZ = ((occluder.minZ - eyeZ) << 8) / deltaMaxY;
occluder.maxDeltaZ = ((occluder.maxZ - eyeZ) << 8) / deltaMaxY;
occluder.minDeltaX = ((occluder.minX - eyeX) << 10) / deltaMaxY;
occluder.maxDeltaX = ((occluder.maxX - eyeX) << 10) / deltaMaxY;
occluder.minDeltaZ = ((occluder.minZ - eyeZ) << 10) / deltaMaxY;
occluder.maxDeltaZ = ((occluder.maxZ - eyeZ) << 10) / deltaMaxY;
activeOccluders[activeOccluderCount++] = occluder;
activeGroundOccluderCount++;
}
@@ -2184,6 +2191,7 @@ public class Scene {
if (occluded(sx + 1, levelHeightmaps[level][x][z], sz + 1) && occluded((sx + 128) - 1, levelHeightmaps[level][x + 1][z], sz + 1) && occluded((sx + 128) - 1, levelHeightmaps[level][x + 1][z + 1], (sz + 128) - 1) && occluded(sx + 1, levelHeightmaps[level][x][z + 1], (sz + 128) - 1)) {
levelTileOcclusionCycles[level][x][z] = Scene.cycle;
tilesCulled++;
return true;
} else {
levelTileOcclusionCycles[level][x][z] = -Scene.cycle;
@@ -2378,10 +2386,10 @@ public class Scene {
continue;
}
int minZ = occluder.minZ + ((occluder.minDeltaZ * dx) >> 8);
int maxZ = occluder.maxZ + ((occluder.maxDeltaZ * dx) >> 8);
int minY = occluder.minY + ((occluder.minDeltaY * dx) >> 8);
int maxY = occluder.maxY + ((occluder.maxDeltaY * dx) >> 8);
int minZ = occluder.minZ + ((occluder.minDeltaZ * dx) >> 10);
int maxZ = occluder.maxZ + ((occluder.maxDeltaZ * dx) >> 10);
int minY = occluder.minY + ((occluder.minDeltaY * dx) >> 10);
int maxY = occluder.maxY + ((occluder.maxDeltaY * dx) >> 10);
if ((z >= minZ) && (z <= maxZ) && (y >= minY) && (y <= maxY)) {
return true;
}
@@ -2390,10 +2398,10 @@ public class Scene {
if (dx <= 0) {
continue;
}
int minZ = occluder.minZ + ((occluder.minDeltaZ * dx) >> 8);
int macZ = occluder.maxZ + ((occluder.maxDeltaZ * dx) >> 8);
int minY = occluder.minY + ((occluder.minDeltaY * dx) >> 8);
int maxY = occluder.maxY + ((occluder.maxDeltaY * dx) >> 8);
int minZ = occluder.minZ + ((occluder.minDeltaZ * dx) >> 10);
int macZ = occluder.maxZ + ((occluder.maxDeltaZ * dx) >> 10);
int minY = occluder.minY + ((occluder.minDeltaY * dx) >> 10);
int maxY = occluder.maxY + ((occluder.maxDeltaY * dx) >> 10);
if ((z >= minZ) && (z <= macZ) && (y >= minY) && (y <= maxY)) {
return true;
}
@@ -2402,10 +2410,10 @@ public class Scene {
if (dz <= 0) {
continue;
}
int minX = occluder.minX + ((occluder.minDeltaX * dz) >> 8);
int maxX = occluder.maxX + ((occluder.maxDeltaX * dz) >> 8);
int minY = occluder.minY + ((occluder.minDeltaY * dz) >> 8);
int maxY = occluder.maxY + ((occluder.maxDeltaY * dz) >> 8);
int minX = occluder.minX + ((occluder.minDeltaX * dz) >> 10);
int maxX = occluder.maxX + ((occluder.maxDeltaX * dz) >> 10);
int minY = occluder.minY + ((occluder.minDeltaY * dz) >> 10);
int maxY = occluder.maxY + ((occluder.maxDeltaY * dz) >> 10);
if ((x >= minX) && (x <= maxX) && (y >= minY) && (y <= maxY)) {
return true;
}
@@ -2414,10 +2422,10 @@ public class Scene {
if (dz <= 0) {
continue;
}
int minX = occluder.minX + ((occluder.minDeltaX * dz) >> 8);
int maxX = occluder.maxX + ((occluder.maxDeltaX * dz) >> 8);
int minY = occluder.minY + ((occluder.minDeltaY * dz) >> 8);
int maxY = occluder.maxY + ((occluder.maxDeltaY * dz) >> 8);
int minX = occluder.minX + ((occluder.minDeltaX * dz) >> 10);
int maxX = occluder.maxX + ((occluder.maxDeltaX * dz) >> 10);
int minY = occluder.minY + ((occluder.minDeltaY * dz) >> 10);
int maxY = occluder.maxY + ((occluder.maxDeltaY * dz) >> 10);
if ((x >= minX) && (x <= maxX) && (y >= minY) && (y <= maxY)) {
return true;
}
@@ -2426,10 +2434,10 @@ public class Scene {
if (dy <= 0) {
continue;
}
int minX = occluder.minX + ((occluder.minDeltaX * dy) >> 8);
int maxX = occluder.maxX + ((occluder.maxDeltaX * dy) >> 8);
int minZ = occluder.minZ + ((occluder.minDeltaZ * dy) >> 8);
int maxZ = occluder.maxZ + ((occluder.maxDeltaZ * dy) >> 8);
int minX = occluder.minX + ((occluder.minDeltaX * dy) >> 10);
int maxX = occluder.maxX + ((occluder.maxDeltaX * dy) >> 10);
int minZ = occluder.minZ + ((occluder.minDeltaZ * dy) >> 10);
int maxZ = occluder.maxZ + ((occluder.maxDeltaZ * dy) >> 10);
if ((x >= minX) && (x <= maxX) && (z >= minZ) && (z <= maxZ)) {
return true;
}
+2 -2
View File
@@ -827,7 +827,7 @@ public class SceneBuilder {
int area = ((maxLevel + 1) - minLevel) * ((maxTileX - minTileX) + 1);
if (area >= 8) {
if (area >= 2) {
int minY = levelHeightmap[maxLevel][minTileX][tileZ] - 240;
int maxY = levelHeightmap[minLevel][minTileX][tileZ];
@@ -881,7 +881,7 @@ public class SceneBuilder {
int area = ((maxLevel + 1) - minLevel) * ((maxTileZ - minTileZ) + 1);
if (area >= 8) {
if (area >= 2) {
int minY = levelHeightmap[maxLevel][tileX][minTileZ] - 240;
int maxY = levelHeightmap[minLevel][tileX][minTileZ];