-
Notifications
You must be signed in to change notification settings - Fork 1
/
baseweapondamageparser.cpp
48 lines (38 loc) · 1.52 KB
/
baseweapondamageparser.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "baseweapondamageparser.h"
const QString BaseWeaponDamageParser::BaseWeaponDamageFileName = "BASE_WEAPON_DAMAGE.DAT";
BaseWeaponDamageParser::BaseWeaponDamageParser(QString databaseFilePath, QObject *parent) :
GraphFileParser(parent)
{
mBaseWeaponDamageTable = new BaseWeaponDamageTable(databaseFilePath);
mNumBaseWeaponDamageProcessed = 0;
}
BaseWeaponDamageParser::~BaseWeaponDamageParser()
{
if (mBaseWeaponDamageTable != NULL)
delete mBaseWeaponDamageTable;
}
void BaseWeaponDamageParser::ParseBaseWeaponDamage()
{
if (mDatFilesFolder.exists() && mBaseWeaponDamageTable != NULL)
{
mNumBaseWeaponDamageProcessed = 0;
qint32 maxLevel = 0;
QFile baseWeaponDamageFile(mDatFilesFolder.absoluteFilePath(BaseWeaponDamageFileName));
QHash<qint32, float>* baseWeaponDamage = ParseLevelGraphFile(baseWeaponDamageFile, maxLevel);
if (mBaseWeaponDamageTable->BeginTransaction())
{
BaseWeaponDamage baseDamage;
for (qint32 i = 0; i <= maxLevel; ++i)
{
baseDamage.Clear();
baseDamage.level = i;
baseDamage.baseDamage = baseWeaponDamage->value(i);
mBaseWeaponDamageTable->AddBaseWeaponDamage(baseDamage);
mNumBaseWeaponDamageProcessed = i;
}
mBaseWeaponDamageTable->CommitTransaction();
}
delete baseWeaponDamage;
}
emit finishedParsingBaseWeaponDamage();
}