GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/dbmanager.cpp Lines: 27 70 38.6 %
Date: 2018-11-12 Branches: 1 6 16.7 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2017-2018  The ManaPlus Developers
4
 *
5
 *  This file is part of The ManaPlus Client.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
#include "resources/dbmanager.h"
22
23
#include "being/being.h"
24
25
#include "net/loginhandler.h"
26
#include "net/net.h"
27
28
#include "resources/db/avatardb.h"
29
#include "resources/db/badgesdb.h"
30
#include "resources/db/chardb.h"
31
#include "resources/db/clandb.h"
32
#include "resources/db/colordb.h"
33
#include "resources/db/deaddb.h"
34
#include "resources/db/elementaldb.h"
35
#include "resources/db/emotedb.h"
36
#include "resources/db/groupdb.h"
37
#include "resources/db/homunculusdb.h"
38
#include "resources/db/horsedb.h"
39
#include "resources/db/itemdb.h"
40
#include "resources/db/itemfielddb.h"
41
#include "resources/db/itemoptiondb.h"
42
#include "resources/db/languagedb.h"
43
#include "resources/db/sounddb.h"
44
#include "resources/db/mapdb.h"
45
#include "resources/db/mercenarydb.h"
46
#include "resources/db/moddb.h"
47
#include "resources/db/monsterdb.h"
48
#include "resources/db/networkdb.h"
49
#include "resources/db/npcdb.h"
50
#include "resources/db/npcdialogdb.h"
51
#include "resources/db/palettedb.h"
52
#include "resources/db/petdb.h"
53
#include "resources/db/skillunitdb.h"
54
#include "resources/db/statdb.h"
55
#include "resources/db/statuseffectdb.h"
56
#include "resources/db/textdb.h"
57
#include "resources/db/unitsdb.h"
58
#include "resources/db/weaponsdb.h"
59
60
#include "debug.h"
61
62
void DbManager::loadDb()
63
{
64
    CharDB::load();
65
    GroupDb::load();
66
    StatDb::load();
67
    DeadDB::load();
68
    PaletteDB::load();
69
    ColorDB::load();
70
    SoundDB::load();
71
    LanguageDb::load();
72
    TextDb::load();
73
    MapDB::load();
74
    ItemFieldDb::load();
75
    ItemOptionDb::load();
76
    ItemDB::load();
77
    Being::load();
78
    const ServerTypeT type = Net::getNetworkType();
79
    if (type == ServerType::EATHENA ||
80
        type == ServerType::EVOL2)
81
    {
82
        NetworkDb::load();
83
        if (loginHandler != nullptr)
84
            loginHandler->updatePacketVersion();
85
        MercenaryDB::load();
86
        HomunculusDB::load();
87
        ElementalDb::load();
88
        SkillUnitDb::load();
89
        HorseDB::load();
90
        ClanDb::load();
91
    }
92
    MonsterDB::load();
93
    AvatarDB::load();
94
    BadgesDB::load();
95
    WeaponsDB::load();
96
    UnitsDb::load();
97
    NPCDB::load();
98
    NpcDialogDB::load();
99
    PETDB::load();
100
    EmoteDB::load();
101
//    ModDB::load();
102
    StatusEffectDB::load();
103
}
104
105
215
void DbManager::unloadDb()
106
{
107
215
    CharDB::unload();
108
215
    GroupDb::unload();
109
215
    StatDb::unload();
110
215
    DeadDB::unload();
111
215
    ColorDB::unload();
112
215
    SoundDB::unload();
113
215
    LanguageDb::unload();
114
215
    TextDb::unload();
115
215
    EmoteDB::unload();
116
215
    ItemDB::unload();
117
215
    ItemOptionDb::unload();
118
215
    ItemFieldDb::unload();
119
215
    const ServerTypeT type = Net::getNetworkType();
120
215
    if (type == ServerType::EATHENA ||
121
        type == ServerType::EVOL2)
122
    {
123
        MercenaryDB::unload();
124
        HomunculusDB::unload();
125
        ClanDb::unload();
126
        ElementalDb::unload();
127
        SkillUnitDb::unload();
128
        HorseDB::unload();
129
        NetworkDb::unload();
130
    }
131
215
    MonsterDB::unload();
132
215
    NPCDB::unload();
133
215
    NpcDialogDB::unload();
134
215
    AvatarDB::unload();
135
215
    BadgesDB::unload();
136
215
    WeaponsDB::unload();
137
215
    UnitsDb::unload();
138
215
    PaletteDB::unload();
139
215
    PETDB::unload();
140
215
    StatusEffectDB::unload();
141
215
    ModDB::unload();
142
217
}