1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 04:23:53 +00:00
openmw/apps/opencs/model/world/infocollection.hpp
elsid 6a3b6c6e4f
Fix handling deleted DIAL records
* Use composite RefId to remove INFO record of deleted DIAL record. OrderedInfo
  stores original RefId while InfoCollection stores composite one.
* Do not erase deleted topic from InfoOrderByTopic map. To keep all deleted
  record ids for InfoCollection::sort call to make sure reorderRowsImp is called
  with correct number of indices.
2023-06-01 23:35:40 +02:00

62 lines
1.5 KiB
C++

#ifndef CSM_WOLRD_INFOCOLLECTION_H
#define CSM_WOLRD_INFOCOLLECTION_H
#include <map>
#include <string>
#include <unordered_map>
#include <vector>
#include "collection.hpp"
#include "info.hpp"
namespace ESM
{
struct Dialogue;
class ESMReader;
template <class T>
class InfoOrder;
}
namespace CSMWorld
{
using InfosRecordPtrByTopic = std::unordered_map<ESM::RefId, std::vector<const Record<Info>*>>;
struct OrderedInfo
{
ESM::RefId mId;
ESM::RefId mNext;
ESM::RefId mPrev;
explicit OrderedInfo(const Info& info)
: mId(info.mOriginalId)
, mNext(info.mNext)
, mPrev(info.mPrev)
{
}
};
using InfoOrder = ESM::InfoOrder<OrderedInfo>;
using InfoOrderByTopic = std::map<ESM::RefId, ESM::InfoOrder<OrderedInfo>>;
class InfoCollection : public Collection<Info>
{
private:
void load(const Info& value, bool base);
public:
void load(ESM::ESMReader& reader, bool base, const ESM::Dialogue& dialogue, InfoOrderByTopic& infoOrder);
void sort(const InfoOrderByTopic& infoOrders);
InfosRecordPtrByTopic getInfosByTopic() const;
int getAppendIndex(const ESM::RefId& id, UniversalId::Type type = UniversalId::Type_None) const override;
bool reorderRows(int baseIndex, const std::vector<int>& newOrder) override;
};
ESM::RefId makeCompositeInfoRefId(const ESM::RefId& topicId, const ESM::RefId& infoId);
}
#endif