Skip to content

Commit

Permalink
No debug messages and hasSustainPoint error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
QuestionableM committed Jul 14, 2023
1 parent 4bfbd06 commit 5b92edc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
25 changes: 18 additions & 7 deletions Code/fmod_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ FMOD_RESULT FMODHooks::h_FMOD_Studio_EventInstance_release(FMOD::Studio::EventIn
{
FakeEventDescription* v_fake_event = FAKE_EVENT_CAST(event_instance);
if (v_fake_event->isValidHook())
{
DebugOutL(__FUNCTION__, " -> ", (std::size_t)event_instance);
return v_fake_event->release();
}

return FMODHooks::o_FMOD_Studio_EventInstance_release(event_instance);
}
Expand All @@ -49,8 +46,6 @@ FMOD_RESULT FMODHooks::h_FMOD_Studio_EventInstance_start(FMOD::Studio::EventInst
FakeEventDescription* v_fake_event = FAKE_EVENT_CAST(event_instance);
if (v_fake_event->isValidHook())
{
DebugOutL(__FUNCTION__);

bool is_playing = false;
v_fake_event->channel->isPlaying(&is_playing);

Expand Down Expand Up @@ -248,10 +243,10 @@ FMOD_RESULT FMODHooks::h_FMOD_Studio_EventDescription_createInstance(FMOD::Studi
if (v_audio_mgr->fmod_system->playSound(v_sound, nullptr, false, &v_channel) == FMOD_OK)
{
v_channel->setMode(FMOD_3D);
// v_channel->set3DMinMaxDistance(0.0f, 500.0f);

FakeEventDescription* v_new_fake_event = new FakeEventDescription(v_sound, v_channel);
*instance = reinterpret_cast<FMOD::Studio::EventInstance*>(v_new_fake_event);

return FMOD_OK;
}
}
Expand All @@ -261,6 +256,18 @@ FMOD_RESULT FMODHooks::h_FMOD_Studio_EventDescription_createInstance(FMOD::Studi
return FMODHooks::o_FMOD_Studio_EventDescription_createInstance(event_desc, instance);
}

FMOD_RESULT FMODHooks::h_FMOD_Studio_EventDescription_hasSustainPoint(FMOD::Studio::EventDescription* event_desc, bool* has_sustain)
{
FakeEventDescription* v_fake_event = FAKE_EVENT_CAST(event_desc);
if (v_fake_event->isValidHook())
{
*has_sustain = false;
return FMOD_OK;
}

return FMODHooks::o_FMOD_Studio_EventDescription_hasSustainPoint(event_desc, has_sustain);
}

#define FMOD_HOOK_FAKE_GUID_SECRET 0xf0f0f0f0f0f0f0f0

union FAKE_GUID_DATA
Expand Down Expand Up @@ -288,7 +295,6 @@ FMOD_RESULT FMODHooks::h_FMOD_Studio_System_lookupID(FMOD::Studio::System* syste
return FMOD_OK;
}

DebugOutL("Lookup id: ", path);
return FMODHooks::o_FMOD_Studio_System_lookupID(system, path, id);
}

Expand Down Expand Up @@ -400,6 +406,11 @@ static FMODHookData g_fmodHookData[] =
"?createInstance@EventDescription@Studio@FMOD@@QEBA?AW4FMOD_RESULT@@PEAPEAVEventInstance@23@@Z",
(LPVOID)FMODHooks::h_FMOD_Studio_EventDescription_createInstance,
(LPVOID*)&FMODHooks::o_FMOD_Studio_EventDescription_createInstance
},
{
"?hasSustainPoint@EventDescription@Studio@FMOD@@QEBA?AW4FMOD_RESULT@@PEA_N@Z",
(LPVOID)FMODHooks::h_FMOD_Studio_EventDescription_hasSustainPoint,
(LPVOID*)&FMODHooks::o_FMOD_Studio_EventDescription_hasSustainPoint
}
};

Expand Down
9 changes: 8 additions & 1 deletion Code/fmod_hooks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace FEventDescription
{
using GetLength = FMOD_RESULT(__fastcall*)(FMOD::Studio::EventDescription*, int*);
using CreateInstance = FMOD_RESULT(__fastcall*)(FMOD::Studio::EventDescription*, FMOD::Studio::EventInstance**);
using HasSustainPoint = FMOD_RESULT(__fastcall*)(FMOD::Studio::EventDescription*, bool*);
}

namespace FStudioSystem
Expand Down Expand Up @@ -60,7 +61,11 @@ struct FakeEventDescription
return v_secret_number == FAKE_EVENT_DESC_MAGIC;
}

FMOD_RESULT release() { return FMOD_OK;/*return sound->release();*/ }
FMOD_RESULT release()
{
delete this;
return FMOD_OK;/*return sound->release();*/
}
};

class SoundStorage
Expand Down Expand Up @@ -134,9 +139,11 @@ class FMODHooks

inline static FEventDescription::GetLength o_FMOD_Studio_EventDescription_getLength = nullptr;
inline static FEventDescription::CreateInstance o_FMOD_Studio_EventDescription_createInstance = nullptr;
inline static FEventDescription::HasSustainPoint o_FMOD_Studio_EventDescription_hasSustainPoint = nullptr;

static FMOD_RESULT h_FMOD_Studio_EventDescription_getLength(FMOD::Studio::EventDescription* event_desc, int* length);
static FMOD_RESULT h_FMOD_Studio_EventDescription_createInstance(FMOD::Studio::EventDescription* event_desc, FMOD::Studio::EventInstance** instance);
static FMOD_RESULT h_FMOD_Studio_EventDescription_hasSustainPoint(FMOD::Studio::EventDescription* event_desc, bool* has_sustain);


inline static FStudioSystem::LookupId o_FMOD_Studio_System_lookupID = nullptr;
Expand Down

0 comments on commit 5b92edc

Please sign in to comment.