mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 07:36:44 +00:00
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
This commit is contained in:
parent
35f8e79d07
commit
46e09c5c75
4 changed files with 33 additions and 22 deletions
|
@ -591,9 +591,16 @@ public:
|
||||||
// Read the next size bytes and return them as a string
|
// Read the next size bytes and return them as a string
|
||||||
std::string getString(int size)
|
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];
|
char *ptr = new char[size];
|
||||||
esm->read(ptr,size);
|
esm->read(ptr,size);
|
||||||
|
|
||||||
|
// Remove any zero terminators
|
||||||
|
for(int i=0; i<size; i++)
|
||||||
|
if(ptr[i] == 0)
|
||||||
|
size = i;
|
||||||
|
|
||||||
|
// Convert to std::string and return
|
||||||
std::string res(ptr,size);
|
std::string res(ptr,size);
|
||||||
delete[] ptr;
|
delete[] ptr;
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -118,6 +118,9 @@ struct Cell
|
||||||
|
|
||||||
void load(ESMReader &esm)
|
void load(ESMReader &esm)
|
||||||
{
|
{
|
||||||
|
// All cells have a name record, even nameless exterior cells.
|
||||||
|
name = esm.getHNString("NAME");
|
||||||
|
|
||||||
// Ignore this for now, it might mean we should delete the entire
|
// Ignore this for now, it might mean we should delete the entire
|
||||||
// cell?
|
// cell?
|
||||||
if(esm.isNextSub("DELE")) esm.skipHSub();
|
if(esm.isNextSub("DELE")) esm.skipHSub();
|
||||||
|
|
|
@ -61,42 +61,42 @@ namespace ESMS
|
||||||
// separately.
|
// separately.
|
||||||
struct CellList : RecList
|
struct CellList : RecList
|
||||||
{
|
{
|
||||||
// Just count them for now
|
// Total cell count. Used for statistics.
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
CellList() : count(0) {}
|
CellList() : count(0) {}
|
||||||
|
int getSize() { return count; }
|
||||||
|
|
||||||
/*
|
// List of interior cells. Indexed by cell name.
|
||||||
What to do here:
|
std::map<std::string,Cell> intCells;
|
||||||
|
|
||||||
load() reads the appropriate records to determine if this is an
|
// List of exterior cells. Indexed as extCells[gridX][gridY].
|
||||||
interior or exterior cell. The old D code should be straight
|
std::map<int, std::map<int, Cell> > extCells;
|
||||||
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<map<>>, so we can do ext_cells[X][Y].whatever. Hmm, I
|
|
||||||
think I like that better actually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void load(ESMReader &esm)
|
void load(ESMReader &esm)
|
||||||
{
|
{
|
||||||
// All cells have a name record, even nameless exterior cells.
|
|
||||||
std::string id = esm.getHNString("NAME");
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
cout << id << endl;
|
|
||||||
|
|
||||||
count++;
|
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:
|
/* We need special lists for:
|
||||||
|
|
||||||
Cells (in progress)
|
|
||||||
Magic effects
|
Magic effects
|
||||||
Skills
|
Skills
|
||||||
Dialog / Info combo
|
Dialog / Info combo
|
||||||
|
|
1
nifogre/tests/.gitignore
vendored
1
nifogre/tests/.gitignore
vendored
|
@ -2,3 +2,4 @@
|
||||||
meshlist.txt
|
meshlist.txt
|
||||||
ogre.cfg
|
ogre.cfg
|
||||||
*_test
|
*_test
|
||||||
|
chris*
|
||||||
|
|
Loading…
Reference in a new issue