Organized npc/player sync and other random things

This commit is contained in:
thedaneeffect committed 2023-01-05 14:08:41 -05:00
1 parent 65b84fdeaa
commit 5461562bb9
8 files changed
+486 -440

No files matched your search

+28 -27
View File
@@ -179,46 +179,47 @@ public class Draw3D {
}
}
public static int getAverageTextureRGB(int textureId) {
if (averageTextureRGB[textureId] != 0) {
return averageTextureRGB[textureId];
public static int getAverageTextureRGB(int textureID) {
if (averageTextureRGB[textureID] != 0) {
return averageTextureRGB[textureID];
}
int r = 0;
int g = 0;
int b = 0;
int length = texturePalette[textureId].length;
int length = texturePalette[textureID].length;
for (int i = 0; i < length; i++) {
r += (texturePalette[textureId][i] >> 16) & 0xff;
g += (texturePalette[textureId][i] >> 8) & 0xff;
b += texturePalette[textureId][i] & 0xff;
r += (texturePalette[textureID][i] >> 16) & 0xff;
g += (texturePalette[textureID][i] >> 8) & 0xff;
b += texturePalette[textureID][i] & 0xff;
}
int rgb = ((r / length) << 16) + ((g / length) << 8) + (b / length);
rgb = setGamma(rgb, 1.3999999999999999D);
if (rgb == 0) {
rgb = 1;
}
averageTextureRGB[textureId] = rgb;
averageTextureRGB[textureID] = rgb;
return rgb;
}
/**
* Pushes the texels of the provided texture id back into the pool.
* Pushes the texels of the provided texture id back into the pool. This causes the texture to be regenerated the
* next time {@link #getTexels(int)} is called for that <code>textureID</code>. This method is actively used for
* scrolling textures by {@link Game#updateTextures(int)}
*
* @param textureId the texture id.
* @param textureID the texture id.
*/
public static void unloadTexture(int textureId) {
if (activeTexels[textureId] == null) {
return;
public static void pushTexture(int textureID) {
if (activeTexels[textureID] != null) {
texelPool[poolSize++] = activeTexels[textureID];
activeTexels[textureID] = null;
}
texelPool[poolSize++] = activeTexels[textureId];
activeTexels[textureId] = null;
}
public static int[] getTexels(int textureId) {
textureCycle[textureId] = cycle++;
public static int[] getTexels(int textureID) {
textureCycle[textureID] = cycle++;
if (activeTexels[textureId] != null) {
return activeTexels[textureId];
if (activeTexels[textureID] != null) {
return activeTexels[textureID];
}
int[] texels;
@@ -241,18 +242,18 @@ public class Draw3D {
activeTexels[selected] = null;
}
activeTexels[textureId] = texels;
Image8 texture = textures[textureId];
int[] palette = texturePalette[textureId];
activeTexels[textureID] = texels;
Image8 texture = textures[textureID];
int[] palette = texturePalette[textureID];
if (lowmem) {
textureTranslucent[textureId] = false;
textureTranslucent[textureID] = false;
for (int i = 0; i < 4096; i++) {
int rgb = texels[i] = palette[texture.pixels[i]] & 0xf8f8ff;
if (rgb == 0) {
textureTranslucent[textureId] = true;
textureTranslucent[textureID] = true;
}
texels[4096 + i] = (rgb - (rgb >>> 3)) & 0xf8f8ff;
@@ -273,7 +274,7 @@ public class Draw3D {
}
}
textureTranslucent[textureId] = false;
textureTranslucent[textureID] = false;
for (int i = 0; i < 16384; i++) {
texels[i] &= 0xf8f8ff;
@@ -281,7 +282,7 @@ public class Draw3D {
int rgb = texels[i];
if (rgb == 0) {
textureTranslucent[textureId] = true;
textureTranslucent[textureID] = true;
}
texels[16384 + i] = (rgb - (rgb >>> 3)) & 0xf8f8ff;
@@ -397,7 +398,7 @@ public class Draw3D {
}
for (int textureID = 0; textureID < 50; textureID++) {
unloadTexture(textureID);
pushTexture(textureID);
}
}
+422 -391
View File
File diff suppressed because it is too large. Load diff
+10 -3
View File
@@ -91,7 +91,7 @@ public class IfType {
iface.inventorySlotObjID = new int[iface.width * iface.height];
iface.inventorySlotObjCount = new int[iface.width * iface.height];
iface.inventoryDraggable = in.read8U() == 1;
iface.aBoolean249 = in.read8U() == 1;
iface.inventoryInteractable = in.read8U() == 1;
iface.inventoryUsable = in.read8U() == 1;
iface.inventoryMoveReplaces = in.read8U() == 1;
iface.inventoryMarginX = in.read8U();
@@ -205,7 +205,7 @@ public class IfType {
iface.color = in.read32();
iface.inventoryMarginX = in.read16();
iface.inventoryMarginY = in.read16();
iface.aBoolean249 = in.read8U() == 1;
iface.inventoryInteractable = in.read8U() == 1;
iface.inventoryOptions = new String[5];
for (int k4 = 0; k4 < 5; k4++) {
iface.inventoryOptions[k4] = in.readString();
@@ -265,7 +265,7 @@ public class IfType {
}
}
public boolean aBoolean249;
public boolean inventoryInteractable;
public int activeColor;
public int activeHoverColor;
public Image24 activeImage;
@@ -308,6 +308,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;
+7 -7
View File
@@ -5,23 +5,23 @@
public class MouseRecorder implements Runnable {
public final Object lock = new Object();
public final Game aGame805;
public final Game game;
public final int[] y = new int[500];
public final int[] x = new int[500];
public boolean aBoolean808 = true;
public boolean active = true;
public int length;
public MouseRecorder(Game game1) {
aGame805 = game1;
public MouseRecorder(Game game) {
this.game = game;
}
@Override
public void run() {
while (aBoolean808) {
while (active) {
synchronized (lock) {
if (length < 500) {
x[length] = aGame805.mouseX;
y[length] = aGame805.mouseY;
x[length] = game.mouseX;
y[length] = game.mouseY;
length++;
}
}
+9 -6
View File
@@ -74,16 +74,19 @@ public class NPCType {
public long uid = -1L;
public int turnSpeed = 32;
public int seqTurnLeftID = -1;
public boolean aBoolean84 = true;
public boolean interactable = true;
public int anInt85;
public int anInt86 = 128;
public boolean aBoolean87 = true;
public boolean showOnMinimap = true;
public int[] overrides;
public byte[] desc;
public int unusedInt1 = -1;
public int anInt91 = 128;
public int anInt92;
public boolean aBoolean93 = false;
/**
* Causes the npc to render on top of other npcs.
*/
public boolean important = false;
public int[] modelIDs;
public int unusedInt2 = -1;
@@ -285,7 +288,7 @@ public class NPCType {
} else if (i == 92) {
unusedInt1 = buffer.read16U();
} else if (i == 93) {
aBoolean87 = false;
showOnMinimap = false;
} else if (i == 95) {
level = buffer.read16U();
} else if (i == 97) {
@@ -293,7 +296,7 @@ public class NPCType {
} else if (i == 98) {
anInt86 = buffer.read16U();
} else if (i == 99) {
aBoolean93 = true;
important = true;
} else if (i == 100) {
anInt85 = buffer.read();
} else if (i == 101) {
@@ -320,7 +323,7 @@ public class NPCType {
}
}
} else if (i == 107) {
aBoolean84 = false;
interactable = false;
}
} while (true);
}
+3 -3
View File
@@ -34,7 +34,7 @@ public class OnDemand implements Runnable {
public int partOffset;
public int partAvailable;
public int[] midiIndex;
public int anInt1349;
public int failCount;
public int[] mapLandFile;
public int loadedPretechFiles;
public boolean running = true;
@@ -314,7 +314,7 @@ public class OnDemand implements Runnable {
out.write(bbuf, 0, 4);
heartbeatCycle = 0;
anInt1349 = -10000;
failCount = -10000;
return;
} catch (IOException e) {
e.printStackTrace();
@@ -328,7 +328,7 @@ public class OnDemand implements Runnable {
in = null;
out = null;
partAvailable = 0;
anInt1349++;
failCount++;
}
public int getSeqFrameCount() {
+5 -1
View File
@@ -43,7 +43,11 @@ public class PathingEntity extends Entity {
public int targetTileX;
public int targetTileZ;
public int size = 1;
public boolean aBoolean1541 = false;
/**
* Passed to {@link Scene#addTemporary(Entity, int, int, int, int, int, int, boolean, int)} to provide an additional
* tile worth of draw padding ahead of this entity for things like animations that extend past the normal boundary.
*/
public boolean needsForwardDrawPadding = false;
public int seqPathLength;
public int forceMoveStartSceneTileX;
public int forceMoveEndSceneTileX;
+2 -2
View File
@@ -37,7 +37,7 @@ public class VarpType {
public int unusedInt1;
public boolean unusedBool0 = false;
public boolean unusedBool1 = true;
public int anInt709;
public int type;
public boolean unusedBool2 = false;
public int unusedInt2;
public int unusedInt3;
@@ -62,7 +62,7 @@ public class VarpType {
} else if (op == 4) {
unusedBool1 = false;
} else if (op == 5) {
anInt709 = buffer.read16U();
type = buffer.read16U();
} else if (op == 6) {
unusedBool2 = true;
} else if (op == 7) {