Better debug prints for errors + fix error where header was interpreted wrong
This commit is contained in:
		
							
								
								
									
										12
									
								
								src/life.cpp
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/life.cpp
									
									
									
									
									
								
							@@ -188,16 +188,20 @@ int main() {
 | 
			
		||||
        return 1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (lines.size() - 2 < rows) {
 | 
			
		||||
        std::cerr << "There's less rows than described in the header!" << std::endl;
 | 
			
		||||
    int possibleRows = lines.size() - 2;
 | 
			
		||||
    if (possibleRows < rows) {
 | 
			
		||||
        std::cerr << "There's less rows (" << possibleRows
 | 
			
		||||
                  << ") than described in the header! (" << rows << ')'
 | 
			
		||||
                  << std::endl;
 | 
			
		||||
        return 1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Grid<Cell> grid(columns, rows);
 | 
			
		||||
    for (int x = 0; x < rows; x++) {
 | 
			
		||||
        std::string &row = lines[x + 2];
 | 
			
		||||
        if (columns < row.size()) {
 | 
			
		||||
            std::cerr << "There's less columns, than described in the header!"
 | 
			
		||||
        if (columns > row.size()) {
 | 
			
		||||
            std::cerr << "There's less columns (" << row.size()
 | 
			
		||||
                      << "), than described in the header! (" << rows << ')'
 | 
			
		||||
                      << std::endl;
 | 
			
		||||
            return 1;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user