Skip to content

Commit

Permalink
Исправил сохранение рекордов
Browse files Browse the repository at this point in the history
  • Loading branch information
kdsli committed Jun 5, 2021
1 parent 24cd950 commit a5a0ca9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/crecordsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <QDataStream>
#include <QGraphicsSvgItem>

#define isBase64 true

CRecordsManager *records_manager = nullptr;

// Максимальное количество хранимых рекордов
Expand Down Expand Up @@ -117,20 +119,24 @@ void CRecordsManager::loadRecords()
ds >> ba;

// Super decode!
#if isBase64
QByteArray dst = QByteArray::fromBase64(ba);
#else
QByteArray dst = ba;
#endif

// А дальше разбираем уже поток из массива
QDataStream buffer(&dst, QIODevice::ReadOnly);
buffer.setVersion(QDataStream::Qt_5_0);

// Читаем количество игр
int game_count;
qint64 game_count;
buffer >> game_count;

// И каждую игру
for (int i = 0; i < game_count; ++i) {
int game_key;
int record_count;
qint64 record_count;
buffer >> game_key >> record_count;
RecordList list;
for (int j = 0; j < record_count; ++j) {
Expand Down Expand Up @@ -174,6 +180,10 @@ void CRecordsManager::saveRecords()
}

// А буфер в файл - super encoding!
#if isBase64
ds << ba.toBase64();
#else
ds << ba;
#endif
}

2 changes: 1 addition & 1 deletion src/crecordsmanager.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef CRECORSDMANAGER_H
#ifndef CRECORSDMANAGER_H
#define CRECORSDMANAGER_H

#include "csettings.h"
Expand Down

0 comments on commit a5a0ca9

Please sign in to comment.