Ok. I managed to narrow it down where it's happening to a constructor:
Code:
#include <fstream>
#include <string>
#include <vector>
#include <iostream>
#include "terrain.h"
using namespace Game;
terrain::terrain (std::string fileName) {
std::ifstream in(fileName.c_str());
if (!in) {
throw GameException("Cannot open terrain file.");
}
else {
std::string entry;
std::string longFile;
std::vector<string> stringVect;
while (getline(in, entry)) {
if (entry > longFile) {
longFile = entry;
}
stringVect.push_back(entry);
}
width = longFile.size();
height = stringVect.size();
}
in.seekg (0);
terrainArray = new Array2D<char>(width, height);
char passTo;
while (in.get(passTo)) {
for(
unsigned y = 0;
y < height;
y++
) {
for(
unsigned x = 0;
x < width;
x++
) {
terrainArray->Put(x, y, passTo);
}
}
}
in.close();
}
The Array2D template was supplied by a lecturer, so it works. I've asked him about this issue, but all he said was to check my file format.