Paylaşım - vSRO 1.188 Ses Düzeltmesi (Sound Fix) - Option Audio Slider, Skill Sesi ve Intro Müziği Fix | SroCave - SRO Destek Forumu

Paylaşım vSRO 1.188 Ses Düzeltmesi (Sound Fix) - Option Audio Slider, Skill Sesi ve Intro Müziği Fix

  • Konbuyu başlatan Konbuyu başlatan PRIDE
  • Başlangıç tarihi Başlangıç tarihi
  • Cevaplar Cevaplar 0
  • Görüntüleme Görüntüleme 8

PRIDE

Uruchi
Katılım
23 Eyl 2025
Mesajlar
58
Tepkime puanı
1,256
Puanları
83
vSRO 1.188 Ses Düzeltmesi (Sound Fix)​

Herkese merhaba,

Muhtemelen bu sorunu biliyorsunuzdur. Option > Audio bölümündeki ses kaydırıcılarını sonuna kadar kısıyorsunuz, oyun yine de gürültülü, sonunda Windows ses karıştırıcısından istemcinin sesini kısmak zorunda kalıyorsunuz. Oynadığım her sunucuda bu vardı, ben de sonunda nedenini araştırdım.

Sorun tam olarak ne?
  • İstemci kaydırıcıları yalnızca -20 dB .. 0 dB aralığına eşliyor, bu yüzden %1 bile hâlâ oldukça yüksek
  • Skill / yürüme sesleri yavaşça kısılmıyor, kaydırıcının belli bir noktasında bir anda kesiliyor
  • Müzik kendiliğinden tam sese geri dönebiliyor (bölge değişimi, yeni parça)
  • Intro / giriş ekranında müzik %100 sesle çalıyor ve kayıtlı ayarınızı yok sayıyor

Bu düzeltme ne yapıyor?
  • Yeni kaydırıcı eğrisi: %0 = kapalı, %1 gerçekten çok kısık, %100 = eskisiyle aynı
  • Müzik akışındaki ve efekt motorundaki dahili -30 dB sınırını yükseltir, böylece hiçbir ses kesilmez veya reddedilmez
  • Kayıtlı müzik sesini intro ekranında da uygular

Tüm yamalar önce orijinal baytları kontrol eder, bu yüzden farklı bir istemcide hiçbir şey yapmaz.

DevKit'inize nasıl eklenir?

1. DevKit_DLL/src/hooks/ klasöründe SoundFix.h ve SoundFix.cpp dosyalarını oluşturun (kodlar aşağıda)

2. Bunları DevKit_DLL/CMakeLists.txt dosyasında diğer hook dosyalarının yanına ekleyin:
Kod:
src/hooks/SoundFix.cpp src/hooks/SoundFix.h

3. DevKit_DLL/src/Util.cpp içinde:
Kod:
#include "hooks/SoundFix.h"

void Setup() {
    // ... your existing hooks ...

    SoundFix::Install();
}

4. Yeniden derleyin ve dll dosyasını istemcinize kopyalayın.

Ana döngüyü zaten 0x00B934D0 adresinden hook'lıyorsanız, SoundFix::Install(false); kullanın ve kendi hook'unuzdan her karede SoundFix::OnFrame(); çağırın.

Ek bağımlılık yoktur, DevKit'in geri kalanı gibi VS2005 ile derlenir.

Test edildiği ortam
vSRO 1.188 istemcisi, SRO_DevKit (VS2005), Windows 11.

Kaynak kodun tamamı aşağıdadır, yalnızca iki dosyadan oluşur.

SoundFix.h
Kod:
#pragma once

// Sound volume fix for vSRO 1.188 (sro_client.exe).
//
// Call SoundFix::Install() once from Setup() in Util.cpp.
// If you already hook the main loop (0x00B934D0) yourself, pass false and call
// SoundFix::OnFrame() once per frame from your own hook.
namespace SoundFix {
    void Install(bool hookMainLoop = true);
    void OnFrame();
}

SoundFix.cpp
Kod:
// Sound volume fix for vSRO 1.188 (sro_client.exe)
//
// What is wrong in the stock client:
//  1. The Option > Audio sliders are mapped with (5*v - 500) * 4, so 0..100 only covers
//     -20 dB..0 dB. Even at 1% the sound is still loud, people end up using the Windows mixer.
//  2. The BGM stream (0x00BB65D0) rejects anything below -3000 and keeps the old volume.
//  3. The effect engine (0x01112FB0) does not play a sound at all when the volume is at or
//     below -3000, so skill/walk sounds cut out at a certain slider point.
//  4. If the music engine is created after the options are loaded (intro/login screen),
//     it starts at 0 dB and ignores the saved slider value.
//
// What this does:
//  - Replaces the slider map with a two slope curve (0 = off, 1 = about -51 dB, 100 = 0 dB).
//  - Moves the -3000 floor to -6000 in the BGM stream, the fade code and the effect engine.
//  - Pushes the saved music volume to the music engine whenever it gets (re)created.
//
// Every patch checks the original bytes first. On a different client nothing is touched.

#include "SoundFix.h"
#include <Windows.h>
#include <string.h>

namespace {

const int DSB_VOLUME_MIN = -10000;

// ---------------------------------------------------------------- helpers

bool BytesMatch(DWORD addr, const BYTE* bytes, size_t size) {
    return memcmp(reinterpret_cast<void*>(addr), bytes, size) == 0;
}

void WriteCode(DWORD addr, const void* data, size_t size) {
    DWORD old = 0;
    if (!VirtualProtect(reinterpret_cast<void*>(addr), size, PAGE_EXECUTE_READWRITE, &old))
        return;
    memcpy(reinterpret_cast<void*>(addr), data, size);
    VirtualProtect(reinterpret_cast<void*>(addr), size, old, &old);
    FlushInstructionCache(GetCurrentProcess(), reinterpret_cast<void*>(addr), size);
}

void WriteJmp(DWORD from, const void* to) {
    BYTE jmp[5] = { 0xE9 };
    *reinterpret_cast<DWORD*>(jmp + 1) = reinterpret_cast<DWORD>(to) - from - 5;
    WriteCode(from, jmp, sizeof(jmp));
}

// ---------------------------------------------------------------- volume floor

const int kFloorOld = 3000;
const int kFloorNew = 6000;

struct FloorPatch { DWORD addr; BYTE orig[6]; size_t size; size_t immOffset; };

// BGM stream range check and fade, all use 0BB8h (3000)
const FloorPatch kStreamPatches[] = {
    { 0x00BB65EC, { 0x8D, 0x8F, 0xB8, 0x0B, 0x00, 0x00 }, 6, 2 },  // lea ecx,[edi+0BB8h]
    { 0x00BB65F2, { 0x81, 0xF9, 0xB8, 0x0B, 0x00, 0x00 }, 6, 2 },  // cmp ecx,0BB8h
    { 0x00BB6655, { 0x05, 0xB8, 0x0B, 0x00, 0x00, 0x00 }, 5, 1 },  // add eax,0BB8h
    { 0x00BB6671, { 0x81, 0xE9, 0xB8, 0x0B, 0x00, 0x00 }, 6, 2 },  // sub ecx,0BB8h
};
const size_t kStreamPatchCount = sizeof(kStreamPatches) / sizeof(kStreamPatches[0]);

// Effect engine: mov dword ptr [esi+1D0h], -3000 in the constructor, plus the live value
const DWORD ADDR_FX_FLOOR_INIT = 0x00BC1A78;
const BYTE  kFxFloorInit[10] = { 0xC7, 0x86, 0xD0, 0x01, 0x00, 0x00, 0x48, 0xF4, 0xFF, 0xFF };
const DWORD ADDR_FX_FLOOR = 0x01113180;

int g_floor = -kFloorOld;

bool PatchStreamFloor() {
    for (size_t i = 0; i < kStreamPatchCount; ++i)
        if (!BytesMatch(kStreamPatches[i].addr, kStreamPatches[i].orig, kStreamPatches[i].size))
            return false;

    for (size_t i = 0; i < kStreamPatchCount; ++i) {
        const FloorPatch& p = kStreamPatches[i];
        BYTE buf[6];
        memcpy(buf, p.orig, p.size);
        *reinterpret_cast<int*>(buf + p.immOffset) = kFloorNew;
        WriteCode(p.addr, buf, p.size);
    }
    return true;
}

bool PatchFxFloor() {
    if (!BytesMatch(ADDR_FX_FLOOR_INIT, kFxFloorInit, sizeof(kFxFloorInit)))
        return false;

    BYTE buf[10];
    memcpy(buf, kFxFloorInit, sizeof(buf));
    *reinterpret_cast<int*>(buf + 6) = -kFloorNew;
    WriteCode(ADDR_FX_FLOOR_INIT, buf, sizeof(buf));

    *reinterpret_cast<int*>(ADDR_FX_FLOOR) = -kFloorNew;   // in case the engine already exists
    return true;
}

// ---------------------------------------------------------------- slider curve

// Used for BGM, FX and Environmental. Values are 1/100 dB.
// 100..40: -0.3 dB per step (40 = -18 dB)
// 40..1:   -0.85 dB per step (25 = -30.75 dB, 10 = -43.5 dB, 1 = -51.15 dB)
// 0:       off
const DWORD ADDR_VOLUME_MAP = 0x00835380;
const BYTE  kVolumeMapOrig[] = { 0x8B, 0x44, 0x24, 0x04, 0x8D, 0x84, 0x80, 0x0C, 0xFE, 0xFF, 0xFF };

const int kKnee = 40;
const int kStepHigh = 30;
const int kStepLow = 85;

// Original is thiscall with one arg. ecx is not used, stdcall cleans the same 4 bytes.
int __stdcall MapVolume(int slider) {
    if (slider <= 0) return DSB_VOLUME_MIN;
    if (slider >= 100) return 0;
    if (slider >= kKnee) return (slider - 100) * kStepHigh;

    int v = (kKnee - 100) * kStepHigh - (kKnee - slider) * kStepLow;
    return v < g_floor ? g_floor : v;
}

// ---------------------------------------------------------------- music engine re-apply

const DWORD ADDR_MUSIC_ENGINE = 0x011114A8;
const DWORD ADDR_MUSIC_OBJECT = 0x0110AAD8;
const DWORD OFFSET_MUSIC_VOLUME = 0xCC;
const DWORD ADDR_MUSIC_SET_VOLUME = 0x00BB6300;

// ---------------------------------------------------------------- main loop hook

// 0x00B934D0 runs once per frame on the main thread. First instruction is
// mov eax,[0110F7C0h] (5 bytes), we run it ourselves and jump back.
const DWORD ADDR_MAIN_LOOP = 0x00B934D0;
const BYTE  kMainLoopOrig[5] = { 0xA1, 0xC0, 0xF7, 0x10, 0x01 };
const DWORD ADDR_MAIN_LOOP_BACK = 0x00B934D5;

void __cdecl OnFrameThunk() {
    SoundFix::OnFrame();
}

__declspec(naked) void MainLoopStub() {
    __asm {
        pushad
        pushfd
        call OnFrameThunk
        popfd
        popad
        mov eax, dword ptr ds:[0x0110F7C0]
        push 0x00B934D5   // ADDR_MAIN_LOOP_BACK
        ret
    }
}

} // namespace

void SoundFix::OnFrame() {
    static DWORD lastEngine = 0;

    DWORD engine = *reinterpret_cast<DWORD*>(ADDR_MUSIC_ENGINE);
    if (engine == lastEngine)
        return;

    DWORD music = *reinterpret_cast<DWORD*>(ADDR_MUSIC_OBJECT);
    if (engine != 0 && music == 0)
        return;   // options not loaded yet, try again next frame

    lastEngine = engine;
    if (engine == 0)
        return;

    int volume = *reinterpret_cast<int*>(music + OFFSET_MUSIC_VOLUME);
    if (volume > DSB_VOLUME_MIN && volume <= 0)
        reinterpret_cast<int (__cdecl*)(int)>(ADDR_MUSIC_SET_VOLUME)(volume);
}

void SoundFix::Install(bool hookMainLoop) {
    if (!BytesMatch(ADDR_VOLUME_MAP, kVolumeMapOrig, sizeof(kVolumeMapOrig)))
        return;   // not a vSRO 1.188 client

    if (PatchStreamFloor() && PatchFxFloor())
        g_floor = -kFloorNew;

    WriteJmp(ADDR_VOLUME_MAP, &MapVolume);

    if (hookMainLoop && BytesMatch(ADDR_MAIN_LOOP, kMainLoopOrig, sizeof(kMainLoopOrig)))
        WriteJmp(ADDR_MAIN_LOOP, &MainLoopStub);
}

Kendi istemcinizde bir şey çalışmazsa buraya yazın, bakarım.



Yararlı mı oldu? Teşekkür Et'e basmayı unutmayın!

Krediler: florian0 (SRO_DevKit için)​
 
Etiketler Etiketler
audio fix bgm volume c++ source devkit florian0 intro müziği müzik sesi ses ayarı ses düzeltmesi silkroad silkroad online silkroad private server silkroad release skill sesi sound fix soundfix.cpp sro devkit sro_client.exe vsro vsro 1.188

Geri
Üst Alt