- Статус
- Оффлайн
- Регистрация
- 18 Май 2023
- Сообщения
- 1,174
- Реакции
- 266
Привет парни, вот вам реализация AspectRatio для ваших мегахаков!
Часть делала нейронка для коррекции багов. Работает по вертикали. Делал для Darkside SDK
Спасибо verteich за фикшеную базу и TayJlaur1337 за обучение!
Знаю что есть эта тема
Классы:
class c_view_setup {
public:
std::byte pad0[ 0x490 ]; //0x0000
float m_ortho_left; //0x0490
float m_ortho_top; //0x0494
float m_ortho_right; //0x0498
float m_ortho_bottom; //0x049C
std::byte pad1[ 0x38 ]; //0x04A0
float m_fov; //0x04D8
float m_viewmodel_fov; //0x04DC
vec3_t m_origin; //0x04E0
std::byte pad2[ 0xC ]; //0x04EC
vec3_t m_angles; //0x04F8F
std::byte pad3[ 0x14 ]; //0x0504
float m_aspect_ratio; //0x0518 <Поле для Aspect Ratio
std::byte pad4[ 0x79 ]; //0x051C
std::uint8_t m_some_flags; //0x0595 <Флаги (бит 2 используется для Aspect Ratio)
};
Пресет обычного разрешения:
float m_aspect_ratio = 16.0f / 9.0f;
Хук:
namespace override_view
{
inline c_hook m_override_view;
void* hk_override_view( void* source_to_client, c_view_setup* view_setup );
}
Сигнатура:
override_view::m_override_view.hook(
g_opcodes->scan(
g_modules->m_modules.client_dll.get_name( ),
"48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 41 56 41 57 48 83 EC ? 48 8B FA E8"
),
override_view::hk_override_view
);
Реализация хука:
void* hooks::override_view::hk_override_view( void* source_to_client, c_view_setup* view_setup ) {
static auto original = m_override_view.get_original< decltype( &hk_override_view ) >( );
void* result = original( source_to_client, view_setup );
c_cs_player_pawn* local_player = g_ctx->m_local_pawn;
if ( !local_player )
{
return result;
}
// Aspect Ratio
if ( g_cfg->misc.m_aspect_ratio == 0.f )
view_setup->m_some_flags &= ~2; // Отключаем Aspect Ratio (убираем флаг)
else
{
view_setup->m_aspect_ratio = g_cfg->misc.m_aspect_ratio;
view_setup->m_some_flags |= 2;
}
return result;
}
НОД:
static int gcd( int a, int b ) {
while ( b ) {
int temp = b;
b = a % b;
a = temp;
}
return a;
}
(это делала нейронка):
static std::string aspect_ratio_to_string( float ratio ) {
// Защита от 0, NaN и некорректных значений
if ( ratio <= 0.f || ratio > 10.f || std::isnan( ratio ) || std::isinf( ratio ) )
return "";
for ( int w = 1; w <= 100; ++w ) {
for ( int h = 1; h <= 100; ++h ) {
float test_ratio = static_cast<float>( w ) / static_cast<float>( h );
if ( std::abs( test_ratio - ratio ) < 0.01f ) {
int divisor = gcd( w, h );
int simplified_w = w / divisor;
int simplified_h = h / divisor;
if ( simplified_w <= 50 && simplified_h <= 50 ) {
std::stringstream ss;
ss << simplified_w << ":" << simplified_h;
return ss.str( );
}
}
}
}
std::stringstream ss;
ss << std::fixed << std::setprecision( 2 ) << ratio;
return ss.str( );
}
Меню:
ImGui::SliderFloat( "Aspect Ratio", &g_cfg->misc.m_aspect_ratio, 0.1f, 5.f, "%.2f" );
std::string aspect_ratio_str = aspect_ratio_to_string( g_cfg->misc.m_aspect_ratio );
if ( !aspect_ratio_str.empty( ) ) {
ImGui::SameLine( );
ImGui::Text( "(%s)", aspect_ratio_str.c_str( ) );
}
Часть делала нейронка для коррекции багов. Работает по вертикали. Делал для Darkside SDK
Спасибо verteich за фикшеную базу и TayJlaur1337 за обучение!
My way how to add in ur paste aspect ratio changer
// 48 89 5C 24 ? 57 48 83 EC ? 8B FA 48 8D 0D @engine2.dll // or u can just hook it from EngineClient interface but i was very lazy ( sorry? ) float __fastcall aspect_ratio( valve::c_engine* const rcx, int width, int height ) { if ( !cfg.m_aspect_ratio.get( ) ) return o_aspect_ratio(...