mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:53:52 +00:00
Merge remote branch 'corristo/pgrd'
Removed a warning Conflicts: CMakeLists.txt
This commit is contained in:
commit
ff866269ec
5 changed files with 163 additions and 26 deletions
|
@ -255,14 +255,8 @@ if (APPLE)
|
||||||
"${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY)
|
"${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY)
|
||||||
|
|
||||||
# prepare plugins
|
# prepare plugins
|
||||||
if (${CMAKE_BUILD_TYPE} MATCHES "Release")
|
if (${CMAKE_BUILD_TYPE} MATCHES "Release" OR
|
||||||
set(OPENMW_RELEASE_BUILD 1)
|
${CMAKE_BUILD_TYPE} MATCHES "RelWithDebugInfo")
|
||||||
endif()
|
|
||||||
if (${CMAKE_BUILD_TYPE} MATCHES "RelWithDebugInfo")
|
|
||||||
set(OPENMW_RELEASE_BUILD 1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (${OPENMW_RELEASE_BUILD})
|
|
||||||
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL})
|
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL})
|
||||||
else()
|
else()
|
||||||
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG})
|
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG})
|
||||||
|
|
|
@ -3,32 +3,68 @@
|
||||||
namespace ESM
|
namespace ESM
|
||||||
{
|
{
|
||||||
|
|
||||||
void PathGrid::load(ESMReader &esm)
|
void Pathgrid::load(ESMReader &esm)
|
||||||
{
|
{
|
||||||
esm.getHNT(data, "DATA", 12);
|
esm.getHNT(data, "DATA", 12);
|
||||||
cell = esm.getHNString("NAME");
|
cell = esm.getHNString("NAME");
|
||||||
|
|
||||||
// Remember this file position
|
// keep track of total connections so we can reserve edge vector size
|
||||||
context = esm.getContext();
|
int edgeCount = 0;
|
||||||
|
|
||||||
// Check that the sizes match up. Size = 16 * s2 (path points?)
|
|
||||||
if (esm.isNextSub("PGRP"))
|
if (esm.isNextSub("PGRP"))
|
||||||
{
|
{
|
||||||
esm.skipHSub();
|
esm.getSubHeader();
|
||||||
int size = esm.getSubSize();
|
int size = esm.getSubSize();
|
||||||
if (size != 16 * data.s2)
|
// Check that the sizes match up. Size = 16 * s2 (path points)
|
||||||
esm.fail("Path grid table size mismatch");
|
if (size != static_cast<int> (sizeof(Point) * data.s2))
|
||||||
|
esm.fail("Path point subrecord size mismatch");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int pointCount = data.s2;
|
||||||
|
points.reserve(pointCount);
|
||||||
|
for (int i = 0; i < pointCount; ++i)
|
||||||
|
{
|
||||||
|
Point p;
|
||||||
|
esm.getExact(&p, sizeof(Point));
|
||||||
|
points.push_back(p);
|
||||||
|
edgeCount += p.connectionNum;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Size varies. Path grid chances? Connections? Multiples of 4
|
|
||||||
// suggest either int or two shorts, or perhaps a float. Study
|
|
||||||
// it later.
|
|
||||||
if (esm.isNextSub("PGRC"))
|
if (esm.isNextSub("PGRC"))
|
||||||
{
|
{
|
||||||
esm.skipHSub();
|
esm.getSubHeader();
|
||||||
int size = esm.getSubSize();
|
int size = esm.getSubSize();
|
||||||
if (size % 4 != 0)
|
if (size % sizeof(int) != 0)
|
||||||
esm.fail("PGRC size not a multiple of 4");
|
esm.fail("PGRC size not a multiple of 4");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int rawConnNum = size / sizeof(int);
|
||||||
|
std::vector<int> rawConnections;
|
||||||
|
rawConnections.reserve(rawConnNum);
|
||||||
|
for (int i = 0; i < rawConnNum; ++i)
|
||||||
|
{
|
||||||
|
int currentValue;
|
||||||
|
esm.getT(currentValue);
|
||||||
|
rawConnections.push_back(currentValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<int>::const_iterator rawIt = rawConnections.begin();
|
||||||
|
int pointIndex = 0;
|
||||||
|
edges.reserve(edgeCount);
|
||||||
|
for(PointList::const_iterator it = points.begin(); it != points.end(); it++, pointIndex++)
|
||||||
|
{
|
||||||
|
unsigned char connectionNum = (*it).connectionNum;
|
||||||
|
for (int i = 0; i < connectionNum; ++i) {
|
||||||
|
Edge edge;
|
||||||
|
edge.v0 = pointIndex;
|
||||||
|
edge.v1 = *rawIt;
|
||||||
|
rawIt++;
|
||||||
|
edges.push_back(edge);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,20 +9,37 @@ namespace ESM
|
||||||
/*
|
/*
|
||||||
* Path grid.
|
* Path grid.
|
||||||
*/
|
*/
|
||||||
struct PathGrid
|
struct Pathgrid
|
||||||
{
|
{
|
||||||
struct DATAstruct
|
struct DATAstruct
|
||||||
{
|
{
|
||||||
int x, y; // Grid location, matches cell for exterior cells
|
int x, y; // Grid location, matches cell for exterior cells
|
||||||
short s1; // ?? Usually but not always a power of 2. Doesn't seem
|
short s1; // ?? Usually but not always a power of 2. Doesn't seem
|
||||||
// to have any relation to the size of PGRC.
|
// to have any relation to the size of PGRC.
|
||||||
short s2; // Number of path points? Size of PGRP block is always 16 * s2;
|
short s2; // Number of path points.
|
||||||
}; // 12 bytes
|
}; // 12 bytes
|
||||||
|
|
||||||
|
struct Point // path grid point
|
||||||
|
{
|
||||||
|
int x, y, z; // Location of point
|
||||||
|
unsigned char autogenerated; // autogenerated vs. user coloring flag?
|
||||||
|
unsigned char connectionNum; // number of connections for this point
|
||||||
|
short unknown;
|
||||||
|
}; // 16 bytes
|
||||||
|
|
||||||
|
struct Edge // path grid edge
|
||||||
|
{
|
||||||
|
int v0, v1; // index of points connected with this edge
|
||||||
|
}; // 8 bytes
|
||||||
|
|
||||||
std::string cell; // Cell name
|
std::string cell; // Cell name
|
||||||
DATAstruct data;
|
DATAstruct data;
|
||||||
ESM_Context context; // Context so we can return here later and
|
|
||||||
// finish the job
|
typedef std::vector<Point> PointList;
|
||||||
|
PointList points;
|
||||||
|
|
||||||
|
typedef std::vector<Edge> EdgeList;
|
||||||
|
EdgeList edges;
|
||||||
|
|
||||||
void load(ESMReader &esm);
|
void load(ESMReader &esm);
|
||||||
};
|
};
|
||||||
|
|
|
@ -390,6 +390,95 @@ namespace ESMS
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PathgridList : RecList
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
|
||||||
|
// List of grids for interior cells. Indexed by cell name.
|
||||||
|
typedef std::map<std::string,ESM::Pathgrid*, ciLessBoost> IntGrids;
|
||||||
|
IntGrids intGrids;
|
||||||
|
|
||||||
|
// List of grids for exterior cells. Indexed as extCells[gridX][gridY].
|
||||||
|
typedef std::map<std::pair<int, int>, ESM::Pathgrid*> ExtGrids;
|
||||||
|
ExtGrids extGrids;
|
||||||
|
|
||||||
|
PathgridList() : count(0) {}
|
||||||
|
|
||||||
|
~PathgridList()
|
||||||
|
{
|
||||||
|
for (IntGrids::iterator it = intGrids.begin(); it!=intGrids.end(); ++it)
|
||||||
|
delete it->second;
|
||||||
|
|
||||||
|
for (ExtGrids::iterator it = extGrids.begin(); it!=extGrids.end(); ++it)
|
||||||
|
delete it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getSize() { return count; }
|
||||||
|
|
||||||
|
virtual void listIdentifier (std::vector<std::string>& identifier) const
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
void load(ESMReader &esm, const std::string &id)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
ESM::Pathgrid *grid = new ESM::Pathgrid;
|
||||||
|
grid->load(esm);
|
||||||
|
if (grid->data.x == 0 && grid->data.y == 0)
|
||||||
|
{
|
||||||
|
intGrids[grid->cell] = grid;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
extGrids[std::make_pair(grid->data.x, grid->data.y)] = grid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Pathgrid *find(int cellX, int cellY, std::string cellName) const
|
||||||
|
{
|
||||||
|
Pathgrid *result = search(cellX, cellY, cellName);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("no pathgrid found for cell " + cellName);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pathgrid *search(int cellX, int cellY, std::string cellName) const
|
||||||
|
{
|
||||||
|
Pathgrid *result = NULL;
|
||||||
|
if (cellX == 0 && cellY == 0) // possibly interior
|
||||||
|
{
|
||||||
|
IntGrids::const_iterator it = intGrids.find(cellName);
|
||||||
|
if (it != intGrids.end())
|
||||||
|
result = it->second;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ExtGrids::const_iterator it = extGrids.find(std::make_pair(cellX, cellY));
|
||||||
|
if (it != extGrids.end())
|
||||||
|
result = it->second;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pathgrid *search(const ESM::Cell &cell) const
|
||||||
|
{
|
||||||
|
int cellX, cellY;
|
||||||
|
if (cell.data.flags & ESM::Cell::Interior)
|
||||||
|
{
|
||||||
|
cellX = cellY = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cellX = cell.data.gridX;
|
||||||
|
cellY = cell.data.gridY;
|
||||||
|
}
|
||||||
|
return search(cellX, cellY, cell.name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename X>
|
template <typename X>
|
||||||
struct ScriptListT : RecList
|
struct ScriptListT : RecList
|
||||||
{
|
{
|
||||||
|
|
|
@ -74,7 +74,8 @@ namespace ESMS
|
||||||
ScriptListT<Script> scripts;
|
ScriptListT<Script> scripts;
|
||||||
IndexListT<MagicEffect> magicEffects;
|
IndexListT<MagicEffect> magicEffects;
|
||||||
IndexListT<Skill> skills;
|
IndexListT<Skill> skills;
|
||||||
//RecListT<PathGrid> pathgrids;
|
//RecListT<Pathgrid> pathgrids;
|
||||||
|
PathgridList pathgrids;
|
||||||
|
|
||||||
// Special entry which is hardcoded and not loaded from an ESM
|
// Special entry which is hardcoded and not loaded from an ESM
|
||||||
IndexListT<Attribute> attributes;
|
IndexListT<Attribute> attributes;
|
||||||
|
@ -124,7 +125,7 @@ namespace ESMS
|
||||||
recLists[REC_MISC] = &miscItems;
|
recLists[REC_MISC] = &miscItems;
|
||||||
recLists[REC_NPC_] = &npcs;
|
recLists[REC_NPC_] = &npcs;
|
||||||
recLists[REC_NPCC] = &npcChange;
|
recLists[REC_NPCC] = &npcChange;
|
||||||
//recLists[REC_PGRD] = &pathgrids;
|
recLists[REC_PGRD] = &pathgrids;
|
||||||
recLists[REC_PROB] = &probes;
|
recLists[REC_PROB] = &probes;
|
||||||
recLists[REC_RACE] = &races;
|
recLists[REC_RACE] = &races;
|
||||||
recLists[REC_REGN] = ®ions;
|
recLists[REC_REGN] = ®ions;
|
||||||
|
|
Loading…
Reference in a new issue