OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
spelldefinitions.cpp
Go to the documentation of this file.
1
#include "
spelldefinitions.h
"
2
#include "
utils/string_frm.h
"
3
4
#include <Tempest/Log>
5
#include <cctype>
6
7
using namespace
Tempest;
8
9
SpellDefinitions::SpellDefinitions
(zenkit::DaedalusVm& vm) : vm(vm) {
10
vm.enumerate_instances_by_class_name(
"C_Spell"
, [
this
, &vm](zenkit::DaedalusSymbol& sym){
11
spl.push_back(vm.init_instance<zenkit::ISpell>(&sym));
12
});
13
}
14
15
SpellDefinitions::~SpellDefinitions
() {
16
}
17
18
const
zenkit::ISpell&
SpellDefinitions::find
(std::string_view instanceName)
const
{
19
string_frm
format(
"SPELL_"
,instanceName);
20
for
(
auto
& i:format)
21
i =
char
(std::toupper(i));
22
23
for
(
auto
& i:spl) {
// TODO: optimize
24
auto
sym = vm.find_symbol_by_instance(i);
25
if
(sym->name()==format)
26
return
*i;
27
}
28
Log::d(
"invalid spell ["
,instanceName.data(),
"]"
);
29
static
zenkit::ISpell szero={};
30
return
szero;
31
}
SpellDefinitions::SpellDefinitions
SpellDefinitions(zenkit::DaedalusVm &vm)
Definition
spelldefinitions.cpp:9
SpellDefinitions::find
const zenkit::ISpell & find(std::string_view instanceName) const
Definition
spelldefinitions.cpp:18
SpellDefinitions::~SpellDefinitions
~SpellDefinitions()
Definition
spelldefinitions.cpp:15
string_frm
Definition
string_frm.h:8
spelldefinitions.h
string_frm.h
game
game
definitions
spelldefinitions.cpp
Generated by
1.9.8