diff --git a/cleo_plugins/Audio/C3DAudioStream.cpp b/cleo_plugins/Audio/C3DAudioStream.cpp index 88861175..d7a46eb8 100644 --- a/cleo_plugins/Audio/C3DAudioStream.cpp +++ b/cleo_plugins/Audio/C3DAudioStream.cpp @@ -6,6 +6,8 @@ using namespace CLEO; C3DAudioStream::C3DAudioStream(const char* filepath) : CAudioStream() { + static_assert(offsetof(C3DAudioStream, streamInternal) == 4, "C3DAudioStream compatibility with CLEO4 broken!"); + if (isNetworkSource(filepath) && !CSoundSystem::allowNetworkSources) { TRACE("Loading of 3d-audiostream '%s' failed. Support of network sources was disabled in SA.Audio.ini", filepath); diff --git a/cleo_plugins/Audio/CAudioStream.cpp b/cleo_plugins/Audio/CAudioStream.cpp index 03dae03b..110ec1fc 100644 --- a/cleo_plugins/Audio/CAudioStream.cpp +++ b/cleo_plugins/Audio/CAudioStream.cpp @@ -6,6 +6,8 @@ using namespace CLEO; CAudioStream::CAudioStream(const char* filepath) { + static_assert(offsetof(CAudioStream, streamInternal) == 4, "CAudioStream compatibility with CLEO4 broken!"); + if (isNetworkSource(filepath) && !CSoundSystem::allowNetworkSources) { TRACE("Loading of audiostream '%s' failed. Support of network sources was disabled in SA.Audio.ini", filepath); @@ -111,7 +113,7 @@ void CAudioStream::SetVolume(float value, float transitionTime) if (transitionTime <= 0.0) volume = value; // instant else - volumeTransitionStep = (volumeTarget - volume) / (1000.0 * transitionTime); + volumeTransitionStep = (volumeTarget - volume) / (1000.0f * transitionTime); } float CAudioStream::GetVolume() const @@ -129,7 +131,7 @@ void CAudioStream::SetSpeed(float value, float transitionTime) if (transitionTime <= 0.0) speed = value; // instant else - speedTransitionStep = (speedTarget - speed) / (1000.0 * transitionTime); + speedTransitionStep = (speedTarget - speed) / (1000.0f * transitionTime); } float CAudioStream::GetSpeed() const @@ -161,11 +163,11 @@ void CAudioStream::UpdateVolume() if (volume != volumeTarget) { auto timeDelta = CTimer::m_snTimeInMillisecondsNonClipped - CTimer::m_snPreviousTimeInMillisecondsNonClipped; - volume += volumeTransitionStep * (double)timeDelta; // animate the transition + volume += volumeTransitionStep * (float)timeDelta; // animate the transition // check progress auto remaining = volumeTarget - volume; - remaining *= (volumeTransitionStep > 0.0) ? 1.0 : -1.0; + remaining *= (volumeTransitionStep > 0.0f) ? 1.0f : -1.0f; if (remaining < 0.0) // overshoot { volume = volumeTarget; @@ -188,11 +190,11 @@ void CAudioStream::UpdateSpeed() if (speed != speedTarget) { auto timeDelta = CTimer::m_snTimeInMillisecondsNonClipped - CTimer::m_snPreviousTimeInMillisecondsNonClipped; - speed += speedTransitionStep * (double)timeDelta; // animate the transition + speed += speedTransitionStep * (float)timeDelta; // animate the transition // check progress auto remaining = speedTarget - speed; - remaining *= (speedTransitionStep > 0.0) ? 1.0 : -1.0; + remaining *= (speedTransitionStep > 0.0f) ? 1.0f : -1.0f; if (remaining < 0.0) // overshoot { speed = speedTarget; // done diff --git a/cleo_plugins/Audio/CAudioStream.h b/cleo_plugins/Audio/CAudioStream.h index fdfa2b60..514084ff 100644 --- a/cleo_plugins/Audio/CAudioStream.h +++ b/cleo_plugins/Audio/CAudioStream.h @@ -58,14 +58,14 @@ namespace CLEO eStreamType type = eStreamType::SoundEffect; bool ok = false; float rate = 44100.0f; // file's sampling rate - double speed = 1.0f; - double volume = 1.0f; + float speed = 1.0f; + float volume = 1.0f; // transitions - double volumeTarget = 1.0f; - double volumeTransitionStep = 1.0f; - double speedTarget = 1.0f; - double speedTransitionStep = 1.0f; + float volumeTarget = 1.0f; + float volumeTransitionStep = 1.0f; + float speedTarget = 1.0f; + float speedTransitionStep = 1.0f; CAudioStream() = default; CAudioStream(const CAudioStream&) = delete; // no copying! diff --git a/cleo_sdk/CLEO.h b/cleo_sdk/CLEO.h index 1a1d3c83..a73a328f 100644 --- a/cleo_sdk/CLEO.h +++ b/cleo_sdk/CLEO.h @@ -530,7 +530,7 @@ void WINAPI CLEO_RemoveScriptDeleteDelegate(FuncScriptDeleteDelegateT func); DWORD WINAPI CLEO_GetScriptTextureById(CRunningScript* thread, int id); // ret RwTexture * -DWORD WINAPI CLEO_GetInternalAudioStream(CRunningScript* thread, DWORD stream); // arg CAudioStream * +DWORD WINAPI CLEO_GetInternalAudioStream(CRunningScript* unused, DWORD audioStreamPtr); // CAudioStream* struct StringList { DWORD count; char** strings; }; void WINAPI CLEO_StringListFree(StringList list); // releases resources used by StringList container diff --git a/source/CleoBase.cpp b/source/CleoBase.cpp index a532b2af..fefc469a 100644 --- a/source/CleoBase.cpp +++ b/source/CleoBase.cpp @@ -252,9 +252,9 @@ namespace CLEO GetInstance().RemoveCallback(id, func); } - DWORD WINAPI CLEO_GetInternalAudioStream(CLEO::CRunningScript* thread, DWORD stream) // arg CAudioStream * + DWORD WINAPI CLEO_GetInternalAudioStream(CLEO::CRunningScript* unused, DWORD audioStreamPtr) { - return stream; // CAudioStream::streamInternal offset is 0 + return *(DWORD*)(audioStreamPtr + 0x4); // CAudioStream->streamInternal } void WINAPI CLEO_ResolvePath(CLEO::CRunningScript* thread, char* inOutPath, DWORD pathMaxLen)