moved parsing blob->int64 to a separate function

This commit is contained in:
kamilprzyb 2020-09-15 00:03:13 +02:00
parent deebc2f51a
commit 4e32663cab
2 changed files with 15 additions and 10 deletions

View File

@ -335,7 +335,6 @@ Database::DbPlayer Database::playerToDb(Player *player)
appendBlob(&result.QuestFlag, flag);
}
return result;
}
@ -387,15 +386,9 @@ Player Database::DbToPlayer(DbPlayer player) {
{
if (it == player.QuestFlag.end())
break;
int64_t toAdd = 0;
for (int j = 0; j < 8; j++) {
int64_t temp = *it;
int64_t check2 = (temp << (8 * (7 - j)));
toAdd += check2;
it++;
}
result.aQuestFlag[i] = toAdd;
result.aQuestFlag[i] = blobToInt64(it);
//move iterator to the next flag
it += 8;
}
return result;
@ -541,4 +534,15 @@ void Database::appendBlob(std::vector<char> *blob, int64_t input) {
blob->push_back(toadd);
}
}
int64_t Database::blobToInt64(std::vector<char>::iterator it) {
int64_t result = 0;
for (int i = 0; i < 8; i++) {
int64_t toAdd = ((int64_t)*it << (8 * (7 - i)));
result += toAdd;
it++;
}
return result;
}
#pragma endregion parsingBlobs

View File

@ -113,4 +113,5 @@ namespace Database {
//parsing blobs
void appendBlob(std::vector<char>*blob, int64_t input);
int64_t blobToInt64(std::vector<char>::iterator it);
}