OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
sounddefinitions.cpp
Go to the documentation of this file.
1#include "sounddefinitions.h"
2
3#include <Tempest/Log>
4#include <gothic.h>
5
6using namespace Tempest;
7
9 auto vm = Gothic::inst().createPhoenixVm("Sfx.dat");
10
11 vm->enumerate_instances_by_class_name("C_SFX", [this, &vm](zenkit::DaedalusSymbol& s) {
12 try {
13 this->sfx[s.name()] = vm->init_instance<zenkit::ISoundEffect>(&s);
14 }
15 catch(const zenkit::DaedalusScriptError&) {
16 // There was an error during initialization. Ignore it.
17 }
18 });
19 }
20
21const zenkit::ISoundEffect& SoundDefinitions::operator[](std::string_view name) const {
22 std::string buf(name); // FIXME
23 auto i = sfx.find(buf);
24 if(i!=sfx.end())
25 return *i->second;
26 static const zenkit::ISoundEffect s {};
27 return s;
28 }
29
static Gothic & inst()
Definition gothic.cpp:249
std::unique_ptr< zenkit::DaedalusVm > createPhoenixVm(std::string_view datFile, const ScriptLang lang=ScriptLang::NONE)
Definition gothic.cpp:711
const zenkit::ISoundEffect & operator[](std::string_view name) const