Update #47 - Singleplayer lag fixes

This commit is contained in:
lax1dude
2025-01-19 13:26:27 -08:00
parent 3f5ee57068
commit 1f0d593a8c
2052 changed files with 133581 additions and 2339 deletions

View File

@ -1,21 +1,7 @@
package net.lax1dude.eaglercraft.v1_8.internal;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.teavm.interop.Import;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
import org.teavm.jso.core.JSString;
import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Uint8Array;
import net.lax1dude.eaglercraft.v1_8.EagUtils;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCBufferAllocator;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCDirectArrayConverter;
import net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm.BetterJSStringConverter;
import net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm.WASMGCWebSocketClient;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;

View File

@ -3,8 +3,6 @@ package net.lax1dude.eaglercraft.v1_8.internal;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import org.teavm.interop.Import;
@ -19,9 +17,13 @@ import org.teavm.jso.dom.html.HTMLElement;
import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Uint8Array;
import com.carrotsearch.hppc.IntObjectHashMap;
import com.carrotsearch.hppc.IntObjectMap;
import com.jcraft.jzlib.Deflater;
import com.jcraft.jzlib.DeflaterOutputStream;
import com.jcraft.jzlib.GZIPInputStream;
import com.jcraft.jzlib.GZIPOutputStream;
import com.jcraft.jzlib.Inflater;
import com.jcraft.jzlib.InflaterInputStream;
import net.lax1dude.eaglercraft.v1_8.Filesystem;
@ -163,11 +165,21 @@ public class PlatformRuntime {
}
public static String getGLVersion() {
return PlatformOpenGL._wglGetString(RealOpenGLEnums.GL_VERSION);
String ret = PlatformOpenGL._wglGetString(RealOpenGLEnums.GL_VERSION);
if(ret != null) {
return ret;
}else {
return "null";
}
}
public static String getGLRenderer() {
return PlatformOpenGL._wglGetString(RealOpenGLEnums.GL_RENDERER);
String ret = PlatformOpenGL._wglGetString(RealOpenGLEnums.GL_RENDERER);
if(ret != null) {
return ret;
}else {
return "null";
}
}
public static ByteBuffer allocateByteBuffer(int length) {
@ -311,7 +323,7 @@ public class PlatformRuntime {
@Import(module = "platformRuntime", name = "getNextEvent")
private static native JSEagRuntimeEvent getNextEvent();
private static final Map<Integer, Consumer<ArrayBuffer>> waitingAsyncDownloads = new HashMap<>();
private static final IntObjectMap<Consumer<ArrayBuffer>> waitingAsyncDownloads = new IntObjectHashMap<>();
private static int asyncDownloadID = 0;
private static void queueAsyncDownload(String uri, boolean forceCache, Consumer<ArrayBuffer> cb) {
@ -479,6 +491,23 @@ public class PlatformRuntime {
return new DeflaterOutputStream(os);
}
@SuppressWarnings("deprecation")
public static int deflateFull(byte[] input, int inputOff, int inputLen, byte[] output, int outputOff,
int outputLen) throws IOException {
Deflater df = new Deflater();
df.setInput(input, inputOff, inputLen, false);
df.setOutput(output, outputOff, outputLen);
df.init(5);
int c;
do {
c = df.deflate(4);
if(c != 0 && c != 1) {
throw new IOException("Deflater failed! Code " + c);
}
}while(c != 1);
return (int)df.getTotalOut();
}
public static OutputStream newGZIPOutputStream(OutputStream os) throws IOException {
return new GZIPOutputStream(os);
}
@ -487,6 +516,22 @@ public class PlatformRuntime {
return new InflaterInputStream(is);
}
@SuppressWarnings("deprecation")
public static int inflateFull(byte[] input, int inputOff, int inputLen, byte[] output, int outputOff,
int outputLen) throws IOException {
Inflater df = new Inflater();
df.setInput(input, inputOff, inputLen, false);
df.setOutput(output, outputOff, outputLen);
int c;
do {
c = df.inflate(0);
if(c != 0 && c != 1) {
throw new IOException("Inflater failed! Code " + c);
}
}while(c != 1);
return (int)df.getTotalOut();
}
public static InputStream newGZIPInputStream(InputStream is) throws IOException {
return new GZIPInputStream(is);
}

View File

@ -20,6 +20,9 @@ import org.teavm.jso.webaudio.MediaStreamAudioDestinationNode;
import org.teavm.jso.webaudio.MediaStreamAudioSourceNode;
import org.teavm.jso.webaudio.PannerNode;
import com.carrotsearch.hppc.IntObjectHashMap;
import com.carrotsearch.hppc.IntObjectMap;
import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
import net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm.BetterJSStringConverter;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
@ -133,7 +136,7 @@ public class PlatformVoiceClient {
}
static final Map<EaglercraftUUID, VoicePeer> peerList = new HashMap<>();
static final Map<Integer, VoicePeer> peerListI = new HashMap<>();
static final IntObjectMap<VoicePeer> peerListI = new IntObjectHashMap<>();
private static class VoicePeer {

View File

@ -4,7 +4,7 @@ import org.teavm.interop.Address;
import org.teavm.interop.DirectMalloc;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
* Copyright (c) 2024-2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -18,7 +18,7 @@ import org.teavm.interop.DirectMalloc;
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class DirectMallocByteBuffer implements ByteBuffer {
public class DirectMallocByteBuffer extends ByteBuffer {
final Address address;
final boolean original;

View File

@ -4,7 +4,7 @@ import org.teavm.interop.Address;
import org.teavm.interop.DirectMalloc;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
* Copyright (c) 2024-2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -18,7 +18,7 @@ import org.teavm.interop.DirectMalloc;
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class DirectMallocFloatBuffer implements FloatBuffer {
public class DirectMallocFloatBuffer extends FloatBuffer {
final Address address;
final boolean original;

View File

@ -4,7 +4,7 @@ import org.teavm.interop.Address;
import org.teavm.interop.DirectMalloc;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
* Copyright (c) 2024-2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -18,7 +18,7 @@ import org.teavm.interop.DirectMalloc;
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class DirectMallocIntBuffer implements IntBuffer {
public class DirectMallocIntBuffer extends IntBuffer {
final Address address;
final boolean original;

View File

@ -4,7 +4,7 @@ import org.teavm.interop.Address;
import org.teavm.interop.DirectMalloc;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
* Copyright (c) 2024-2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -18,7 +18,7 @@ import org.teavm.interop.DirectMalloc;
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class DirectMallocShortBuffer implements ShortBuffer {
public class DirectMallocShortBuffer extends ShortBuffer {
final Address address;
final boolean original;

View File

@ -202,7 +202,7 @@ public class WASMGCBufferAllocator {
}
public static Uint8Array getUnsignedByteBufferView(ShortBuffer buffer) {
DirectMallocIntBuffer buf = (DirectMallocIntBuffer)buffer;
DirectMallocShortBuffer buf = (DirectMallocShortBuffer)buffer;
return getUnsignedByteBufferView0(buf.address.add(buf.position()), buf.remaining() << 1);
}

View File

@ -1,13 +1,11 @@
package net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm;
import org.teavm.interop.Address;
import org.teavm.interop.DirectMalloc;
import org.teavm.interop.Import;
import org.teavm.interop.Unmanaged;
import org.teavm.jso.core.JSArray;
import org.teavm.jso.core.JSString;
import net.lax1dude.eaglercraft.v1_8.EagUtils;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCBufferAllocator;
/**

View File

@ -2,13 +2,6 @@ package net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.ArrayBufferView;
import org.teavm.jso.typedarrays.Float32Array;
import org.teavm.jso.typedarrays.Int16Array;
import org.teavm.jso.typedarrays.Int32Array;
import org.teavm.jso.typedarrays.Int8Array;
import org.teavm.jso.typedarrays.Uint8Array;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.

View File

@ -1,6 +1,5 @@
package net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

View File

@ -23,7 +23,6 @@ import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCDirectArrayConverter;
import net.lax1dude.eaglercraft.v1_8.internal.vfs2.VFile2;
import net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm.BetterJSStringConverter;
import net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm.WASMGCClientConfigAdapter;
import net.lax1dude.eaglercraft.v1_8.sp.server.EaglerIntegratedServerWorker;
import net.lax1dude.eaglercraft.v1_8.sp.server.IWASMCrashCallback;
import net.lax1dude.eaglercraft.v1_8.sp.server.internal.wasm_gc_teavm.JS_IPCPacketData;

View File

@ -2,10 +2,12 @@ package net.lax1dude.eaglercraft.v1_8.sp.server.internal.wasm_gc_teavm;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
import org.teavm.jso.core.JSString;
import org.teavm.jso.typedarrays.Uint8Array;
import net.lax1dude.eaglercraft.v1_8.internal.IPCPacketData;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCDirectArrayConverter;
import net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm.BetterJSStringConverter;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
@ -25,13 +27,14 @@ import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCDirectArrayConverter;
public interface JS_IPCPacketData extends JSObject {
@JSProperty
String getCh();
JSString getCh();
@JSProperty
Uint8Array getData();
default IPCPacketData internalize() {
return new IPCPacketData(getCh(), WASMGCDirectArrayConverter.externU8ArrayToByteArray(getData()));
return new IPCPacketData(BetterJSStringConverter.stringFromJS(getCh()),
WASMGCDirectArrayConverter.externU8ArrayToByteArray(getData()));
}
}