mirror of
https://github.com/Eaglercraft-Archive/Eaglercraftx-1.8.8-src.git
synced 2025-06-28 10:58:15 -05:00
Update #45 - Fixed various issues with the client
This commit is contained in:
@ -14,8 +14,6 @@ import org.lwjgl.glfw.GLFWGamepadState;
|
||||
import org.lwjgl.glfw.GLFWVidMode;
|
||||
import org.lwjgl.system.MemoryStack;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.Display;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
@ -302,7 +300,7 @@ public class PlatformInput {
|
||||
update(0);
|
||||
}
|
||||
|
||||
private static final long[] syncTimer = new long[1];
|
||||
private static long syncTimer = 0l;
|
||||
|
||||
public static void update(int limitFps) {
|
||||
glfwPollEvents();
|
||||
@ -311,10 +309,23 @@ public class PlatformInput {
|
||||
glfwVSyncState = vsync;
|
||||
}
|
||||
glfwSwapBuffers(win);
|
||||
if(limitFps > 0 && !vsync) {
|
||||
Display.sync(limitFps, syncTimer);
|
||||
if(!vsync && limitFps > 0 && limitFps <= 1000) {
|
||||
long frameNanos = (1000000000l / limitFps);
|
||||
if(syncTimer == 0l) {
|
||||
syncTimer = System.nanoTime() + frameNanos;
|
||||
}else {
|
||||
long nanos = System.nanoTime();
|
||||
int remaining = (int)((syncTimer - nanos) / 1000000l);
|
||||
if(remaining > 0) {
|
||||
PlatformRuntime.sleep(remaining);
|
||||
nanos = System.nanoTime();
|
||||
}
|
||||
if((syncTimer += frameNanos) < nanos) {
|
||||
syncTimer = nanos;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
syncTimer[0] = 0l;
|
||||
syncTimer = 0l;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -647,4 +647,8 @@ public class PlatformRuntime {
|
||||
// nope
|
||||
}
|
||||
|
||||
public static boolean immediateContinueSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,48 +33,74 @@ public class EaglerLWJGLAllocator {
|
||||
return allocCount;
|
||||
}
|
||||
|
||||
private static final ByteBuffer ZERO_LENGTH_BYTE_BUFFER = new EaglerLWJGLByteBuffer(0l, 0, true);
|
||||
|
||||
public static ByteBuffer allocByteBuffer(int len) {
|
||||
long ret = JEmalloc.nje_malloc(len);
|
||||
if(ret == 0l) {
|
||||
throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
|
||||
if(len != 0) {
|
||||
long ret = JEmalloc.nje_malloc(len);
|
||||
if(ret == 0l) {
|
||||
throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
|
||||
}
|
||||
if(enableAllocCount) ++allocCount;
|
||||
return new EaglerLWJGLByteBuffer(ret, len, true);
|
||||
}else {
|
||||
return ZERO_LENGTH_BYTE_BUFFER;
|
||||
}
|
||||
if(enableAllocCount) ++allocCount;
|
||||
return new EaglerLWJGLByteBuffer(ret, len, true);
|
||||
}
|
||||
|
||||
private static final ShortBuffer ZERO_LENGTH_SHORT_BUFFER = new EaglerLWJGLShortBuffer(0l, 0, true);
|
||||
|
||||
public static ShortBuffer allocShortBuffer(int len) {
|
||||
long ret = JEmalloc.nje_malloc(len << 1);
|
||||
if(ret == 0l) {
|
||||
throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
|
||||
if(len != 0) {
|
||||
long ret = JEmalloc.nje_malloc(len << 1);
|
||||
if(ret == 0l) {
|
||||
throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
|
||||
}
|
||||
if(enableAllocCount) ++allocCount;
|
||||
return new EaglerLWJGLShortBuffer(ret, len, true);
|
||||
}else {
|
||||
return ZERO_LENGTH_SHORT_BUFFER;
|
||||
}
|
||||
if(enableAllocCount) ++allocCount;
|
||||
return new EaglerLWJGLShortBuffer(ret, len, true);
|
||||
}
|
||||
|
||||
private static final IntBuffer ZERO_LENGTH_INT_BUFFER = new EaglerLWJGLIntBuffer(0l, 0, true);
|
||||
|
||||
public static IntBuffer allocIntBuffer(int len) {
|
||||
long ret = JEmalloc.nje_malloc(len << 2);
|
||||
if(ret == 0l) {
|
||||
throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
|
||||
if(len != 0) {
|
||||
long ret = JEmalloc.nje_malloc(len << 2);
|
||||
if(ret == 0l) {
|
||||
throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
|
||||
}
|
||||
if(enableAllocCount) ++allocCount;
|
||||
return new EaglerLWJGLIntBuffer(ret, len, true);
|
||||
}else {
|
||||
return ZERO_LENGTH_INT_BUFFER;
|
||||
}
|
||||
if(enableAllocCount) ++allocCount;
|
||||
return new EaglerLWJGLIntBuffer(ret, len, true);
|
||||
}
|
||||
|
||||
private static final FloatBuffer ZERO_LENGTH_FLOAT_BUFFER = new EaglerLWJGLFloatBuffer(0l, 0, true);
|
||||
|
||||
public static FloatBuffer allocFloatBuffer(int len) {
|
||||
long ret = JEmalloc.nje_malloc(len << 2);
|
||||
if(ret == 0l) {
|
||||
throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
|
||||
if(len != 0) {
|
||||
long ret = JEmalloc.nje_malloc(len << 2);
|
||||
if(ret == 0l) {
|
||||
throw new OutOfMemoryError("Native je_malloc call returned null pointer!");
|
||||
}
|
||||
if(enableAllocCount) ++allocCount;
|
||||
return new EaglerLWJGLFloatBuffer(ret, len, true);
|
||||
}else {
|
||||
return ZERO_LENGTH_FLOAT_BUFFER;
|
||||
}
|
||||
if(enableAllocCount) ++allocCount;
|
||||
return new EaglerLWJGLFloatBuffer(ret, len, true);
|
||||
}
|
||||
|
||||
public static void freeByteBuffer(ByteBuffer buffer) {
|
||||
if(buffer instanceof EaglerLWJGLByteBuffer) {
|
||||
EaglerLWJGLByteBuffer buf = (EaglerLWJGLByteBuffer)buffer;
|
||||
if(buf.original) {
|
||||
JEmalloc.nje_free(buf.address);
|
||||
if(enableAllocCount) --allocCount;
|
||||
if(buf.address != 0l) {
|
||||
JEmalloc.nje_free(buf.address);
|
||||
if(enableAllocCount) --allocCount;
|
||||
}
|
||||
}else {
|
||||
throwNotOriginal(buffer);
|
||||
}
|
||||
@ -96,8 +122,10 @@ public class EaglerLWJGLAllocator {
|
||||
if(buffer instanceof EaglerLWJGLShortBuffer) {
|
||||
EaglerLWJGLShortBuffer buf = (EaglerLWJGLShortBuffer)buffer;
|
||||
if(buf.original) {
|
||||
JEmalloc.nje_free(buf.address);
|
||||
if(enableAllocCount) --allocCount;
|
||||
if(buf.address != 0l) {
|
||||
JEmalloc.nje_free(buf.address);
|
||||
if(enableAllocCount) --allocCount;
|
||||
}
|
||||
}else {
|
||||
throwNotOriginal(buffer);
|
||||
}
|
||||
@ -119,8 +147,10 @@ public class EaglerLWJGLAllocator {
|
||||
if(buffer instanceof EaglerLWJGLIntBuffer) {
|
||||
EaglerLWJGLIntBuffer buf = (EaglerLWJGLIntBuffer)buffer;
|
||||
if(buf.original) {
|
||||
JEmalloc.nje_free(buf.address);
|
||||
if(enableAllocCount) --allocCount;
|
||||
if(buf.address != 0l) {
|
||||
JEmalloc.nje_free(buf.address);
|
||||
if(enableAllocCount) --allocCount;
|
||||
}
|
||||
}else {
|
||||
throwNotOriginal(buffer);
|
||||
}
|
||||
@ -142,8 +172,10 @@ public class EaglerLWJGLAllocator {
|
||||
if(buffer instanceof EaglerLWJGLFloatBuffer) {
|
||||
EaglerLWJGLFloatBuffer buf = (EaglerLWJGLFloatBuffer)buffer;
|
||||
if(buf.original) {
|
||||
JEmalloc.nje_free(buf.address);
|
||||
if(enableAllocCount) --allocCount;
|
||||
if(buf.address != 0l) {
|
||||
JEmalloc.nje_free(buf.address);
|
||||
if(enableAllocCount) --allocCount;
|
||||
}
|
||||
}else {
|
||||
throwNotOriginal(buffer);
|
||||
}
|
||||
|
Reference in New Issue
Block a user