Renamed: OnDemand#prefetches
Renamed: OnDemand#buffer Refactored: OnDemand#validate Renamed: OnDemand#handlePending Renamed: OnDemand#handleExtras Renamed: OnDemand#hasMidi Refactored: Scene#wallVisible Refactored: Scene#visible Refactored: Scene#prefetchLocs Renamed: Signlink#dnslookup
This commit is contained in:
1 parent
bd4703f511
commit
3a09dac490
9 files changed
+187
-186
No files matched your search
+27
-21
@@ -871,8 +871,8 @@ public class Game extends GameShell {
|
||||
|
||||
total = ondemand.getFileCount(0);
|
||||
|
||||
for (int i = 0; i < total; i++) {
|
||||
int flags = ondemand.getModelFlags(i);
|
||||
for (int modelID = 0; modelID < total; modelID++) {
|
||||
int flags = ondemand.getModelFlags(modelID);
|
||||
byte priority = 0;
|
||||
if ((flags & 8) != 0) {
|
||||
priority = 10;
|
||||
@@ -889,20 +889,22 @@ public class Game extends GameShell {
|
||||
} else if ((flags & 4) != 0) {
|
||||
priority = 4;
|
||||
}
|
||||
|
||||
if ((flags & 1) != 0) {
|
||||
priority = 3;
|
||||
}
|
||||
|
||||
if (priority != 0) {
|
||||
ondemand.prefetch(priority, 0, i);
|
||||
ondemand.prefetch(priority, 0, modelID);
|
||||
}
|
||||
}
|
||||
ondemand.prefetchMaps(members);
|
||||
|
||||
if (!lowmem) {
|
||||
int l = ondemand.getFileCount(2);
|
||||
for (int i3 = 1; i3 < l; i3++) {
|
||||
if (ondemand.method569(i3)) {
|
||||
ondemand.prefetch((byte) 1, 2, i3);
|
||||
int midiCount = ondemand.getFileCount(2);
|
||||
for (int midi = 1; midi < midiCount; midi++) {
|
||||
if (ondemand.hasMidi(midi)) {
|
||||
ondemand.prefetch((byte) 1, 2, midi);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -921,33 +923,33 @@ public class Game extends GameShell {
|
||||
imageMapedge = new Image24(archiveMedia, "mapedge", 0);
|
||||
imageMapedge.crop();
|
||||
try {
|
||||
for (int k3 = 0; k3 < 100; k3++) {
|
||||
imageMapscene[k3] = new Image8(archiveMedia, "mapscene", k3);
|
||||
for (int i = 0; i < 100; i++) {
|
||||
imageMapscene[i] = new Image8(archiveMedia, "mapscene", i);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
for (int l3 = 0; l3 < 100; l3++) {
|
||||
imageMapfunction[l3] = new Image24(archiveMedia, "mapfunction", l3);
|
||||
for (int i = 0; i < 100; i++) {
|
||||
imageMapfunction[i] = new Image24(archiveMedia, "mapfunction", i);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
for (int i4 = 0; i4 < 20; i4++) {
|
||||
imageHitmarks[i4] = new Image24(archiveMedia, "hitmarks", i4);
|
||||
for (int i = 0; i < 20; i++) {
|
||||
imageHitmarks[i] = new Image24(archiveMedia, "hitmarks", i);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
for (int j4 = 0; j4 < 20; j4++) {
|
||||
imageHeadicons[j4] = new Image24(archiveMedia, "headicons", j4);
|
||||
for (int i = 0; i < 20; i++) {
|
||||
imageHeadicons[i] = new Image24(archiveMedia, "headicons", i);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
imageMapmarker0 = new Image24(archiveMedia, "mapmarker", 0);
|
||||
imageMapmarker1 = new Image24(archiveMedia, "mapmarker", 1);
|
||||
for (int k4 = 0; k4 < 8; k4++) {
|
||||
imageCrosses[k4] = new Image24(archiveMedia, "cross", k4);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
imageCrosses[i] = new Image24(archiveMedia, "cross", i);
|
||||
}
|
||||
imageMapdot0 = new Image24(archiveMedia, "mapdots", 0);
|
||||
imageMapdot1 = new Image24(archiveMedia, "mapdots", 1);
|
||||
@@ -1791,7 +1793,7 @@ public class Game extends GameShell {
|
||||
|
||||
System.gc();
|
||||
Draw3D.initPool(20);
|
||||
ondemand.method566();
|
||||
ondemand.clearPrefetches();
|
||||
|
||||
int minMapX = ((sceneCenterZoneX - 6) / 8) - 1;
|
||||
int maxMapX = ((sceneCenterZoneX + 6) / 8) + 1;
|
||||
@@ -11483,14 +11485,18 @@ public class Game extends GameShell {
|
||||
if ((lastAddress != 0) && (viewportInterfaceID == -1)) {
|
||||
Signlink.dnslookup(StringUtil.formatIPv4(lastAddress));
|
||||
closeInterfaces();
|
||||
char cmpType = 650;
|
||||
|
||||
int reportAbuseContentType = 650;
|
||||
|
||||
if ((daysSinceRecoveriesChanged != 201) || (warnMembersInNonMembers == 1)) {
|
||||
cmpType = 655;
|
||||
reportAbuseContentType = 655;
|
||||
}
|
||||
|
||||
reportAbuseInput = "";
|
||||
reportAbuseMuteOption = false;
|
||||
|
||||
for (int i = 0; i < IfType.instances.length; i++) {
|
||||
if ((IfType.instances[i] == null) || (IfType.instances[i].contentType != cmpType)) {
|
||||
if ((IfType.instances[i] == null) || (IfType.instances[i].contentType != reportAbuseContentType)) {
|
||||
continue;
|
||||
}
|
||||
viewportInterfaceID = IfType.instances[i].parentID;
|
||||
|
||||
@@ -65,8 +65,8 @@ public class IdkType {
|
||||
return true;
|
||||
}
|
||||
boolean loaded = true;
|
||||
for (int modelId : modelIDs) {
|
||||
if (!Model.validate(modelId)) {
|
||||
for (int modelID : modelIDs) {
|
||||
if (!Model.validate(modelID)) {
|
||||
loaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -657,10 +657,10 @@ public class Model extends Entity {
|
||||
faceCount++;
|
||||
}
|
||||
|
||||
for (int tface = 0; tface < model.texturedFaceCount; tface++) {
|
||||
texturedVertexA[texturedFaceCount] = addVertex(model, model.texturedVertexA[tface]);
|
||||
texturedVertexB[texturedFaceCount] = addVertex(model, model.texturedVertexB[tface]);
|
||||
texturedVertexC[texturedFaceCount] = addVertex(model, model.texturedVertexC[tface]);
|
||||
for (int face = 0; face < model.texturedFaceCount; face++) {
|
||||
texturedVertexA[texturedFaceCount] = addVertex(model, model.texturedVertexA[face]);
|
||||
texturedVertexB[texturedFaceCount] = addVertex(model, model.texturedVertexB[face]);
|
||||
texturedVertexC[texturedFaceCount] = addVertex(model, model.texturedVertexC[face]);
|
||||
texturedFaceCount++;
|
||||
}
|
||||
|
||||
|
||||
+22
-14
@@ -87,9 +87,9 @@ public class ObjType {
|
||||
|
||||
if (amount > 1) {
|
||||
int newID = -1;
|
||||
for (int j1 = 0; j1 < 10; j1++) {
|
||||
if ((amount >= type.stackCount[j1]) && (type.stackCount[j1] != 0)) {
|
||||
newID = type.stackID[j1];
|
||||
for (int stack = 0; stack < 10; stack++) {
|
||||
if ((amount >= type.stackCount[stack]) && (type.stackCount[stack] != 0)) {
|
||||
newID = type.stackID[stack];
|
||||
}
|
||||
}
|
||||
if (newID != -1) {
|
||||
@@ -103,13 +103,13 @@ public class ObjType {
|
||||
return null;
|
||||
}
|
||||
|
||||
// this will typically be the certificate item for noted stuff
|
||||
Image24 originalIcon = null;
|
||||
// this will be the original item icon to draw over the certificate icon (if present)
|
||||
Image24 linkedIcon = null;
|
||||
|
||||
if (type.certificateID != -1) {
|
||||
originalIcon = getIcon(type.linkedID, 10, -1);
|
||||
linkedIcon = getIcon(type.linkedID, 10, -1);
|
||||
|
||||
if (originalIcon == null) {
|
||||
if (linkedIcon == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -197,13 +197,13 @@ public class ObjType {
|
||||
}
|
||||
|
||||
if (type.certificateID != -1) {
|
||||
int w = originalIcon.cropW;
|
||||
int h = originalIcon.cropH;
|
||||
originalIcon.cropW = 32;
|
||||
originalIcon.cropH = 32;
|
||||
originalIcon.draw(0, 0);
|
||||
originalIcon.cropW = w;
|
||||
originalIcon.cropH = h;
|
||||
int w = linkedIcon.cropW;
|
||||
int h = linkedIcon.cropH;
|
||||
linkedIcon.cropW = 32;
|
||||
linkedIcon.cropH = 32;
|
||||
linkedIcon.draw(0, 0);
|
||||
linkedIcon.cropW = w;
|
||||
linkedIcon.cropH = h;
|
||||
}
|
||||
|
||||
if (outlineColor == 0) {
|
||||
@@ -307,6 +307,10 @@ public class ObjType {
|
||||
|
||||
Model model = Model.tryGet(modelID0);
|
||||
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (modelID1 != -1) {
|
||||
model = new Model(2, new Model[]{model, Model.tryGet(modelID1)});
|
||||
}
|
||||
@@ -364,6 +368,10 @@ public class ObjType {
|
||||
|
||||
Model model = Model.tryGet(modelID0);
|
||||
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (modelID1 != -1) {
|
||||
if (modelID2 != -1) {
|
||||
model = new Model(3, new Model[]{model, Model.tryGet(modelID1), Model.tryGet(modelID2)});
|
||||
|
||||
+63
-60
@@ -12,11 +12,10 @@ public class OnDemand implements Runnable {
|
||||
|
||||
public final DoublyLinkedList pending = new DoublyLinkedList();
|
||||
public final CRC32 crc32 = new CRC32();
|
||||
public final byte[] bbuf = new byte[500];
|
||||
public final byte[] buffer = new byte[500];
|
||||
public final byte[][] storeFilePriorities = new byte[4][];
|
||||
public final DoublyLinkedList aList_1344 = new DoublyLinkedList();
|
||||
public final DoublyLinkedList prefetches = new DoublyLinkedList();
|
||||
public final DoublyLinkedList completed = new DoublyLinkedList();
|
||||
public final byte[] aByteArray1359 = new byte[65000];
|
||||
public final LinkedList<OnDemandRequest> requests = new LinkedList<>();
|
||||
public final int[][] storeFileVersions = new int[4][];
|
||||
public final int[][] storeFileChecksums = new int[4][];
|
||||
@@ -40,7 +39,7 @@ public class OnDemand implements Runnable {
|
||||
public boolean running = true;
|
||||
public OutputStream out;
|
||||
public int[] mapPrefetched;
|
||||
public boolean aBoolean1357 = false;
|
||||
public boolean active = false;
|
||||
public int[] animIndex;
|
||||
public InputStream in;
|
||||
public Socket socket;
|
||||
@@ -54,22 +53,23 @@ public class OnDemand implements Runnable {
|
||||
public OnDemand() {
|
||||
}
|
||||
|
||||
public boolean validate(int version, int crc, byte[] src) {
|
||||
public boolean validate(int expectedVersion, int crc, byte[] src) {
|
||||
if (src != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((src == null) || (src.length < 2)) {
|
||||
return false;
|
||||
}
|
||||
int foot = src.length - 2;
|
||||
int footVersion = ((src[foot] & 0xff) << 8) + (src[foot + 1] & 0xff);
|
||||
|
||||
int fileEndPos = src.length - 2;
|
||||
int fileVersion = ((src[fileEndPos] & 0xff) << 8) + (src[fileEndPos + 1] & 0xff);
|
||||
|
||||
crc32.reset();
|
||||
crc32.update(src, 0, foot);
|
||||
int srcCrc = (int) crc32.getValue();
|
||||
if (footVersion != version) {
|
||||
return false;
|
||||
}
|
||||
return srcCrc == crc;
|
||||
crc32.update(src, 0, fileEndPos);
|
||||
|
||||
return fileVersion == expectedVersion && (int) crc32.getValue() == crc;
|
||||
|
||||
}
|
||||
|
||||
public void read() {
|
||||
@@ -77,14 +77,14 @@ public class OnDemand implements Runnable {
|
||||
int available = in.available();
|
||||
|
||||
if ((partAvailable == 0) && (available >= 6)) {
|
||||
aBoolean1357 = true;
|
||||
active = true;
|
||||
|
||||
in.read(bbuf, 0, 6);
|
||||
in.read(buffer, 0, 6);
|
||||
|
||||
int store = bbuf[0] & 0xff;
|
||||
int file = ((bbuf[1] & 0xff) << 8) + (bbuf[2] & 0xff);
|
||||
int size = ((bbuf[3] & 0xff) << 8) + (bbuf[4] & 0xff);
|
||||
int part = bbuf[5] & 0xff;
|
||||
int store = buffer[0] & 0xff;
|
||||
int file = ((buffer[1] & 0xff) << 8) + (buffer[2] & 0xff);
|
||||
int size = ((buffer[3] & 0xff) << 8) + (buffer[4] & 0xff);
|
||||
int part = buffer[5] & 0xff;
|
||||
|
||||
current = null;
|
||||
|
||||
@@ -134,8 +134,8 @@ public class OnDemand implements Runnable {
|
||||
}
|
||||
|
||||
if ((partAvailable > 0) && (available >= partAvailable)) {
|
||||
aBoolean1357 = true;
|
||||
byte[] dst = bbuf;
|
||||
active = true;
|
||||
byte[] dst = buffer;
|
||||
int offset = 0;
|
||||
|
||||
if (current != null) {
|
||||
@@ -300,19 +300,19 @@ public class OnDemand implements Runnable {
|
||||
waitCycles = 0;
|
||||
}
|
||||
|
||||
bbuf[0] = (byte) request.store;
|
||||
bbuf[1] = (byte) (request.file >> 8);
|
||||
bbuf[2] = (byte) request.file;
|
||||
buffer[0] = (byte) request.store;
|
||||
buffer[1] = (byte) (request.file >> 8);
|
||||
buffer[2] = (byte) request.file;
|
||||
|
||||
if (request.important) {
|
||||
bbuf[3] = 2;
|
||||
buffer[3] = 2;
|
||||
} else if (!game.ingame) {
|
||||
bbuf[3] = 1;
|
||||
buffer[3] = 1;
|
||||
} else {
|
||||
bbuf[3] = 0;
|
||||
buffer[3] = 0;
|
||||
}
|
||||
|
||||
out.write(bbuf, 0, 4);
|
||||
out.write(buffer, 0, 4);
|
||||
heartbeatCycle = 0;
|
||||
failCount = -10000;
|
||||
return;
|
||||
@@ -381,23 +381,23 @@ public class OnDemand implements Runnable {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
aBoolean1357 = true;
|
||||
active = true;
|
||||
|
||||
for (int j = 0; j < 100; j++) {
|
||||
if (!aBoolean1357) {
|
||||
if (!active) {
|
||||
break;
|
||||
}
|
||||
|
||||
aBoolean1357 = false;
|
||||
active = false;
|
||||
|
||||
handleQueue();
|
||||
method565();
|
||||
handlePending();
|
||||
|
||||
if ((importantCount == 0) && (j >= 5)) {
|
||||
break;
|
||||
}
|
||||
|
||||
method568();
|
||||
handleExtras();
|
||||
|
||||
if (in != null) {
|
||||
read();
|
||||
@@ -453,13 +453,13 @@ public class OnDemand implements Runnable {
|
||||
|
||||
if (heartbeatCycle > 500) {
|
||||
heartbeatCycle = 0;
|
||||
bbuf[0] = 0;
|
||||
bbuf[1] = 0;
|
||||
bbuf[2] = 0;
|
||||
bbuf[3] = 10;
|
||||
buffer[0] = 0;
|
||||
buffer[1] = 0;
|
||||
buffer[2] = 0;
|
||||
buffer[3] = 10;
|
||||
|
||||
try {
|
||||
out.write(bbuf, 0, 4);
|
||||
out.write(buffer, 0, 4);
|
||||
} catch (IOException _ex) {
|
||||
waitCycles = 5000;
|
||||
}
|
||||
@@ -488,8 +488,8 @@ public class OnDemand implements Runnable {
|
||||
request.store = store;
|
||||
request.file = file;
|
||||
request.important = false;
|
||||
synchronized (aList_1344) {
|
||||
aList_1344.pushBack(request);
|
||||
synchronized (prefetches) {
|
||||
prefetches.pushBack(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,7 +569,7 @@ public class OnDemand implements Runnable {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void method565() {
|
||||
public void handlePending() {
|
||||
importantCount = 0;
|
||||
requestCount = 0;
|
||||
|
||||
@@ -596,13 +596,13 @@ public class OnDemand implements Runnable {
|
||||
pending.pushBack(request);
|
||||
importantCount++;
|
||||
send(request);
|
||||
aBoolean1357 = true;
|
||||
active = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void method566() {
|
||||
synchronized (aList_1344) {
|
||||
aList_1344.clear();
|
||||
public void clearPrefetches() {
|
||||
synchronized (prefetches) {
|
||||
prefetches.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -613,7 +613,7 @@ public class OnDemand implements Runnable {
|
||||
}
|
||||
|
||||
while (request != null) {
|
||||
aBoolean1357 = true;
|
||||
active = true;
|
||||
byte[] data = null;
|
||||
|
||||
if (game.filestores[0] != null) {
|
||||
@@ -638,7 +638,7 @@ public class OnDemand implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public void method568() {
|
||||
public void handleExtras() {
|
||||
while ((importantCount == 0) && (requestCount < 10)) {
|
||||
if (topPriority == 0) {
|
||||
break;
|
||||
@@ -646,8 +646,8 @@ public class OnDemand implements Runnable {
|
||||
|
||||
OnDemandRequest extra;
|
||||
|
||||
synchronized (aList_1344) {
|
||||
extra = (OnDemandRequest) aList_1344.pollFront();
|
||||
synchronized (prefetches) {
|
||||
extra = (OnDemandRequest) prefetches.pollFront();
|
||||
}
|
||||
|
||||
while (extra != null) {
|
||||
@@ -655,7 +655,7 @@ public class OnDemand implements Runnable {
|
||||
storeFilePriorities[extra.store][extra.file] = 0;
|
||||
pending.pushBack(extra);
|
||||
send(extra);
|
||||
aBoolean1357 = true;
|
||||
active = true;
|
||||
|
||||
if (loadedPretechFiles < totalPrefetchFiles) {
|
||||
loadedPretechFiles++;
|
||||
@@ -668,8 +668,8 @@ public class OnDemand implements Runnable {
|
||||
return;
|
||||
}
|
||||
}
|
||||
synchronized (aList_1344) {
|
||||
extra = (OnDemandRequest) aList_1344.pollFront();
|
||||
synchronized (prefetches) {
|
||||
extra = (OnDemandRequest) prefetches.pollFront();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -682,18 +682,21 @@ public class OnDemand implements Runnable {
|
||||
|
||||
priorities[file] = 0;
|
||||
|
||||
OnDemandRequest request_1 = new OnDemandRequest();
|
||||
request_1.store = store;
|
||||
request_1.file = file;
|
||||
request_1.important = false;
|
||||
pending.pushBack(request_1);
|
||||
send(request_1);
|
||||
aBoolean1357 = true;
|
||||
OnDemandRequest req = new OnDemandRequest();
|
||||
req.store = store;
|
||||
req.file = file;
|
||||
req.important = false;
|
||||
pending.pushBack(req);
|
||||
send(req);
|
||||
active = true;
|
||||
|
||||
if (loadedPretechFiles < totalPrefetchFiles) {
|
||||
loadedPretechFiles++;
|
||||
}
|
||||
|
||||
message = "Loading extra files - " + loadedPretechFiles * 100 / totalPrefetchFiles + "%";
|
||||
requestCount++;
|
||||
|
||||
if (requestCount == 10) {
|
||||
return;
|
||||
}
|
||||
@@ -703,7 +706,7 @@ public class OnDemand implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean method569(int i) {
|
||||
public boolean hasMidi(int i) {
|
||||
return midiIndex[i] == 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -206,9 +206,9 @@ public class PlayerEntity extends PathingEntity {
|
||||
appearanceHashcode += (appearances[1] - 256) >> 8;
|
||||
}
|
||||
|
||||
for (int i2 = 0; i2 < 5; i2++) {
|
||||
for (int part = 0; part < 5; part++) {
|
||||
appearanceHashcode <<= 3;
|
||||
appearanceHashcode += colors[i2];
|
||||
appearanceHashcode += colors[part];
|
||||
}
|
||||
|
||||
appearanceHashcode <<= 1;
|
||||
|
||||
+61
-70
@@ -815,12 +815,6 @@ public class Scene {
|
||||
|
||||
/**
|
||||
* Merges touching normals of all Locs (Walls, Ground Decorations, etc) and then reapplies their lighting.
|
||||
*
|
||||
* @param lightAmbient
|
||||
* @param lightAttenuation
|
||||
* @param lightSrcX
|
||||
* @param lightSrcY
|
||||
* @param lightSrcZ
|
||||
*/
|
||||
public void buildModels(int lightAmbient, int lightAttenuation, int lightSrcX, int lightSrcY, int lightSrcZ) {
|
||||
int lightMagnitude = (int) Math.sqrt((lightSrcX * lightSrcX) + (lightSrcY * lightSrcY) + (lightSrcZ * lightSrcZ));
|
||||
@@ -1390,9 +1384,6 @@ public class Scene {
|
||||
if (wall != null) {
|
||||
if ((wall.typeA & DIRECTION_ALLOW_WALL_CORNER_TYPE[direction]) != 0) {
|
||||
switch (wall.typeA) {
|
||||
/**
|
||||
* @see SceneTile#locSpans
|
||||
*/
|
||||
case 16:
|
||||
tile.checkLocSpans = 0b0011;
|
||||
tile.blockLocSpans = WALL_CORNER_TYPE_16_BLOCK_LOC_SPANS[direction];
|
||||
@@ -1418,16 +1409,16 @@ public class Scene {
|
||||
tile.checkLocSpans = 0;
|
||||
}
|
||||
|
||||
if (((wall.typeA & frontWallTypes) != 0) && !wallOccluded(occludeLevel, tileX, tileZ, wall.typeA)) {
|
||||
if (((wall.typeA & frontWallTypes) != 0) && wallVisible(occludeLevel, tileX, tileZ, wall.typeA)) {
|
||||
wall.entityA.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall.x - eyeX, wall.y - eyeY, wall.z - eyeZ, wall.bitset);
|
||||
}
|
||||
|
||||
if (((wall.typeB & frontWallTypes) != 0) && !wallOccluded(occludeLevel, tileX, tileZ, wall.typeB)) {
|
||||
if (((wall.typeB & frontWallTypes) != 0) && wallVisible(occludeLevel, tileX, tileZ, wall.typeB)) {
|
||||
wall.entityB.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall.x - eyeX, wall.y - eyeY, wall.z - eyeZ, wall.bitset);
|
||||
}
|
||||
}
|
||||
|
||||
if ((decor != null) && !occluded(occludeLevel, tileX, tileZ, decor.entity.minY)) {
|
||||
if ((decor != null) && visible(occludeLevel, tileX, tileZ, decor.entity.minY)) {
|
||||
drawWallDecor(frontWallTypes, decor, true);
|
||||
}
|
||||
|
||||
@@ -1490,7 +1481,7 @@ public class Scene {
|
||||
if (draw) {
|
||||
SceneWall wall = tile.wall;
|
||||
|
||||
if (!wallOccluded(occludeLevel, tileX, tileZ, wall.typeA)) {
|
||||
if (wallVisible(occludeLevel, tileX, tileZ, wall.typeA)) {
|
||||
wall.entityA.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall.x - eyeX, wall.y - eyeY, wall.z - eyeZ, wall.bitset);
|
||||
}
|
||||
|
||||
@@ -1599,7 +1590,7 @@ public class Scene {
|
||||
SceneLoc farthest = locBuffer[farthestIndex];
|
||||
farthest.cycle = cycle;
|
||||
|
||||
if (!occluded(occludeLevel, farthest.minSceneTileX, farthest.maxSceneTileX, farthest.minSceneTileZ, farthest.maxSceneTileZ, farthest.entity.minY)) {
|
||||
if (locVisible(occludeLevel, farthest.minSceneTileX, farthest.maxSceneTileX, farthest.minSceneTileZ, farthest.maxSceneTileZ, farthest.entity.minY)) {
|
||||
farthest.entity.draw(farthest.yaw, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, farthest.x - eyeX, farthest.y - eyeY, farthest.z - eyeZ, farthest.bitset);
|
||||
}
|
||||
|
||||
@@ -1668,18 +1659,18 @@ public class Scene {
|
||||
if (tile.backWallTypes != 0) {
|
||||
SceneWallDecoration decor = tile.wallDecoration;
|
||||
|
||||
if ((decor != null) && !occluded(occludeLevel, tileX, tileZ, decor.entity.minY)) {
|
||||
if ((decor != null) && visible(occludeLevel, tileX, tileZ, decor.entity.minY)) {
|
||||
drawWallDecor(tile.backWallTypes, decor, false);
|
||||
}
|
||||
|
||||
SceneWall wall = tile.wall;
|
||||
|
||||
if (wall != null) {
|
||||
if (((wall.typeB & tile.backWallTypes) != 0) && !wallOccluded(occludeLevel, tileX, tileZ, wall.typeB)) {
|
||||
if (((wall.typeB & tile.backWallTypes) != 0) && wallVisible(occludeLevel, tileX, tileZ, wall.typeB)) {
|
||||
wall.entityB.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall.x - eyeX, wall.y - eyeY, wall.z - eyeZ, wall.bitset);
|
||||
}
|
||||
|
||||
if (((wall.typeA & tile.backWallTypes) != 0) && !wallOccluded(occludeLevel, tileX, tileZ, wall.typeA)) {
|
||||
if (((wall.typeA & tile.backWallTypes) != 0) && wallVisible(occludeLevel, tileX, tileZ, wall.typeA)) {
|
||||
wall.entityA.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall.x - eyeX, wall.y - eyeY, wall.z - eyeZ, wall.bitset);
|
||||
}
|
||||
}
|
||||
@@ -1794,11 +1785,11 @@ public class Scene {
|
||||
|
||||
private boolean drawTileUnderlayOrOverlay(SceneTile tile, int x, int z, int level) {
|
||||
if (tile.underlay != null) {
|
||||
if (!tileOccluded(level, x, z)) {
|
||||
if (tileVisible(level, x, z)) {
|
||||
drawTileUnderlay(tile.underlay, level, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, x, z);
|
||||
return true;
|
||||
}
|
||||
} else if ((tile.overlay != null) && !tileOccluded(level, x, z)) {
|
||||
} else if ((tile.overlay != null) && tileVisible(level, x, z)) {
|
||||
drawTileOverlay(x, sinEyePitch, sinEyeYaw, tile.overlay, cosEyePitch, z, cosEyeYaw);
|
||||
return true;
|
||||
}
|
||||
@@ -2219,15 +2210,15 @@ public class Scene {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean tileOccluded(int level, int x, int z) {
|
||||
public boolean tileVisible(int level, int x, int z) {
|
||||
int cycle = levelTileOcclusionCycles[level][x][z];
|
||||
|
||||
if (cycle == -Scene.cycle) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cycle == Scene.cycle) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int sx = x << 7;
|
||||
@@ -2236,16 +2227,16 @@ 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;
|
||||
return false;
|
||||
} else {
|
||||
levelTileOcclusionCycles[level][x][z] = -Scene.cycle;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean wallOccluded(int level, int tileX, int tileZ, int type) {
|
||||
if (!tileOccluded(level, tileX, tileZ)) {
|
||||
return false;
|
||||
public boolean wallVisible(int level, int tileX, int tileZ, int type) {
|
||||
if (tileVisible(level, tileX, tileZ)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int sceneX = tileX << 7;
|
||||
@@ -2259,131 +2250,131 @@ public class Scene {
|
||||
if (type == 1) {
|
||||
if (sceneX > eyeX) {
|
||||
if (!occluded(sceneX, sceneY, sceneZ)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (!occluded(sceneX, sceneY, sceneZ + 128)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (level > 0) {
|
||||
if (!occluded(sceneX, y0, sceneZ)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (!occluded(sceneX, y0, sceneZ + 128)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!occluded(sceneX, y1, sceneZ)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return occluded(sceneX, y1, sceneZ + 128);
|
||||
return !occluded(sceneX, y1, sceneZ + 128);
|
||||
} else if (type == 2) {
|
||||
if (sceneZ < eyeZ) {
|
||||
if (!occluded(sceneX, sceneY, sceneZ + 128)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (!occluded(sceneX + 128, sceneY, sceneZ + 128)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (level > 0) {
|
||||
if (!occluded(sceneX, y0, sceneZ + 128)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (!occluded(sceneX + 128, y0, sceneZ + 128)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!occluded(sceneX, y1, sceneZ + 128)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return occluded(sceneX + 128, y1, sceneZ + 128);
|
||||
return !occluded(sceneX + 128, y1, sceneZ + 128);
|
||||
} else if (type == 4) {
|
||||
if (sceneX < eyeX) {
|
||||
if (!occluded(sceneX + 128, sceneY, sceneZ)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (!occluded(sceneX + 128, sceneY, sceneZ + 128)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (level > 0) {
|
||||
if (!occluded(sceneX + 128, y0, sceneZ)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (!occluded(sceneX + 128, y0, sceneZ + 128)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!occluded(sceneX + 128, y1, sceneZ)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return occluded(sceneX + 128, y1, sceneZ + 128);
|
||||
return !occluded(sceneX + 128, y1, sceneZ + 128);
|
||||
} else if (type == 8) {
|
||||
if (sceneZ > eyeZ) {
|
||||
if (!occluded(sceneX, sceneY, sceneZ)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (!occluded(sceneX + 128, sceneY, sceneZ)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (level > 0) {
|
||||
if (!occluded(sceneX, y0, sceneZ)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (!occluded(sceneX + 128, y0, sceneZ)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!occluded(sceneX, y1, sceneZ)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return occluded(sceneX + 128, y1, sceneZ);
|
||||
return !occluded(sceneX + 128, y1, sceneZ);
|
||||
}
|
||||
}
|
||||
|
||||
if (!occluded(sceneX + 64, y2, sceneZ + 64)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (type == 16) {
|
||||
return occluded(sceneX, y1, sceneZ + 128);
|
||||
return !occluded(sceneX, y1, sceneZ + 128);
|
||||
} else if (type == 32) {
|
||||
return occluded(sceneX + 128, y1, sceneZ + 128);
|
||||
return !occluded(sceneX + 128, y1, sceneZ + 128);
|
||||
} else if (type == 64) {
|
||||
return occluded(sceneX + 128, y1, sceneZ);
|
||||
return !occluded(sceneX + 128, y1, sceneZ);
|
||||
} else if (type == 128) {
|
||||
return occluded(sceneX, y1, sceneZ);
|
||||
return !occluded(sceneX, y1, sceneZ);
|
||||
} else {
|
||||
System.out.println("Warning unsupported wall type");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean occluded(int level, int tileX, int tileZ, int y) {
|
||||
if (!tileOccluded(level, tileX, tileZ)) {
|
||||
return false;
|
||||
public boolean visible(int level, int tileX, int tileZ, int y) {
|
||||
if (tileVisible(level, tileX, tileZ)) {
|
||||
return true;
|
||||
}
|
||||
int x = tileX << 7;
|
||||
int z = tileZ << 7;
|
||||
return occluded(x + 1, levelHeightmaps[level][tileX][tileZ] - y, z + 1) && occluded((x + 128) - 1, levelHeightmaps[level][tileX + 1][tileZ] - y, z + 1) && occluded((x + 128) - 1, levelHeightmaps[level][tileX + 1][tileZ + 1] - y, (z + 128) - 1) && occluded(x + 1, levelHeightmaps[level][tileX][tileZ + 1] - y, (z + 128) - 1);
|
||||
return !occluded(x + 1, levelHeightmaps[level][tileX][tileZ] - y, z + 1) || !occluded((x + 128) - 1, levelHeightmaps[level][tileX + 1][tileZ] - y, z + 1) || !occluded((x + 128) - 1, levelHeightmaps[level][tileX + 1][tileZ + 1] - y, (z + 128) - 1) || !occluded(x + 1, levelHeightmaps[level][tileX][tileZ + 1] - y, (z + 128) - 1);
|
||||
}
|
||||
|
||||
public boolean occluded(int level, int minTileX, int maxTileX, int minTileZ, int maxTileZ, int y) {
|
||||
public boolean locVisible(int level, int minTileX, int maxTileX, int minTileZ, int maxTileZ, int y) {
|
||||
if ((minTileX == maxTileX) && (minTileZ == maxTileZ)) {
|
||||
if (!tileOccluded(level, minTileX, minTileZ)) {
|
||||
return false;
|
||||
if (tileVisible(level, minTileX, minTileZ)) {
|
||||
return true;
|
||||
}
|
||||
int x = minTileX << 7;
|
||||
int z = minTileZ << 7;
|
||||
return occluded(x + 1, levelHeightmaps[level][minTileX][minTileZ] - y, z + 1) && occluded((x + 128) - 1, levelHeightmaps[level][minTileX + 1][minTileZ] - y, z + 1) && occluded((x + 128) - 1, levelHeightmaps[level][minTileX + 1][minTileZ + 1] - y, (z + 128) - 1) && occluded(x + 1, levelHeightmaps[level][minTileX][minTileZ + 1] - y, (z + 128) - 1);
|
||||
return !occluded(x + 1, levelHeightmaps[level][minTileX][minTileZ] - y, z + 1) || !occluded((x + 128) - 1, levelHeightmaps[level][minTileX + 1][minTileZ] - y, z + 1) || !occluded((x + 128) - 1, levelHeightmaps[level][minTileX + 1][minTileZ + 1] - y, (z + 128) - 1) || !occluded(x + 1, levelHeightmaps[level][minTileX][minTileZ + 1] - y, (z + 128) - 1);
|
||||
}
|
||||
|
||||
for (int stx = minTileX; stx <= maxTileX; stx++) {
|
||||
for (int stz = minTileZ; stz <= maxTileZ; stz++) {
|
||||
if (levelTileOcclusionCycles[level][stx][stz] == -cycle) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2393,22 +2384,22 @@ public class Scene {
|
||||
int y0 = levelHeightmaps[level][minTileX][minTileZ] - y;
|
||||
|
||||
if (!occluded(x0, y0, z0)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
int x1 = (maxTileX << 7) - 1;
|
||||
|
||||
if (!occluded(x1, y0, z0)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
int z1 = (maxTileZ << 7) - 1;
|
||||
|
||||
if (!occluded(x0, y0, z1)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return occluded(x1, y0, z1);
|
||||
return !occluded(x1, y0, z1);
|
||||
}
|
||||
|
||||
public boolean occluded(int x, int y, int z) {
|
||||
|
||||
@@ -45,10 +45,7 @@ public class SceneBuilder {
|
||||
LocType type = LocType.get(locID);
|
||||
type.prefetch(onDemand);
|
||||
|
||||
for (; ; ) {
|
||||
if (buffer.readSmartU() == 0) {
|
||||
break;
|
||||
}
|
||||
while (buffer.readSmartU() != 0) {
|
||||
buffer.read8U();
|
||||
}
|
||||
}
|
||||
@@ -586,7 +583,7 @@ public class SceneBuilder {
|
||||
int underlayID = levelTileUnderlayIDs[level][x0][z0] & 0xff;
|
||||
int overlayID = levelTileOverlayIDs[level][x0][z0] & 0xff;
|
||||
|
||||
if ((underlayID <= 0) && (overlayID <= 0)) {
|
||||
if ((underlayID == 0) && (overlayID == 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -623,11 +620,7 @@ public class SceneBuilder {
|
||||
}
|
||||
|
||||
if (level > 0) {
|
||||
boolean occludes = true;
|
||||
|
||||
if ((underlayID == 0) && (levelTileOverlayShape[level][x0][z0] != 0)) {
|
||||
occludes = false;
|
||||
}
|
||||
boolean occludes = (underlayID != 0) || (levelTileOverlayShape[level][x0][z0] == 0);
|
||||
|
||||
if ((overlayID > 0) && !FloType.instances[overlayID - 1].occludes) {
|
||||
occludes = false;
|
||||
|
||||
@@ -107,9 +107,9 @@ public class Signlink implements Runnable {
|
||||
}
|
||||
|
||||
|
||||
public static synchronized void dnslookup(String s) {
|
||||
dns = s;
|
||||
dnsreq = s;
|
||||
public static synchronized void dnslookup(String dns) {
|
||||
Signlink.dns = dns;
|
||||
dnsreq = dns;
|
||||
}
|
||||
|
||||
public static synchronized boolean wavesave(byte[] src, int len) {
|
||||
|
||||
Reference in new issue
Block a user