Tweaks & Fixes
This commit is contained in:
parent
35cafec1ee
commit
d03a1a96ff
@ -6,12 +6,12 @@ if(MCPI_HEADLESS_MODE)
|
|||||||
set(GLES_SRC src/stubs.c)
|
set(GLES_SRC src/stubs.c)
|
||||||
elseif(MCPI_USE_GLES1_COMPATIBILITY_LAYER)
|
elseif(MCPI_USE_GLES1_COMPATIBILITY_LAYER)
|
||||||
# GLESv1_CM Compatibility Layer
|
# GLESv1_CM Compatibility Layer
|
||||||
set(GLES_SRC src/compatibility-layer/state.c src/compatibility-layer/passthrough.c src/compatibility-layer/matrix.c src/compatibility-layer/draw.c src/compatibility-layer/buffer.cpp)
|
set(GLES_SRC src/compatibility-layer/state.c src/compatibility-layer/passthrough.c src/compatibility-layer/matrix.c src/compatibility-layer/draw.c)
|
||||||
else()
|
else()
|
||||||
# Passthrough To glfwGetProcAddress()
|
# Passthrough To glfwGetProcAddress()
|
||||||
set(GLES_SRC src/passthrough.c)
|
set(GLES_SRC src/passthrough.c)
|
||||||
endif()
|
endif()
|
||||||
add_library(GLESv1_CM SHARED ${GLES_SRC})
|
add_library(GLESv1_CM OBJECT ${GLES_SRC})
|
||||||
if(NOT MCPI_HEADLESS_MODE)
|
if(NOT MCPI_HEADLESS_MODE)
|
||||||
target_link_libraries(GLESv1_CM PRIVATE glfw PUBLIC reborn-util PRIVATE dl PRIVATE m)
|
target_link_libraries(GLESv1_CM PRIVATE glfw PUBLIC reborn-util PRIVATE dl PRIVATE m)
|
||||||
# Shaders
|
# Shaders
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#include <GLES/gl.h>
|
|
||||||
|
|
||||||
#include "../passthrough.h"
|
|
||||||
|
|
||||||
// Store Buffers
|
|
||||||
static std::unordered_map<GLuint, GLuint> buffers_map;
|
|
||||||
// Get Buffer
|
|
||||||
GL_FUNC(glGenBuffers, void, (GLsizei n, GLuint *buffers));
|
|
||||||
static GLuint get_real_buffer(GLuint fake_buffer) {
|
|
||||||
if (buffers_map.count(fake_buffer) > 0) {
|
|
||||||
return buffers_map[fake_buffer];
|
|
||||||
} else {
|
|
||||||
GLuint new_buffer;
|
|
||||||
real_glGenBuffers()(1, &new_buffer);
|
|
||||||
buffers_map[fake_buffer] = new_buffer;
|
|
||||||
return get_real_buffer(fake_buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert Fake Buffers To Real Buffers When Calling GL
|
|
||||||
GL_FUNC(glBindBuffer, void, (GLenum target, GLuint buffer));
|
|
||||||
void glBindBuffer(GLenum target, GLuint buffer) {
|
|
||||||
real_glBindBuffer()(target, get_real_buffer(buffer));
|
|
||||||
}
|
|
||||||
GL_FUNC(glDeleteBuffers, void, (GLsizei n, const GLuint *buffers));
|
|
||||||
void glDeleteBuffers(GLsizei n, const GLuint *buffers) {
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
if (buffers_map.count(buffers[i]) > 0) {
|
|
||||||
real_glDeleteBuffers()(1, &buffers_map[i]);
|
|
||||||
buffers_map.erase(buffers[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -39,6 +39,10 @@ GL_FUNC(glDepthRangef, void, (GLclampf near, GLclampf far));
|
|||||||
void glDepthRangef(GLclampf near, GLclampf far) {
|
void glDepthRangef(GLclampf near, GLclampf far) {
|
||||||
real_glDepthRangef()(near, far);
|
real_glDepthRangef()(near, far);
|
||||||
}
|
}
|
||||||
|
GL_FUNC(glBindBuffer, void, (GLenum target, GLuint buffer));
|
||||||
|
void glBindBuffer(GLenum target, GLuint buffer) {
|
||||||
|
real_glBindBuffer()(target, buffer);
|
||||||
|
}
|
||||||
GL_FUNC(glDepthFunc, void, (GLenum func));
|
GL_FUNC(glDepthFunc, void, (GLenum func));
|
||||||
void glDepthFunc(GLenum func) {
|
void glDepthFunc(GLenum func) {
|
||||||
real_glDepthFunc()(func);
|
real_glDepthFunc()(func);
|
||||||
@ -57,6 +61,10 @@ void glHint(GLenum target, GLenum mode) {
|
|||||||
real_glHint()(target, mode);
|
real_glHint()(target, mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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));
|
GL_FUNC(glColorMask, void, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha));
|
||||||
void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {
|
void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {
|
||||||
real_glColorMask()(red, green, blue, alpha);
|
real_glColorMask()(red, green, blue, alpha);
|
||||||
@ -103,3 +111,7 @@ void glShadeModel(__attribute__((unused)) GLenum mode) {
|
|||||||
void glNormal3f(__attribute__((unused)) GLfloat nx, __attribute__((unused)) GLfloat ny, __attribute__((unused)) GLfloat nz) {
|
void glNormal3f(__attribute__((unused)) GLfloat nx, __attribute__((unused)) GLfloat ny, __attribute__((unused)) GLfloat nz) {
|
||||||
// Do Nothing
|
// Do Nothing
|
||||||
}
|
}
|
||||||
|
GL_FUNC(glGenBuffers, void, (GLsizei n, GLuint *buffers));
|
||||||
|
void glGenBuffers(GLsizei n, GLuint *buffers) {
|
||||||
|
real_glGenBuffers()(n, buffers);
|
||||||
|
}
|
||||||
|
@ -202,3 +202,7 @@ GL_FUNC(glReadPixels, void, (GLint x, GLint y, GLsizei width, GLsizei height, GL
|
|||||||
void glReadPixels(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);
|
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);
|
||||||
|
}
|
||||||
|
@ -76,7 +76,7 @@ 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 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 glGenTextures(GLsizei n, GLuint *textures) {
|
||||||
static int i = 0;
|
static int i = 1;
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
textures[j] = i++;
|
textures[j] = i++;
|
||||||
}
|
}
|
||||||
@ -160,5 +160,11 @@ void glGetIntegerv(GLenum pname, GLint *data) {
|
|||||||
}
|
}
|
||||||
void glReadPixels(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) {
|
||||||
}
|
}
|
||||||
|
void glGenBuffers(GLsizei n, GLuint *buffers) {
|
||||||
|
static int i = 1;
|
||||||
|
for (int j = 0; j < n; j++) {
|
||||||
|
buffers[j] = i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -41,9 +44,6 @@ extern "C" {
|
|||||||
#define GL_FOG_COLOR 0xb66
|
#define GL_FOG_COLOR 0xb66
|
||||||
#define GL_BLEND 0xbe2
|
#define GL_BLEND 0xbe2
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
typedef float GLfloat;
|
typedef float GLfloat;
|
||||||
typedef float GLclampf;
|
typedef float GLclampf;
|
||||||
typedef int GLint;
|
typedef int GLint;
|
||||||
@ -107,6 +107,7 @@ void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz);
|
|||||||
GLboolean glIsEnabled(GLenum cap);
|
GLboolean glIsEnabled(GLenum cap);
|
||||||
void glGetIntegerv(GLenum pname, GLint *data);
|
void glGetIntegerv(GLenum pname, GLint *data);
|
||||||
void glReadPixels(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);
|
||||||
|
void glGenBuffers(GLsizei n, GLuint *buffers);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -168,6 +168,7 @@ CALL(15, glDrawArrays, void, (GLenum mode, GLint first, GLsizei count)) {
|
|||||||
|
|
||||||
// Release Proxy
|
// Release Proxy
|
||||||
end_proxy_call();
|
end_proxy_call();
|
||||||
|
flush_write_cache();
|
||||||
#else
|
#else
|
||||||
GLenum mode = (GLenum) read_int();
|
GLenum mode = (GLenum) read_int();
|
||||||
GLint first = (GLint) read_int();
|
GLint first = (GLint) read_int();
|
||||||
@ -1242,3 +1243,30 @@ CALL(65, glReadPixels, void, (GLint x, GLint y, GLsizei width, GLsizei height, G
|
|||||||
free(pixels);
|
free(pixels);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CALL(67, glGenBuffers, void, (GLsizei n, GLuint *buffers)) {
|
||||||
|
#if defined(MEDIA_LAYER_PROXY_SERVER)
|
||||||
|
// Lock Proxy
|
||||||
|
start_proxy_call();
|
||||||
|
|
||||||
|
// Arguments
|
||||||
|
write_int((uint32_t) n);
|
||||||
|
|
||||||
|
// Get Return Value
|
||||||
|
for (GLsizei i = 0; i < n; i++) {
|
||||||
|
buffers[i] = (GLuint) read_int();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Release Proxy
|
||||||
|
end_proxy_call();
|
||||||
|
#else
|
||||||
|
GLsizei n = (GLsizei) read_int();
|
||||||
|
GLuint buffers[n];
|
||||||
|
// Run
|
||||||
|
glGenBuffers(n, buffers);
|
||||||
|
// Return Value
|
||||||
|
for (GLsizei i = 0; i < n; i++) {
|
||||||
|
write_int((uint32_t) buffers[i]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@ -182,6 +182,7 @@ CALL(8, media_swap_buffers, void, ()) {
|
|||||||
start_proxy_call();
|
start_proxy_call();
|
||||||
// Release Proxy
|
// Release Proxy
|
||||||
end_proxy_call();
|
end_proxy_call();
|
||||||
|
flush_write_cache();
|
||||||
#else
|
#else
|
||||||
// Run
|
// Run
|
||||||
media_swap_buffers();
|
media_swap_buffers();
|
||||||
|
@ -164,6 +164,4 @@ void _start_proxy_call(unsigned char call_id) {
|
|||||||
write_byte(call_id);
|
write_byte(call_id);
|
||||||
}
|
}
|
||||||
void end_proxy_call() {
|
void end_proxy_call() {
|
||||||
// Flush Write Cache
|
|
||||||
flush_write_cache();
|
|
||||||
}
|
}
|
||||||
|
@ -197,9 +197,9 @@ static void Inventory_setupDefault_FillingContainer_addItem_call_injection(unsig
|
|||||||
|
|
||||||
// Make Liquids Selectable
|
// Make Liquids Selectable
|
||||||
static bool is_holding_bucket = false;
|
static bool is_holding_bucket = false;
|
||||||
static void Mob_pick_Level_clip_injection(unsigned char *level, unsigned char *param_1, unsigned char *param_2, bool param_3, __attribute__((unused)) bool clip_liquids) {
|
static HitResult Mob_pick_Level_clip_injection(unsigned char *level, unsigned char *param_1, unsigned char *param_2, __attribute__((unused)) bool clip_liquids, bool param_3) {
|
||||||
// Call Original Method
|
// Call Original Method
|
||||||
(*Level_clip)(level, param_1, param_2, param_3, is_holding_bucket);
|
return (*Level_clip)(level, param_1, param_2, is_holding_bucket, param_3);
|
||||||
}
|
}
|
||||||
static void handle_tick(unsigned char *minecraft) {
|
static void handle_tick(unsigned char *minecraft) {
|
||||||
unsigned char *player = *(unsigned char **) (minecraft + Minecraft_player_property_offset);
|
unsigned char *player = *(unsigned char **) (minecraft + Minecraft_player_property_offset);
|
||||||
|
@ -22,8 +22,8 @@ static int32_t MouseBuildInput_tickBuild_injection(unsigned char *mouse_build_in
|
|||||||
if (ret != 0 && is_left_click == 1 && *build_action_intention_return == 0xa) {
|
if (ret != 0 && is_left_click == 1 && *build_action_intention_return == 0xa) {
|
||||||
// Get Target HitResult
|
// Get Target HitResult
|
||||||
unsigned char *minecraft = *(unsigned char **) (local_player + LocalPlayer_minecraft_property_offset);
|
unsigned char *minecraft = *(unsigned char **) (local_player + LocalPlayer_minecraft_property_offset);
|
||||||
unsigned char *hit_result = minecraft + Minecraft_hit_result_property_offset;
|
HitResult *hit_result = (HitResult *) (minecraft + Minecraft_hit_result_property_offset);
|
||||||
int32_t hit_result_type = *(int32_t *) (hit_result + HitResult_type_property_offset);
|
int32_t hit_result_type = hit_result->type;
|
||||||
// Check if The Target Is An Entity Using HitResult
|
// Check if The Target Is An Entity Using HitResult
|
||||||
if (hit_result_type == 1) {
|
if (hit_result_type == 1) {
|
||||||
// Change BuildActionIntention To Attack/Place Mode (Place Will Not Happen Because The HitResult Is An Entity)
|
// Change BuildActionIntention To Attack/Place Mode (Place Will Not Happen Because The HitResult Is An Entity)
|
||||||
|
@ -297,6 +297,11 @@ int32_t misc_get_real_selected_slot(unsigned char *player) {
|
|||||||
return selected_slot;
|
return selected_slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Properly Generate Buffers
|
||||||
|
static void anGenBuffers_injection(int32_t count, uint32_t *buffers) {
|
||||||
|
glGenBuffers(count, buffers);
|
||||||
|
}
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
static void nop() {
|
static void nop() {
|
||||||
}
|
}
|
||||||
@ -379,6 +384,9 @@ void init_misc() {
|
|||||||
overwrite_calls((void *) sleepMs, (void *) nop);
|
overwrite_calls((void *) sleepMs, (void *) nop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Properly Generate Buffers
|
||||||
|
overwrite((void *) anGenBuffers, (void *) anGenBuffers_injection);
|
||||||
|
|
||||||
// Init C++ And Logging
|
// Init C++ And Logging
|
||||||
_init_misc_cpp();
|
_init_misc_cpp();
|
||||||
_init_misc_logging();
|
_init_misc_logging();
|
||||||
|
@ -21,6 +21,9 @@ static sleepMs_t sleepMs = (sleepMs_t) 0x13cf4;
|
|||||||
typedef int32_t (*sdl_key_to_minecraft_key_t)(int32_t sdl_key);
|
typedef int32_t (*sdl_key_to_minecraft_key_t)(int32_t sdl_key);
|
||||||
static sdl_key_to_minecraft_key_t sdl_key_to_minecraft_key = (sdl_key_to_minecraft_key_t) 0x1243c;
|
static sdl_key_to_minecraft_key_t sdl_key_to_minecraft_key = (sdl_key_to_minecraft_key_t) 0x1243c;
|
||||||
|
|
||||||
|
typedef void (*anGenBuffers_t)(int32_t count, uint32_t *buffers);
|
||||||
|
static anGenBuffers_t anGenBuffers = (anGenBuffers_t) 0x5f28c;
|
||||||
|
|
||||||
static char **default_path = (char **) 0xe264; // /.minecraft/
|
static char **default_path = (char **) 0xe264; // /.minecraft/
|
||||||
static char **default_username = (char **) 0x18fd4; // StevePi
|
static char **default_username = (char **) 0x18fd4; // StevePi
|
||||||
static char **minecraft_pi_version = (char **) 0x39d94; // v0.1.1 alpha
|
static char **minecraft_pi_version = (char **) 0x39d94; // v0.1.1 alpha
|
||||||
@ -261,9 +264,26 @@ static uint32_t StartGamePacket_game_mode_property_offset = 0x14; // int32_t
|
|||||||
|
|
||||||
static uint32_t ChatPacket_message_property_offset = 0xc; // char *
|
static uint32_t ChatPacket_message_property_offset = 0xc; // char *
|
||||||
|
|
||||||
|
// Vec3
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
} Vec3;
|
||||||
|
|
||||||
// HitResult
|
// HitResult
|
||||||
|
|
||||||
static uint32_t HitResult_type_property_offset = 0x0;
|
typedef struct {
|
||||||
|
int32_t type;
|
||||||
|
int32_t x;
|
||||||
|
int32_t y;
|
||||||
|
int32_t z;
|
||||||
|
int32_t side;
|
||||||
|
Vec3 exact;
|
||||||
|
unsigned char *entity;
|
||||||
|
unsigned char unknown;
|
||||||
|
} HitResult;
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
|
|
||||||
@ -470,7 +490,7 @@ static Level_getTile_t Level_getTile = (Level_getTile_t) 0xa3380;
|
|||||||
typedef unsigned char *(*Level_getMaterial_t)(unsigned char *level, int32_t x, int32_t y, int32_t z);
|
typedef unsigned char *(*Level_getMaterial_t)(unsigned char *level, int32_t x, int32_t y, int32_t z);
|
||||||
static Level_getMaterial_t Level_getMaterial = (Level_getMaterial_t) 0xa27f8;
|
static Level_getMaterial_t Level_getMaterial = (Level_getMaterial_t) 0xa27f8;
|
||||||
|
|
||||||
typedef void (*Level_clip_t)(unsigned char *level, unsigned char *param_1, unsigned char *param_2, bool param_3, bool clip_liquids);
|
typedef HitResult (*Level_clip_t)(unsigned char *level, unsigned char *param_1, unsigned char *param_2, bool clip_liquids, bool param_3);
|
||||||
static Level_clip_t Level_clip = (Level_clip_t) 0xa3db0;
|
static Level_clip_t Level_clip = (Level_clip_t) 0xa3db0;
|
||||||
|
|
||||||
static uint32_t Level_players_property_offset = 0x60; // std::vector<ServerPlayer *>
|
static uint32_t Level_players_property_offset = 0x60; // std::vector<ServerPlayer *>
|
||||||
|
Loading…
Reference in New Issue
Block a user