ManaPlus
src
resources
db
weaponsdb.cpp
Go to the documentation of this file.
1
/*
2
* The ManaPlus Client
3
* Copyright (C) 2014-2019 The ManaPlus Developers
4
* Copyright (C) 2019-2021 Andrei Karas
5
*
6
* This file is part of The ManaPlus Client.
7
*
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
#include "
resources/db/weaponsdb.h
"
23
24
#include "
configuration.h
"
25
#include "
logger.h
"
26
27
#include "
utils/xmlutils.h
"
28
29
#include "
debug.h
"
30
31
namespace
32
{
33
WeaponsInfos
mBows
;
34
WeaponsInfos
mSwords
;
35
WeaponsInfos
mShields
;
36
bool
mLoaded
=
false
;
37
}
// namespace
38
39
static
void
loadDB
(
const
std::string &name,
40
WeaponsInfos
&arr)
41
{
42
readXmlIntVector
(
paths
.
getStringValue
(
"weaponsFile"
),
43
"weapons"
,
44
name,
45
"item"
,
46
"id"
,
47
arr,
48
SkipError_false
);
49
}
50
51
void
WeaponsDB::load
()
52
{
53
if
(
mLoaded
)
54
unload
();
55
56
logger
->
log1
(
"Initializing weapon database..."
);
57
58
loadDB
(
"swords"
,
mSwords
);
59
loadDB
(
"bows"
,
mBows
);
60
loadDB
(
"shields"
,
mShields
);
61
}
62
63
void
WeaponsDB::unload
()
64
{
65
logger
->
log1
(
"Unloading weapon database..."
);
66
67
mBows
.clear();
68
mSwords
.clear();
69
mShields
.clear();
70
mLoaded
=
false
;
71
}
72
73
const
WeaponsInfos
&
WeaponsDB::getBows
()
74
{
75
return
mBows
;
76
}
77
78
const
WeaponsInfos
&
WeaponsDB::getSwords
()
79
{
80
return
mSwords
;
81
}
82
83
const
WeaponsInfos
&
WeaponsDB::getShields
()
84
{
85
return
mShields
;
86
}
Configuration::getStringValue
std::string getStringValue(const std::string &key) const
Definition:
configuration.cpp:488
Logger::log1
void log1(const char *const log_text)
Definition:
logger.cpp:238
paths
Configuration paths
Definition:
configuration.cpp:56
configuration.h
debug.h
logger
Logger * logger
Definition:
logger.cpp:89
logger.h
Net::unload
void unload()
Definition:
net.cpp:180
WeaponsDB::load
void load()
Definition:
weaponsdb.cpp:51
WeaponsDB::unload
void unload()
Definition:
weaponsdb.cpp:63
WeaponsDB::getShields
const WeaponsInfos & getShields()
Definition:
weaponsdb.cpp:83
WeaponsDB::getSwords
const WeaponsInfos & getSwords()
Definition:
weaponsdb.cpp:78
WeaponsDB::getBows
const WeaponsInfos & getBows()
Definition:
weaponsdb.cpp:73
anonymous_namespace{weaponsdb.cpp}::mLoaded
bool mLoaded
Definition:
weaponsdb.cpp:36
anonymous_namespace{weaponsdb.cpp}::mSwords
WeaponsInfos mSwords
Definition:
weaponsdb.cpp:34
anonymous_namespace{weaponsdb.cpp}::mBows
WeaponsInfos mBows
Definition:
weaponsdb.cpp:33
anonymous_namespace{weaponsdb.cpp}::mShields
WeaponsInfos mShields
Definition:
weaponsdb.cpp:35
SkipError_false
const bool SkipError_false
Definition:
skiperror.h:30
loadDB
static void loadDB(const std::string &name, WeaponsInfos &arr)
Definition:
weaponsdb.cpp:39
weaponsdb.h
WeaponsInfos
std::vector< int > WeaponsInfos
Definition:
weaponsdb.h:29
readXmlIntVector
void readXmlIntVector(const std::string &fileName, const std::string &rootName, const std::string §ionName, const std::string &itemName, const std::string &attributeName, std::vector< int > &arr, const SkipError skipError)
Definition:
xmlutils.cpp:30
xmlutils.h
Generated on Wed Mar 17 2021 19:19:09 for ManaPlus by
1.9.1