From c68148497ca1084361319ad7c55d0eff81ce1fdc Mon Sep 17 00:00:00 2001 From: Berthalamew <40469582+Berthalamew@users.noreply.github.com> Date: Wed, 4 Dec 2024 19:46:06 -0500 Subject: [PATCH] fix type mismatch warnings --- .../animations/animation_definitions.cpp | 4 ++-- .../Engine/animations/animation_definitions.h | 2 +- xlive/Blam/Engine/game/player_vibration.cpp | 6 ++--- xlive/Blam/Engine/interface/interface.cpp | 4 ++-- xlive/Blam/Engine/interface/new_hud_draw.cpp | 4 ++-- xlive/Blam/Engine/interface/new_hud_draw.h | 2 +- .../screen_cartographer_account_manager.h | 2 +- .../Engine/interface/user_interface_guide.cpp | 2 ++ .../interface/user_interface_utilities.cpp | 1 - .../dx9/rasterizer_dx9_lens_flares.cpp | 16 ++++++------- .../rasterizer/dx9/rasterizer_dx9_targets.cpp | 23 +++++++++--------- .../render/render_cartographer_ingame_ui.cpp | 6 ++--- xlive/Blam/Engine/text/font_cache.cpp | 17 +++++++------ xlive/Blam/Engine/text/font_cache.h | 6 +++-- .../imgui_integration/AdvancedSettings.cpp | 24 +++++++++---------- xlive/XLive/achievements/XAchievements.cpp | 6 ++--- xlive/XLive/achievements/XAchievements.h | 2 +- xlive/xliveless.cpp | 16 ++++++------- 18 files changed, 74 insertions(+), 69 deletions(-) diff --git a/xlive/Blam/Engine/animations/animation_definitions.cpp b/xlive/Blam/Engine/animations/animation_definitions.cpp index 2ced325c5..3a32a4be4 100644 --- a/xlive/Blam/Engine/animations/animation_definitions.cpp +++ b/xlive/Blam/Engine/animations/animation_definitions.cpp @@ -113,7 +113,7 @@ int16 c_model_animation::find_first_key_of_type(const e_frame_event_type event_t return result; } -int16 c_model_animation::find_first_sound_event(int32* sound) const +int16 c_model_animation::find_first_sound_event(int16* sound) const { int16 frame = 0; if (this->sound_events.count > 0) @@ -252,7 +252,7 @@ size_t c_model_animation::get_sound_events_size(void) const int16 c_model_animation::get_sound_reference_index(void) const { - int32 sound = NONE; + int16 sound = NONE; this->find_first_sound_event(&sound); return sound; } diff --git a/xlive/Blam/Engine/animations/animation_definitions.h b/xlive/Blam/Engine/animations/animation_definitions.h index ec84b2d34..f4c4d2ccc 100644 --- a/xlive/Blam/Engine/animations/animation_definitions.h +++ b/xlive/Blam/Engine/animations/animation_definitions.h @@ -335,7 +335,7 @@ class c_model_animation public: bool animation_is_world_relative(void) const; int16 find_first_key_of_type(const e_frame_event_type event_type) const; - int16 find_first_sound_event(int32* sound) const; + int16 find_first_sound_event(int16* sound) const; int16 find_next_key_of_type(const e_frame_event_type event_type, const int32 frame) const; e_animation_type get_animation_type(void) const; real32 get_authored_duration(void) const; diff --git a/xlive/Blam/Engine/game/player_vibration.cpp b/xlive/Blam/Engine/game/player_vibration.cpp index 5edcc2243..8be0ca89e 100644 --- a/xlive/Blam/Engine/game/player_vibration.cpp +++ b/xlive/Blam/Engine/game/player_vibration.cpp @@ -89,11 +89,9 @@ void __cdecl vibration_update(real32 dt) } } - for (uint32 controller_index = 0; controller_index < NUMBEROF(controller_vibration_states); ++controller_index) + for (int16 controller_index = 0; controller_index < NUMBEROF(controller_vibration_states); ++controller_index) { - const XINPUT_VIBRATION state = controller_vibration_states[controller_index]; - - input_set_gamepad_rumbler_state(controller_index, state.wLeftMotorSpeed, state.wRightMotorSpeed); + input_set_gamepad_rumbler_state(controller_index, controller_vibration_states[controller_index].wLeftMotorSpeed, controller_vibration_states[controller_index].wRightMotorSpeed); } } } diff --git a/xlive/Blam/Engine/interface/interface.cpp b/xlive/Blam/Engine/interface/interface.cpp index 2e623b839..255eb7181 100644 --- a/xlive/Blam/Engine/interface/interface.cpp +++ b/xlive/Blam/Engine/interface/interface.cpp @@ -111,8 +111,8 @@ void render_splitscreen_line(void) ASSERT(IN_RANGE(player_window_count, 1, 4)); const s_rasterizer_globals* rasterizer_globals = rasterizer_globals_get(); - const int32 resolution_x = rasterizer_globals->resolution_x; - const int32 resolution_y = rasterizer_globals->resolution_y; + const int16 resolution_x = (int16)rasterizer_globals->resolution_x; + const int16 resolution_y = (int16)rasterizer_globals->resolution_y; // We calculate the size of the line by dividing our resolution by the height the original game ran at const int32 line_size = resolution_y / 480; diff --git a/xlive/Blam/Engine/interface/new_hud_draw.cpp b/xlive/Blam/Engine/interface/new_hud_draw.cpp index 61675902e..fa4736c23 100644 --- a/xlive/Blam/Engine/interface/new_hud_draw.cpp +++ b/xlive/Blam/Engine/interface/new_hud_draw.cpp @@ -797,9 +797,9 @@ datum hud_bitmap_tag_index_get(void) return *Memory::GetAddress(0x976678); } -int32 hud_bitmap_data_index_get(void) +int16 hud_bitmap_data_index_get(void) { - return *Memory::GetAddress(0x97667C); + return *Memory::GetAddress(0x97667C); } void hud_player_indicators_draw_enabled_set(int32 user_index, bool enabled) diff --git a/xlive/Blam/Engine/interface/new_hud_draw.h b/xlive/Blam/Engine/interface/new_hud_draw.h index 1ed8b2951..0484a8eb5 100644 --- a/xlive/Blam/Engine/interface/new_hud_draw.h +++ b/xlive/Blam/Engine/interface/new_hud_draw.h @@ -16,7 +16,7 @@ void hud_draw_on_map_load(void); datum hud_bitmap_tag_index_get(void); -int32 hud_bitmap_data_index_get(void); +int16 hud_bitmap_data_index_get(void); void hud_player_indicators_draw_enabled_set(int32 user_index, bool enabled); diff --git a/xlive/Blam/Engine/interface/screens/screen_cartographer_account_manager.h b/xlive/Blam/Engine/interface/screens/screen_cartographer_account_manager.h index 409467967..0eff7c973 100644 --- a/xlive/Blam/Engine/interface/screens/screen_cartographer_account_manager.h +++ b/xlive/Blam/Engine/interface/screens/screen_cartographer_account_manager.h @@ -117,7 +117,7 @@ class c_cartographer_account_manager_menu : protected c_screen_with_menu virtual void pre_destroy(void) override; virtual void initialize(s_screen_parameters* screen_parameters) override; virtual void post_initialize(void) override; - const virtual const void* load_proc(void) const override; + virtual const void* load_proc(void) const override; }; // ASSERT_STRUCT_SIZE(c_cartographer_account_manager_menu, 3396); diff --git a/xlive/Blam/Engine/interface/user_interface_guide.cpp b/xlive/Blam/Engine/interface/user_interface_guide.cpp index fc9a48196..991857cfb 100644 --- a/xlive/Blam/Engine/interface/user_interface_guide.cpp +++ b/xlive/Blam/Engine/interface/user_interface_guide.cpp @@ -2,6 +2,7 @@ #include "user_interface_guide.h" #include "screens/screen_cartographer_account_manager.h" +/* public code */ c_user_interface_guide_state_manager* user_interface_guide_state_manager_get(void) { @@ -13,4 +14,5 @@ void c_user_interface_guide_state_manager::add_user_signin_task(bool sign_to_liv //INVOKE_TYPE(0xDD7550, 0x0, int(__thiscall*)(c_user_interface_guide_state_manager*, bool, void*), this, sign_to_live, signin_callback); this->m_callback_task = signin_callback; cartographer_account_manager_open_list(); + return; } diff --git a/xlive/Blam/Engine/interface/user_interface_utilities.cpp b/xlive/Blam/Engine/interface/user_interface_utilities.cpp index 349ccd14e..aa4194d12 100644 --- a/xlive/Blam/Engine/interface/user_interface_utilities.cpp +++ b/xlive/Blam/Engine/interface/user_interface_utilities.cpp @@ -3,7 +3,6 @@ #include "hud.h" #include "user_interface_controller.h" -#include "rasterizer/rasterizer_globals.h" #include "render/render.h" datum __cdecl user_interface_get_widget_tag_index_from_screen_id(e_user_interface_screen_id screen_id) diff --git a/xlive/Blam/Engine/rasterizer/dx9/rasterizer_dx9_lens_flares.cpp b/xlive/Blam/Engine/rasterizer/dx9/rasterizer_dx9_lens_flares.cpp index 0b5df6f06..7889b542e 100644 --- a/xlive/Blam/Engine/rasterizer/dx9/rasterizer_dx9_lens_flares.cpp +++ b/xlive/Blam/Engine/rasterizer/dx9/rasterizer_dx9_lens_flares.cpp @@ -102,10 +102,10 @@ e_rasterizer_target rasterizer_dx9_sun_glow_draw(datum tag_index, real_point3d* real32 viewport_middle_y = (real32)(viewport_height / 2); RECT rect; - rect.left = viewport_left + (viewport_width * sun_surface_quad.x0 / 2.0f + viewport_middle_x); - rect.top = viewport_bottom - (viewport_height * sun_surface_quad.y1 / 2.0f + viewport_middle_y); - rect.right = viewport_left + (viewport_width * sun_surface_quad.x1 / 2.0f + viewport_middle_x); - rect.bottom = viewport_bottom - (viewport_height * sun_surface_quad.y0 / 2.0f + viewport_middle_y); + rect.left = (LONG)(viewport_left + (viewport_width * sun_surface_quad.x0 / 2.0f + viewport_middle_x)); + rect.top = (LONG)(viewport_bottom - (viewport_height * sun_surface_quad.y1 / 2.0f + viewport_middle_y)); + rect.right = (LONG)(viewport_left + (viewport_width * sun_surface_quad.x1 / 2.0f + viewport_middle_x)); + rect.bottom = (LONG)(viewport_bottom - (viewport_height * sun_surface_quad.y0 / 2.0f + viewport_middle_y)); // Make sure we limit the rect to within the bounds of the viewport // Without this the StretchRect call to copy to the sun target will fail @@ -363,10 +363,10 @@ void rasterizer_dx9_sun_glow_copy_source(const RECT* rect, e_rasterizer_target t real_rectangle2d rectangle; if (rect) { - rectangle.x0 = rect->left; - rectangle.x1 = rect->right; - rectangle.y0 = rect->top; - rectangle.y1 = rect->bottom; + rectangle.x0 = (real32)rect->left; + rectangle.x1 = (real32)rect->right; + rectangle.y0 = (real32)rect->top; + rectangle.y1 = (real32)rect->bottom; p_rect = &rectangle; } diff --git a/xlive/Blam/Engine/rasterizer/dx9/rasterizer_dx9_targets.cpp b/xlive/Blam/Engine/rasterizer/dx9/rasterizer_dx9_targets.cpp index f1a36d642..9a4ca2df9 100644 --- a/xlive/Blam/Engine/rasterizer/dx9/rasterizer_dx9_targets.cpp +++ b/xlive/Blam/Engine/rasterizer/dx9/rasterizer_dx9_targets.cpp @@ -171,13 +171,14 @@ void __cdecl rasterizer_set_render_target_internal_hook_set_viewport(IDirect3DSu // NOTE: *ONLY* use this function for entire screen surfaces (e.g the backbuffer, a render target) rasterizer_dx9_set_render_target_internal(target, z_stencil, a3); - D3DVIEWPORT9 vp = { - global_camera->viewport_bounds.left, - global_camera->viewport_bounds.top, - rectangle2d_width(&global_camera->viewport_bounds), - rectangle2d_height(&global_camera->viewport_bounds), - 0.0f, - 1.0f + D3DVIEWPORT9 vp = + { + (DWORD)global_camera->viewport_bounds.left, + (DWORD)global_camera->viewport_bounds.top, + (DWORD)rectangle2d_width(&global_camera->viewport_bounds), + (DWORD)rectangle2d_height(&global_camera->viewport_bounds), + 0.f, + 1.f }; // set the viewport, after setting the main render target // to note that the viewport will always gets reset when a new render target is set @@ -528,10 +529,10 @@ void __cdecl rasterizer_dx9_set_target(e_rasterizer_target rasterizer_target, in else { viewport_scale = 1.0; - viewport.X = global_window_parameters->camera.viewport_bounds.left * viewport_scale; - viewport.Y = global_window_parameters->camera.viewport_bounds.top * viewport_scale; - viewport.Width = viewport_width * viewport_scale; - viewport.Height = viewport_height * viewport_scale; + viewport.X = (DWORD)(global_window_parameters->camera.viewport_bounds.left * viewport_scale); + viewport.Y = (DWORD)(global_window_parameters->camera.viewport_bounds.top * viewport_scale); + viewport.Width = (DWORD)(viewport_width * viewport_scale); + viewport.Height = (DWORD)(viewport_height * viewport_scale); } } // By default set the viewport as the desc params diff --git a/xlive/Blam/Engine/render/render_cartographer_ingame_ui.cpp b/xlive/Blam/Engine/render/render_cartographer_ingame_ui.cpp index 39e6955fa..eeac09950 100644 --- a/xlive/Blam/Engine/render/render_cartographer_ingame_ui.cpp +++ b/xlive/Blam/Engine/render/render_cartographer_ingame_ui.cpp @@ -105,7 +105,7 @@ void render_cartographer_status_bar(const char *build_text) text_color_console.alpha = .5f; } - const int32 line_height = get_text_size_from_font_cache(k_status_text_font); + const int16 line_height = get_text_size_from_font_cache(k_status_text_font); bool paused_or_in_main_menu = game_is_main_menu || paused_or_in_menus; if (paused_or_in_main_menu) { @@ -133,7 +133,7 @@ void render_cartographer_git_build_info(void) #if defined(GEN_GIT_VER_VERSION_STRING) && defined(CARTOGRAPHER_TEST_BUILD_DRAW_TEXT) const s_rasterizer_globals* rasterizer_globals = rasterizer_globals_get(); - const int32 line_height = get_text_size_from_font_cache(k_status_text_font); + const int16 line_height = get_text_size_from_font_cache(k_status_text_font); real_argb_color text_color_console = *global_real_argb_white; text_color_console.alpha = .55f; @@ -172,7 +172,7 @@ bool render_cartographer_achievement_message(const char *achivement_message) { rectangle2d bounds; wchar_t cheevo_message[256]; - int32 widget_total_height = get_text_size_from_font_cache(k_cheevo_title_font) + (get_text_size_from_font_cache(k_cheevo_message_font) * 2); + const int16 widget_total_height = get_text_size_from_font_cache(k_cheevo_title_font) + (get_text_size_from_font_cache(k_cheevo_message_font) * 2); real_argb_color text_color = *global_real_argb_white; text_color.alpha = (float)(x_cheevo_timer - time_now) / k_cheevo_display_lifetime; diff --git a/xlive/Blam/Engine/text/font_cache.cpp b/xlive/Blam/Engine/text/font_cache.cpp index 5e210148e..c5a57b01b 100644 --- a/xlive/Blam/Engine/text/font_cache.cpp +++ b/xlive/Blam/Engine/text/font_cache.cpp @@ -3,15 +3,18 @@ #include "interface/hud.h" +/* public code */ -// Multiply font size by the global text scale to fix scaling issues on resolutions higher than 1080 pixels vertically -int __cdecl get_text_size_from_font_cache(int font_cache_index) +void font_group_apply_hooks(void) { - auto p_get_text_size_from_font_cache = Memory::GetAddress(0x31865); - return (int)((float)p_get_text_size_from_font_cache(font_cache_index) * *get_secondary_hud_scale()); + PatchCall(Memory::GetAddress(0x6AE0D), get_text_size_from_font_cache); + return; } -void font_group_apply_hooks() +// Multiply font size by the global text scale to fix scaling issues on resolutions higher than 1080 pixels vertically +int16 __cdecl get_text_size_from_font_cache(int32 font_cache_index) { - PatchCall(Memory::GetAddress(0x6AE0D), get_text_size_from_font_cache); -} \ No newline at end of file + int16 size = INVOKE(0x31865, 0x0, get_text_size_from_font_cache, font_cache_index); + return (int16)(size * *get_secondary_hud_scale()); +} + diff --git a/xlive/Blam/Engine/text/font_cache.h b/xlive/Blam/Engine/text/font_cache.h index 4b15d20b3..72722de68 100644 --- a/xlive/Blam/Engine/text/font_cache.h +++ b/xlive/Blam/Engine/text/font_cache.h @@ -1,5 +1,7 @@ #pragma once -int __cdecl get_text_size_from_font_cache(int font_cache_index); +/* prototypes */ -void font_group_apply_hooks(); +void font_group_apply_hooks(void); + +int16 __cdecl get_text_size_from_font_cache(int32 font_cache_index); diff --git a/xlive/H2MOD/GUI/imgui_integration/AdvancedSettings.cpp b/xlive/H2MOD/GUI/imgui_integration/AdvancedSettings.cpp index 729f59319..7944d94a4 100644 --- a/xlive/H2MOD/GUI/imgui_integration/AdvancedSettings.cpp +++ b/xlive/H2MOD/GUI/imgui_integration/AdvancedSettings.cpp @@ -32,7 +32,7 @@ const char* k_button_items[] = { "Dpad Up","Dpad Down","Dpad Left","Dpad Right","Start","Back","Left Thumb","Right Thumb","Left Bumper","Right Bumper","A","B","X","Y" }; const char* k_action_items[] = { "Dpad Up","Dpad Down","Dpad Left","Dpad Right","Start","Back","Crouch","Zoom","Flashlight","Switch Grenades","Jump","Melee","Reload","Switch Weapons" }; -const uint32 k_button_values[k_number_of_xinput_buttons] = +const uint16 k_button_values[k_number_of_xinput_buttons] = { XINPUT_GAMEPAD_DPAD_UP, XINPUT_GAMEPAD_DPAD_DOWN, @@ -93,17 +93,17 @@ namespace ImGuiHandler { if (current_cartographer_profile->controller_deadzone_type == _controller_deadzone_type_axial || current_cartographer_profile->controller_deadzone_type == _controller_deadzone_type_combined) { - int X_Axis = current_cartographer_profile->deadzone_axial.x; - int Y_Axis = current_cartographer_profile->deadzone_axial.y; + real32 x_axis = current_cartographer_profile->deadzone_axial.x; + real32 y_axis = current_cartographer_profile->deadzone_axial.y; ImVec2 Y_TopLeft( Center.x - 100, - Center.y - Y_Axis); + Center.y - y_axis); ImVec2 Y_BottomRight( Center.x + 100, - Center.y + Y_Axis); + Center.y + y_axis); draw_list->AddRectFilled(Y_TopLeft, Y_BottomRight, ImColor(20, 20, 20, 125)); - ImVec2 X_TopLeft(Center.x - X_Axis, Center.y - 100); - ImVec2 X_BottomRight(Center.x + X_Axis, Center.y + 100); + ImVec2 X_TopLeft(Center.x - x_axis, Center.y - 100); + ImVec2 X_BottomRight(Center.x + x_axis, Center.y + 100); draw_list->AddRectFilled(X_TopLeft, X_BottomRight, ImColor(20, 20, 20, 125)); } if (current_cartographer_profile->controller_deadzone_type == _controller_deadzone_type_radial @@ -124,10 +124,10 @@ namespace ImGuiHandler { if (abs(state->thumb_right.y) <= THUMBSTICK_PERCENTAGE_TO_POINT(current_cartographer_profile->deadzone_axial.y)) axial_invalid++; bool radial_invalid = false; - unsigned int ar = pow((short)THUMBSTICK_PERCENTAGE_TO_POINT(current_cartographer_profile->deadzone_radial), 2); - unsigned int arx = pow(state->thumb_right.x, 2); - unsigned int ary = pow(state->thumb_right.y, 2); - unsigned int rh = arx + ary; + uint32 ar = (uint32)pow((short)THUMBSTICK_PERCENTAGE_TO_POINT(current_cartographer_profile->deadzone_radial), 2); + uint32 arx = (uint32)pow(state->thumb_right.x, 2); + uint32 ary = (uint32)pow(state->thumb_right.y, 2); + uint32 rh = arx + ary; if (rh <= ar) { radial_invalid = true; @@ -219,7 +219,7 @@ namespace ImGuiHandler { ImGui::PushItemWidth(WidthPercentage(10)); ImGui::InputFloat("##Crosshair2", ¤t_cartographer_profile->crosshair_offset, 0, 110, "%.3f"); ImGui::SameLine(); if (ImGui::IsItemEdited()) { - current_cartographer_profile->crosshair_offset = PIN(current_cartographer_profile->crosshair_offset, 0, 0.5); + current_cartographer_profile->crosshair_offset = PIN(current_cartographer_profile->crosshair_offset, 0.f, 0.5f); } ImGui::PushItemWidth(WidthPercentage(10)); if (ImGui::Button(advanced_settings_get_string(_advanced_string_reset, "Crosshair3"), b2_size)) diff --git a/xlive/XLive/achievements/XAchievements.cpp b/xlive/XLive/achievements/XAchievements.cpp index 152b7d274..2ee4a5978 100644 --- a/xlive/XLive/achievements/XAchievements.cpp +++ b/xlive/XLive/achievements/XAchievements.cpp @@ -4,9 +4,9 @@ #include "H2MOD/Modules/Achievements/Achievements.h" -int achievementCount = 0; -int achievementEnumeratorFlags = 0; -int achievementEnumeratorIndex = 0; +DWORD achievementCount = 0; +DWORD achievementEnumeratorFlags = 0; +DWORD achievementEnumeratorIndex = 0; extern void Check_Overlapped(PXOVERLAPPED pOverlapped); HANDLE g_dwFakeAchievementContent = INVALID_HANDLE_VALUE; diff --git a/xlive/XLive/achievements/XAchievements.h b/xlive/XLive/achievements/XAchievements.h index bccc2a88f..787d0d1a6 100644 --- a/xlive/XLive/achievements/XAchievements.h +++ b/xlive/XLive/achievements/XAchievements.h @@ -1,5 +1,5 @@ #pragma once -extern int achievementCount; +extern DWORD achievementCount; extern HANDLE g_dwFakeAchievementContent; #define XACHIEVEMENT_TYPE_COMPLETION 1 diff --git a/xlive/xliveless.cpp b/xlive/xliveless.cpp index 03d8f794a..8cdbf7bcb 100644 --- a/xlive/xliveless.cpp +++ b/xlive/xliveless.cpp @@ -134,19 +134,19 @@ LONG WINAPI XLivePBufferAllocate (DWORD size, FakePBuffer **pBuffer) //initialize fake buffer *pBuffer = (FakePBuffer*)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(FakePBuffer)); - (*pBuffer)->dwSize = size; - (*pBuffer)->id = CreateMutex(NULL,NULL,NULL); - (*pBuffer)->magic = 0xDEADC0DE; - - //initialize real buffer inside fake buffer - (*pBuffer)->pbData = (PBYTE)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,size); - if(!*pBuffer) { LOG_ERROR_XLIVE("XLivePBufferAllocate() unable to allocate {} bytes", size); return E_OUTOFMEMORY; } + (*pBuffer)->dwSize = size; + (*pBuffer)->id = CreateMutex(NULL, NULL, NULL); + (*pBuffer)->magic = 0xDEADC0DE; + + //initialize real buffer inside fake buffer + (*pBuffer)->pbData = (PBYTE)HeapAlloc(hHeap, HEAP_ZERO_MEMORY, size); + return 0; } @@ -342,7 +342,7 @@ DWORD WINAPI XStringVerify( DWORD dwFlags, const CHAR *szLocale, DWORD dwNumStri if( pResults ) { - pResults->wNumStrings = dwNumStrings; + pResults->wNumStrings = (WORD)dwNumStrings; pResults->pStringResult = (HRESULT *) ((BYTE *) pResults + sizeof(STRING_VERIFY_RESPONSE));