CPoiToWorld: Make use of size_t where applicable
Plays nicer with standard containers.
This commit is contained in:
parent
709fcf18ae
commit
09de312ac3
|
@ -30,12 +30,12 @@ public:
|
|||
void RemovePoi(uint32 PoiID);
|
||||
void RemovePoiMeshMap(uint32 PoiID, uint32 ModelID);
|
||||
|
||||
uint32 NumMappedPOIs() const
|
||||
size_t NumMappedPOIs() const
|
||||
{
|
||||
return mMaps.size();
|
||||
}
|
||||
|
||||
const SPoiMap* MapByIndex(uint32 Index) const
|
||||
const SPoiMap* MapByIndex(size_t Index) const
|
||||
{
|
||||
return mMaps[Index];
|
||||
}
|
||||
|
|
|
@ -10,26 +10,23 @@ bool CPoiToWorldCooker::CookEGMC(CPoiToWorld *pPoiToWorld, IOutputStream& rOut)
|
|||
};
|
||||
std::vector<SPoiMapping> Mappings;
|
||||
|
||||
for (uint32 iPoi = 0; iPoi < pPoiToWorld->NumMappedPOIs(); iPoi++)
|
||||
for (size_t iPoi = 0; iPoi < pPoiToWorld->NumMappedPOIs(); iPoi++)
|
||||
{
|
||||
const CPoiToWorld::SPoiMap *pkMap = pPoiToWorld->MapByIndex(iPoi);
|
||||
|
||||
for (auto it = pkMap->ModelIDs.begin(); it != pkMap->ModelIDs.end(); it++)
|
||||
for (const auto meshID : pkMap->ModelIDs)
|
||||
{
|
||||
SPoiMapping Mapping;
|
||||
Mapping.MeshID = *it;
|
||||
Mapping.PoiID = pkMap->PoiID;
|
||||
Mappings.push_back(Mapping);
|
||||
Mappings.push_back({meshID, pkMap->PoiID});
|
||||
}
|
||||
}
|
||||
|
||||
// Write EGMC
|
||||
rOut.WriteLong(Mappings.size());
|
||||
|
||||
for (uint32 iMap = 0; iMap < Mappings.size(); iMap++)
|
||||
for (const auto& mapping : Mappings)
|
||||
{
|
||||
rOut.WriteLong(Mappings[iMap].MeshID);
|
||||
rOut.WriteLong(Mappings[iMap].PoiID);
|
||||
rOut.WriteLong(mapping.MeshID);
|
||||
rOut.WriteLong(mapping.PoiID);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -23,14 +23,14 @@ QVariant CPoiMapModel::headerData(int Section, Qt::Orientation Orientation, int
|
|||
|
||||
int CPoiMapModel::rowCount(const QModelIndex& /*rkParent*/) const
|
||||
{
|
||||
return mpPoiToWorld ? mpPoiToWorld->NumMappedPOIs() : 0;
|
||||
return mpPoiToWorld ? static_cast<int>(mpPoiToWorld->NumMappedPOIs()) : 0;
|
||||
}
|
||||
|
||||
QVariant CPoiMapModel::data(const QModelIndex& rkIndex, int Role) const
|
||||
{
|
||||
if (rkIndex.row() < rowCount(QModelIndex()))
|
||||
{
|
||||
const CPoiToWorld::SPoiMap *pkMap = mpPoiToWorld->MapByIndex(rkIndex.row());
|
||||
const CPoiToWorld::SPoiMap *pkMap = mpPoiToWorld->MapByIndex(static_cast<size_t>(rkIndex.row()));
|
||||
CScriptObject *pPOI = mpArea->InstanceByID(pkMap->PoiID);
|
||||
|
||||
if (Role == Qt::DisplayRole)
|
||||
|
@ -67,17 +67,17 @@ QVariant CPoiMapModel::data(const QModelIndex& rkIndex, int Role) const
|
|||
|
||||
void CPoiMapModel::AddPOI(CScriptNode *pPOI)
|
||||
{
|
||||
if (!mModelMap.contains(pPOI))
|
||||
{
|
||||
int NewIndex = mpPoiToWorld->NumMappedPOIs();
|
||||
beginInsertRows(QModelIndex(), NewIndex, NewIndex);
|
||||
if (mModelMap.contains(pPOI))
|
||||
return;
|
||||
|
||||
QList<CModelNode*> *pList = new QList<CModelNode*>;
|
||||
mModelMap[pPOI] = pList;
|
||||
mpPoiToWorld->AddPoi(pPOI->Instance()->InstanceID());
|
||||
const int NewIndex = static_cast<int>(mpPoiToWorld->NumMappedPOIs());
|
||||
beginInsertRows(QModelIndex(), NewIndex, NewIndex);
|
||||
|
||||
endInsertRows();
|
||||
}
|
||||
QList<CModelNode*> *pList = new QList<CModelNode*>;
|
||||
mModelMap[pPOI] = pList;
|
||||
mpPoiToWorld->AddPoi(pPOI->Instance()->InstanceID());
|
||||
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void CPoiMapModel::AddMapping(const QModelIndex& rkIndex, CModelNode *pNode)
|
||||
|
@ -142,9 +142,11 @@ bool CPoiMapModel::IsModelMapped(const QModelIndex& rkIndex, CModelNode *pNode)
|
|||
|
||||
CScriptNode* CPoiMapModel::PoiNodePointer(const QModelIndex& rkIndex) const
|
||||
{
|
||||
if ((uint32) rkIndex.row() < mpPoiToWorld->NumMappedPOIs())
|
||||
const auto rowIndex = static_cast<size_t>(rkIndex.row());
|
||||
|
||||
if (rowIndex < mpPoiToWorld->NumMappedPOIs())
|
||||
{
|
||||
const CPoiToWorld::SPoiMap *pkMap = mpPoiToWorld->MapByIndex(rkIndex.row());
|
||||
const CPoiToWorld::SPoiMap *pkMap = mpPoiToWorld->MapByIndex(rowIndex);
|
||||
return mpEditor->Scene()->NodeForInstanceID(pkMap->PoiID);
|
||||
}
|
||||
|
||||
|
@ -180,7 +182,7 @@ void CPoiMapModel::OnMapChange(CWorld*, CGameArea *pArea)
|
|||
}
|
||||
|
||||
// Create internal model map
|
||||
for (uint32 iPoi = 0; iPoi < mpPoiToWorld->NumMappedPOIs(); iPoi++)
|
||||
for (size_t iPoi = 0; iPoi < mpPoiToWorld->NumMappedPOIs(); iPoi++)
|
||||
{
|
||||
const CPoiToWorld::SPoiMap *pkMap = mpPoiToWorld->MapByIndex(iPoi);
|
||||
CScriptNode *pPoiNode = mpEditor->Scene()->NodeForInstanceID(pkMap->PoiID);
|
||||
|
@ -189,10 +191,10 @@ void CPoiMapModel::OnMapChange(CWorld*, CGameArea *pArea)
|
|||
{
|
||||
QList<CModelNode*> *pModelList = new QList<CModelNode*>;
|
||||
|
||||
for (auto it = pkMap->ModelIDs.begin(); it != pkMap->ModelIDs.end(); it++)
|
||||
for (const auto modelID : pkMap->ModelIDs)
|
||||
{
|
||||
if (NodeMap.contains(*it))
|
||||
*pModelList << NodeMap[*it];
|
||||
if (NodeMap.contains(modelID))
|
||||
*pModelList << NodeMap[modelID];
|
||||
}
|
||||
|
||||
mModelMap[pPoiNode] = pModelList;
|
||||
|
|
Loading…
Reference in New Issue