Skip to content

Commit

Permalink
Fixed Radical's dodgy sounds
Browse files Browse the repository at this point in the history
- Moved the `tt` engine sound fix to `FixAudiTT`.
- Made `FixCartune` check loaded sounds.
  • Loading branch information
Hampo committed Jul 1, 2024
1 parent 4e716dc commit 386c198
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 7 deletions.
18 changes: 18 additions & 0 deletions Randomiser/Resources/Modules/General/FixAudiTT.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,22 @@ FixAudiTT:AddP3DHandler("art/cars/tt.p3d", function(Path, P3DFile)
return true
end)

FixAudiTT:AddSPTHandler("sound/scripts/car_tune.spt", function(Path, SPT)
local changed = false

for carSoundParameters in SPT:GetClasses("carSoundParameters") do
for method, index in carSoundParameters:GetMethods(true) do
local name = method.Name
if name == "SetEngineClipName" or name == "SetEngineIdleClipName" then
if method.Parameters[1] == "tt" then
method.Parameters[1] = "apu_car"
changed = true
end
end
end
end

return changed
end)

return FixAudiTT
51 changes: 44 additions & 7 deletions Randomiser/Resources/Modules/General/FixCartune.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,55 @@
local table_remove = table.remove

local FixCartune = Module("Fix Cartune", nil, 1)
local FixCartune = Module("Fix Cartune", nil, 2)

local LoadedSounds = {}

FixCartune:AddSPTHandler("*.spt", function(Path, SPT)
for daSoundResourceData in SPT:GetClasses("daSoundResourceData") do
LoadedSounds[daSoundResourceData.Name] = true
end

return false
end)

local DefaultEngine = "snake_car"
local DefaultDamagedEngine = "fire"
local DefaultHorn = "horn"
local RemoveIfNotLoaded = {
["SetRoadSkidClipName"] = true,
["SetDirtSkidClipName"] = true,
["SetBackupClipName"] = true,
["SetCarDoorOpenClipName"] = true,
["SetCarDoorCloseClipName"] = true,
["SetOverlayClipName"] = true,
}
FixCartune:AddSPTHandler("sound/scripts/car_tune.spt", function(Path, SPT)
for carSoundParameters in SPT:GetClasses("carSoundParameters") do
for method, index in carSoundParameters:GetMethods(true) do
local name = method.Name
if name == "SetEngineClipName" or name == "SetEngineIdleClipName" then
if method.Parameters[1] == "tt" then
method.Parameters[1] = "apu_car"
if name == "SetEngineClipName" then
if not LoadedSounds[method.Parameters[1]] then
print(string.format("Replacing not-loaded engine sound \"%s\" with \"%s\".", method.Parameters[1], DefaultEngine))
method.Parameters[1] = DefaultEngine
end
elseif name == "SetEngineIdleClipName" then
if not LoadedSounds[method.Parameters[1]] then
print(string.format("Replacing not-loaded idle engine sound \"%s\" with \"%s\".", method.Parameters[1], DefaultEngine))
method.Parameters[1] = DefaultEngine
end
elseif name == "SetDamagedEngineClipName" then
if not LoadedSounds[method.Parameters[1]] then
print(string.format("Replacing not-loaded damaged engine sound \"%s\" with \"%s\".", method.Parameters[1], DefaultDamagedEngineEngine))
method.Parameters[1] = DefaultDamagedEngine
end
elseif name == "SetHornClipName" then
if not LoadedSounds[method.Parameters[1]] then
print(string.format("Replacing not-loaded horn sound \"%s\" with \"%s\".", method.Parameters[1], DefaultHorn))
method.Parameters[1] = DefaultHorn
end
elseif name == "SetOverlayClipName" then
local clipName = method.Parameters[1]
if clipName == "" or clipName == "generator" then
elseif RemoveIfNotLoaded[name] then
if not LoadedSounds[method.Parameters[1]] then
print(string.format("Removing not-loaded sound \"%s\".", method.Parameters[1]))
carSoundParameters:RemoveMethod(index)
end
end
Expand Down

0 comments on commit 386c198

Please sign in to comment.