mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 10:53:54 +00:00
20da0892ef
Slowly moving through the open-cs errors Good progress in openCS Very good progress on openCS Getting closer with openCS OpenCS compiles and runs! Didn't have time to test it all though ix openMW everything compiles on windows?? Fix gcc Fix Clang
58 lines
1.4 KiB
C++
58 lines
1.4 KiB
C++
#include "idcollection.hpp"
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <utility>
|
|
|
|
#include <apps/opencs/model/world/collection.hpp>
|
|
#include <apps/opencs/model/world/pathgrid.hpp>
|
|
#include <apps/opencs/model/world/record.hpp>
|
|
|
|
#include <components/esm3/loadpgrd.hpp>
|
|
|
|
namespace ESM
|
|
{
|
|
class ESMReader;
|
|
}
|
|
|
|
namespace CSMWorld
|
|
{
|
|
template <>
|
|
int IdCollection<Pathgrid, IdAccessor<Pathgrid>>::load(ESM::ESMReader& reader, bool base)
|
|
{
|
|
Pathgrid record;
|
|
bool isDeleted = false;
|
|
|
|
loadRecord(record, reader, isDeleted);
|
|
|
|
auto id = IdAccessor<Pathgrid>().getId(record);
|
|
int index = this->searchId(id);
|
|
|
|
if (record.mPoints.empty() || record.mEdges.empty())
|
|
isDeleted = true;
|
|
|
|
if (isDeleted)
|
|
{
|
|
if (index == -1)
|
|
{
|
|
// deleting a record that does not exist
|
|
// ignore it for now
|
|
/// \todo report the problem to the user
|
|
return -1;
|
|
}
|
|
|
|
if (base)
|
|
{
|
|
this->removeRows(index, 1);
|
|
return -1;
|
|
}
|
|
|
|
auto baseRecord = std::make_unique<Record<Pathgrid>>(this->getRecord(index));
|
|
baseRecord->mState = RecordBase::State_Deleted;
|
|
this->setRecord(index, std::move(baseRecord));
|
|
return index;
|
|
}
|
|
|
|
return load(record, base, index);
|
|
}
|
|
}
|