- bugfix for cell bad cell management in map preview

This commit is contained in:
Mark Vejvoda 2010-09-13 23:10:29 +00:00
parent 40489e0687
commit f373a7f9bb
2 changed files with 21 additions and 10 deletions

View File

@ -2635,7 +2635,8 @@ void MenuStateCustomGame::cleanupFactionTexture() {
MapPreview::MapPreview() {
altFactor = 3;
waterLevel = 4;
cells = NULL;
//cells = NULL;
cells.clear();
startLocations = NULL;
reset(128, 128, 10.f, 1);
resetFactions(8);
@ -2650,13 +2651,15 @@ MapPreview::~MapPreview() {
startLocations = NULL;
if(hasFileLoaded() == true) {
for (int i = 0; i < h; i++) {
delete [] cells[i];
}
delete [] cells;
//for (int i = 0; i < h; i++) {
// delete [] cells[i];
//}
//delete [] cells;
fileLoaded = false;
}
cells = NULL;
//cells = NULL;
cells.clear();
}
@ -2709,20 +2712,26 @@ void MapPreview::reset(int w, int h, float alt, int surf) {
return;
}
/*
if (cells != NULL) {
for (int i = 0; i < this->w; i++) {
delete [] cells[i];
}
delete [] cells;
}
*/
cells.clear();
this->w = w;
this->h = h;
this->maxFactions = maxFactions;
cells = new Cell*[w];
cells.resize(w);
//cells = new Cell*[w];
for (int i = 0; i < w; i++) {
cells[i] = new Cell[h];
//cells[i] = new Cell[h];
cells[i].resize(h);
for (int j = 0; j < h; j++) {
cells[i][j].height = alt;
cells[i][j].object = 0;
@ -2762,7 +2771,8 @@ int MapPreview::getWaterLevel() const {
void MapPreview::loadFromFile(const string &path) {
altFactor = 3;
waterLevel = 4;
cells = NULL;
//cells = NULL;
cells.clear();
startLocations = NULL;
reset(128, 128, 10.f, 1);
resetFactions(8);

View File

@ -64,7 +64,8 @@ private:
int w;
int altFactor;
int waterLevel;
Cell **cells;
//Cell **cells;
std::vector<std::vector<Cell> > cells;
int maxFactions;
StartLocation *startLocations;
int refAlt;