diff --git a/src/DivaGL/auth_3d.cpp b/src/DivaGL/auth_3d.cpp index 2caf2ac..0cb4da6 100644 --- a/src/DivaGL/auth_3d.cpp +++ b/src/DivaGL/auth_3d.cpp @@ -696,13 +696,13 @@ HOOK(void, FASTCALL, auth_3d_object_disp, 0x00000001401D0970, auth_3d_object* o, morph = fmodf(morph, 1.0f); if (morph > 0.0f && morph < 1.0f) { sprintf_s(buf, sizeof(buf), "%.*s%03d", uid_name_length - 3, uid_name, morph_int + 1); - object_info morph_obj_info = obj_database_get_object_info(buf); + object_info morph_obj_info = object_database_get_object_info(buf); if (morph_obj_info.is_null()) morph_obj_info = o->object_info; disp_manager.set_morph(morph_obj_info, morph); sprintf_s(buf, sizeof(buf), "%.*s%03d", uid_name_length - 3, uid_name, morph_int); - object_info obj_info = obj_database_get_object_info(buf); + object_info obj_info = object_database_get_object_info(buf); if (auth->alpha < 0.999f) disp_manager.entry_obj_by_object_info(&mat, obj_info, auth->alpha); else @@ -714,7 +714,7 @@ HOOK(void, FASTCALL, auth_3d_object_disp, 0x00000001401D0970, auth_3d_object* o, morph_int++; sprintf_s(buf, sizeof(buf), "%.*s%03d", uid_name_length - 3, uid_name, morph_int); - object_info obj_info = obj_database_get_object_info(buf); + object_info obj_info = object_database_get_object_info(buf); if (obj_info.is_null()) obj_info = o->object_info; disp_manager.entry_obj_by_object_info(&mat, obj_info); @@ -723,7 +723,7 @@ HOOK(void, FASTCALL, auth_3d_object_disp, 0x00000001401D0970, auth_3d_object* o, else if (o->pattern.curve) { sprintf_s(buf, sizeof(buf), "%.*s%03d", uid_name_length - 3, uid_name, (int32_t)prj::roundf(o->pattern.value)); - object_info obj_info = obj_database_get_object_info(buf); + object_info obj_info = object_database_get_object_info(buf); disp_manager.entry_obj_by_object_info(&mat, obj_info); } else diff --git a/src/DivaGL/mdl/disp_manager.cpp b/src/DivaGL/mdl/disp_manager.cpp index 9d69417..8ac5665 100644 --- a/src/DivaGL/mdl/disp_manager.cpp +++ b/src/DivaGL/mdl/disp_manager.cpp @@ -2227,7 +2227,7 @@ namespace mdl { if (!object) return false; - prj::vector* textures = obj_database_get_obj_set_textures(obj_info.set_id); + prj::vector* textures = object_database_get_set_gentex(obj_info.set_id); obj_mesh_vertex_buffer* obj_vertex_buffer = object_info_get_mesh_vertex_buffer(obj_info, 0); obj_mesh_index_buffer* obj_index_buffer = object_info_get_mesh_index_buffer(obj_info, 0); @@ -2264,7 +2264,7 @@ namespace mdl { void DispManager::entry_obj_by_object_info_object_skin(object_info obj_info, prj::vector* texture_pattern, texture_data_struct* texture_data, float_t alpha, mat4* matrices, mat4* ex_data_matrices, const mat4* mat, const mat4* global_mat) { - obj_skin* skin = obj_database_get_object_skin(obj_info); + obj_skin* skin = object_database_get_object_skin(obj_info); if (!skin) return; @@ -2649,8 +2649,8 @@ namespace mdl { || *(int32_t*)(a1 + 0x74) >= *(int32_t*)(a1 + 0x70)) return; - int32_t set_id = obj_database_get_set_id(*(int32_t*)(a1 + 0x68)); - int32_t id = obj_database_get_obj_set_obj_id(*(int32_t*)(a1 + 0x68), *(int32_t*)(a1 + 0x74)); + int32_t set_id = object_database_get_set_id(*(int32_t*)(a1 + 0x68)); + int32_t id = object_database_get_set_obj_id(*(int32_t*)(a1 + 0x68), *(int32_t*)(a1 + 0x74)); disp_manager->set_obj_flags((mdl::ObjFlags)(*(int32_t*)(a1 + 0x84) | mdl::OBJ_40 | mdl::OBJ_20)); mat4 mat; mat4_rotate_xyz(*(float_t*)(a1 + 0x78), *(float_t*)(a1 + 0x7C), *(float_t*)(a1 + 0x80), &mat); @@ -2700,17 +2700,9 @@ namespace mdl { disp_manager->entry_obj_etc(&mat4_identity, etc); } - HOOK(void, FASTCALL, DispManager__entry_obj_by_obj, 0x0000000140439A20, obj* obj_data, prj::vector* textures, - obj_mesh_vertex_buffer* obj_vert_buf, obj_mesh_index_buffer* obj_index_buf, mat4* bone_mat, float_t alpha) { - if (!obj_data) - return; - - vec4 blend_color = 1.0f; - blend_color.w = alpha; - - vec4* blend_color_ptr = alpha < 1.0f ? &blend_color : 0; - disp_manager->entry_obj(obj_data, obj_vert_buf, obj_index_buf, rob_chara_item_equip_mat, - textures, blend_color_ptr, bone_mat, 0, 0, 0, 0, 0, 0, 0, !!bone_mat); + HOOK(void, FASTCALL, DispManager__entry_obj_by_obj, 0x0000000140439A20, obj * obj_data, prj::vector*textures, + obj_mesh_vertex_buffer * obj_vert_buf, obj_mesh_index_buffer * obj_index_buf, mat4 * bone_mat, float_t alpha) { + disp_manager->entry_obj_by_obj(rob_chara_item_equip_mat, obj_data, textures, obj_vert_buf, obj_index_buf, bone_mat, alpha); } HOOK(void, FASTCALL, sub_1404BCC60, 0x00000001404BCC60, vec3* pos, float_t width, float_t height) { diff --git a/src/DivaGL/object.cpp b/src/DivaGL/object.cpp index e331af8..649a121 100644 --- a/src/DivaGL/object.cpp +++ b/src/DivaGL/object.cpp @@ -16,23 +16,23 @@ struct BufObjMgr { int32_t ib_all_size; }; -uint32_t(FASTCALL* obj_database_get_object_info)(const char* name) +uint32_t(FASTCALL* object_database_get_object_info)(const char* name) = (uint32_t(FASTCALL*)(const char* name))0x0000000140459F80; obj* (FASTCALL* object_info_get_object)(object_info obj_info) = (obj * (FASTCALL*)(object_info obj_info))0x000000014045A140; obj_mesh_index_buffer* (FASTCALL* object_info_get_mesh_index_buffer)(object_info obj_info, int32_t a2) = (obj_mesh_index_buffer * (FASTCALL*)(object_info obj_info, int32_t a2))0x000000014045A250; -obj_skin* (FASTCALL* obj_database_get_object_skin)(object_info obj_info) +obj_skin* (FASTCALL* object_database_get_object_skin)(object_info obj_info) = (obj_skin * (FASTCALL*)(object_info obj_info))0x000000014045A3E0; obj_mesh_vertex_buffer* (FASTCALL* object_info_get_mesh_vertex_buffer)(object_info obj_info, int32_t a2) = (obj_mesh_vertex_buffer * (FASTCALL*)(object_info obj_info, int32_t a2))0x000000014045A480; -int32_t(FASTCALL* obj_database_get_obj_set_obj_id)(int32_t set_index, int32_t obj_index) +int32_t(FASTCALL* object_database_get_set_obj_id)(int32_t set_index, int32_t obj_index) = (int32_t(FASTCALL*)(int32_t set_index, int32_t obj_index))0x000000014045A750; -GLuint(FASTCALL* obj_database_get_obj_set_texture)(int32_t set, int32_t tex_id) +GLuint(FASTCALL* object_database_get_set_texture)(int32_t set, int32_t tex_id) = (GLuint(FASTCALL*)(int32_t set, int32_t tex_id))0x000000014045A8F0; -prj::vector* (FASTCALL* obj_database_get_obj_set_textures)(int32_t set) +prj::vector* (FASTCALL* object_database_get_set_gentex)(int32_t set) = (prj::vector * (FASTCALL*)(int32_t set))0x000000014045A9E0; -int32_t(FASTCALL* obj_database_get_set_id)(int32_t set_index) +int32_t(FASTCALL* object_database_get_set_id)(int32_t set_index) = (int32_t(FASTCALL*)(int32_t set_index))0x000000014045AA10; static BufObjMgr& bufobj_mgr = *(BufObjMgr*)0x00000001411A34D0; diff --git a/src/DivaGL/object.hpp b/src/DivaGL/object.hpp index 5001572..4fbf52d 100644 --- a/src/DivaGL/object.hpp +++ b/src/DivaGL/object.hpp @@ -354,6 +354,8 @@ struct obj_mesh_vertex_array { void* field_98; }; +static_assert(sizeof(obj_mesh_vertex_array) == 0xA0, "\"obj_mesh_vertex_array\" struct should have a size of 0xA0"); + struct obj_mesh { uint32_t flags; obj_bounding_sphere bounding_sphere; @@ -385,6 +387,8 @@ struct obj { uint32_t reserved[10]; }; +static_assert(sizeof(obj) == 0x60, "\"obj\" struct should have a size of 0x60"); + struct obj_skin_ex_data { uint32_t num_osage_name; uint32_t num_osage_node; @@ -399,6 +403,8 @@ struct obj_skin_ex_data { uint32_t reserved[7]; }; +static_assert(sizeof(obj_skin_ex_data) == 0x60, "\"obj_skin_ex_data\" struct should have a size of 0x60"); + struct obj_skin { uint32_t* bone_id_array; mat4* bone_matrix_array; @@ -411,6 +417,8 @@ struct obj_skin { int32_t field_30; }; +static_assert(sizeof(obj_skin) == 0x38, "\"obj_skin\" struct should have a size of 0x38"); + struct object_info { uint16_t id; uint16_t set_id; @@ -507,15 +515,15 @@ struct obj_vertex_buffer { static_assert(sizeof(obj_vertex_buffer) == 0x10, "\"obj_vertex_buffer\" struct should have a size of 0x10"); -extern uint32_t(FASTCALL* obj_database_get_object_info)(const char* name); +extern uint32_t(FASTCALL* object_database_get_object_info)(const char* name); extern obj* (FASTCALL* object_info_get_object)(object_info obj_info); extern obj_mesh_index_buffer* (FASTCALL* object_info_get_mesh_index_buffer)(object_info obj_info, int32_t a2); -extern obj_skin* (FASTCALL* obj_database_get_object_skin)(object_info obj_info); +extern obj_skin* (FASTCALL* object_database_get_object_skin)(object_info obj_info); extern obj_mesh_vertex_buffer* (FASTCALL* object_info_get_mesh_vertex_buffer)(object_info obj_info, int32_t a2); -extern int32_t(FASTCALL* obj_database_get_obj_set_obj_id)(int32_t set_index, int32_t obj_index); -extern GLuint(FASTCALL* obj_database_get_obj_set_texture)(int32_t set, int32_t tex_id); -extern prj::vector* (FASTCALL* obj_database_get_obj_set_textures)(int32_t set); -extern int32_t(FASTCALL* obj_database_get_set_id)(int32_t set_index); +extern int32_t(FASTCALL* object_database_get_set_obj_id)(int32_t set_index, int32_t obj_index); +extern GLuint(FASTCALL* object_database_get_set_texture)(int32_t set, int32_t tex_id); +extern prj::vector* (FASTCALL* object_database_get_set_gentex)(int32_t set); +extern int32_t(FASTCALL* object_database_get_set_id)(int32_t set_index); extern int32_t obj_material_texture_type_get_texcoord_index( obj_material_texture_type type, int32_t index); diff --git a/src/DivaGL/render.cpp b/src/DivaGL/render.cpp index 515d436..737aca9 100644 --- a/src/DivaGL/render.cpp +++ b/src/DivaGL/render.cpp @@ -378,7 +378,7 @@ namespace rndr { if (!lens_flare_texture) return; - GLuint tex = obj_database_get_obj_set_texture(5, 4549); + GLuint tex = object_database_get_set_texture(5, 4549); if (!tex) return; diff --git a/src/DivaGL/stage.cpp b/src/DivaGL/stage.cpp index 52797d7..d43675f 100644 --- a/src/DivaGL/stage.cpp +++ b/src/DivaGL/stage.cpp @@ -125,12 +125,12 @@ HOOK(void, FASTCALL, stage__disp, 0x0000000140649560, stage* s) { if (s->stage_data->lens_flare_texture != -1 && s->lens_flare) { int32_t object_set_id = s->stage_data->object_set_id; rndr::Render* rend = render; - rend->lens_flare_texture = obj_database_get_obj_set_texture( + rend->lens_flare_texture = object_database_get_set_texture( object_set_id, s->stage_data->lens_flare_texture); if (rend->lens_flare_texture) { - rend->lens_shaft_texture = obj_database_get_obj_set_texture( + rend->lens_shaft_texture = object_database_get_set_texture( object_set_id, s->stage_data->lens_shaft_texture); - rend->lens_ghost_texture = obj_database_get_obj_set_texture( + rend->lens_ghost_texture = object_database_get_set_texture( object_set_id, s->stage_data->lens_ghost_texture); rend->lens_ghost_count = 16; rend->lens_shaft_inv_scale = s->stage_data->lens_shaft_inv_scale; diff --git a/src/DivaGL/types.hpp b/src/DivaGL/types.hpp index 3265e2a..88fe5fb 100644 --- a/src/DivaGL/types.hpp +++ b/src/DivaGL/types.hpp @@ -12,19 +12,22 @@ #pragma once -typedef enum HeapCMallocType { - HeapCMallocSystem = 0x00, - HeapCMallocTemp = 0x01, - HeapCMallocMode = 0x02, - HeapCMallocEvent = 0x03, - HeapCMallocDebug = 0x04, - HeapCMallocMax = 0x05, -} HeapCMallocType; +namespace prj { + typedef enum HeapCMallocType { + HeapCMallocSystem = 0x00, + HeapCMallocTemp = 0x01, + HeapCMallocMode = 0x02, + HeapCMallocEvent = 0x03, + HeapCMallocDebug = 0x04, + HeapCMallocMax = 0x05, + } HeapCMallocType; + + static void* (*HeapCMallocAllocate)(HeapCMallocType type, size_t size, const char* name) + = (void* (*)(HeapCMallocType, size_t, const char*))0x00000001403F2A00; + static void(*HeapCMallocFree)(HeapCMallocType type, void* data) + = (void(*)(HeapCMallocType, void*))0x00000001403F2960; +}; -static void* (*HeapCMallocAllocate)(HeapCMallocType type, size_t size, const char* name) - = (void* (*)(HeapCMallocType, size_t, const char*))0x00000001403F2A00; -static void(*HeapCMallocFree)(HeapCMallocType type, void* data) - = (void(*)(HeapCMallocType, void*))0x00000001403F2960; static void* (*_operator_new)(size_t) = (void* (*)(size_t))0x000000014084530C; static void(*_operator_delete)(void*) = (void(*)(void*))0x0000000140845378;