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
8std::vector<NPCRecord> npcs;
9
10ItemRecord::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 {
25 break;
27 break;
29 break;
31 break;
32 default: sheath = SHEATHETYPE_NONE; //-V1048
33 }
34 name = vals[1];
35}
36
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.
89{
90 ItemRecord all;
91 all.name = "---- None ----";
92 all.type = IT_ALL;
93
94 items.push_back(all);
95}
96
98{
99 for (auto& item : items)
100 {
101 if (item.id == id)
102 return item;
103 }
104 return items[0];
105}
106
107NPCRecord::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
125NPCRecord::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}
In-memory item database loaded from the CSV item list.
Definition database.h:41
std::vector< ItemRecord > items
Definition database.h:45
const ItemRecord & getById(int id) const
Definition database.cpp:97
std::vector< NPCRecord > npcs
Definition database.cpp:8
ItemDatabase items
Definition database.cpp:7
A single equipment item record from the item database.
Definition database.h:26
int itemclass
Definition database.h:28
int quality
Definition database.h:28
int slot()
Definition database.cpp:37
int model
Definition database.h:28
std::string name
Display name of the item.
Definition database.h:27
int sheath
Definition database.h:28
int subclass
Definition database.h:28
std::string name
Display name of the NPC.
Definition database.h:54
int type
Creature ID, display model ID, and type.
Definition database.h:55
int model
Definition database.h:55
NPCRecord()
Definition database.h:60
@ IT_THROWN
Definition wow_enums.h:257
@ IT_BOOTS
Definition wow_enums.h:240
@ IT_LEFTHANDED
Definition wow_enums.h:254
@ IT_SHIELD
Definition wow_enums.h:246
@ IT_OFFHAND
Definition wow_enums.h:255
@ IT_CAPE
Definition wow_enums.h:248
@ IT_UNUSED
Definition wow_enums.h:259
@ IT_TABARD
Definition wow_enums.h:251
@ IT_AMMO
Definition wow_enums.h:256
@ IT_BOW
Definition wow_enums.h:247
@ IT_ROBE
Definition wow_enums.h:252
@ IT_PANTS
Definition wow_enums.h:239
@ IT_RIGHTHANDED
Definition wow_enums.h:253
@ IT_RELIC
Definition wow_enums.h:260
@ IT_BRACERS
Definition wow_enums.h:241
@ IT_CHEST
Definition wow_enums.h:237
@ IT_ACCESSORY
Definition wow_enums.h:244
@ IT_NECK
Definition wow_enums.h:234
@ IT_SHIRT
Definition wow_enums.h:236
@ IT_ALL
Definition wow_enums.h:232
@ IT_GUN
Definition wow_enums.h:258
@ IT_QUIVER
Definition wow_enums.h:250
@ IT_BELT
Definition wow_enums.h:238
@ IT_GLOVES
Definition wow_enums.h:242
@ IT_SHOULDER
Definition wow_enums.h:235
@ IT_2HANDED
Definition wow_enums.h:249
@ IT_HEAD
Definition wow_enums.h:233
@ IT_RINGS
Definition wow_enums.h:243
@ IT_DAGGER
Definition wow_enums.h:245
@ ATT_LEFT_HIP_SHEATH
Definition wow_enums.h:113
@ ATT_LEFT_BACK
Definition wow_enums.h:111
@ ATT_MIDDLE_BACK_SHEATH
Definition wow_enums.h:109
@ ATT_LEFT_BACK_SHEATH
Definition wow_enums.h:108
@ CS_BRACERS
Definition wow_enums.h:13
@ CS_HAND_LEFT
Definition wow_enums.h:16
@ CS_BELT
Definition wow_enums.h:9
@ CS_CAPE
Definition wow_enums.h:17
@ CS_SHOULDER
Definition wow_enums.h:7
@ CS_PANTS
Definition wow_enums.h:11
@ CS_TABARD
Definition wow_enums.h:18
@ CS_CHEST
Definition wow_enums.h:12
@ CS_HAND_RIGHT
Definition wow_enums.h:15
@ CS_HEAD
Definition wow_enums.h:6
@ CS_BOOTS
Definition wow_enums.h:8
@ CS_SHIRT
Definition wow_enums.h:10
@ CS_GLOVES
Definition wow_enums.h:14
@ SHEATHETYPE_SHIELD
Definition wow_enums.h:226
@ SHEATHETYPE_HIPWEAPON
Definition wow_enums.h:225
@ SHEATHETYPE_MAINHAND
Definition wow_enums.h:223
@ SHEATHETYPE_NONE
Definition wow_enums.h:222
@ SHEATHETYPE_LARGEWEAPON
Definition wow_enums.h:224