GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/dbmanager.cpp Lines: 27 68 39.7 %
Date: 2017-11-29 Branches: 1 6 16.7 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2017  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/colordb.h"
32
#include "resources/db/deaddb.h"
33
#include "resources/db/elementaldb.h"
34
#include "resources/db/emotedb.h"
35
#include "resources/db/groupdb.h"
36
#include "resources/db/homunculusdb.h"
37
#include "resources/db/horsedb.h"
38
#include "resources/db/itemdb.h"
39
#include "resources/db/itemfielddb.h"
40
#include "resources/db/itemoptiondb.h"
41
#include "resources/db/languagedb.h"
42
#include "resources/db/sounddb.h"
43
#include "resources/db/mapdb.h"
44
#include "resources/db/mercenarydb.h"
45
#include "resources/db/moddb.h"
46
#include "resources/db/monsterdb.h"
47
#include "resources/db/networkdb.h"
48
#include "resources/db/npcdb.h"
49
#include "resources/db/npcdialogdb.h"
50
#include "resources/db/palettedb.h"
51
#include "resources/db/petdb.h"
52
#include "resources/db/skillunitdb.h"
53
#include "resources/db/statdb.h"
54
#include "resources/db/statuseffectdb.h"
55
#include "resources/db/textdb.h"
56
#include "resources/db/unitsdb.h"
57
#include "resources/db/weaponsdb.h"
58
59
#include "debug.h"
60
61
void DbManager::loadDb()
62
{
63
    CharDB::load();
64
    GroupDb::load();
65
    StatDb::load();
66
    DeadDB::load();
67
    PaletteDB::load();
68
    ColorDB::load();
69
    SoundDB::load();
70
    LanguageDb::load();
71
    TextDb::load();
72
    MapDB::load();
73
    ItemFieldDb::load();
74
    ItemOptionDb::load();
75
    ItemDB::load();
76
    Being::load();
77
    const ServerTypeT type = Net::getNetworkType();
78
    if (type == ServerType::EATHENA ||
79
        type == ServerType::EVOL2)
80
    {
81
        NetworkDb::load();
82
        if (loginHandler != nullptr)
83
            loginHandler->updatePacketVersion();
84
        MercenaryDB::load();
85
        HomunculusDB::load();
86
        ElementalDb::load();
87
        SkillUnitDb::load();
88
        HorseDB::load();
89
    }
90
    MonsterDB::load();
91
    AvatarDB::load();
92
    BadgesDB::load();
93
    WeaponsDB::load();
94
    UnitsDb::load();
95
    NPCDB::load();
96
    NpcDialogDB::load();
97
    PETDB::load();
98
    EmoteDB::load();
99
//    ModDB::load();
100
    StatusEffectDB::load();
101
}
102
103
384
void DbManager::unloadDb()
104
{
105
384
    CharDB::unload();
106
384
    GroupDb::unload();
107
384
    StatDb::unload();
108
384
    DeadDB::unload();
109
384
    ColorDB::unload();
110
384
    SoundDB::unload();
111
384
    LanguageDb::unload();
112
384
    TextDb::unload();
113
384
    EmoteDB::unload();
114
384
    ItemDB::unload();
115
384
    ItemOptionDb::unload();
116
384
    ItemFieldDb::unload();
117
384
    const ServerTypeT type = Net::getNetworkType();
118
384
    if (type == ServerType::EATHENA ||
119
        type == ServerType::EVOL2)
120
    {
121
        MercenaryDB::unload();
122
        HomunculusDB::unload();
123
        ElementalDb::unload();
124
        SkillUnitDb::unload();
125
        HorseDB::unload();
126
        NetworkDb::unload();
127
    }
128
384
    MonsterDB::unload();
129
384
    NPCDB::unload();
130
384
    NpcDialogDB::unload();
131
384
    AvatarDB::unload();
132
384
    BadgesDB::unload();
133
384
    WeaponsDB::unload();
134
384
    UnitsDb::unload();
135
384
    PaletteDB::unload();
136
384
    PETDB::unload();
137
384
    StatusEffectDB::unload();
138
384
    ModDB::unload();
139
388
}