This commit is contained in:
Bigjango13 2024-10-16 14:11:10 -07:00
commit 7a50e6031e
65 changed files with 1104 additions and 498 deletions

3
.gitmodules vendored
View File

@ -7,9 +7,6 @@
[submodule "dependencies/LIEF/src"] [submodule "dependencies/LIEF/src"]
path = dependencies/LIEF/src path = dependencies/LIEF/src
url = https://github.com/lief-project/LIEF.git url = https://github.com/lief-project/LIEF.git
[submodule "media-layer/core/gles/dependencies/gles-compatibility-layer"]
path = dependencies/gles-compatibility-layer/src
url = https://gitea.thebrokenrail.com/minecraft-pi-reborn/gles-compatibility-layer.git
[submodule "dependencies/stb_image/include"] [submodule "dependencies/stb_image/include"]
path = dependencies/stb_image/include path = dependencies/stb_image/include
url = https://github.com/nothings/stb.git url = https://github.com/nothings/stb.git

View File

@ -23,7 +23,6 @@ if(BUILD_NATIVE_COMPONENTS AND NOT IS_ARM_TARGETING)
set(DEFAULT_USE_MEDIA_LAYER_TRAMPOLINE TRUE) set(DEFAULT_USE_MEDIA_LAYER_TRAMPOLINE TRUE)
endif() endif()
mcpi_option(USE_MEDIA_LAYER_TRAMPOLINE "Whether To Enable The Media Layer Trampoline" BOOL "${DEFAULT_USE_MEDIA_LAYER_TRAMPOLINE}") mcpi_option(USE_MEDIA_LAYER_TRAMPOLINE "Whether To Enable The Media Layer Trampoline" BOOL "${DEFAULT_USE_MEDIA_LAYER_TRAMPOLINE}")
mcpi_option(USE_GLES1_COMPATIBILITY_LAYER "Whether To Enable The GLESv1_CM Compatibility Layer" BOOL TRUE)
if(MCPI_USE_MEDIA_LAYER_TRAMPOLINE) if(MCPI_USE_MEDIA_LAYER_TRAMPOLINE)
set(BUILD_MEDIA_LAYER_CORE "${BUILD_NATIVE_COMPONENTS}") set(BUILD_MEDIA_LAYER_CORE "${BUILD_NATIVE_COMPONENTS}")
else() else()

View File

@ -22,10 +22,6 @@ add_subdirectory(runtime)
if(BUILD_MEDIA_LAYER_CORE) if(BUILD_MEDIA_LAYER_CORE)
add_subdirectory(glfw) add_subdirectory(glfw)
endif() endif()
# GLES Compatibility Layer
if(BUILD_MEDIA_LAYER_CORE AND MCPI_USE_GLES1_COMPATIBILITY_LAYER)
add_subdirectory(gles-compatibility-layer)
endif()
# UTF8-CPP # UTF8-CPP
add_subdirectory(utf8cpp) add_subdirectory(utf8cpp)
# Symbol Prcoessor # Symbol Prcoessor

View File

@ -1,4 +0,0 @@
project(gles-compatibility-layer)
# GLES Compatibility Layer
add_subdirectory(src)

@ -1 +0,0 @@
Subproject commit fedc5ac21865fe44dcbc7adb0818af612205cd57

View File

@ -43,6 +43,11 @@
* `Allow High-Resolution Title` (Enabled By Default) * `Allow High-Resolution Title` (Enabled By Default)
* `Improved Classic Title Positioning` (Enabled By Default) * `Improved Classic Title Positioning` (Enabled By Default)
* `Use Updated Title` (Enabled By Default) * `Use Updated Title` (Enabled By Default)
* `Hide Block Outline When GUI Is Hidden` (Enabled By Default)
* `Fix Crash When Generating Certain Seeds` (Enabled By Default)
* `Click Buttons On Mouse Down` (Enabled By Default)
* `3D Dropped Items` (Enabled By Default)
* `Render Entity Shadows` (Enabled By Default)
* Existing Functionality (All Enabled By Default) * Existing Functionality (All Enabled By Default)
* `Fix Screen Rendering When Hiding HUD` * `Fix Screen Rendering When Hiding HUD`
* `Sanitize Usernames` * `Sanitize Usernames`

View File

@ -20,16 +20,14 @@ HOOK(chat_handle_packet_send, void, (const Minecraft *minecraft, ChatPacket *pac
gui->addMessage(out); gui->addMessage(out);
} else { } else {
// Call Original Method // Call Original Method
ensure_chat_handle_packet_send(); real_chat_handle_packet_send()(minecraft, packet);
real_chat_handle_packet_send(minecraft, packet);
} }
} }
// Add Server Command // Add Server Command
HOOK(server_get_commands, std::vector<ServerCommand> *, (Minecraft *minecraft, ServerSideNetworkHandler *server_side_network_handler)) { HOOK(server_get_commands, std::vector<ServerCommand> *, (Minecraft *minecraft, ServerSideNetworkHandler *server_side_network_handler)) {
// Call Original Method // Call Original Method
ensure_server_get_commands(); std::vector<ServerCommand> *commands = real_server_get_commands()(minecraft, server_side_network_handler);
std::vector<ServerCommand> *commands = real_server_get_commands(minecraft, server_side_network_handler);
// Add Command // Add Command
commands->push_back({ commands->push_back({
.name = "greet", .name = "greet",

View File

@ -13,11 +13,15 @@ install(
RENAME "titleBG.png" RENAME "titleBG.png"
) )
# Chest Model # Mojang Textures
install( install(
FILES "chest.png" FILES "mojang/chest.png"
DESTINATION "${MCPI_INSTALL_DIR}/data/images/item" DESTINATION "${MCPI_INSTALL_DIR}/data/images/item"
) )
install(
FILES "mojang/shadow.png" "mojang/vignette.png"
DESTINATION "${MCPI_INSTALL_DIR}/data/images/misc"
)
# Icon # Icon
set(ICON_DIR "${MCPI_SHARE_DIR}/icons/hicolor/512x512/apps") set(ICON_DIR "${MCPI_SHARE_DIR}/icons/hicolor/512x512/apps")

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
images/mojang/shadow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

BIN
images/mojang/vignette.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -106,4 +106,10 @@ TRUE Property Scale Animated Textures
TRUE Allow High-Resolution Title TRUE Allow High-Resolution Title
TRUE Improved Classic Title Positioning TRUE Improved Classic Title Positioning
TRUE Use Updated Title TRUE Use Updated Title
TRUE Hide Block Outline When GUI Is Hidden
TRUE Fix Crash When Generating Certain Seeds
TRUE Click Buttons On Mouse Down
TRUE 3D Dropped Items
TRUE Render Entity Shadows
TRUE Render Vignette
TRUE Implement RaspberryJuice API TRUE Implement RaspberryJuice API

View File

@ -3,7 +3,6 @@
#cmakedefine MCPI_IS_APPIMAGE_BUILD #cmakedefine MCPI_IS_APPIMAGE_BUILD
#cmakedefine MCPI_IS_FLATPAK_BUILD #cmakedefine MCPI_IS_FLATPAK_BUILD
#cmakedefine MCPI_USE_PREBUILT_ARMHF_TOOLCHAIN #cmakedefine MCPI_USE_PREBUILT_ARMHF_TOOLCHAIN
#cmakedefine MCPI_USE_GLES1_COMPATIBILITY_LAYER
#cmakedefine MCPI_APP_BASE_TITLE "@MCPI_APP_BASE_TITLE@" #cmakedefine MCPI_APP_BASE_TITLE "@MCPI_APP_BASE_TITLE@"
#cmakedefine MCPI_APP_TITLE "@MCPI_APP_TITLE@" #cmakedefine MCPI_APP_TITLE "@MCPI_APP_TITLE@"
#cmakedefine MCPI_APP_ID "@MCPI_APP_ID@" #cmakedefine MCPI_APP_ID "@MCPI_APP_ID@"

View File

@ -28,25 +28,26 @@
}) })
// Hook Library Function // Hook Library Function
#define EXTERNAL_FUNC(name, return_type, args) \
typedef return_type (*real_##name##_t)args; \
__attribute__((__unused__)) static real_##name##_t real_##name() { \
static real_##name##_t func = NULL; \
if (!func) { \
dlerror(); \
func = (real_##name##_t) dlsym(RTLD_NEXT, #name); \
if (!func) { \
ERR("Error Resolving Symbol: " #name ": %s", dlerror()); \
} \
} \
return func; \
}
#ifdef __cplusplus #ifdef __cplusplus
#define hooked_function_setup extern "C" #define hooked_function_setup extern "C"
#else #else
#define hooked_function_setup #define hooked_function_setup
#endif #endif
#define HOOK(name, return_type, args) \ #define HOOK(name, return_type, args) \
typedef return_type (*name##_t)args; \ EXTERNAL_FUNC(name, return_type, args) \
static name##_t real_##name = NULL; \
\
__attribute__((__unused__)) static void ensure_##name() { \
if (!real_##name) { \
dlerror(); \
real_##name = (name##_t) dlsym(RTLD_NEXT, #name); \
if (!real_##name) { \
ERR("Error Resolving Symbol: " #name ": %s", dlerror()); \
} \
} \
} \
\
hooked_function_setup __attribute__((__used__)) return_type name args hooked_function_setup __attribute__((__used__)) return_type name args
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -16,12 +16,6 @@ if(BUILD_ARM_COMPONENTS)
install( install(
DIRECTORY "include/" DIRECTORY "include/"
DESTINATION "${MCPI_SDK_INCLUDE_DIR}/media-layer" DESTINATION "${MCPI_SDK_INCLUDE_DIR}/media-layer"
PATTERN "${GLES_HEADERS}" EXCLUDE
)
get_filename_component(GLES_HEADERS "${GLES_HEADERS}" REALPATH)
install(
DIRECTORY "${GLES_HEADERS}/"
DESTINATION "${MCPI_SDK_INCLUDE_DIR}/media-layer/GLES"
) )
endif() endif()
@ -30,6 +24,7 @@ add_subdirectory(extras)
# Add Core # Add Core
if(BUILD_MEDIA_LAYER_CORE) if(BUILD_MEDIA_LAYER_CORE)
add_subdirectory(gles)
add_subdirectory(core) add_subdirectory(core)
endif() endif()

View File

@ -1,8 +1,5 @@
project(media-layer-core) project(media-layer-core)
# OpenGL
add_subdirectory(gles)
# SDL Re-Implementation Using GLFW # SDL Re-Implementation Using GLFW
set(CORE_SRC set(CORE_SRC
src/base.cpp src/base.cpp

View File

@ -1,12 +0,0 @@
project(media-layer-gles)
# Build
if(MCPI_USE_GLES1_COMPATIBILITY_LAYER)
# GLESv1_CM Compatibility Layer
add_library(GLESv1_CM INTERFACE)
target_link_libraries(GLESv1_CM INTERFACE gles-compatibility-layer)
else()
# Passthrough To glfwGetProcAddress()
add_library(GLESv1_CM OBJECT src/passthrough.c)
target_link_libraries(GLESv1_CM PRIVATE glfw media-layer-headers)
endif()

View File

@ -1,208 +0,0 @@
#include <GLES/gl.h>
#include "../../../../dependencies/gles-compatibility-layer/src/src/passthrough.h"
GL_FUNC(glFogfv, void, (GLenum pname, const GLfloat *params));
void glFogfv(GLenum pname, const GLfloat *params) {
real_glFogfv()(pname, params);
}
GL_FUNC(glVertexPointer, void, (GLint size, GLenum type, GLsizei stride, const void *pointer));
void glVertexPointer(GLint size, GLenum type, GLsizei stride, const void *pointer) {
real_glVertexPointer()(size, type, stride, pointer);
}
GL_FUNC(glLineWidth, void, (GLfloat width));
void glLineWidth(GLfloat width) {
real_glLineWidth()(width);
}
GL_FUNC(glBlendFunc, void, (GLenum sfactor, GLenum dfactor));
void glBlendFunc(GLenum sfactor, GLenum dfactor) {
real_glBlendFunc()(sfactor, dfactor);
}
GL_FUNC(glDrawArrays, void, (GLenum mode, GLint first, GLsizei count));
void glDrawArrays(GLenum mode, GLint first, GLsizei count) {
real_glDrawArrays()(mode, first, count);
}
GL_FUNC(glColor4f, void, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha));
void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
real_glColor4f()(red, green, blue, alpha);
}
GL_FUNC(glClear, void, (GLbitfield mask));
void glClear(GLbitfield mask) {
real_glClear()(mask);
}
GL_FUNC(glBufferData, void, (GLenum target, GLsizeiptr size, const void *data, GLenum usage));
void glBufferData(GLenum target, GLsizeiptr size, const void *data, GLenum usage) {
real_glBufferData()(target, size, data, usage);
}
GL_FUNC(glFogx, void, (GLenum pname, GLfixed param));
void glFogx(GLenum pname, GLfixed param) {
real_glFogx()(pname, param);
}
GL_FUNC(glFogf, void, (GLenum pname, GLfloat param));
void glFogf(GLenum pname, GLfloat param) {
real_glFogf()(pname, param);
}
GL_FUNC(glMatrixMode, void, (GLenum mode));
void glMatrixMode(GLenum mode) {
real_glMatrixMode()(mode);
}
GL_FUNC(glColorPointer, void, (GLint size, GLenum type, GLsizei stride, const void *pointer));
void glColorPointer(GLint size, GLenum type, GLsizei stride, const void *pointer) {
real_glColorPointer()(size, type, stride, pointer);
}
GL_FUNC(glScissor, void, (GLint x, GLint y, GLsizei width, GLsizei height));
void glScissor(GLint x, GLint y, GLsizei width, GLsizei height) {
real_glScissor()(x, y, width, height);
}
GL_FUNC(glTexParameteri, void, (GLenum target, GLenum pname, GLint param));
void glTexParameteri(GLenum target, GLenum pname, GLint param) {
real_glTexParameteri()(target, pname, param);
}
GL_FUNC(glTexImage2D, void, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels));
void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels) {
real_glTexImage2D()(target, level, internalformat, width, height, border, format, type, pixels);
}
GL_FUNC(glEnable, void, (GLenum cap));
void glEnable(GLenum cap) {
real_glEnable()(cap);
}
GL_FUNC(glEnableClientState, void, (GLenum array));
void glEnableClientState(GLenum array) {
real_glEnableClientState()(array);
}
GL_FUNC(glPolygonOffset, void, (GLfloat factor, GLfloat units));
void glPolygonOffset(GLfloat factor, GLfloat units) {
real_glPolygonOffset()(factor, units);
}
GL_FUNC(glDisableClientState, void, (GLenum array));
void glDisableClientState(GLenum array) {
real_glDisableClientState()(array);
}
GL_FUNC(glDepthRangef, void, (GLclampf near, GLclampf far));
void glDepthRangef(GLclampf near, GLclampf far) {
real_glDepthRangef()(near, far);
}
GL_FUNC(glDepthFunc, void, (GLenum func));
void glDepthFunc(GLenum func) {
real_glDepthFunc()(func);
}
GL_FUNC(glBindBuffer, void, (GLenum target, GLuint buffer));
void glBindBuffer(GLenum target, GLuint buffer) {
real_glBindBuffer()(target, buffer);
}
GL_FUNC(glClearColor, void, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha));
void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
real_glClearColor()(red, green, blue, alpha);
}
GL_FUNC(glPopMatrix, void, ());
void glPopMatrix() {
real_glPopMatrix()();
}
GL_FUNC(glLoadIdentity, void, ());
void glLoadIdentity() {
real_glLoadIdentity()();
}
GL_FUNC(glScalef, void, (GLfloat x, GLfloat y, GLfloat z));
void glScalef(GLfloat x, GLfloat y, GLfloat z) {
real_glScalef()(x, y, z);
}
GL_FUNC(glPushMatrix, void, ());
void glPushMatrix() {
real_glPushMatrix()();
}
GL_FUNC(glDepthMask, void, (GLboolean flag));
void glDepthMask(GLboolean flag) {
real_glDepthMask()(flag);
}
GL_FUNC(glHint, void, (GLenum target, GLenum mode));
void glHint(GLenum target, GLenum mode) {
real_glHint()(target, mode);
}
GL_FUNC(glMultMatrixf, void, (const GLfloat *m));
void glMultMatrixf(const GLfloat *m) {
real_glMultMatrixf()(m);
}
GL_FUNC(glTexCoordPointer, void, (GLint size, GLenum type, GLsizei stride, const void *pointer));
void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const void *pointer) {
real_glTexCoordPointer()(size, type, stride, pointer);
}
GL_FUNC(glDeleteBuffers, void, (GLsizei n, const GLuint *buffers));
void glDeleteBuffers(GLsizei n, const GLuint *buffers) {
real_glDeleteBuffers()(n, buffers);
}
GL_FUNC(glColorMask, void, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha));
void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {
real_glColorMask()(red, green, blue, alpha);
}
GL_FUNC(glTexSubImage2D, void, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels));
void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels) {
real_glTexSubImage2D()(target, level, xoffset, yoffset, width, height, format, type, pixels);
}
GL_FUNC(glGenTextures, void, (GLsizei n, GLuint *textures));
void glGenTextures(GLsizei n, GLuint *textures) {
real_glGenTextures()(n, textures);
}
GL_FUNC(glDeleteTextures, void, (GLsizei n, const GLuint *textures));
void glDeleteTextures(GLsizei n, const GLuint *textures) {
real_glDeleteTextures()(n, textures);
}
GL_FUNC(glAlphaFunc, void, (GLenum func, GLclampf ref));
void glAlphaFunc(GLenum func, GLclampf ref) {
real_glAlphaFunc()(func, ref);
}
GL_FUNC(glGetFloatv, void, (GLenum pname, GLfloat *params));
void glGetFloatv(GLenum pname, GLfloat *params) {
real_glGetFloatv()(pname, params);
}
GL_FUNC(glBindTexture, void, (GLenum target, GLuint texture));
void glBindTexture(GLenum target, GLuint texture) {
real_glBindTexture()(target, texture);
}
GL_FUNC(glTranslatef, void, (GLfloat x, GLfloat y, GLfloat z));
void glTranslatef(GLfloat x, GLfloat y, GLfloat z) {
real_glTranslatef()(x, y, z);
}
GL_FUNC(glShadeModel, void, (GLenum mode));
void glShadeModel(GLenum mode) {
real_glShadeModel()(mode);
}
GL_FUNC(glOrthof, void, (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near, GLfloat far));
void glOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near, GLfloat far) {
real_glOrthof()(left, right, bottom, top, near, far);
}
GL_FUNC(glDisable, void, (GLenum cap));
void glDisable(GLenum cap) {
real_glDisable()(cap);
}
GL_FUNC(glCullFace, void, (GLenum mode));
void glCullFace(GLenum mode) {
real_glCullFace()(mode);
}
GL_FUNC(glRotatef, void, (GLfloat angle, GLfloat x, GLfloat y, GLfloat z));
void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) {
real_glRotatef()(angle, x, y, z);
}
GL_FUNC(glViewport, void, (GLint x, GLint y, GLsizei width, GLsizei height));
void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
real_glViewport()(x, y, width, height);
}
GL_FUNC(glNormal3f, void, (GLfloat nx, GLfloat ny, GLfloat nz));
void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz) {
real_glNormal3f()(nx, ny, nz);
}
GL_FUNC(glIsEnabled, GLboolean, (GLenum cap));
GLboolean glIsEnabled(GLenum cap) {
return real_glIsEnabled()(cap);
}
GL_FUNC(glGetIntegerv, void, (GLenum pname, GLint *data));
void glGetIntegerv(GLenum pname, GLint *data) {
real_glGetIntegerv()(pname, data);
}
GL_FUNC(glReadPixels, void, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *data));
void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *data) {
real_glReadPixels()(x, y, width, height, format, type, data);
}
GL_FUNC(glGenBuffers, void, (GLsizei n, GLuint *buffers));
void glGenBuffers(GLsizei n, GLuint *buffers) {
real_glGenBuffers()(n, buffers);
}

View File

@ -321,9 +321,6 @@ void media_force_egl() {
// Init Media Layer // Init Media Layer
#define GL_VERSION 0x1f02 #define GL_VERSION 0x1f02
typedef const char *(*glGetString_t)(unsigned int name); typedef const char *(*glGetString_t)(unsigned int name);
#ifdef MCPI_USE_GLES1_COMPATIBILITY_LAYER
extern "C" void init_gles_compatibility_layer(void *);
#endif
void SDL_WM_SetCaption(const char *title, __attribute__((unused)) const char *icon) { void SDL_WM_SetCaption(const char *title, __attribute__((unused)) const char *icon) {
// Disable In Headless Mode // Disable In Headless Mode
if (reborn_is_headless()) { if (reborn_is_headless()) {
@ -337,15 +334,9 @@ void SDL_WM_SetCaption(const char *title, __attribute__((unused)) const char *ic
ERR("Unable To Initialize GLFW"); ERR("Unable To Initialize GLFW");
} }
// Create OpenGL ES Context // Create OpenGL Context
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
#ifdef MCPI_USE_GLES1_COMPATIBILITY_LAYER
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
#else
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
#endif
// Use EGL // Use EGL
if (force_egl) { if (force_egl) {
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API); glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
@ -374,14 +365,9 @@ void SDL_WM_SetCaption(const char *title, __attribute__((unused)) const char *ic
// Make Window Context Current // Make Window Context Current
glfwMakeContextCurrent(glfw_window); glfwMakeContextCurrent(glfw_window);
// Setup Compatibility Layer
#ifdef MCPI_USE_GLES1_COMPATIBILITY_LAYER
init_gles_compatibility_layer((void *) glfwGetProcAddress);
#endif
// Debug // Debug
const glGetString_t glGetString = (glGetString_t) glfwGetProcAddress("glGetString"); const glGetString_t glGetString = (glGetString_t) glfwGetProcAddress("glGetString");
DEBUG("Using %s", (*glGetString)(GL_VERSION)); DEBUG("Using OpenGL %s", (*glGetString)(GL_VERSION));
// Init OpenAL // Init OpenAL
_media_audio_init(); _media_audio_init();

View File

@ -0,0 +1,5 @@
project(media-layer-gles)
# Build
add_library(GLESv1_CM OBJECT src/passthrough.cpp)
target_link_libraries(GLESv1_CM PRIVATE glfw media-layer-headers reborn-util)

View File

@ -0,0 +1,230 @@
#include <GLES/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
#include <libreborn/libreborn.h>
// Load GL Function
static char *gl_dlerror() {
return (char *) "Unknown Error";
}
#define dlerror gl_dlerror
static void *gl_dlsysm(__attribute__((unused)) void *handle, __attribute__((unused)) const char *name) {
return (void *) glfwGetProcAddress(name);
}
#define dlsym gl_dlsysm
#define GL_FUNC EXTERNAL_FUNC
// Passthrough Functions
GL_FUNC(glFogfv, void, (GLenum pname, const GLfloat *params))
void glFogfv(const GLenum pname, const GLfloat *params) {
real_glFogfv()(pname, params);
}
GL_FUNC(glVertexPointer, void, (GLint size, GLenum type, GLsizei stride, const void *pointer))
void glVertexPointer(const GLint size, const GLenum type, const GLsizei stride, const void *pointer) {
real_glVertexPointer()(size, type, stride, pointer);
}
GL_FUNC(glLineWidth, void, (GLfloat width))
void glLineWidth(const GLfloat width) {
real_glLineWidth()(width);
}
GL_FUNC(glBlendFunc, void, (GLenum sfactor, GLenum dfactor))
void glBlendFunc(const GLenum sfactor, const GLenum dfactor) {
real_glBlendFunc()(sfactor, dfactor);
}
GL_FUNC(glDrawArrays, void, (GLenum mode, GLint first, GLsizei count))
void glDrawArrays(const GLenum mode, const GLint first, const GLsizei count) {
real_glDrawArrays()(mode, first, count);
}
GL_FUNC(glMultiDrawArraysEXT, void, (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount))
void glMultiDrawArrays(const GLenum mode, const GLint *first, const GLsizei *count, const GLsizei drawcount) {
real_glMultiDrawArraysEXT()(mode, first, count, drawcount);
}
GL_FUNC(glColor4f, void, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha))
void glColor4f(const GLfloat red, const GLfloat green, const GLfloat blue, const GLfloat alpha) {
real_glColor4f()(red, green, blue, alpha);
}
GL_FUNC(glClear, void, (GLbitfield mask))
void glClear(const GLbitfield mask) {
real_glClear()(mask);
}
GL_FUNC(glBufferData, void, (GLenum target, GLsizeiptr size, const void *data, GLenum usage))
void glBufferData(const GLenum target, const GLsizeiptr size, const void *data, const GLenum usage) {
real_glBufferData()(target, size, data, usage);
}
GL_FUNC(glBufferSubData, void, (GLenum target, GLintptr offset, GLsizeiptr size, const void *data))
void glBufferSubData(const GLenum target, const GLintptr offset, const GLsizeiptr size, const void *data) {
real_glBufferSubData()(target, offset, size, data);
}
GL_FUNC(glFogi, void, (GLenum pname, GLint param))
void glFogx(const GLenum pname, const GLfixed param) {
real_glFogi()(pname, param);
}
GL_FUNC(glFogf, void, (GLenum pname, GLfloat param))
void glFogf(const GLenum pname, const GLfloat param) {
real_glFogf()(pname, param);
}
GL_FUNC(glMatrixMode, void, (GLenum mode))
void glMatrixMode(const GLenum mode) {
real_glMatrixMode()(mode);
}
GL_FUNC(glColorPointer, void, (GLint size, GLenum type, GLsizei stride, const void *pointer))
void glColorPointer(const GLint size, const GLenum type, const GLsizei stride, const void *pointer) {
real_glColorPointer()(size, type, stride, pointer);
}
GL_FUNC(glScissor, void, (GLint x, GLint y, GLsizei width, GLsizei height))
void glScissor(const GLint x, const GLint y, const GLsizei width, const GLsizei height) {
real_glScissor()(x, y, width, height);
}
GL_FUNC(glTexParameteri, void, (GLenum target, GLenum pname, GLint param))
void glTexParameteri(const GLenum target, const GLenum pname, const GLint param) {
real_glTexParameteri()(target, pname, param);
}
GL_FUNC(glTexImage2D, void, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels))
void glTexImage2D(const GLenum target, const GLint level, const GLint internalformat, const GLsizei width, const GLsizei height, const GLint border, const GLenum format, const GLenum type, const void *pixels) {
real_glTexImage2D()(target, level, internalformat, width, height, border, format, type, pixels);
}
GL_FUNC(glEnable, void, (GLenum cap))
void glEnable(const GLenum cap) {
real_glEnable()(cap);
}
GL_FUNC(glEnableClientState, void, (GLenum array))
void glEnableClientState(const GLenum array) {
real_glEnableClientState()(array);
}
GL_FUNC(glPolygonOffset, void, (GLfloat factor, GLfloat units))
void glPolygonOffset(const GLfloat factor, const GLfloat units) {
real_glPolygonOffset()(factor, units);
}
GL_FUNC(glDisableClientState, void, (GLenum array))
void glDisableClientState(const GLenum array) {
real_glDisableClientState()(array);
}
GL_FUNC(glDepthRange, void, (GLclampd near, GLclampd far))
void glDepthRangef(const GLclampf near, const GLclampf far) {
real_glDepthRange()(near, far);
}
GL_FUNC(glDepthFunc, void, (GLenum func))
void glDepthFunc(const GLenum func) {
real_glDepthFunc()(func);
}
GL_FUNC(glBindBuffer, void, (GLenum target, GLuint buffer))
void glBindBuffer(const GLenum target, const GLuint buffer) {
real_glBindBuffer()(target, buffer);
}
GL_FUNC(glClearColor, void, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha))
void glClearColor(const GLclampf red, const GLclampf green, const GLclampf blue, const GLclampf alpha) {
real_glClearColor()(red, green, blue, alpha);
}
GL_FUNC(glPopMatrix, void, ())
void glPopMatrix() {
real_glPopMatrix()();
}
GL_FUNC(glLoadIdentity, void, ())
void glLoadIdentity() {
real_glLoadIdentity()();
}
GL_FUNC(glScalef, void, (GLfloat x, GLfloat y, GLfloat z))
void glScalef(const GLfloat x, const GLfloat y, const GLfloat z) {
real_glScalef()(x, y, z);
}
GL_FUNC(glPushMatrix, void, ())
void glPushMatrix() {
real_glPushMatrix()();
}
GL_FUNC(glDepthMask, void, (GLboolean flag))
void glDepthMask(const GLboolean flag) {
real_glDepthMask()(flag);
}
GL_FUNC(glHint, void, (GLenum target, GLenum mode))
void glHint(const GLenum target, const GLenum mode) {
real_glHint()(target, mode);
}
GL_FUNC(glMultMatrixf, void, (const GLfloat *m))
void glMultMatrixf(const GLfloat *m) {
real_glMultMatrixf()(m);
}
GL_FUNC(glTexCoordPointer, void, (GLint size, GLenum type, GLsizei stride, const void *pointer))
void glTexCoordPointer(const GLint size, const GLenum type, const GLsizei stride, const void *pointer) {
real_glTexCoordPointer()(size, type, stride, pointer);
}
GL_FUNC(glDeleteBuffers, void, (GLsizei n, const GLuint *buffers))
void glDeleteBuffers(const GLsizei n, const GLuint *buffers) {
real_glDeleteBuffers()(n, buffers);
}
GL_FUNC(glColorMask, void, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha))
void glColorMask(const GLboolean red, const GLboolean green, const GLboolean blue, const GLboolean alpha) {
real_glColorMask()(red, green, blue, alpha);
}
GL_FUNC(glTexSubImage2D, void, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels))
void glTexSubImage2D(const GLenum target, const GLint level, const GLint xoffset, const GLint yoffset, const GLsizei width, const GLsizei height, const GLenum format, const GLenum type, const void *pixels) {
real_glTexSubImage2D()(target, level, xoffset, yoffset, width, height, format, type, pixels);
}
GL_FUNC(glGenTextures, void, (GLsizei n, GLuint *textures))
void glGenTextures(const GLsizei n, GLuint *textures) {
real_glGenTextures()(n, textures);
}
GL_FUNC(glDeleteTextures, void, (GLsizei n, const GLuint *textures))
void glDeleteTextures(const GLsizei n, const GLuint *textures) {
real_glDeleteTextures()(n, textures);
}
GL_FUNC(glAlphaFunc, void, (GLenum func, GLclampf ref))
void glAlphaFunc(const GLenum func, const GLclampf ref) {
real_glAlphaFunc()(func, ref);
}
GL_FUNC(glGetFloatv, void, (GLenum pname, GLfloat *params))
void glGetFloatv(const GLenum pname, GLfloat *params) {
real_glGetFloatv()(pname, params);
}
GL_FUNC(glBindTexture, void, (GLenum target, GLuint texture))
void glBindTexture(const GLenum target, const GLuint texture) {
real_glBindTexture()(target, texture);
}
GL_FUNC(glTranslatef, void, (GLfloat x, GLfloat y, GLfloat z))
void glTranslatef(const GLfloat x, const GLfloat y, const GLfloat z) {
real_glTranslatef()(x, y, z);
}
GL_FUNC(glShadeModel, void, (GLenum mode))
void glShadeModel(const GLenum mode) {
real_glShadeModel()(mode);
}
GL_FUNC(glOrtho, void, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far))
void glOrthof(const GLfloat left, const GLfloat right, const GLfloat bottom, const GLfloat top, const GLfloat near, const GLfloat far) {
real_glOrtho()(left, right, bottom, top, near, far);
}
GL_FUNC(glDisable, void, (GLenum cap))
void glDisable(const GLenum cap) {
real_glDisable()(cap);
}
GL_FUNC(glCullFace, void, (GLenum mode))
void glCullFace(const GLenum mode) {
real_glCullFace()(mode);
}
GL_FUNC(glRotatef, void, (GLfloat angle, GLfloat x, GLfloat y, GLfloat z))
void glRotatef(const GLfloat angle, const GLfloat x, const GLfloat y, const GLfloat z) {
real_glRotatef()(angle, x, y, z);
}
GL_FUNC(glViewport, void, (GLint x, GLint y, GLsizei width, GLsizei height))
void glViewport(const GLint x, const GLint y, const GLsizei width, const GLsizei height) {
real_glViewport()(x, y, width, height);
}
GL_FUNC(glNormal3f, void, (GLfloat nx, GLfloat ny, GLfloat nz))
void glNormal3f(const GLfloat nx, const GLfloat ny, const GLfloat nz) {
real_glNormal3f()(nx, ny, nz);
}
GL_FUNC(glIsEnabled, GLboolean, (GLenum cap))
GLboolean glIsEnabled(const GLenum cap) {
return real_glIsEnabled()(cap);
}
GL_FUNC(glGetIntegerv, void, (GLenum pname, GLint *data))
void glGetIntegerv(const GLenum pname, GLint *data) {
real_glGetIntegerv()(pname, data);
}
GL_FUNC(glReadPixels, void, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *data))
void glReadPixels(const GLint x, const GLint y, const GLsizei width, const GLsizei height, const GLenum format, const GLenum type, void *data) {
real_glReadPixels()(x, y, width, height, format, type, data);
}
GL_FUNC(glGenBuffers, void, (GLsizei n, GLuint *buffers))
void glGenBuffers(const GLsizei n, GLuint *buffers) {
real_glGenBuffers()(n, buffers);
}

View File

@ -1 +0,0 @@
../../dependencies/gles-compatibility-layer/src/include/GLES

View File

@ -0,0 +1,164 @@
#pragma once
#include <stdio.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define GL_FALSE 0
#define GL_ARRAY_BUFFER_BINDING 0x8894
#define GL_ARRAY_BUFFER 0x8892
#define GL_TEXTURE_BINDING_2D 0x8069
#define GL_UNSIGNED_BYTE 0x1401
#define GL_FLOAT 0x1406
#define GL_RGB 0x1907
#define GL_RGBA 0x1908
#define GL_MODELVIEW_MATRIX 0xba6
#define GL_PROJECTION_MATRIX 0xba7
#define GL_VIEWPORT 0xba2
#define GL_DEPTH_TEST 0xb71
#define GL_PACK_ALIGNMENT 0xd05
#define GL_UNPACK_ALIGNMENT 0xcf5
#define GL_SRC_ALPHA 0x302
#define GL_DST_ALPHA 0x304
#define GL_ONE_MINUS_SRC_ALPHA 0x303
#define GL_MODELVIEW 0x1700
#define GL_PROJECTION 0x1701
#define GL_TEXTURE 0x1702
#define GL_VERTEX_ARRAY 0x8074
#define GL_COLOR_ARRAY 0x8076
#define GL_TEXTURE_COORD_ARRAY 0x8078
#define GL_GREATER 0x204
#define GL_ALPHA_TEST 0xbc0
#define GL_TEXTURE_2D 0xde1
#define GL_COLOR_MATERIAL 0xb57
#define GL_PERSPECTIVE_CORRECTION_HINT 0xc50
#define GL_FOG 0xb60
#define GL_LINEAR 0x2601
#define GL_EXP 0x800
#define GL_FOG_DENSITY 0xb62
#define GL_FOG_START 0xb63
#define GL_FOG_END 0xb64
#define GL_FOG_MODE 0xb65
#define GL_FOG_COLOR 0xb66
#define GL_BLEND 0xbe2
#define GL_TRIANGLES 0x4
#define GL_TRIANGLE_STRIP 0x5
#define GL_TRIANGLE_FAN 0x6
#define GL_FASTEST 0x1101
#define GL_BACK 0x405
#define GL_CULL_FACE 0xb44
#define GL_LEQUAL 0x203
#define GL_EQUAL 0x202
#define GL_ONE_MINUS_DST_COLOR 0x307
#define GL_ONE_MINUS_SRC_COLOR 0x301
#define GL_ZERO 0
#define GL_FLAT 0x1d00
#define GL_SMOOTH 0x1d01
#define GL_SCISSOR_TEST 0xc11
#define GL_TRUE 1
#define GL_POLYGON_OFFSET_FILL 0x8037
#define GL_SRC_COLOR 0x300
#define GL_DST_COLOR 0x306
#define GL_ONE 1
#define GL_LINES 0x1
#define GL_LINE_STRIP 0x3
#define GL_STATIC_DRAW 0x88e4
#define GL_DYNAMIC_DRAW 0x88e8
#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
#define GL_UNSIGNED_SHORT_5_6_5 0x8363
#define GL_TEXTURE_WRAP_T 0x2803
#define GL_TEXTURE_WRAP_S 0x2802
#define GL_REPEAT 0x2901
#define GL_CLAMP_TO_EDGE 0x812f
#define GL_TEXTURE_MAG_FILTER 0x2800
#define GL_TEXTURE_MIN_FILTER 0x2801
#define GL_NEAREST 0x2600
#define GL_LINEAR_MIPMAP_LINEAR 0x2703
#define GL_DEPTH_BUFFER_BIT 0x100
#define GL_COLOR_BUFFER_BIT 0x4000
#define GL_NO_ERROR 0
#define GL_BYTE 0x1400
#define GL_ACCUM 0x100
#define GL_ALPHA 0x1906
#define GL_NONE 0
#define GL_ALIASED_LINE_WIDTH_RANGE 0x846e
typedef float GLfloat;
typedef float GLclampf;
typedef double GLdouble;
typedef double GLclampd;
typedef int GLint;
typedef unsigned char GLboolean;
typedef int GLsizei;
typedef unsigned int GLuint;
typedef ssize_t GLsizeiptr;
typedef intptr_t GLintptr;
typedef int32_t GLfixed;
typedef unsigned int GLbitfield;
typedef unsigned int GLenum;
typedef char GLchar;
typedef void GLvoid;
void glFogfv(GLenum pname, const GLfloat *params);
void glVertexPointer(GLint size, GLenum type, GLsizei stride, const void *pointer);
void glLineWidth(GLfloat width);
void glBlendFunc(GLenum sfactor, GLenum dfactor);
void glDrawArrays(GLenum mode, GLint first, GLsizei count);
void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
void glClear(GLbitfield mask);
void glBufferData(GLenum target, GLsizeiptr size, const void *data, GLenum usage);
void glFogx(GLenum pname, GLfixed param);
void glFogf(GLenum pname, GLfloat param);
void glMatrixMode(GLenum mode);
void glColorPointer(GLint size, GLenum type, GLsizei stride, const void *pointer);
void glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
void glTexParameteri(GLenum target, GLenum pname, GLint param);
void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);
void glEnable(GLenum cap);
void glEnableClientState(GLenum array);
void glPolygonOffset(GLfloat factor, GLfloat units);
void glDisableClientState(GLenum array);
void glDepthRangef(GLclampf near, GLclampf far);
void glDepthFunc(GLenum func);
void glBindBuffer(GLenum target, GLuint buffer);
void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void glPopMatrix();
void glLoadIdentity();
void glScalef(GLfloat x, GLfloat y, GLfloat z);
void glPushMatrix();
void glDepthMask(GLboolean flag);
void glHint(GLenum target, GLenum mode);
void glMultMatrixf(const GLfloat *m);
void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const void *pointer);
void glDeleteBuffers(GLsizei n, const GLuint *buffers);
void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);
void glGenTextures(GLsizei n, GLuint *textures);
void glDeleteTextures(GLsizei n, const GLuint *textures);
void glAlphaFunc(GLenum func, GLclampf ref);
void glGetFloatv(GLenum pname, GLfloat *params);
void glBindTexture(GLenum target, GLuint texture);
void glTranslatef(GLfloat x, GLfloat y, GLfloat z);
void glShadeModel(GLenum mode);
void glOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near, GLfloat far);
void glDisable(GLenum cap);
void glCullFace(GLenum mode);
void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz);
GLboolean glIsEnabled(GLenum cap);
void glGetIntegerv(GLenum pname, GLint *data);
void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *data);
void glGenBuffers(GLsizei n, GLuint *buffers);
GLenum glGetError();
void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void *data);
void glPixelStorei(GLenum pname, GLint param);
void glMultiDrawArrays(GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount);
#ifdef __cplusplus
}
#endif

View File

@ -6,7 +6,7 @@
#include "common/common.h" #include "common/common.h"
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
static int get_glFogfv_params_length(GLenum pname) { static int get_glFogfv_params_length(const GLenum pname) {
return pname == GL_FOG_COLOR ? 4 : 1; return pname == GL_FOG_COLOR ? 4 : 1;
} }
#endif #endif
@ -90,12 +90,13 @@ static gl_state_t gl_state;
state.type = type; \ state.type = type; \
state.stride = stride; \ state.stride = stride; \
state.pointer = uint32_t(pointer); \ state.pointer = uint32_t(pointer); \
trampoline(true, state); \ trampoline(true, gl_state.bound_array_buffer, state); \
} \ } \
} }
#else #else
#define CALL_GL_POINTER(unique_id, name) \ #define CALL_GL_POINTER(unique_id, name) \
CALL(unique_id, name, unused, ()) \ CALL(unique_id, name, unused, ()) \
glBindBuffer(GL_ARRAY_BUFFER, args.next<GLuint>()); \
gl_array_details_t state = args.next<gl_array_details_t>(); \ gl_array_details_t state = args.next<gl_array_details_t>(); \
func(state.size, state.type, state.stride, (const void *) uintptr_t(state.pointer)); \ func(state.size, state.type, state.stride, (const void *) uintptr_t(state.pointer)); \
return 0; \ return 0; \
@ -138,7 +139,6 @@ CALL(15, glDrawArrays, void, (GLenum mode, GLint first, GLsizei count))
#endif #endif
} }
#ifdef MCPI_USE_GLES1_COMPATIBILITY_LAYER
CALL(70, glMultiDrawArrays, void, (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount)) CALL(70, glMultiDrawArrays, void, (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(true, gl_state, mode, copy_array(drawcount, first), copy_array(drawcount, count)); trampoline(true, gl_state, mode, copy_array(drawcount, first), copy_array(drawcount, count));
@ -153,7 +153,6 @@ CALL(70, glMultiDrawArrays, void, (GLenum mode, const GLint *first, const GLsize
return 0; return 0;
#endif #endif
} }
#endif
CALL(16, glColor4f, void, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)) CALL(16, glColor4f, void, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
@ -335,8 +334,6 @@ CALL_GL_POINTER(41, glTexCoordPointer)
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
void glDisableClientState(const GLenum array) { void glDisableClientState(const GLenum array) {
gl_state.get_array_enabled(array) = false; gl_state.get_array_enabled(array) = false;
// Not needed when using compatibility layer
#ifndef MCPI_USE_GLES1_COMPATIBILITY_LAYER
switch (array) { switch (array) {
case GL_VERTEX_ARRAY: { case GL_VERTEX_ARRAY: {
gl_array_details.glVertexPointer.size = -1; gl_array_details.glVertexPointer.size = -1;
@ -351,7 +348,6 @@ void glDisableClientState(const GLenum array) {
break; break;
} }
} }
#endif
} }
#endif #endif
@ -382,12 +378,9 @@ void glBindBuffer(const GLenum target, const GLuint buffer) {
} else { } else {
ERR("Unsupported Buffer Binding: %u", target); ERR("Unsupported Buffer Binding: %u", target);
} }
// Not needed when using compatibility layer
#ifndef MCPI_USE_GLES1_COMPATIBILITY_LAYER
gl_array_details.glVertexPointer.size = -1; gl_array_details.glVertexPointer.size = -1;
gl_array_details.glColorPointer.size = -1; gl_array_details.glColorPointer.size = -1;
gl_array_details.glTexCoordPointer.size = -1; gl_array_details.glTexCoordPointer.size = -1;
#endif
} }
#endif #endif

View File

@ -15,7 +15,7 @@ __attribute__((visibility("internal"))) void _add_handler(unsigned char id, hand
} \ } \
static uint32_t _run_##name(__attribute__((unused)) trampoline_writer_t writer, const unsigned char *raw_args) { \ static uint32_t _run_##name(__attribute__((unused)) trampoline_writer_t writer, const unsigned char *raw_args) { \
__attribute__((unused)) TrampolineArguments args(raw_args); \ __attribute__((unused)) TrampolineArguments args(raw_args); \
static typeof(name) *func = name; static constexpr typeof(name) *func = name;
// Arguments // Arguments
struct TrampolineArguments { struct TrampolineArguments {

View File

@ -1,3 +1,4 @@
#pragma once #pragma once
extern double fps; extern double fps;
extern double tps;

View File

@ -11,8 +11,8 @@ void misc_render_background(int color, const Minecraft *minecraft, int x, int y,
extern bool is_in_chat; extern bool is_in_chat;
typedef RakNet_RakString *(*RakNet_RakString_constructor_t)(RakNet_RakString *self, const char *format, ...); typedef RakNet_RakString *(*RakNet_RakString_constructor_2_t)(RakNet_RakString *self, const char *format, ...);
extern RakNet_RakString_constructor_t RakNet_RakString_constructor; extern RakNet_RakString_constructor_2_t RakNet_RakString_constructor_2;
} }
void misc_run_on_update(const std::function<void(Minecraft *)> &func); void misc_run_on_update(const std::function<void(Minecraft *)> &func);

View File

@ -6,7 +6,7 @@
#include <vector> #include <vector>
struct ServerProperty { struct ServerProperty {
static std::vector<const ServerProperty *> all; static std::vector<const ServerProperty *> &get_all();
const char *const key; const char *const key;
const char *const def; const char *const def;
const char *const comment; const char *const comment;
@ -14,7 +14,7 @@ struct ServerProperty {
key(key_), key(key_),
def(def_), def(def_),
comment(comment_) { comment(comment_) {
all.push_back(this); get_all().push_back(this);
} }
}; };

View File

@ -80,6 +80,16 @@ void _chat_send_message(const Minecraft *minecraft, const char *message) {
send_api_chat_command(minecraft, message); send_api_chat_command(minecraft, message);
} }
// Allow Reading Longer ChatPacket Messages
static void ChatPacket_read_injection(__attribute__((unused)) ChatPacket_read_t original, ChatPacket *self, RakNet_BitStream *stream) {
RakNet_RakString *str = RakNet_RakString::allocate();
str->constructor();
str->Deserialize(stream);
self->message = str->sharedString->c_str;
str->Free();
::operator delete(str);
}
// Init // Init
void init_chat() { void init_chat() {
if (feature_has("Implement Chat", server_enabled)) { if (feature_has("Implement Chat", server_enabled)) {
@ -95,5 +105,6 @@ void init_chat() {
// Disable Built-In Chat Message Limiting // Disable Built-In Chat Message Limiting
unsigned char message_limit_patch[4] = {0x03, 0x00, 0x53, 0xe1}; // "cmp r4, r4" unsigned char message_limit_patch[4] = {0x03, 0x00, 0x53, 0xe1}; // "cmp r4, r4"
patch((void *) 0x6b4c0, message_limit_patch); patch((void *) 0x6b4c0, message_limit_patch);
overwrite_calls(ChatPacket_read, ChatPacket_read_injection);
} }
} }

View File

@ -17,15 +17,13 @@
// Custom Title // Custom Title
HOOK(SDL_WM_SetCaption, void, (__attribute__((unused)) const char *title, const char *icon)) { HOOK(SDL_WM_SetCaption, void, (__attribute__((unused)) const char *title, const char *icon)) {
ensure_SDL_WM_SetCaption(); real_SDL_WM_SetCaption()(MCPI_APP_TITLE, icon);
real_SDL_WM_SetCaption(MCPI_APP_TITLE, icon);
} }
// Mouse Cursor Is Always Invisible In Vanilla MCPI // Mouse Cursor Is Always Invisible In Vanilla MCPI
// Because In Vanilla MCPI, The GPU Overlay Covered The Normal Mouse Cursor // Because In Vanilla MCPI, The GPU Overlay Covered The Normal Mouse Cursor
HOOK(SDL_ShowCursor, int, (int toggle)) { HOOK(SDL_ShowCursor, int, (int toggle)) {
ensure_SDL_ShowCursor(); return real_SDL_ShowCursor()(toggle == SDL_QUERY ? SDL_QUERY : SDL_DISABLE);
return real_SDL_ShowCursor(toggle == SDL_QUERY ? SDL_QUERY : SDL_DISABLE);
} }
// Intercept SDL Events // Intercept SDL Events
@ -40,8 +38,7 @@ HOOK(SDL_PollEvent, int, (SDL_Event *event)) {
} }
// Poll Events // Poll Events
ensure_SDL_PollEvent(); int ret = real_SDL_PollEvent()(event);
int ret = real_SDL_PollEvent(event);
// Handle Events // Handle Events
if (ret == 1 && event != nullptr) { if (ret == 1 && event != nullptr) {

View File

@ -1,6 +1,7 @@
#include <vector> #include <vector>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
#include <cmath>
#include <symbols/minecraft.h> #include <symbols/minecraft.h>
#include <libreborn/libreborn.h> #include <libreborn/libreborn.h>
@ -18,15 +19,34 @@ static std::string to_string_with_precision(const double x, const int precision)
stream << std::fixed << std::setprecision(precision) << x; stream << std::fixed << std::setprecision(precision) << x;
return stream.str(); return stream.str();
} }
static float wrap_degrees(float x) {
x = std::fmod(x, 360);
if (x >= 180) {
x -= 360;
}
if (x < -180) {
x += 360;
}
return x;
}
static int debug_precision = 3; static int debug_precision = 3;
static std::vector<std::string> get_debug_info(const Minecraft *minecraft) { static std::vector<std::string> get_debug_info_left(const Minecraft *minecraft) {
std::vector<std::string> info; std::vector<std::string> info;
// Version // Version
info.push_back(std::string("MCPI ") + version_get()); info.push_back(std::string("MCPI ") + version_get());
// FPS // FPS
info.push_back("FPS: " + to_string_with_precision(fps, debug_precision)); info.push_back("FPS: " + to_string_with_precision(fps, debug_precision));
// X/Y/Z // Level Information
if (minecraft->level) {
info.push_back("");
info.push_back("Seed: " + std::to_string(minecraft->level->data.seed));
info.push_back("Time: " + std::to_string(minecraft->level->data.time));
info.push_back("Entities: " + std::to_string(minecraft->level->entities.size()));
info.push_back("Players: " + std::to_string(minecraft->level->players.size()));
}
// Player Information
if (minecraft->player) { if (minecraft->player) {
// X/Y/Z
info.push_back(""); info.push_back("");
float x = minecraft->player->x; float x = minecraft->player->x;
float y = minecraft->player->y - minecraft->player->height_offset; float y = minecraft->player->y - minecraft->player->height_offset;
@ -35,6 +55,94 @@ static std::vector<std::string> get_debug_info(const Minecraft *minecraft) {
info.push_back("X: " + to_string_with_precision(x, debug_precision)); info.push_back("X: " + to_string_with_precision(x, debug_precision));
info.push_back("Y: " + to_string_with_precision(y, debug_precision)); info.push_back("Y: " + to_string_with_precision(y, debug_precision));
info.push_back("Z: " + to_string_with_precision(z, debug_precision)); info.push_back("Z: " + to_string_with_precision(z, debug_precision));
// Rotation
info.push_back("");
const float yaw = wrap_degrees(minecraft->player->yaw);
info.push_back("Yaw: " + to_string_with_precision(yaw, debug_precision));
const float pitch = wrap_degrees(minecraft->player->pitch);
info.push_back("Pitch: " + to_string_with_precision(pitch, debug_precision));
// Facing
char axis[3] = {};
bool is_positive_on_axis;
std::string direction;
if (const float abs_yaw = std::abs(yaw); abs_yaw < 45 || abs_yaw > 135) {
// Z-Axis
axis[1] = 'Z';
is_positive_on_axis = abs_yaw < 90;
direction = is_positive_on_axis ? "South" : "North";
} else {
// X-Axis
axis[1] = 'X';
is_positive_on_axis = yaw < 0;
direction = is_positive_on_axis ? "East" : "West";
}
axis[0] = is_positive_on_axis ? '+' : '-';
info.push_back("Facing: " + direction + " (" + axis + ")");
}
// Return
return info;
}
static std::vector<std::string> get_debug_info_right(const Minecraft *minecraft) {
std::vector<std::string> info;
// TPS
info.push_back("TPS: " + to_string_with_precision(tps, debug_precision));
// Target Information
const HitResult &target = minecraft->hit_result;
if (target.type != 2) {
float x;
float y;
float z;
std::string type;
std::vector<std::string> type_info;
int xyz_precision;
if (target.type == 0) {
// Tile
x = float(target.x);
y = float(target.y);
z = float(target.z);
type = "Tile";
if (minecraft->level) {
const int id = minecraft->level->getTile(x, y, z);
std::string id_info = "ID: " + std::to_string(id);
if (Tile *tile = Tile::tiles[id]) {
const std::string description_id = tile->getDescriptionId();
std::string name = description_id + ".name";
if (I18n::_strings.contains(name)) {
name = I18n::_strings[name];
} else {
name = description_id;
}
if (!name.empty()) {
id_info += " (" + name + ')';
}
}
type_info.push_back(id_info);
type_info.push_back("Data: " + std::to_string(minecraft->level->getData(x, y, z)));
}
xyz_precision = 0;
} else {
// Entity
Entity *entity = target.entity;
x = entity->x;
y = entity->y;
z = entity->z;
type = "Entity";
type_info.push_back("Type ID: " + std::to_string(entity->getEntityTypeId())); // TODO: Specify name when RJ PR is merged
type_info.push_back("ID: " + std::to_string(entity->id));
if (entity->isMob()) {
Mob *mob = (Mob *) entity;
type_info.push_back("Health: " + std::to_string(mob->health) + '/' + std::to_string(mob->getMaxHealth()));
}
xyz_precision = debug_precision;
}
minecraft->command_server->pos_translator.to(x, y, z);
info.push_back("");
info.push_back("Target X: " + to_string_with_precision(x, xyz_precision));
info.push_back("Target Y: " + to_string_with_precision(y, xyz_precision));
info.push_back("Target Z: " + to_string_with_precision(z, xyz_precision));
info.push_back("");
info.push_back("Target Type: " + type);
info.insert(info.end(), type_info.begin(), type_info.end());
} }
// Return // Return
return info; return info;
@ -43,14 +151,21 @@ static std::vector<std::string> get_debug_info(const Minecraft *minecraft) {
// Render Text With Background // Render Text With Background
static constexpr uint32_t debug_background_color = 0x90505050; static constexpr uint32_t debug_background_color = 0x90505050;
static constexpr int debug_text_color = 0xe0e0e0; static constexpr int debug_text_color = 0xe0e0e0;
static constexpr int debug_background_padding = 1; static void render_debug_line(Gui *gui, const std::string &line, int x, const int y, const bool right_aligned) {
static void render_debug_line(Gui *gui, std::string &line, const int x, const int y) {
// Draw Background // Draw Background
const int width = gui->minecraft->font->width(line); const int width = gui->minecraft->font->width(line);
if (width == 0) { if (width == 0) {
return; return;
} }
gui->fill(x - debug_background_padding, y - debug_background_padding, x + width + debug_background_padding, y + line_height, debug_background_color); if (right_aligned) {
const int screen_width = int(float(gui->minecraft->screen_width) * Gui::InvGuiScale);
x = screen_width - x - width + 1;
}
int x1 = x - 1;
int y1 = y - 1;
int x2 = x + width;
int y2 = y + line_height;
gui->fill(x1, y1, x2, y2, debug_background_color);
// Draw Text // Draw Text
gui->minecraft->font->draw(line, float(x), float(y), debug_text_color); gui->minecraft->font->draw(line, float(x), float(y), debug_text_color);
} }
@ -58,16 +173,19 @@ static void render_debug_line(Gui *gui, std::string &line, const int x, const in
static bool debug_info_shown = false; static bool debug_info_shown = false;
static constexpr int debug_margin = 2; static constexpr int debug_margin = 2;
static constexpr int debug_line_padding = 1; static constexpr int debug_line_padding = 1;
static void Gui_renderDebugInfo_injection(__attribute__((unused)) Gui_renderDebugInfo_t original, Gui *self) { static void render_debug_info(Gui *self, const std::vector<std::string> &info, const bool right_aligned) {
if (debug_info_shown) {
std::vector<std::string> info = get_debug_info(self->minecraft);
int y = debug_margin; int y = debug_margin;
for (std::string &line : info) { for (const std::string &line : info) {
render_debug_line(self, line, debug_margin, y); render_debug_line(self, line, debug_margin, y, right_aligned);
y += line_height; y += line_height;
y += debug_line_padding; y += debug_line_padding;
} }
} }
static void Gui_renderDebugInfo_injection(__attribute__((unused)) Gui_renderDebugInfo_t original, Gui *self) {
if (debug_info_shown) {
render_debug_info(self, get_debug_info_left(self->minecraft), false);
render_debug_info(self, get_debug_info_right(self->minecraft), true);
}
} }
// Init // Init

View File

@ -16,32 +16,65 @@ static long long int get_time() {
return a + b; return a + b;
} }
// Track FPS // Tracker
static bool log_fps; struct Tracker {
double fps = 0; // State
static void update_fps() { long long int counter = 0;
// Track Frames long long int last_time = get_time();
static long long int frames = 0; // Properties
frames++; double &out;
const std::function<void()> callback;
// Constructor
Tracker(double &out_, const std::function<void()> &callback_):
out(out_),
callback(callback_) {}
// Update
void update() {
// Update Counter
counter++;
// Get Delta // Get Delta
const long long int time = get_time(); const long long int time = get_time();
static long long int last_time = time;
const long long int delta = time - last_time; const long long int delta = time - last_time;
const double delta_seconds = double(delta) / double(NANOSECONDS_IN_SECOND); const double delta_seconds = double(delta) / double(NANOSECONDS_IN_SECOND);
// Calculate FPS // Calculate FPS
if (delta_seconds >= 1) { if (delta_seconds >= 1) {
fps = double(frames) / delta_seconds; out = double(counter) / delta_seconds;
frames = 0; counter = 0;
last_time = time; last_time = time;
// Callback
if (callback) {
callback();
}
}
}
};
// Track FPS
static bool log_fps;
double fps = 0;
static void fps_callback() {
// Log // Log
if (log_fps) { if (log_fps) {
INFO("FPS: %f", fps); INFO("FPS: %f", fps);
} }
} }
static Tracker fps_tracker(fps, fps_callback);
static void update_fps() {
fps_tracker.update();
}
// Track TPS
double tps = 0;
static Tracker tps_tracker(tps, nullptr);
static void update_tps(__attribute__((unused)) Minecraft *minecraft) {
tps_tracker.update();
} }
// Init // Init
void init_fps() { void init_fps() {
if (!reborn_is_headless()) {
misc_run_on_swap_buffers(update_fps); misc_run_on_swap_buffers(update_fps);
log_fps = feature_has("Log FPS", server_disabled); log_fps = feature_has("Log FPS", server_disabled);
} }
misc_run_on_tick(update_tps);
}

View File

@ -24,8 +24,8 @@ __attribute__((constructor)) static void init() {
init_title_screen(); init_title_screen();
if (!reborn_is_headless()) { if (!reborn_is_headless()) {
init_skin(); init_skin();
init_fps();
} }
init_fps();
init_touch(); init_touch();
init_textures(); init_textures();
init_creative(); init_creative();

View File

@ -43,8 +43,7 @@ static void Inventory_setupDefault_FillingContainer_addItem_call_injection(Filli
SETUP_CALLBACK(swap_buffers); SETUP_CALLBACK(swap_buffers);
HOOK(media_swap_buffers, void, ()) { HOOK(media_swap_buffers, void, ()) {
get_misc_swap_buffers_functions().run(); get_misc_swap_buffers_functions().run();
ensure_media_swap_buffers(); real_media_swap_buffers()();
real_media_swap_buffers();
} }
// API // API

View File

@ -1,3 +1,5 @@
#include <cmath>
#include <libreborn/libreborn.h> #include <libreborn/libreborn.h>
#include <symbols/minecraft.h> #include <symbols/minecraft.h>
@ -88,12 +90,11 @@ static void sort_chunks(Chunk **chunks_begin, Chunk **chunks_end, const Distance
} }
// Fire Rendering // Fire Rendering
static void EntityRenderDispatcher_render_EntityRenderer_render_injection(EntityRenderer *self, Entity *entity, float x, float y, float z, float rot, float unknown) { static void render_fire(EntityRenderer *self, Entity *entity, const float x, float y, const float z) {
// Call Original Method // Check If Entity Is On Fire
self->render(entity, x, y, z, rot, unknown); if (!entity->isOnFire()) {
return;
// Render Fire }
if (entity->isOnFire()) {
// Here Be Decompiled Code // Here Be Decompiled Code
y -= entity->height_offset; y -= entity->height_offset;
const int texture = Tile::fire->texture; const int texture = Tile::fire->texture;
@ -152,6 +153,131 @@ static void EntityRenderDispatcher_render_EntityRenderer_render_injection(Entity
t.draw(); t.draw();
glPopMatrix(); glPopMatrix();
} }
// Entity Shadows
static void render_shadow_tile(Tile *tile, const float x, const float y, const float z, int xt, int yt, int zt, const float pow, const float r, const float xo, const float yo, const float zo) {
Tesselator &t = Tesselator::instance;
if (!tile->isCubeShaped()) {
return;
}
float a = ((pow - (y - (float(yt) + yo)) / 2) * 0.5f) * EntityRenderer::entityRenderDispatcher->level->getBrightness(xt, yt, zt);
if (a < 0) {
return;
} else if (a > 1) {
a = 1;
}
t.color(255, 255, 255, int(a * 255));
float x0 = float(xt) + tile->x1 + xo;
float x1 = float(xt) + tile->x2 + xo;
float y0 = float(yt) + tile->y1 + yo + 1.0f / 64.0f;
float z0 = float(zt) + tile->z1 + zo;
float z1 = float(zt) + tile->z2 + zo;
float u0 = (x - x0) / 2 / r + 0.5f;
float u1 = (x - x1) / 2 / r + 0.5f;
float v0 = (z - z0) / 2 / r + 0.5f;
float v1 = (z - z1) / 2 / r + 0.5f;
t.vertexUV(x0, y0, z0, u0, v0);
t.vertexUV(x0, y0, z1, u0, v1);
t.vertexUV(x1, y0, z1, u1, v1);
t.vertexUV(x1, y0, z0, u1, v0);
}
static void render_shadow(const EntityRenderer *self, Entity *entity, float x, float y, float z, const float a) {
// Calculate Power
float pow = 0;
if (self->shadow_radius > 0) {
const float dist = EntityRenderer::entityRenderDispatcher->distanceToSqr(entity->x, entity->y, entity->z);
pow = (1 - dist / (16.0f * 16.0f)) * self->shadow_strength;
}
if (pow <= 0) {
return;
}
// Render
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Textures *textures = EntityRenderer::entityRenderDispatcher->textures;
textures->loadAndBindTexture("misc/shadow.png");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
Level *level = EntityRenderer::entityRenderDispatcher->level;
glDepthMask(false);
const float r = self->shadow_radius;
const float ex = entity->old_x + (entity->x - entity->old_x) * a;
float ey = entity->old_y + (entity->y - entity->old_y) * a + entity->getShadowHeightOffs() - entity->height_offset;
const float ez = entity->old_z + (entity->z - entity->old_z) * a;
const int x0 = Mth::floor(ex - r);
const int x1 = Mth::floor(ex + r);
const int y0 = Mth::floor(ey - r);
const int y1 = Mth::floor(ey);
const int z0 = Mth::floor(ez - r);
const int z1 = Mth::floor(ez + r);
const float xo = x - ex;
const float yo = y - ey;
const float zo = z - ez;
Tesselator &tt = Tesselator::instance;
tt.begin(7);
for (int xt = x0; xt <= x1; xt++) {
for (int yt = y0; yt <= y1; yt++) {
for (int zt = z0; zt <= z1; zt++) {
const int t = level->getTile(xt, yt - 1, zt);
if (t > 0 && level->getRawBrightness(xt, yt, zt) > 3) {
render_shadow_tile(
Tile::tiles[t],
x, y + entity->getShadowHeightOffs() - entity->height_offset, z,
xt, yt, zt,
pow, r,
xo, yo + entity->getShadowHeightOffs() - entity->height_offset, zo
);
}
}
}
}
tt.draw();
glColor4f(1, 1, 1, 1);
glDisable(GL_BLEND);
glDepthMask(true);
}
static void EntityRenderDispatcher_assign_injection(EntityRenderDispatcher_assign_t original, EntityRenderDispatcher *self, const uchar entity_id, EntityRenderer *renderer) {
// Modify Shadow Size
float new_radius;
switch (entity_id) {
case 16:
case 3: {
new_radius = 0.5f;
break;
}
case 9:
case 7:
case 8: {
new_radius = 0.7f;
break;
}
case 6: {
new_radius = 0.3f;
break;
}
default: {
new_radius = renderer->shadow_radius;
}
}
renderer->shadow_radius = new_radius;
// Call Original Method
original(self, entity_id, renderer);
}
// Modify Entity Rendering
static bool should_render_fire;
static bool should_render_shadows;
static void EntityRenderDispatcher_render_EntityRenderer_render_injection(EntityRenderer *self, Entity *entity, float x, float y, float z, float rot, float unknown) {
// Call Original Method
self->render(entity, x, y, z, rot, unknown);
// Render Shadow
if (should_render_shadows) {
render_shadow(self, entity, x, y, z, unknown);
}
// Render Fire
if (should_render_fire) {
render_fire(self, entity, x, y, z);
}
} }
// Nicer Water Rendering // Nicer Water Rendering
@ -261,6 +387,86 @@ static ContainerMenu *ContainerMenu_destructor_injection(ContainerMenu_destructo
return original(container_menu); return original(container_menu);
} }
// 3D Dropped Items
static bool disable_hand_positioning = false;
static void ItemInHandRenderer_renderItem_glTranslatef_injection(const float x, const float y, const float z) {
if (disable_hand_positioning) {
glPopMatrix();
glPushMatrix();
} else {
glTranslatef(x, y, z);
}
}
static void ItemRenderer_render_injection(ItemRenderer_render_t original, ItemRenderer *self, Entity *entity, const float x, const float y, const float z, const float a, const float b) {
// Get Item
const ItemEntity *item_entity = (ItemEntity *) entity;
ItemInstance item = item_entity->item;
// Check If Item Is Tile
if (item.id < 256 && TileRenderer::canRender(Tile::tiles[item.id]->getRenderShape())) {
// Call Original Method
original(self, entity, x, y, z, a, b);
} else {
// 3D Item
self->random.setSeed(187);
glPushMatrix();
// Count
int count;
if (item.count < 2) {
count = 1;
} else if (item.count < 16) {
count = 2;
} else if (item.count < 32) {
count = 3;
} else {
count = 4;
}
// Bob
const float age = float(item_entity->age) + b;
const float bob = (Mth::sin((age / 10.0f) + item_entity->bob_offset) * 0.1f) + 0.1f;
glTranslatef(x, y + bob, z);
// Scale
glScalef(0.5f, 0.5f, 0.5f);
// Spin
const float spin = ((age / 20.0f) + item_entity->bob_offset) * float(180.0f / M_PI);
glRotatef(spin, 0, 1, 0);
// Position
constexpr float xo = 0.5f;
constexpr float yo = 0.25f;
constexpr float width = 1 / 16.0f;
constexpr float margin = 0.35f / 16.0f;
constexpr float zo = width + margin;
glTranslatef(-xo, -yo, -((zo * float(count)) / 2));
// Draw
disable_hand_positioning = true;
for (int i = 0; i < count; i++) {
glTranslatef(0, 0, zo);
EntityRenderer::entityRenderDispatcher->item_renderer->renderItem(nullptr, &item);
}
disable_hand_positioning = false;
// Finish
glPopMatrix();
}
}
// Vignette
static void Gui_renderProgressIndicator_injection(Gui_renderProgressIndicator_t original, Gui *self, const bool is_touch, int width, int height, float a) {
// Render
glEnable(GL_BLEND);
self->minecraft->textures->blur = true;
self->renderVignette(self->minecraft->player->getBrightness(a), width, height);
self->minecraft->textures->blur = false;
glDisable(GL_BLEND);
// Call Original Method
original(self, is_touch, width, height, a);
}
// Init // Init
void _init_misc_graphics() { void _init_misc_graphics() {
// Disable V-Sync // Disable V-Sync
@ -288,6 +494,15 @@ void _init_misc_graphics() {
overwrite_call((void *) 0x4d764, (void *) LevelRenderer_render_AABB_glColor4f_injection); overwrite_call((void *) 0x4d764, (void *) LevelRenderer_render_AABB_glColor4f_injection);
} }
// Properly Hide Block Outline
if (feature_has("Hide Block Outline When GUI Is Hidden", server_disabled)) {
overwrite_calls(LevelRenderer_renderHitSelect, [](LevelRenderer_renderHitSelect_t original, LevelRenderer *self, Player *player, const HitResult &hit_result, const int i, void *vp, const float f) {
if (!self->minecraft->options.hide_gui) {
original(self, player, hit_result, i, vp, f);
}
});
}
// Java Light Ramp // Java Light Ramp
if (feature_has("Use Java Beta 1.3 Light Ramp", server_disabled)) { if (feature_has("Use Java Beta 1.3 Light Ramp", server_disabled)) {
overwrite_calls(Dimension_updateLightRamp, Dimension_updateLightRamp_injection); overwrite_calls(Dimension_updateLightRamp, Dimension_updateLightRamp_injection);
@ -298,9 +513,12 @@ void _init_misc_graphics() {
overwrite_calls_manual((void *) 0x51fac, (void *) sort_chunks); overwrite_calls_manual((void *) 0x51fac, (void *) sort_chunks);
} }
// Render Fire In Third-Person // Modify Entity Rendering
if (feature_has("Render Fire In Third-Person", server_disabled)) {
overwrite_call((void *) 0x606c0, (void *) EntityRenderDispatcher_render_EntityRenderer_render_injection); overwrite_call((void *) 0x606c0, (void *) EntityRenderDispatcher_render_EntityRenderer_render_injection);
should_render_fire = feature_has("Render Fire In Third-Person", server_disabled);
should_render_shadows = feature_has("Render Entity Shadows", server_disabled);
if (should_render_shadows) {
overwrite_calls(EntityRenderDispatcher_assign, EntityRenderDispatcher_assign_injection);
} }
// Slightly Nicer Water Rendering // Slightly Nicer Water Rendering
@ -342,6 +560,17 @@ void _init_misc_graphics() {
overwrite_calls(ChestTileEntity_shouldSave, ChestTileEntity_shouldSave_injection); overwrite_calls(ChestTileEntity_shouldSave, ChestTileEntity_shouldSave_injection);
} }
// 3D Dropped Items
if (feature_has("3D Dropped Items", server_disabled)) {
overwrite_calls(ItemRenderer_render, ItemRenderer_render_injection);
overwrite_call((void *) 0x4bf34, (void *) ItemInHandRenderer_renderItem_glTranslatef_injection);
}
// Vignette
if (feature_has("Render Vignette", server_disabled)) {
overwrite_calls(Gui_renderProgressIndicator, Gui_renderProgressIndicator_injection);
}
// Don't Render Game In Headless Mode // Don't Render Game In Headless Mode
if (reborn_is_headless()) { if (reborn_is_headless()) {
overwrite_calls(GameRenderer_render, nop<GameRenderer_render_t, GameRenderer *, float>); overwrite_calls(GameRenderer_render, nop<GameRenderer_render_t, GameRenderer *, float>);

View File

@ -48,10 +48,10 @@ static void LoginPacket_read_injection(LoginPacket_read_t original, LoginPacket
// RakNet::RakString's format constructor is often given unsanitized user input and is never used for formatting, // RakNet::RakString's format constructor is often given unsanitized user input and is never used for formatting,
// this is a massive security risk, allowing clients to run arbitrary format specifiers, this disables the // this is a massive security risk, allowing clients to run arbitrary format specifiers, this disables the
// formatting functionality. // formatting functionality.
RakNet_RakString_constructor_t RakNet_RakString_constructor = (RakNet_RakString_constructor_t) 0xea5cc; RakNet_RakString_constructor_2_t RakNet_RakString_constructor_2 = (RakNet_RakString_constructor_2_t) 0xea5cc;
static RakNet_RakString *RakNet_RakString_injection(RakNet_RakString *rak_string, const char *format, ...) { static RakNet_RakString *RakNet_RakString_injection(RakNet_RakString *rak_string, const char *format, ...) {
// Call Original Method // Call Original Method
return RakNet_RakString_constructor(rak_string, "%s", format); return RakNet_RakString_constructor_2(rak_string, "%s", format);
} }
// Print Error Message If RakNet Startup Fails // Print Error Message If RakNet Startup Fails
@ -145,8 +145,7 @@ HOOK(bind, int, (int sockfd, const struct sockaddr *addr, socklen_t addrlen)) {
} }
new_addr = (const sockaddr *) &in_addr; new_addr = (const sockaddr *) &in_addr;
} }
ensure_bind(); return real_bind()(sockfd, new_addr, addrlen);
return real_bind(sockfd, new_addr, addrlen);
} }
// Generate Caves // Generate Caves
@ -434,6 +433,15 @@ static void Player_tick_injection(Player_tick_t original, Player *self) {
original(self); original(self);
} }
// Rare Segfault
static int Dimension_isValidSpawn_Level_getTopTile_injection(Level *self, int x, int z) {
int ret = self->getTopTile(x, z);
if (ret == 0) {
ret = Tile::invisible_bedrock->id;
}
return ret;
}
// Init // Init
void init_misc() { void init_misc() {
// Sanitize Username // Sanitize Username
@ -443,7 +451,7 @@ void init_misc() {
// Fix RakNet::RakString Security Bug // Fix RakNet::RakString Security Bug
if (feature_has("Patch RakNet Security Bug", server_enabled)) { if (feature_has("Patch RakNet Security Bug", server_enabled)) {
overwrite_calls_manual((void *) RakNet_RakString_constructor, (void *) RakNet_RakString_injection); overwrite_calls_manual((void *) RakNet_RakString_constructor_2, (void *) RakNet_RakString_injection);
} }
// Print Error Message If RakNet Startup Fails // Print Error Message If RakNet Startup Fails
@ -579,6 +587,11 @@ void init_misc() {
overwrite_calls(Player_tick, Player_tick_injection); overwrite_calls(Player_tick, Player_tick_injection);
} }
// Rare Segfault
if (feature_has("Fix Crash When Generating Certain Seeds", server_enabled)) {
overwrite_call((void *) 0xb198c, (void *) Dimension_isValidSpawn_Level_getTopTile_injection);
}
// Init Other Components // Init Other Components
_init_misc_tinting(); _init_misc_tinting();
_init_misc_ui(); _init_misc_ui();

View File

@ -199,6 +199,41 @@ static void PauseScreen_init_injection(PauseScreen_init_t original, PauseScreen
} }
} }
// Click Buttons On Mouse Down
static void Screen_mouseClicked_injection(__attribute__((unused)) Screen_mouseClicked_t original, Screen *self, int x, int y, const int param_1) {
if (param_1 == 1) {
for (Button *button : self->rendered_buttons) {
if (button->clicked(self->minecraft, x, y)) {
// Click
button->setPressed();
self->clicked_button = button;
self->buttonClicked(button);
// Play Sound
self->minecraft->sound_engine->playUI("random.click", 1, 1);
}
}
}
}
static void Screen_mouseReleased_injection(__attribute__((unused)) Screen_mouseReleased_t original, Screen *self, int x, int y, const int param_1) {
if (param_1 == 1 && self->clicked_button) {
self->clicked_button->released(x, y);
self->clicked_button = nullptr;
}
}
// Fix Exiting Pause Screen
static void Minecraft_grabMouse_injection(Minecraft_grabMouse_t original, Minecraft *self) {
original(self);
self->miss_time = 10000;
}
static void Minecraft_handleMouseDown_injection(Minecraft_handleMouseDown_t original, Minecraft *self, int param_1, bool can_destroy) {
// Call Original Method
original(self, param_1, can_destroy);
// Reset Miss Time
if (!can_destroy) {
self->miss_time = 0;
}
}
// Init // Init
void _init_misc_ui() { void _init_misc_ui() {
// Food Overlay // Food Overlay
@ -288,4 +323,12 @@ void _init_misc_ui() {
uchar set_true_patch[] = {0x01, 0x30, 0xa0, 0x03}; // "moveq r3, #0x1" uchar set_true_patch[] = {0x01, 0x30, 0xa0, 0x03}; // "moveq r3, #0x1"
patch((void *) 0x4b93c, set_true_patch); patch((void *) 0x4b93c, set_true_patch);
} }
// Click Buttons On Mouse Down
if (feature_has("Click Buttons On Mouse Down", server_disabled)) {
overwrite_calls(Screen_mouseClicked, Screen_mouseClicked_injection);
overwrite_calls(Screen_mouseReleased, Screen_mouseReleased_injection);
overwrite_calls(Minecraft_grabMouse, Minecraft_grabMouse_injection);
overwrite_calls(Minecraft_handleMouseDown, Minecraft_handleMouseDown_injection);
}
} }

View File

@ -26,8 +26,7 @@ HOOK(glDeleteBuffers, void, (GLsizei n, const GLuint *buffers)) {
if (buffers[0] >= MULTIDRAW_BASE) { if (buffers[0] >= MULTIDRAW_BASE) {
delete storage; delete storage;
} else { } else {
ensure_glDeleteBuffers(); real_glDeleteBuffers()(n, buffers);
real_glDeleteBuffers(n, buffers);
} }
} }
@ -40,15 +39,13 @@ HOOK(glBindBuffer, void, (const GLenum target, GLuint buffer)) {
} else { } else {
current_chunk = -1; current_chunk = -1;
} }
ensure_glBindBuffer(); real_glBindBuffer()(target, buffer);
real_glBindBuffer(target, buffer);
} }
HOOK(glBufferData, void, (GLenum target, GLsizeiptr size, const void *data, GLenum usage)) { HOOK(glBufferData, void, (GLenum target, GLsizeiptr size, const void *data, GLenum usage)) {
if (target == GL_ARRAY_BUFFER && current_chunk >= 0 && storage != nullptr) { if (target == GL_ARRAY_BUFFER && current_chunk >= 0 && storage != nullptr) {
storage->upload(current_chunk, size, data); storage->upload(current_chunk, size, data);
} else { } else {
ensure_glBufferData(); real_glBufferData()(target, size, data, usage);
real_glBufferData(target, size, data, usage);
} }
} }
@ -84,17 +81,13 @@ static void multidraw_renderSameAsLast(const LevelRenderer *self, const float b)
glColorPointer(4, GL_UNSIGNED_BYTE, VERTEX_SIZE, (void *) 0x14); glColorPointer(4, GL_UNSIGNED_BYTE, VERTEX_SIZE, (void *) 0x14);
// Draw // Draw
#ifdef MCPI_USE_GLES1_COMPATIBILITY_LAYER
if (supports_multidraw()) { if (supports_multidraw()) {
glMultiDrawArrays(GL_TRIANGLES, multidraw_firsts, multidraw_counts, multidraw_total); glMultiDrawArrays(GL_TRIANGLES, multidraw_firsts, multidraw_counts, multidraw_total);
} else { } else {
#endif
for (int i = 0; i < multidraw_total; i++) { for (int i = 0; i < multidraw_total; i++) {
glDrawArrays(GL_TRIANGLES, multidraw_firsts[i], multidraw_counts[i]); glDrawArrays(GL_TRIANGLES, multidraw_firsts[i], multidraw_counts[i]);
} }
#ifdef MCPI_USE_GLES1_COMPATIBILITY_LAYER
} }
#endif
// Cleanup // Cleanup
glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_COLOR_ARRAY);

View File

@ -16,8 +16,7 @@
HOOK(access, int, (const char *pathname, int mode)) { HOOK(access, int, (const char *pathname, int mode)) {
char *new_path = override_get_path(pathname); char *new_path = override_get_path(pathname);
// Open File // Open File
ensure_access(); const int ret = real_access()(new_path != nullptr ? new_path : pathname, mode);
const int ret = real_access(new_path != nullptr ? new_path : pathname, mode);
// Free Data // Free Data
if (new_path != nullptr) { if (new_path != nullptr) {
free(new_path); free(new_path);
@ -61,8 +60,7 @@ char *override_get_path(const char *filename) {
// Test Asset Folders // Test Asset Folders
for (int i = 0; !asset_folders[i].empty(); i++) { for (int i = 0; !asset_folders[i].empty(); i++) {
new_path = asset_folders[i] + '/' + &filename[data_prefix_length]; new_path = asset_folders[i] + '/' + &filename[data_prefix_length];
ensure_access(); if (real_access()(new_path.c_str(), F_OK) == -1) {
if (real_access(new_path.c_str(), F_OK) == -1) {
// Not Found In Asset Folder // Not Found In Asset Folder
new_path = ""; new_path = "";
continue; continue;
@ -87,8 +85,7 @@ char *override_get_path(const char *filename) {
HOOK(fopen, FILE *, (const char *filename, const char *mode)) { HOOK(fopen, FILE *, (const char *filename, const char *mode)) {
char *new_path = override_get_path(filename); char *new_path = override_get_path(filename);
// Open File // Open File
ensure_fopen(); FILE *file = real_fopen()(new_path != nullptr ? new_path : filename, mode);
FILE *file = real_fopen(new_path != nullptr ? new_path : filename, mode);
// Free Data // Free Data
if (new_path != nullptr) { if (new_path != nullptr) {
free(new_path); free(new_path);
@ -101,8 +98,7 @@ HOOK(fopen, FILE *, (const char *filename, const char *mode)) {
HOOK(fopen64, FILE *, (const char *filename, const char *mode)) { HOOK(fopen64, FILE *, (const char *filename, const char *mode)) {
char *new_path = override_get_path(filename); char *new_path = override_get_path(filename);
// Open File // Open File
ensure_fopen64(); FILE *file = real_fopen64()(new_path != nullptr ? new_path : filename, mode);
FILE *file = real_fopen64(new_path != nullptr ? new_path : filename, mode);
// Free Data // Free Data
if (new_path != nullptr) { if (new_path != nullptr) {
free(new_path); free(new_path);

View File

@ -1,6 +1,5 @@
#include <string> #include <string>
#include <cstdint> #include <cstdint>
#include <ctime>
#include <cstdio> #include <cstdio>
#include <fstream> #include <fstream>
#include <vector> #include <vector>
@ -21,6 +20,7 @@
#include <mods/compat/compat.h> #include <mods/compat/compat.h>
#include <mods/misc/misc.h> #include <mods/misc/misc.h>
#include <mods/game-mode/game-mode.h> #include <mods/game-mode/game-mode.h>
#include <mods/fps/fps.h>
// --only-generate: Ony Generate World And Then Exit // --only-generate: Ony Generate World And Then Exit
static bool only_generate = false; static bool only_generate = false;
@ -35,24 +35,28 @@ ServerProperties &get_server_properties() {
} }
// Default Server Properties // Default Server Properties
namespace ServerPropertyTypes { struct ServerPropertyTypes {
static ServerProperty message_of_the_day("motd", "Minecraft Server", "Message Of The Day"); const ServerProperty message_of_the_day = ServerProperty("motd", "Minecraft Server", "Message Of The Day");
static ServerProperty show_minecon_badge("show-minecon-badge", "false", "Show The MineCon Badge Next To MOTD In Server List"); const ServerProperty show_minecon_badge = ServerProperty("show-minecon-badge", "false", "Show The MineCon Badge Next To MOTD In Server List");
static ServerProperty game_mode("game-mode", "0", "Game Mode (0 = Survival, 1 = Creative)"); const ServerProperty game_mode = ServerProperty("game-mode", "0", "Game Mode (0 = Survival, 1 = Creative)");
static ServerProperty port("port", "19132", "Port"); const ServerProperty port = ServerProperty("port", "19132", "Port");
static ServerProperty seed("seed", "", "World Seed (Blank = Random Seed)"); const ServerProperty seed = ServerProperty("seed", "", "World Seed (Blank = Random Seed)");
static ServerProperty force_mob_spawning("force-mob-spawning", "false", "Force Mob Spawning (false = Disabled, true = Enabled)"); const ServerProperty force_mob_spawning = ServerProperty("force-mob-spawning", "false", "Force Mob Spawning (false = Disabled, true = Enabled)");
static ServerProperty peaceful_mode("peaceful-mode", "false", "Peaceful Mode (false = Disabled, true = Enabled)"); const ServerProperty peaceful_mode = ServerProperty("peaceful-mode", "false", "Peaceful Mode (false = Disabled, true = Enabled)");
static ServerProperty world_name("world-name", "world", "World To Select"); const ServerProperty world_name = ServerProperty("world-name", "world", "World To Select");
static ServerProperty max_players("max-players", "4", "Maximum Player Count"); const ServerProperty max_players = ServerProperty("max-players", "4", "Maximum Player Count");
static ServerProperty enable_whitelist("whitelist", "false", "Enable Whitelist"); const ServerProperty enable_whitelist = ServerProperty("whitelist", "false", "Enable Whitelist");
static ServerProperty enable_death_messages("death-messages", "true", "Enable Death Messages"); const ServerProperty enable_death_messages = ServerProperty("death-messages", "true", "Enable Death Messages");
static ServerProperty enable_cave_generation("generate-caves", "true", "Generate Caves"); const ServerProperty enable_cave_generation = ServerProperty("generate-caves", "true", "Generate Caves");
};
static ServerPropertyTypes &get_property_types() {
static ServerPropertyTypes types;
return types;
} }
// Get World Name // Get World Name
static std::string get_world_name() { static std::string get_world_name() {
const std::string name = get_server_properties().get_string(ServerPropertyTypes::world_name); const std::string name = get_server_properties().get_string(get_property_types().world_name);
char *safe_name_c = to_cp437(name.c_str()); char *safe_name_c = to_cp437(name.c_str());
std::string safe_name = safe_name_c; std::string safe_name = safe_name_c;
free(safe_name_c); free(safe_name_c);
@ -69,12 +73,12 @@ static void start_world(Minecraft *minecraft) {
// Peaceful Mode // Peaceful Mode
Options *options = &minecraft->options; Options *options = &minecraft->options;
options->game_difficulty = get_server_properties().get_bool(ServerPropertyTypes::peaceful_mode) ? 0 : 2; options->game_difficulty = get_server_properties().get_bool(get_property_types().peaceful_mode) ? 0 : 2;
// Specify Level Settings // Specify Level Settings
LevelSettings settings; LevelSettings settings;
settings.game_type = get_server_properties().get_int(ServerPropertyTypes::game_mode); settings.game_type = get_server_properties().get_int(get_property_types().game_mode);
const std::string seed_str = get_server_properties().get_string(ServerPropertyTypes::seed); const std::string seed_str = get_server_properties().get_string(get_property_types().seed);
const int32_t seed = get_seed_from_string(seed_str); const int32_t seed = get_seed_from_string(seed_str);
settings.seed = seed; settings.seed = seed;
@ -84,7 +88,7 @@ static void start_world(Minecraft *minecraft) {
// Don't Open Port When Using --only-generate // Don't Open Port When Using --only-generate
if (!only_generate) { if (!only_generate) {
// Open Port // Open Port
const int port = get_server_properties().get_int(ServerPropertyTypes::port); const int port = get_server_properties().get_int(get_property_types().port);
INFO("Listening On: %i", port); INFO("Listening On: %i", port);
minecraft->hostMultiplayer(port); minecraft->hostMultiplayer(port);
} }
@ -98,7 +102,7 @@ static void start_world(Minecraft *minecraft) {
// Check If Running In Whitelist Mode // Check If Running In Whitelist Mode
static bool is_whitelist() { static bool is_whitelist() {
return get_server_properties().get_bool(ServerPropertyTypes::enable_whitelist); return get_server_properties().get_bool(get_property_types().enable_whitelist);
} }
// Get Path Of Blacklist (Or Whitelist) File // Get Path Of Blacklist (Or Whitelist) File
static std::string get_blacklist_file() { static std::string get_blacklist_file() {
@ -195,29 +199,6 @@ static void list_callback(Minecraft *minecraft, const std::string &username, Pla
INFO(" - %s (%s)", username.c_str(), get_player_ip(minecraft, player)); INFO(" - %s (%s)", username.c_str(), get_player_ip(minecraft, player));
} }
// Track TPS
#define NANOSECONDS_IN_SECOND 1000000000ll
static long long int get_time() {
timespec ts = {};
clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
const long long int a = (long long int) ts.tv_nsec;
const long long int b = ((long long int) ts.tv_sec) * NANOSECONDS_IN_SECOND;
return a + b;
}
static bool is_last_tick_time_set = false;
static long long int last_tick_time;
static double tps = 0;
static void Minecraft_tick_injection(__attribute__((unused)) const Minecraft *minecraft) {
const long long int time = get_time();
if (is_last_tick_time_set) {
const long long int tick_time = time - last_tick_time;
tps = ((double) NANOSECONDS_IN_SECOND) / ((double) tick_time);
} else {
is_last_tick_time_set = true;
}
last_tick_time = time;
}
// Get ServerSideNetworkHandler From Minecraft // Get ServerSideNetworkHandler From Minecraft
static ServerSideNetworkHandler *get_server_side_network_handler(const Minecraft *minecraft) { static ServerSideNetworkHandler *get_server_side_network_handler(const Minecraft *minecraft) {
return (ServerSideNetworkHandler *) minecraft->network_handler; return (ServerSideNetworkHandler *) minecraft->network_handler;
@ -498,7 +479,7 @@ static Player *ServerSideNetworkHandler_onReady_ClientGeneration_ServerSideNetwo
// Get MOTD // Get MOTD
static std::string get_motd() { static std::string get_motd() {
std::string motd(get_server_properties().get_string(ServerPropertyTypes::message_of_the_day)); std::string motd(get_server_properties().get_string(get_property_types().message_of_the_day));
return motd; return motd;
} }
@ -510,13 +491,13 @@ static const char *get_features() {
loaded_features = true; loaded_features = true;
features.clear(); features.clear();
if (get_server_properties().get_bool(ServerPropertyTypes::force_mob_spawning)) { if (get_server_properties().get_bool(get_property_types().force_mob_spawning)) {
features += "Force Mob Spawning|"; features += "Force Mob Spawning|";
} }
if (get_server_properties().get_bool(ServerPropertyTypes::enable_death_messages)) { if (get_server_properties().get_bool(get_property_types().enable_death_messages)) {
features += "Implement Death Messages|"; features += "Implement Death Messages|";
} }
if (get_server_properties().get_bool(ServerPropertyTypes::enable_cave_generation)) { if (get_server_properties().get_bool(get_property_types().enable_cave_generation)) {
features += "Generate Caves|"; features += "Generate Caves|";
} }
} }
@ -525,7 +506,7 @@ static const char *get_features() {
// Get Max Players // Get Max Players
static unsigned char get_max_players() { static unsigned char get_max_players() {
int val = get_server_properties().get_int(ServerPropertyTypes::max_players); int val = get_server_properties().get_int(get_property_types().max_players);
if (val < 0) { if (val < 0) {
val = 0; val = 0;
} }
@ -546,7 +527,8 @@ static void server_init() {
if (!properties_file.good()) { if (!properties_file.good()) {
// Write Defaults // Write Defaults
std::ofstream properties_file_output(file); std::ofstream properties_file_output(file);
for (const ServerProperty *property : ServerProperty::all) { get_property_types();
for (const ServerProperty *property : ServerProperty::get_all()) {
properties_file_output << "# " << property->comment << '\n'; properties_file_output << "# " << property->comment << '\n';
properties_file_output << property->key << '=' << property->def << '\n'; properties_file_output << property->key << '=' << property->def << '\n';
} }
@ -591,7 +573,7 @@ static void server_init() {
overwrite_calls(RakNet_RakPeer_IsBanned, RakNet_RakPeer_IsBanned_injection); overwrite_calls(RakNet_RakPeer_IsBanned, RakNet_RakPeer_IsBanned_injection);
// Show The MineCon Icon Next To MOTD In Server List // Show The MineCon Icon Next To MOTD In Server List
if (get_server_properties().get_bool(ServerPropertyTypes::show_minecon_badge)) { if (get_server_properties().get_bool(get_property_types().show_minecon_badge)) {
unsigned char minecon_badge_patch[4] = {0x04, 0x1a, 0x9f, 0xe5}; // "ldr r1, [0x741f0]" unsigned char minecon_badge_patch[4] = {0x04, 0x1a, 0x9f, 0xe5}; // "ldr r1, [0x741f0]"
patch((void *) 0x737e4, minecon_badge_patch); patch((void *) 0x737e4, minecon_badge_patch);
} }
@ -599,9 +581,6 @@ static void server_init() {
// Log IPs // Log IPs
overwrite_call((void *) 0x75e54, (void *) ServerSideNetworkHandler_onReady_ClientGeneration_ServerSideNetworkHandler_popPendingPlayer_injection); overwrite_call((void *) 0x75e54, (void *) ServerSideNetworkHandler_onReady_ClientGeneration_ServerSideNetworkHandler_popPendingPlayer_injection);
// Track TPS
misc_run_on_tick(Minecraft_tick_injection);
// Start Reading STDIN // Start Reading STDIN
pthread_create(&read_stdin_thread_obj, nullptr, read_stdin_thread, nullptr); pthread_create(&read_stdin_thread_obj, nullptr, read_stdin_thread, nullptr);
} }

View File

@ -1,6 +1,9 @@
#include <mods/server/server_properties.h> #include <mods/server/server_properties.h>
std::vector<const ServerProperty *> ServerProperty::all; std::vector<const ServerProperty *> &ServerProperty::get_all() {
static std::vector<const ServerProperty *> out;
return out;
}
static bool is_true(std::string const& val) { static bool is_true(std::string const& val) {
return (val == "true" || val == "yes" || val == "1"); return (val == "true" || val == "yes" || val == "1");

View File

@ -216,11 +216,7 @@ static DynamicTexture *create_fire_texture(const int a2) {
texture->super()->vtable = get_fire_texture_vtable(); texture->super()->vtable = get_fire_texture_vtable();
// Setup Random // Setup Random
texture->data.m_random = Random::allocate(); texture->data.m_random = Random::allocate();
const int seed = Common::getTimeMs(); texture->data.m_random->constructor();
texture->data.m_random->seed = seed;
texture->data.m_random->param_1 = 0x271;
texture->data.m_random->param_2 = false;
texture->data.m_random->param_3 = 0;
for (int i = 0; i < 320; i++) { for (int i = 0; i < 320; i++) {
texture->data.m_data1[i] = 0.0f; texture->data.m_data1[i] = 0.0f;
texture->data.m_data2[i] = 0.0f; texture->data.m_data2[i] = 0.0f;

View File

@ -43,8 +43,7 @@ HOOK(glTexImage2D, void, (GLenum target, GLint level, GLint internalformat, GLsi
get_texture_data().push_back(data); get_texture_data().push_back(data);
// Call Original Method // Call Original Method
ensure_glTexImage2D(); real_glTexImage2D()(target, level, internalformat, width, height, border, format, type, pixels);
real_glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
} }
HOOK(glDeleteTextures, void, (GLsizei n, const GLuint *textures)) { HOOK(glDeleteTextures, void, (GLsizei n, const GLuint *textures)) {
// Remove Old Data // Remove Old Data
@ -62,8 +61,7 @@ HOOK(glDeleteTextures, void, (GLsizei n, const GLuint *textures)) {
} }
// Call Original Method // Call Original Method
ensure_glDeleteTextures(); real_glDeleteTextures()(n, textures);
real_glDeleteTextures(n, textures);
} }
static void get_texture_size(const GLint id, GLsizei *width, GLsizei *height) { static void get_texture_size(const GLint id, GLsizei *width, GLsizei *height) {
// Iterate // Iterate

View File

@ -37,6 +37,7 @@ set(SRC
src/entity/PathfinderMob.def src/entity/PathfinderMob.def
src/entity/HumanoidModel.def src/entity/HumanoidModel.def
src/entity/TripodCameraRenderer.def src/entity/TripodCameraRenderer.def
src/entity/TripodCamera.def
src/entity/MobFactory.def src/entity/MobFactory.def
src/entity/EntityRenderDispatcher.def src/entity/EntityRenderDispatcher.def
src/entity/MobRenderer.def src/entity/MobRenderer.def

View File

@ -22,15 +22,16 @@ virtual-method int getAuxData() = 0xf4;
virtual-method bool isOnFire() = 0x90; virtual-method bool isOnFire() = 0x90;
virtual-method void baseTick() = 0x38; virtual-method void baseTick() = 0x38;
virtual-method bool isSneaking() = 0x88; virtual-method bool isSneaking() = 0x88;
virtual-method float getShadowHeightOffs() = 0x60;
property float x = 0x4; property float x = 0x4;
property float y = 0x8; property float y = 0x8;
property float z = 0xc; property float z = 0xc;
property int id = 0x1c; property int id = 0x1c;
property Level *level = 0x24; property Level *level = 0x24;
property float old_x = 0x28; property float old_x = 0x7c;
property float old_y = 0x2c; property float old_y = 0x80;
property float old_z = 0x30; property float old_z = 0x84;
property float vel_x = 0x34; property float vel_x = 0x34;
property float vel_y = 0x38; property float vel_y = 0x38;
property float vel_z = 0x3c; property float vel_z = 0x3c;

View File

@ -2,8 +2,11 @@ constructor () = 0x6096c;
method void assign(uchar entity_id, EntityRenderer *renderer) = 0x6094c; method void assign(uchar entity_id, EntityRenderer *renderer) = 0x6094c;
method void render(Entity *entity, float x, float y, float z, float rot, float unknown) = 0x60674; method void render(Entity *entity, float x, float y, float z, float rot, float unknown) = 0x60674;
method float distanceToSqr(float x, float y, float z) = 0x60790;
static-method EntityRenderDispatcher *getInstance() = 0x60e90; static-method EntityRenderDispatcher *getInstance() = 0x60e90;
property ItemInHandRenderer *item_renderer = 0x0; property ItemInHandRenderer *item_renderer = 0x0;
property float player_rot_y = 0x14; property float player_rot_y = 0x14;
property Minecraft *minecraft = 0xc; property Minecraft *minecraft = 0xc;
property Level *level = 0x8;
property Textures *textures = 0x4;

View File

@ -1,7 +1,12 @@
vtable 0x1075a8;
virtual-method void render(Entity *entity, float param_2, float param_3, float param_4, float param_5, float param_6) = 0x8; virtual-method void render(Entity *entity, float param_2, float param_3, float param_4, float param_5, float param_6) = 0x8;
// Can be called without an EntityRenderer, just do EntityRenderer_bindTexture(NULL, &file); // Can be called without an EntityRenderer, just do EntityRenderer_bindTexture->get(false)(NULL, &file);
method void bindTexture(const std::string &file) = 0x62540; method void bindTexture(const std::string &file) = 0x62540;
property float shadow_radius = 0x4;
property float shadow_strength = 0x8;
// Globals // Globals
static-property EntityRenderDispatcher *entityRenderDispatcher = 0x137bc0; static-property EntityRenderDispatcher *entityRenderDispatcher = 0x137bc0;

View File

@ -5,3 +5,4 @@ constructor (Level *level, float x, float y, float z, const ItemInstance &item)
property ItemInstance item = 0xd0; property ItemInstance item = 0xd0;
property int age = 0xdc; property int age = 0xdc;
property float bob_offset = 0xe4;

View File

@ -10,6 +10,7 @@ virtual-method ItemInstance *getCarriedItem() = 0x1ac;
virtual-method void updateAi() = 0x1cc; virtual-method void updateAi() = 0x1cc;
virtual-method float getWalkingSpeedModifier() = 0x1e8; virtual-method float getWalkingSpeedModifier() = 0x1e8;
virtual-method void aiStep() = 0x180; virtual-method void aiStep() = 0x180;
virtual-method int getMaxHealth() = 0x168;
method bool getSharedFlag(int flag) = 0x81fd8; method bool getSharedFlag(int flag) = 0x81fd8;
method void setSharedFlag(int flag, bool value) = 0x81ef8; method void setSharedFlag(int flag, bool value) = 0x81ef8;

View File

@ -0,0 +1,3 @@
extends Mob;
vtable 0x10c870;

View File

@ -26,8 +26,8 @@ virtual-method void selectLevel(const std::string &level_dir, const std::string
property int screen_width = 0x20; property int screen_width = 0x20;
property int screen_height = 0x24; property int screen_height = 0x24;
property Options options = 0x3c; property Options options = 0x3c;
property LevelRenderer *levelrenderer = 0x150; property LevelRenderer *level_renderer = 0x150;
property GameRenderer *gamerenderer = 0x154; property GameRenderer *game_renderer = 0x154;
property GameMode *game_mode = 0x160; property GameMode *game_mode = 0x160;
property Textures *textures = 0x164; property Textures *textures = 0x164;
property ScreenChooser screen_chooser = 0x168; property ScreenChooser screen_chooser = 0x168;
@ -45,6 +45,8 @@ property int ticks_per_update = 0xc70;
property bool is_creative_mode = 0xcb5; property bool is_creative_mode = 0xcb5;
property PerfRenderer *perf_renderer = 0xcbc; property PerfRenderer *perf_renderer = 0xcbc;
property CommandServer *command_server = 0xcc0; property CommandServer *command_server = 0xcc0;
property SoundEngine *sound_engine = 0x15c;
property int miss_time = 0xca0;
// Smooth Lighting // Smooth Lighting
static-property bool useAmbientOcclusion = 0x136b90; static-property bool useAmbientOcclusion = 0x136b90;

View File

@ -15,6 +15,8 @@ method void renderSlotText(const ItemInstance *item, float x, float y, bool fini
method void handleKeyPressed(int key) = 0x25a08; method void handleKeyPressed(int key) = 0x25a08;
method void renderHearts() = 0x2641c; method void renderHearts() = 0x2641c;
method void renderDebugInfo() = 0x26958; method void renderDebugInfo() = 0x26958;
method void renderProgressIndicator(bool is_touch, int width, int height, float a) = 0x26098;
method void renderVignette(float param_1, int width, int height) = 0x25b0c;
property std::vector<GuiMessage> messages = 0x18; property std::vector<GuiMessage> messages = 0x18;
property Minecraft *minecraft = 0x9f4; property Minecraft *minecraft = 0x9f4;

View File

@ -5,6 +5,10 @@ constructor (int id, const std::string &text) = 0x1bc54;
method int hovered(Minecraft *minecraft, int click_x, int click_y) = 0x1be2c; method int hovered(Minecraft *minecraft, int click_x, int click_y) = 0x1be2c;
virtual-method bool clicked(Minecraft *minecraft, int click_x, int click_y) = 0x20;
virtual-method void setPressed() = 0x28;
virtual-method bool released(int click_x, int click_y) = 0x24;
property int width = 0x14; property int width = 0x14;
property int height = 0x18; property int height = 0x18;
property int x = 0xc; property int x = 0xc;

View File

@ -16,6 +16,7 @@ virtual-method void removed() = 0x2c;
virtual-method void renderBackground() = 0x30; virtual-method void renderBackground() = 0x30;
virtual-method void buttonClicked(Button *button) = 0x60; virtual-method void buttonClicked(Button *button) = 0x60;
virtual-method void mouseClicked(int x, int y, int param_1) = 0x64; virtual-method void mouseClicked(int x, int y, int param_1) = 0x64;
virtual-method void mouseReleased(int x, int y, int param_1) = 0x68;
virtual-method void keyPressed(int key) = 0x6c; virtual-method void keyPressed(int key) = 0x6c;
virtual-method void keyboardNewChar(char key) = 0x70; virtual-method void keyboardNewChar(char key) = 0x70;
@ -26,3 +27,4 @@ property Minecraft *minecraft = 0x14;
property std::vector<Button *> rendered_buttons = 0x18; property std::vector<Button *> rendered_buttons = 0x18;
property std::vector<Button *> selectable_buttons = 0x30; property std::vector<Button *> selectable_buttons = 0x30;
property Font *font = 0x40; property Font *font = 0x40;
property Button *clicked_button = 0x44;

View File

@ -1,3 +1,7 @@
extends EntityRenderer;
vtable 0x107970;
static-method void renderGuiItem_one(Font *font, Textures *textures, const ItemInstance *item_instance, float x, float y, bool param_3) = 0x63e58; static-method void renderGuiItem_one(Font *font, Textures *textures, const ItemInstance *item_instance, float x, float y, bool param_3) = 0x63e58;
static-method void renderGuiItem_two(Font *font, Textures *textures, const ItemInstance *item_instance, float x, float y, float w, float h, bool param_5) = 0x63be0; static-method void renderGuiItem_two(Font *font, Textures *textures, const ItemInstance *item_instance, float x, float y, float w, float h, bool param_5) = 0x63be0;
static-method void renderGuiItemCorrect(Font *font, Textures *textures, const ItemInstance *item_instance, int x, int y) = 0x639a0; static-method void renderGuiItemCorrect(Font *font, Textures *textures, const ItemInstance *item_instance, int x, int y) = 0x639a0;
@ -7,3 +11,5 @@ static-method void blit(float x, float y, float texture_x, float texture_y, floa
// This doesn't include things that it doesn't need for item rendering (like the level) // This doesn't include things that it doesn't need for item rendering (like the level)
// So if you are (ab)using it for something else, be sure to set what you need // So if you are (ab)using it for something else, be sure to set what you need
static-property TileRenderer *tileRenderer = 0x137c18; static-property TileRenderer *tileRenderer = 0x137c18;
property Random random = 0xc;

View File

@ -49,6 +49,7 @@ method bool hasDirectSignal(int x, int y, int z) = 0xa5d88;
method bool getDirectSignal(int x, int y, int z, int direction) = 0xa5d2c; method bool getDirectSignal(int x, int y, int z, int direction) = 0xa5d2c;
method bool canSeeSky(int x, int y, int z) = 0xa39b8; method bool canSeeSky(int x, int y, int z) = 0xa39b8;
method bool isDay() = 0xa3d9c; method bool isDay() = 0xa3d9c;
method int getTopTile(int x, int z) = 0xa2cc8;
virtual-method void tick() = 0x28; virtual-method void tick() = 0x28;
virtual-method void updateSleepingPlayerList() = 0x2c; virtual-method void updateSleepingPlayerList() = 0x2c;

View File

@ -3,3 +3,4 @@ method void setTime(int time) = 0xbab28;
method bool getSpawnMobs() = 0xbabec; method bool getSpawnMobs() = 0xbabec;
property int time = 0x68; property int time = 0x68;
property int seed = 0x58;

View File

@ -1,6 +1,6 @@
virtual-method int getTile(int x, int y, int z) = 0x8; virtual-method int getTile(int x, int y, int z) = 0x8;
virtual-method int isEmptyTile(int x, int y, int z) = 0xc; virtual-method int isEmptyTile(int x, int y, int z) = 0xc;
virtual-method int getBrightness(int x, int y, int z) = 0x10; virtual-method float getBrightness(int x, int y, int z) = 0x10;
virtual-method int getData(int x, int y, int z) = 0x14; virtual-method int getData(int x, int y, int z) = 0x14;
virtual-method Material *getMaterial(int x, int y, int z) = 0x18; virtual-method Material *getMaterial(int x, int y, int z) = 0x18;
virtual-method bool isSolidRenderTile(int x, int y, int z) = 0x1c; virtual-method bool isSolidRenderTile(int x, int y, int z) = 0x1c;

View File

@ -1,5 +1,6 @@
method void tick() = 0x4da1c; method void tick() = 0x4da1c;
method int render(Mob *mob, int param_1, float delta) = 0x4f710; method int render(Mob *mob, int param_1, float delta) = 0x4f710;
method void render_AABB(const AABB &box) = 0x4d740;
method void renderDebug(const AABB &aabb, float delta) = 0x4d310; method void renderDebug(const AABB &aabb, float delta) = 0x4d310;
method void generateSky() = 0x4d0d4; method void generateSky() = 0x4d0d4;
method void renderHitSelect(Player *player, const HitResult &hit_result, int i, void *vp, float f) = 0x4e318; method void renderHitSelect(Player *player, const HitResult &hit_result, int i, void *vp, float f) = 0x4e318;

View File

@ -1,8 +1,11 @@
size 0x9d0; size 0x9d0;
constructor () = 0xb7490;
method float nextFloat() = 0x42cf8; method float nextFloat() = 0x42cf8;
method uint genrand_int32() = 0x50e14; method uint genrand_int32() = 0x50e14;
method void init_genrand(uint seed) = 0x27d38; method void init_genrand(uint seed) = 0x27d38;
method void setSeed(int seed) = 0xaf884;
property uint seed = 0x0; property uint seed = 0x0;
property int param_1 = 0x9c4; // Set To 0x271 property int param_1 = 0x9c4; // Set To 0x271

View File

@ -5,10 +5,11 @@ method void Write_short(short *i) = 0x71918;
// right_aligned should be true // right_aligned should be true
method void WriteBits(const uchar *buff, uint bits, bool right_aligned) = 0xd41b4; method void WriteBits(const uchar *buff, uint bits, bool right_aligned) = 0xd41b4;
method void Read_uchar(uchar *i) = 0x45ab0; method bool Read_uchar(uchar *i) = 0x45ab0;
method void Read_int(int *i) = 0x184ec; method bool Read_int(int *i) = 0x184ec;
method void Read_ushort(ushort *i) = 0x45acc; method bool Read_ushort(ushort *i) = 0x45acc;
method void Read_short(short *i) = 0x72070; method bool Read_short(short *i) = 0x72070;
method bool Read_str(char *str) = 0xd5174;
// right_aligned should be true // right_aligned should be true
method void ReadBits(uchar *buff, uint bits, bool right_aligned) = 0xd3e18; method void ReadBits(uchar *buff, uint bits, bool right_aligned) = 0xd3e18;

View File

@ -1,5 +1,10 @@
size 0x4;
constructor () = 0xe8f80;
//constructor (const char *format, ...) = 0xea5cc; //constructor (const char *format, ...) = 0xea5cc;
method void Assign(const char *str) = 0xe9e34; method void Assign(const char *str) = 0xe9e34;
method void Free() = 0xe9b50;
method bool Deserialize(RakNet_BitStream *stream) = 0xea990;
property RakNet_RakString_SharedString *sharedString = 0x0; property RakNet_RakString_SharedString *sharedString = 0x0;

View File

@ -3,3 +3,5 @@ method int loadAndBindTexture(const std::string &name) = 0x539cc;
method int assignTexture(const std::string &name, uchar *data) = 0x5354c; method int assignTexture(const std::string &name, uchar *data) = 0x5354c;
method void addDynamicTexture(DynamicTexture *texture) = 0x534f8; method void addDynamicTexture(DynamicTexture *texture) = 0x534f8;
method Texture *getTemporaryTextureData(uint id) = 0x53168; method Texture *getTemporaryTextureData(uint id) = 0x53168;
property bool blur = 0x39;

View File

@ -1,5 +1,7 @@
extends Tile; extends Tile;
constructor (int id, int texture, const Material *material) = 0xbe578;
vtable 0x111348; vtable 0x111348;
vtable-size 0x108; vtable-size 0x108;
size 0x5c; size 0x5c;

View File

@ -48,6 +48,7 @@ virtual-method bool getSignal2(LevelSource *level, int x, int y, int z, int dire
// Called by Level_hasDirectSignal // Called by Level_hasDirectSignal
virtual-method bool getDirectSignal(Level *level, int x, int y, int z, int direction) = 0xc8; virtual-method bool getDirectSignal(Level *level, int x, int y, int z, int direction) = 0xc8;
virtual-method void entityInside(Level *level, int x, int y, int z, Entity *entity) = 0xcc; virtual-method void entityInside(Level *level, int x, int y, int z, Entity *entity) = 0xcc;
virtual-method std::string getName() = 0xd8;
virtual-method std::string getDescriptionId() = 0xdc; virtual-method std::string getDescriptionId() = 0xdc;
virtual-method Tile *setDescriptionId(const std::string &description_id) = 0xe0; virtual-method Tile *setDescriptionId(const std::string &description_id) = 0xe0;
virtual-method Tile *setSoundType(const Tile_SoundType &sound_type) = 0xe8; virtual-method Tile *setSoundType(const Tile_SoundType &sound_type) = 0xe8;