From 46e09c5c75b87ee463ceb41479b6217143357af9 Mon Sep 17 00:00:00 2001 From: Nicolay Korslund Date: Thu, 20 May 2010 12:04:34 +0200 Subject: [PATCH] CellList is done, cells can be looked up - finished CellList in game/esm_reclists.hpp - esm_reader: get*String() now removes trailing zero terminators from result --- esm/esm_reader.hpp | 9 ++++++++- esm/loadcell.hpp | 3 +++ game/esm_reclists.hpp | 42 ++++++++++++++++++++-------------------- nifogre/tests/.gitignore | 1 + 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/esm/esm_reader.hpp b/esm/esm_reader.hpp index 4e9d6c85dc..0d895582d2 100644 --- a/esm/esm_reader.hpp +++ b/esm/esm_reader.hpp @@ -591,9 +591,16 @@ public: // Read the next size bytes and return them as a string std::string getString(int size) { - // Not very optimized, but we'll fix that later + // Not very optimized, but we can fix that later char *ptr = new char[size]; esm->read(ptr,size); + + // Remove any zero terminators + for(int i=0; i intCells; - load() reads the appropriate records to determine if this is an - interior or exterior cell. The old D code should be straight - forward to port here. Unlike the lists above, this struct - contains two lists, one for each cell type. We will have to hack - around again to get good indexing of exterior cells, but I think - a hash thingie like we did in D will work. An alternative is - just a map>, so we can do ext_cells[X][Y].whatever. Hmm, I - think I like that better actually. - */ + // List of exterior cells. Indexed as extCells[gridX][gridY]. + std::map > extCells; void load(ESMReader &esm) { - // All cells have a name record, even nameless exterior cells. - std::string id = esm.getHNString("NAME"); - using namespace std; - cout << id << endl; count++; - esm.skipRecord(); - } - int getSize() { return count; } + // The cell itself takes care of all the hairy details + Cell cell; + cell.load(esm); + + if(cell.data.flags & Cell::Interior) + { + // Store interior cell by name + intCells[cell.name] = cell; + } + else + { + // Store exterior cells by grid position + extCells[cell.data.gridX][cell.data.gridY] = cell; + } + } }; /* We need special lists for: - Cells (in progress) Magic effects Skills Dialog / Info combo diff --git a/nifogre/tests/.gitignore b/nifogre/tests/.gitignore index e04e76c5e3..1a55699834 100644 --- a/nifogre/tests/.gitignore +++ b/nifogre/tests/.gitignore @@ -2,3 +2,4 @@ meshlist.txt ogre.cfg *_test +chris*