From af2abb8cbf662a62a2113601307ff921cbddf36a Mon Sep 17 00:00:00 2001 From: Stan Date: Sat, 24 Feb 2018 18:13:03 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20units=20not=20being=20able=20to=20play=20?= =?UTF-8?q?sounds=20when=20walking=20and=20running=20This=20currently=20di?= =?UTF-8?q?sabled=20by=20variants,=20and=20will=20be=20reenabled=20when=20?= =?UTF-8?q?sounds=20have=20been=20chosen.=20Reviewed=20by:=20Vladislav,=20?= =?UTF-8?q?Comments=20by:=20Itms,=20elexis=20Differential=20Revision:=20?= =?UTF-8?q?=E2=80=8Bhttps://code.wildfiregames.com/1257=20This=20was=20SVN?= =?UTF-8?q?=20commit=20r21359.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/components/Foundation.js | 2 +- .../mods/public/simulation/components/Gate.js | 4 +- .../public/simulation/components/Health.js | 2 +- .../mods/public/simulation/components/Pack.js | 4 +- .../public/simulation/components/UnitAI.js | 34 ++++------------ .../simulation/components/interfaces/Sound.js | 1 - .../components/tests/test_Foundation.js | 2 +- .../simulation/components/tests/test_Pack.js | 2 +- source/simulation2/TypeList.h | 3 ++ .../components/CCmpSoundManager.cpp | 27 +++++++------ .../components/CCmpVisualActor.cpp | 14 ++++--- source/simulation2/components/ICmpSound.cpp | 39 +++++++++++++++++++ source/simulation2/components/ICmpSound.h | 36 +++++++++++++++++ source/simulation2/components/ICmpVisual.cpp | 4 +- source/simulation2/components/ICmpVisual.h | 4 +- source/soundmanager/scripting/SoundGroup.cpp | 37 ++++++++---------- .../tools/atlas/GameInterface/ActorViewer.cpp | 10 +---- 17 files changed, 137 insertions(+), 88 deletions(-) delete mode 100644 binaries/data/mods/public/simulation/components/interfaces/Sound.js create mode 100644 source/simulation2/components/ICmpSound.cpp create mode 100644 source/simulation2/components/ICmpSound.h diff --git a/binaries/data/mods/public/simulation/components/Foundation.js b/binaries/data/mods/public/simulation/components/Foundation.js index 834c0b2cfa..3846365e3d 100644 --- a/binaries/data/mods/public/simulation/components/Foundation.js +++ b/binaries/data/mods/public/simulation/components/Foundation.js @@ -246,7 +246,7 @@ Foundation.prototype.Build = function(builderEnt, work) // Switch foundation to scaffold variant var cmpFoundationVisual = Engine.QueryInterface(this.entity, IID_Visual); if (cmpFoundationVisual) - cmpFoundationVisual.SelectAnimation("scaffold", false, 1.0, ""); + cmpFoundationVisual.SelectAnimation("scaffold", false, 1.0); // Create preview entity and copy various parameters from the foundation if (cmpFoundationVisual && cmpFoundationVisual.HasConstructionPreview()) diff --git a/binaries/data/mods/public/simulation/components/Gate.js b/binaries/data/mods/public/simulation/components/Gate.js index 51a13a0f51..a3aa510839 100644 --- a/binaries/data/mods/public/simulation/components/Gate.js +++ b/binaries/data/mods/public/simulation/components/Gate.js @@ -199,7 +199,7 @@ Gate.prototype.OpenGate = function() PlaySound("gate_opening", this.entity); var cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); if (cmpVisual) - cmpVisual.SelectAnimation("gate_opening", true, 1.0, ""); + cmpVisual.SelectAnimation("gate_opening", true, 1.0); }; /** @@ -238,7 +238,7 @@ Gate.prototype.CloseGate = function() PlaySound("gate_closing", this.entity); var cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); if (cmpVisual) - cmpVisual.SelectAnimation("gate_closing", true, 1.0, ""); + cmpVisual.SelectAnimation("gate_closing", true, 1.0); }; Engine.RegisterComponentType(IID_Gate, "Gate", Gate); diff --git a/binaries/data/mods/public/simulation/components/Health.js b/binaries/data/mods/public/simulation/components/Health.js index 79e697b7e3..d9c0d3bd75 100644 --- a/binaries/data/mods/public/simulation/components/Health.js +++ b/binaries/data/mods/public/simulation/components/Health.js @@ -317,7 +317,7 @@ Health.prototype.CreateCorpse = function(leaveResources) cmpCorpseVisual.SetActorSeed(cmpVisual.GetActorSeed()); // Make it fall over - cmpCorpseVisual.SelectAnimation("death", true, 1.0, ""); + cmpCorpseVisual.SelectAnimation("death", true, 1.0); return corpse; }; diff --git a/binaries/data/mods/public/simulation/components/Pack.js b/binaries/data/mods/public/simulation/components/Pack.js index 489b27858c..5bfbc7a3ce 100644 --- a/binaries/data/mods/public/simulation/components/Pack.js +++ b/binaries/data/mods/public/simulation/components/Pack.js @@ -76,7 +76,7 @@ Pack.prototype.Unpack = function() let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); if (cmpVisual) - cmpVisual.SelectAnimation("unpacking", true, 1.0, "unpacking"); + cmpVisual.SelectAnimation("unpacking", true, 1.0); }; Pack.prototype.CancelPack = function() @@ -91,7 +91,7 @@ Pack.prototype.CancelPack = function() // Clear animation let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); if (cmpVisual) - cmpVisual.SelectAnimation("idle", false, 1.0, ""); + cmpVisual.SelectAnimation("idle", false, 1.0); }; Pack.prototype.GetPackTime = function() diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index f3db9426bd..765cbddf24 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -1896,7 +1896,7 @@ UnitAI.prototype.UnitFsmSpec = { animationName = cmpFormation.GetFormationAnimation(this.entity, animationName); } this.SetAnimationVariant("combat"); - this.SelectAnimation(animationName, false, 1.0, animationName); + this.SelectAnimation(animationName); this.SetAnimationSync(prepare, this.attackTimers.repeat); this.StartTimer(prepare, this.attackTimers.repeat); // TODO: we should probably only bother syncing projectile attacks, not melee @@ -2308,7 +2308,7 @@ UnitAI.prototype.UnitFsmSpec = { { this.SetDefaultAnimationVariant(); var typename = "gather_" + this.order.data.type.specific; - this.SelectAnimation(typename, false, 1.0, typename); + this.SelectAnimation(typename); } return false; }, @@ -2512,7 +2512,7 @@ UnitAI.prototype.UnitFsmSpec = { prepare = Math.max(prepare, repeatLeft); } - this.SelectAnimation("heal", false, 1.0, "heal"); + this.SelectAnimation("heal"); this.SetAnimationSync(prepare, this.healTimers.repeat); this.StartTimer(prepare, this.healTimers.repeat); @@ -2735,7 +2735,7 @@ UnitAI.prototype.UnitFsmSpec = { if (cmpBuilderList) cmpBuilderList.AddBuilder(this.entity); - this.SelectAnimation("build", false, 1.0, "build"); + this.SelectAnimation("build"); this.StartTimer(1000, 1000); return false; }, @@ -4226,9 +4226,9 @@ UnitAI.prototype.SetDefaultAnimationVariant = function() this.SetAnimationVariant(""); }; -UnitAI.prototype.SelectAnimation = function(name, once, speed, sound) +UnitAI.prototype.SelectAnimation = function(name, once = false, speed = 1.0) { - var cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); + let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); if (!cmpVisual) return; @@ -4237,29 +4237,11 @@ UnitAI.prototype.SelectAnimation = function(name, once, speed, sound) if (name == "move") { // Speed to switch from walking to running animations - var runThreshold = (this.GetWalkSpeed() + this.GetRunSpeed()) / 2; - - cmpVisual.SelectMovementAnimation(runThreshold); + cmpVisual.SelectMovementAnimation((this.GetWalkSpeed() + this.GetRunSpeed()) / 2); return; } - var soundgroup; - if (sound) - { - var cmpSound = Engine.QueryInterface(this.entity, IID_Sound); - if (cmpSound) - soundgroup = cmpSound.GetSoundGroup(sound); - } - - // Set default values if unspecified - if (once === undefined) - once = false; - if (speed === undefined) - speed = 1.0; - if (soundgroup === undefined) - soundgroup = ""; - - cmpVisual.SelectAnimation(name, once, speed, soundgroup); + cmpVisual.SelectAnimation(name, once, speed); }; UnitAI.prototype.SetAnimationSync = function(actiontime, repeattime) diff --git a/binaries/data/mods/public/simulation/components/interfaces/Sound.js b/binaries/data/mods/public/simulation/components/interfaces/Sound.js deleted file mode 100644 index b598a6f57d..0000000000 --- a/binaries/data/mods/public/simulation/components/interfaces/Sound.js +++ /dev/null @@ -1 +0,0 @@ -Engine.RegisterInterface("Sound"); diff --git a/binaries/data/mods/public/simulation/components/tests/test_Foundation.js b/binaries/data/mods/public/simulation/components/tests/test_Foundation.js index 1387aad395..bef3839230 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Foundation.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Foundation.js @@ -193,7 +193,7 @@ testFoundation([foundationEnt, IID_Visual, { TS_ASSERT_EQUALS(key, "numbuilders"); TS_ASSERT(num == 1 || num == 2); }, - "SelectAnimation": () => {}, + "SelectAnimation": (name, once, speed) => name "HasConstructionPreview": () => true, }]); diff --git a/binaries/data/mods/public/simulation/components/tests/test_Pack.js b/binaries/data/mods/public/simulation/components/tests/test_Pack.js index 767c6d9f72..236abfd7d1 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Pack.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Pack.js @@ -22,7 +22,7 @@ const PACKING_INTERVAL = 250; let timerActivated = false; AddMock(ent, IID_Visual, { - "SelectAnimation": (name, once, speed, soundgroup) => name + "SelectAnimation": (name, once, speed) => name }); AddMock(ent, IID_Ownership, { diff --git a/source/simulation2/TypeList.h b/source/simulation2/TypeList.h index b08a3cdc91..12c22cfb27 100644 --- a/source/simulation2/TypeList.h +++ b/source/simulation2/TypeList.h @@ -162,6 +162,9 @@ COMPONENT(Selectable) INTERFACE(Settlement) COMPONENT(SettlementScripted) +INTERFACE(Sound) +COMPONENT(SoundScripted) + INTERFACE(SoundManager) COMPONENT(SoundManager) diff --git a/source/simulation2/components/CCmpSoundManager.cpp b/source/simulation2/components/CCmpSoundManager.cpp index f3620f5d83..204aad2140 100644 --- a/source/simulation2/components/CCmpSoundManager.cpp +++ b/source/simulation2/components/CCmpSoundManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -62,27 +62,26 @@ public: virtual void PlaySoundGroup(const std::wstring& name, entity_id_t source) { - if ( ! g_SoundManager || (source == INVALID_ENTITY) ) + if (!g_SoundManager || (source == INVALID_ENTITY)) return; - CmpPtr cmpRangeManager(GetSystemEntity()); int currentPlayer = GetSimContext().GetCurrentDisplayedPlayer(); - if ( !cmpRangeManager || - ( cmpRangeManager->GetLosVisibility(source, currentPlayer) != ICmpRangeManager::VIS_VISIBLE ) ) + CmpPtr cmpRangeManager(GetSystemEntity()); + if (!cmpRangeManager || (cmpRangeManager->GetLosVisibility(source, currentPlayer) != ICmpRangeManager::VIS_VISIBLE)) return; CmpPtr cmpPosition(GetSimContext(), source); - if (cmpPosition && cmpPosition->IsInWorld()) - { - bool playerOwned = false; - CmpPtr cmpOwnership( GetSimContext(), source); - if (cmpOwnership) - playerOwned = cmpOwnership->GetOwner() == currentPlayer; + if (!cmpPosition || !cmpPosition->IsInWorld()) + return; - CVector3D sourcePos = CVector3D(cmpPosition->GetPosition()); - g_SoundManager->PlayAsGroup(name, sourcePos, source, playerOwned); - } + bool playerOwned = false; + CmpPtr cmpOwnership(GetSimContext(), source); + if (cmpOwnership) + playerOwned = cmpOwnership->GetOwner() == currentPlayer; + + CVector3D sourcePos = CVector3D(cmpPosition->GetPosition()); + g_SoundManager->PlayAsGroup(name, sourcePos, source, playerOwned); } virtual void PlaySoundGroupAtPosition(const std::wstring& name, const CFixedVector3D& sourcePos) diff --git a/source/simulation2/components/CCmpVisualActor.cpp b/source/simulation2/components/CCmpVisualActor.cpp index 5e8f2aaa5d..0fca388fd3 100644 --- a/source/simulation2/components/CCmpVisualActor.cpp +++ b/source/simulation2/components/CCmpVisualActor.cpp @@ -31,6 +31,7 @@ #include "ICmpUnitMotion.h" #include "ICmpValueModificationManager.h" #include "ICmpVisibility.h" +#include "ICmpSound.h" #include "simulation2/serialization/SerializeTemplates.h" @@ -206,7 +207,7 @@ public: InitModel(paramNode); - SelectAnimation("idle", false, fixed::FromInt(1), L""); + SelectAnimation("idle"); } virtual void Deinit() @@ -436,16 +437,20 @@ public: return m_AnimName; } - virtual void SelectAnimation(const std::string& name, bool once, fixed speed, const std::wstring& soundgroup) + virtual void SelectAnimation(const std::string& name, bool once = false, fixed speed = fixed::FromInt(1)) { m_AnimRunThreshold = fixed::Zero(); m_AnimName = name; m_AnimOnce = once; m_AnimSpeed = speed; - m_SoundGroup = soundgroup; + m_SoundGroup = L""; m_AnimDesync = fixed::FromInt(1)/20; // TODO: make this an argument m_AnimSyncRepeatTime = fixed::Zero(); m_AnimSyncOffsetTime = fixed::Zero(); + + CmpPtr cmpSound(GetSimContext(), m_Unit->GetID()); + if(cmpSound) + m_SoundGroup = cmpSound->GetSoundGroup(wstring_from_utf8(m_AnimName)); SetVariant("animation", m_AnimName); @@ -467,7 +472,6 @@ public: virtual void SelectMovementAnimation(fixed runThreshold) { - SelectAnimation("walk", false, fixed::FromFloat(1.f), L""); m_AnimRunThreshold = runThreshold; } @@ -795,6 +799,6 @@ void CCmpVisualActor::Update(fixed UNUSED(turnLength)) // Selecting the animation is going to reset the anim run threshold, so save it fixed runThreshold = m_AnimRunThreshold; - SelectAnimation(name, false, speed, L""); + SelectAnimation(name, false, speed); m_AnimRunThreshold = runThreshold; } diff --git a/source/simulation2/components/ICmpSound.cpp b/source/simulation2/components/ICmpSound.cpp new file mode 100644 index 0000000000..99a3cbef75 --- /dev/null +++ b/source/simulation2/components/ICmpSound.cpp @@ -0,0 +1,39 @@ +/* Copyright (C) 2018 Wildfire Games. +* This file is part of 0 A.D. +* +* 0 A.D. is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 2 of the License, or +* (at your option) any later version. +* +* 0 A.D. is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with 0 A.D. If not, see . +*/ + +#include "precompiled.h" + +#include "ICmpSound.h" + +#include "simulation2/scripting/ScriptComponent.h" +#include "simulation2/system/InterfaceScripted.h" + +BEGIN_INTERFACE_WRAPPER(Sound) +END_INTERFACE_WRAPPER(Sound) + +class CCmpSoundScripted : public ICmpSound +{ +public: + DEFAULT_SCRIPT_WRAPPER(SoundScripted) + + virtual std::wstring GetSoundGroup(const std::wstring& soundName) const + { + return m_Script.Call("GetSoundGroup", soundName); + } +}; + +REGISTER_COMPONENT_SCRIPT_WRAPPER(SoundScripted) diff --git a/source/simulation2/components/ICmpSound.h b/source/simulation2/components/ICmpSound.h new file mode 100644 index 0000000000..f9907ff29e --- /dev/null +++ b/source/simulation2/components/ICmpSound.h @@ -0,0 +1,36 @@ +/* Copyright (C) 2018 Wildfire Games. +* This file is part of 0 A.D. +* +* 0 A.D. is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 2 of the License, or +* (at your option) any later version. +* +* 0 A.D. is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with 0 A.D. If not, see . +*/ + +#ifndef INCLUDED_ICMPSOUND +#define INCLUDED_ICMPSOUND + +#include "simulation2/system/Interface.h" + +/** +* Sound data. +* (This interface includes functions needed by native code for loading soundgroups. +* Most of the sound interaction is handled by scripts instead). +*/ +class ICmpSound : public IComponent +{ +public: + virtual std::wstring GetSoundGroup(const std::wstring& soundName) const = 0; + + DECLARE_INTERFACE_TYPE(Sound) +}; + +#endif // INCLUDED_ICMPSOUND diff --git a/source/simulation2/components/ICmpVisual.cpp b/source/simulation2/components/ICmpVisual.cpp index 7e0893d502..3993ce9779 100644 --- a/source/simulation2/components/ICmpVisual.cpp +++ b/source/simulation2/components/ICmpVisual.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -26,7 +26,7 @@ DEFINE_INTERFACE_METHOD_2("SetVariant", void, ICmpVisual, SetVariant, CStr, CStr DEFINE_INTERFACE_METHOD_CONST_0("GetAnimationName", std::string, ICmpVisual, GetAnimationName) DEFINE_INTERFACE_METHOD_CONST_0("GetProjectileActor", std::wstring, ICmpVisual, GetProjectileActor) DEFINE_INTERFACE_METHOD_CONST_0("GetProjectileLaunchPoint", CFixedVector3D, ICmpVisual, GetProjectileLaunchPoint) -DEFINE_INTERFACE_METHOD_4("SelectAnimation", void, ICmpVisual, SelectAnimation, std::string, bool, fixed, std::wstring) +DEFINE_INTERFACE_METHOD_3("SelectAnimation", void, ICmpVisual, SelectAnimation, std::string, bool, fixed) DEFINE_INTERFACE_METHOD_1("SelectMovementAnimation", void, ICmpVisual, SelectMovementAnimation, fixed) DEFINE_INTERFACE_METHOD_1("ResetMoveAnimation", void, ICmpVisual, ResetMoveAnimation, std::string) DEFINE_INTERFACE_METHOD_2("ReplaceMoveAnimation", void, ICmpVisual, ReplaceMoveAnimation, std::string, std::string) diff --git a/source/simulation2/components/ICmpVisual.h b/source/simulation2/components/ICmpVisual.h index cc19d4ddd2..cb197eaf3b 100644 --- a/source/simulation2/components/ICmpVisual.h +++ b/source/simulation2/components/ICmpVisual.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -103,7 +103,7 @@ public: * @param speed animation speed multiplier (typically 1.0 for the default speed) * @param soundgroup VFS path of sound group .xml, relative to audio/, or empty string for none */ - virtual void SelectAnimation(const std::string& name, bool once, fixed speed, const std::wstring& soundgroup) = 0; + virtual void SelectAnimation(const std::string& name, bool once, fixed speed) = 0; /** * Replaces a specified animation with another. Only affects the special speed-based diff --git a/source/soundmanager/scripting/SoundGroup.cpp b/source/soundmanager/scripting/SoundGroup.cpp index bad65329ae..ae9192d8c8 100644 --- a/source/soundmanager/scripting/SoundGroup.cpp +++ b/source/soundmanager/scripting/SoundGroup.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -156,50 +156,46 @@ float CSoundGroup::RadiansOffCenter(const CVector3D& position, bool& onScreen, f void CSoundGroup::UploadPropertiesAndPlay(size_t theIndex, const CVector3D& position, entity_id_t source) { #if CONFIG2_AUDIO - if ( !g_SoundManager ) + if (!g_SoundManager) return; bool isOnscreen = false; - ALfloat initialRolllOff = 0.1f; - ALfloat itemRollOff = initialRolllOff; - - - float offSet = RadiansOffCenter(position, isOnscreen, itemRollOff); - bool shouldBePlayed = isOnscreen || TestFlag(eDistanceless) || TestFlag(eOmnipresent); - - if ( !shouldBePlayed ) + ALfloat itemRollOff = 0.1f; + float offset = RadiansOffCenter(position, isOnscreen, itemRollOff); + + if (!isOnscreen && !TestFlag(eDistanceless) && !TestFlag(eOmnipresent)) return; if (snd_group.size() == 0) Reload(); - if ( snd_group.size() <= theIndex ) + if (snd_group.size() <= theIndex) return; CSoundData* sndData = snd_group[theIndex]; - if ( sndData == NULL ) + if (sndData == nullptr) return; - ISoundItem* hSound = ((CSoundManager*)g_SoundManager)->ItemForEntity( source, sndData); - if ( hSound == NULL ) + ISoundItem* hSound = static_cast(g_SoundManager)->ItemForEntity(source, sndData); + if (hSound == nullptr) return; if (!TestFlag(eOmnipresent)) { CVector3D origin = g_Game->GetView()->GetCamera()->GetOrientation().GetTranslation(); float sndDist = origin.Y; - float itemDist = ( position - origin ).Length(); + float itemDist = (position - origin).Length(); - if ( (sndDist * 2) < itemDist ) + if ((sndDist * 2) < itemDist) sndDist = itemDist; if (TestFlag(eDistanceless)) itemRollOff = 0; - if ( sndData->IsStereo() ) + if (sndData->IsStereo()) LOGWARNING("OpenAL: stereo sounds can't be positioned: %s", sndData->GetFileName().string8()); - hSound->SetLocation(CVector3D((sndDist * sin(offSet)), 0, - sndDist * cos(offSet))); + hSound->SetLocation(CVector3D((sndDist * sin(offset)), 0, -sndDist * cos(offset))); hSound->SetRollOff(itemRollOff); } @@ -208,12 +204,11 @@ void CSoundGroup::UploadPropertiesAndPlay(size_t theIndex, const CVector3D& posi else hSound->SetPitch(m_Pitch); - ALfloat theGain = m_Gain; if (TestFlag(eRandGain)) - theGain = RandFloat(m_GainLower, m_GainUpper); + m_Gain = RandFloat(m_GainLower, m_GainUpper); hSound->SetCone(m_ConeInnerAngle, m_ConeOuterAngle, m_ConeOuterGain); - ((CSoundManager*)g_SoundManager)->PlayGroupItem(hSound, theGain); + static_cast(g_SoundManager)->PlayGroupItem(hSound, m_Gain); #else // !CONFIG2_AUDIO UNUSED2(theIndex); diff --git a/source/tools/atlas/GameInterface/ActorViewer.cpp b/source/tools/atlas/GameInterface/ActorViewer.cpp index 999cde719e..f46b46e2c0 100644 --- a/source/tools/atlas/GameInterface/ActorViewer.cpp +++ b/source/tools/atlas/GameInterface/ActorViewer.cpp @@ -425,19 +425,11 @@ void ActorViewer::SetActor(const CStrW& name, const CStrW& animation, player_id_ else if (anim.Find("gather_") == 0) sound = anim; - std::wstring soundgroup; - if (!sound.empty()) - { - CStr code = "var cmp = Engine.QueryInterface("+CStr::FromUInt(m.Entity)+", IID_Sound); " + - "if (cmp) cmp.GetSoundGroup('"+sound+"'); else '';"; - m.Simulation2.GetScriptInterface().Eval(code.c_str(), soundgroup); - } - CmpPtr cmpVisual(m.Simulation2, m.Entity); if (cmpVisual) { // TODO: SetEntitySelection(anim) - cmpVisual->SelectAnimation(anim, false, fixed::FromFloat(speed), soundgroup); + cmpVisual->SelectAnimation(anim, false, fixed::FromFloat(speed)); if (repeattime) cmpVisual->SetAnimationSyncRepeat(fixed::FromFloat(repeattime)); }