fix les gros polyos
This commit is contained in:
@@ -48,4 +48,7 @@ The settings file has the following format:
|
|||||||
- The last selected height of the board, stored with 1 byte
|
- The last selected height of the board, stored with 1 byte
|
||||||
- The uniformity mode (0 for default distribution, 1 for uniformous distribution, 2 for custom distribution), stored with 1 byte
|
- The uniformity mode (0 for default distribution, 1 for uniformous distribution, 2 for custom distribution), stored with 1 byte
|
||||||
- For each size, store the custom proportion (from 0 to 10) (15x1 byte total)
|
- For each size, store the custom proportion (from 0 to 10) (15x1 byte total)
|
||||||
- Every selected pieces, using 1 byte for the type of selection (once again converted from an Enum) and 1 byte for the actual value
|
- Every selected pieces
|
||||||
|
- For every groupe of piece (ALL, CONVEX, HOLELESS, OTHER), use 1 byte for the type (once again converted from an Enum) and 1 byte for the size
|
||||||
|
- For every single piece, use 1 byte for (the size + encoding that it is a single piece),
|
||||||
|
and 3 bytes to store the number of the piece (allows number up to 16M, size 15 has 6M pieces).
|
||||||
|
|||||||
@@ -82,12 +82,25 @@ void Settings::loadSettingsFromFile() {
|
|||||||
// selected pieces
|
// selected pieces
|
||||||
char pieceType;
|
char pieceType;
|
||||||
char pieceValue;
|
char pieceValue;
|
||||||
|
char lowByte;
|
||||||
|
char midByte;
|
||||||
|
char highByte;
|
||||||
|
|
||||||
this->selectedPieces.clear();
|
this->selectedPieces.clear();
|
||||||
while (settingsFile.get(pieceType)) {
|
while (settingsFile.get(pieceType)) {
|
||||||
if (settingsFile.eof()) break;
|
if (settingsFile.eof()) break;
|
||||||
|
|
||||||
settingsFile.get(pieceValue);
|
if (getSizeOfPieces(PiecesType(pieceType)) == 0) {
|
||||||
this->selectedPieces.push_back({PiecesType(pieceType), pieceValue});
|
settingsFile.get(pieceValue);
|
||||||
|
this->selectedPieces.emplace_back(PiecesType(pieceType), pieceValue);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
settingsFile.get(lowByte);
|
||||||
|
settingsFile.get(midByte);
|
||||||
|
settingsFile.get(highByte);
|
||||||
|
int pieceNumber = ((unsigned char) lowByte) + ((unsigned char) midByte << 8) + ((unsigned char) highByte << 16);
|
||||||
|
this->selectedPieces.emplace_back(PiecesType(pieceType), pieceNumber);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this->confirmSelectedPieces();
|
this->confirmSelectedPieces();
|
||||||
}
|
}
|
||||||
@@ -147,8 +160,18 @@ void Settings::saveSettingsToFile() const {
|
|||||||
for (const auto& [type, value] : this->selectedPieces) {
|
for (const auto& [type, value] : this->selectedPieces) {
|
||||||
byte = type;
|
byte = type;
|
||||||
settingsFile.write(&byte, 1);
|
settingsFile.write(&byte, 1);
|
||||||
byte = value;
|
if (getSizeOfPieces(type) == 0) {
|
||||||
settingsFile.write(&byte, 1);
|
byte = value;
|
||||||
|
settingsFile.write(&byte, 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int number = value;
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
byte = (number % 256);
|
||||||
|
settingsFile.write(&byte, 1);
|
||||||
|
number = (number >> 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user