Better debug prints for errors + fix error where header was interpreted wrong

This commit is contained in:
Love 2024-09-04 22:04:37 +02:00
parent bf01891211
commit cf3362dabb

View File

@ -188,16 +188,20 @@ int main() {
return 1; return 1;
} }
if (lines.size() - 2 < rows) { int possibleRows = lines.size() - 2;
std::cerr << "There's less rows than described in the header!" << std::endl; if (possibleRows < rows) {
std::cerr << "There's less rows (" << possibleRows
<< ") than described in the header! (" << rows << ')'
<< std::endl;
return 1; return 1;
} }
Grid<Cell> grid(columns, rows); Grid<Cell> grid(columns, rows);
for (int x = 0; x < rows; x++) { for (int x = 0; x < rows; x++) {
std::string &row = lines[x + 2]; std::string &row = lines[x + 2];
if (columns < row.size()) { if (columns > row.size()) {
std::cerr << "There's less columns, than described in the header!" std::cerr << "There's less columns (" << row.size()
<< "), than described in the header! (" << rows << ')'
<< std::endl; << std::endl;
return 1; return 1;
} }