WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
database.cpp
Go to the documentation of this file.
1
#include "
database.h
"
2
#include <sstream>
3
4
#include "
wow_enums.h
"
5
#include "
Logger.h
"
6
7
ItemDatabase
items
;
8
std::vector<NPCRecord>
npcs
;
9
10
ItemRecord::ItemRecord
(
const
std::vector<std::string>& vals)
11
: id(0), itemclass(0), subclass(0), type(0), model(0), sheath(0), quality(0)
12
{
13
if
(vals.size() < 6)
14
return
;
15
16
id
= std::stoi(vals[0]);
17
type
= std::stoi(vals[2]);
18
itemclass
= std::stoi(vals[3]);
19
subclass
= std::stoi(vals[4]);
20
model
= 1;
21
quality
= 0;
22
switch
(std::stoi(vals[5]))
23
{
24
case
SHEATHETYPE_MAINHAND
:
sheath
=
ATT_LEFT_BACK_SHEATH
;
25
break
;
26
case
SHEATHETYPE_LARGEWEAPON
:
sheath
=
ATT_LEFT_BACK
;
27
break
;
28
case
SHEATHETYPE_HIPWEAPON
:
sheath
=
ATT_LEFT_HIP_SHEATH
;
29
break
;
30
case
SHEATHETYPE_SHIELD
:
sheath
=
ATT_MIDDLE_BACK_SHEATH
;
31
break
;
32
default
:
sheath
=
SHEATHETYPE_NONE
;
//-V1048
33
}
34
name
= vals[1];
35
}
36
37
int
ItemRecord::slot
()
38
{
39
switch
(
type
)
40
{
41
case
IT_HEAD
:
42
return
CS_HEAD
;
43
case
IT_SHOULDER
:
44
return
CS_SHOULDER
;
45
case
IT_SHIRT
:
46
return
CS_SHIRT
;
47
case
IT_CHEST
:
48
case
IT_ROBE
:
49
return
CS_CHEST
;
50
case
IT_BELT
:
51
return
CS_BELT
;
52
case
IT_PANTS
:
53
return
CS_PANTS
;
54
case
IT_BOOTS
:
55
return
CS_BOOTS
;
56
case
IT_BRACERS
:
57
return
CS_BRACERS
;
58
case
IT_GLOVES
:
59
return
CS_GLOVES
;
60
case
IT_DAGGER
:
61
case
IT_RIGHTHANDED
:
62
case
IT_GUN
:
63
case
IT_THROWN
:
64
case
IT_2HANDED
:
65
case
IT_BOW
:
66
return
CS_HAND_RIGHT
;
67
case
IT_SHIELD
:
68
case
IT_LEFTHANDED
:
69
case
IT_OFFHAND
:
70
return
CS_HAND_LEFT
;
71
case
IT_CAPE
:
72
return
CS_CAPE
;
73
case
IT_TABARD
:
74
return
CS_TABARD
;
75
case
IT_RINGS
:
76
case
IT_ACCESSORY
:
77
case
IT_QUIVER
:
78
case
IT_AMMO
:
79
case
IT_UNUSED
:
80
case
IT_RELIC
:
81
case
IT_NECK
:
82
default
:
83
return
-1;
84
}
85
}
86
87
// Alfred. prevent null items bug.
88
ItemDatabase::ItemDatabase
()
89
{
90
ItemRecord
all;
91
all.
name
=
"---- None ----"
;
92
all.
type
=
IT_ALL
;
93
94
items
.push_back(all);
95
}
96
97
const
ItemRecord
&
ItemDatabase::getById
(
int
id
)
const
98
{
99
for
(
auto
& item :
items
)
100
{
101
if
(item.id ==
id
)
102
return
item;
103
}
104
return
items
[0];
105
}
106
107
NPCRecord::NPCRecord
(
const
std::string& line)
108
: id(0), model(0), type(0)
109
{
110
std::vector<std::string> values;
111
std::istringstream stream(line);
112
std::string token;
113
while
(std::getline(stream, token,
','
))
114
values.push_back(token);
115
116
if
(values.size() <= 3)
117
return
;
118
119
id
= std::stoi(values[0]);
120
model
= std::stoi(values[1]);
121
type
= std::stoi(values[2]);
122
name
= values[3];
123
}
124
125
NPCRecord::NPCRecord
(
const
std::vector<std::string>& vals)
126
: id(0), model(0), type(0)
127
{
128
if
(vals.size() < 4)
129
return
;
130
131
id
= std::stoi(vals[0]);
132
model
= std::stoi(vals[1]);
133
type
= std::stoi(vals[2]);
134
name
= vals[3];
135
}
Logger.h
ItemDatabase
In-memory item database loaded from the CSV item list.
Definition
database.h:41
ItemDatabase::items
std::vector< ItemRecord > items
Definition
database.h:45
ItemDatabase::ItemDatabase
ItemDatabase()
Definition
database.cpp:88
ItemDatabase::getById
const ItemRecord & getById(int id) const
Definition
database.cpp:97
npcs
std::vector< NPCRecord > npcs
Definition
database.cpp:8
items
ItemDatabase items
Definition
database.cpp:7
database.h
ItemRecord
A single equipment item record from the item database.
Definition
database.h:26
ItemRecord::ItemRecord
ItemRecord()
Definition
database.h:32
ItemRecord::type
int type
Definition
database.h:28
ItemRecord::itemclass
int itemclass
Definition
database.h:28
ItemRecord::quality
int quality
Definition
database.h:28
ItemRecord::slot
int slot()
Definition
database.cpp:37
ItemRecord::model
int model
Definition
database.h:28
ItemRecord::name
std::string name
Display name of the item.
Definition
database.h:27
ItemRecord::sheath
int sheath
Definition
database.h:28
ItemRecord::subclass
int subclass
Definition
database.h:28
NPCRecord::name
std::string name
Display name of the NPC.
Definition
database.h:54
NPCRecord::type
int type
Creature ID, display model ID, and type.
Definition
database.h:55
NPCRecord::model
int model
Definition
database.h:55
NPCRecord::NPCRecord
NPCRecord()
Definition
database.h:60
wow_enums.h
IT_THROWN
@ IT_THROWN
Definition
wow_enums.h:257
IT_BOOTS
@ IT_BOOTS
Definition
wow_enums.h:240
IT_LEFTHANDED
@ IT_LEFTHANDED
Definition
wow_enums.h:254
IT_SHIELD
@ IT_SHIELD
Definition
wow_enums.h:246
IT_OFFHAND
@ IT_OFFHAND
Definition
wow_enums.h:255
IT_CAPE
@ IT_CAPE
Definition
wow_enums.h:248
IT_UNUSED
@ IT_UNUSED
Definition
wow_enums.h:259
IT_TABARD
@ IT_TABARD
Definition
wow_enums.h:251
IT_AMMO
@ IT_AMMO
Definition
wow_enums.h:256
IT_BOW
@ IT_BOW
Definition
wow_enums.h:247
IT_ROBE
@ IT_ROBE
Definition
wow_enums.h:252
IT_PANTS
@ IT_PANTS
Definition
wow_enums.h:239
IT_RIGHTHANDED
@ IT_RIGHTHANDED
Definition
wow_enums.h:253
IT_RELIC
@ IT_RELIC
Definition
wow_enums.h:260
IT_BRACERS
@ IT_BRACERS
Definition
wow_enums.h:241
IT_CHEST
@ IT_CHEST
Definition
wow_enums.h:237
IT_ACCESSORY
@ IT_ACCESSORY
Definition
wow_enums.h:244
IT_NECK
@ IT_NECK
Definition
wow_enums.h:234
IT_SHIRT
@ IT_SHIRT
Definition
wow_enums.h:236
IT_ALL
@ IT_ALL
Definition
wow_enums.h:232
IT_GUN
@ IT_GUN
Definition
wow_enums.h:258
IT_QUIVER
@ IT_QUIVER
Definition
wow_enums.h:250
IT_BELT
@ IT_BELT
Definition
wow_enums.h:238
IT_GLOVES
@ IT_GLOVES
Definition
wow_enums.h:242
IT_SHOULDER
@ IT_SHOULDER
Definition
wow_enums.h:235
IT_2HANDED
@ IT_2HANDED
Definition
wow_enums.h:249
IT_HEAD
@ IT_HEAD
Definition
wow_enums.h:233
IT_RINGS
@ IT_RINGS
Definition
wow_enums.h:243
IT_DAGGER
@ IT_DAGGER
Definition
wow_enums.h:245
ATT_LEFT_HIP_SHEATH
@ ATT_LEFT_HIP_SHEATH
Definition
wow_enums.h:113
ATT_LEFT_BACK
@ ATT_LEFT_BACK
Definition
wow_enums.h:111
ATT_MIDDLE_BACK_SHEATH
@ ATT_MIDDLE_BACK_SHEATH
Definition
wow_enums.h:109
ATT_LEFT_BACK_SHEATH
@ ATT_LEFT_BACK_SHEATH
Definition
wow_enums.h:108
CS_BRACERS
@ CS_BRACERS
Definition
wow_enums.h:13
CS_HAND_LEFT
@ CS_HAND_LEFT
Definition
wow_enums.h:16
CS_BELT
@ CS_BELT
Definition
wow_enums.h:9
CS_CAPE
@ CS_CAPE
Definition
wow_enums.h:17
CS_SHOULDER
@ CS_SHOULDER
Definition
wow_enums.h:7
CS_PANTS
@ CS_PANTS
Definition
wow_enums.h:11
CS_TABARD
@ CS_TABARD
Definition
wow_enums.h:18
CS_CHEST
@ CS_CHEST
Definition
wow_enums.h:12
CS_HAND_RIGHT
@ CS_HAND_RIGHT
Definition
wow_enums.h:15
CS_HEAD
@ CS_HEAD
Definition
wow_enums.h:6
CS_BOOTS
@ CS_BOOTS
Definition
wow_enums.h:8
CS_SHIRT
@ CS_SHIRT
Definition
wow_enums.h:10
CS_GLOVES
@ CS_GLOVES
Definition
wow_enums.h:14
SHEATHETYPE_SHIELD
@ SHEATHETYPE_SHIELD
Definition
wow_enums.h:226
SHEATHETYPE_HIPWEAPON
@ SHEATHETYPE_HIPWEAPON
Definition
wow_enums.h:225
SHEATHETYPE_MAINHAND
@ SHEATHETYPE_MAINHAND
Definition
wow_enums.h:223
SHEATHETYPE_NONE
@ SHEATHETYPE_NONE
Definition
wow_enums.h:222
SHEATHETYPE_LARGEWEAPON
@ SHEATHETYPE_LARGEWEAPON
Definition
wow_enums.h:224
Source
WoW
Database
database.cpp
Generated by
1.9.8