mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-18 13:12:50 +00:00
Read NiStringPalette and NiBoolData
This commit is contained in:
parent
c79f509652
commit
afea11b70a
@ -392,4 +392,29 @@ void NiPalette::read(NIFStream *nif)
|
||||
colors[i] = nif->getUInt() | alphaMask;
|
||||
}
|
||||
|
||||
void NiStringPalette::read(NIFStream *nif)
|
||||
{
|
||||
unsigned int size = nif->getUInt();
|
||||
if (!size)
|
||||
return;
|
||||
std::vector<char> source;
|
||||
nif->getChars(source, size);
|
||||
if (nif->getUInt() != size)
|
||||
nif->file->warn("Failed size check in NiStringPalette");
|
||||
if (source[source.size()-1] != '\0')
|
||||
source.emplace_back('\0');
|
||||
const char* buffer = source.data();
|
||||
while (static_cast<size_t>(buffer - source.data()) < source.size())
|
||||
{
|
||||
palette.emplace_back(buffer);
|
||||
buffer += palette.back().size() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void NiBoolData::read(NIFStream *nif)
|
||||
{
|
||||
mKeyList = std::make_shared<ByteKeyMap>();
|
||||
mKeyList->read(nif);
|
||||
}
|
||||
|
||||
} // Namespace
|
||||
|
@ -240,5 +240,17 @@ public:
|
||||
void read(NIFStream *nif) override;
|
||||
};
|
||||
|
||||
struct NiStringPalette : public Record
|
||||
{
|
||||
std::vector<std::string> palette;
|
||||
void read(NIFStream *nif) override;
|
||||
};
|
||||
|
||||
struct NiBoolData : public Record
|
||||
{
|
||||
ByteKeyMapPtr mKeyList;
|
||||
void read(NIFStream *nif) override;
|
||||
};
|
||||
|
||||
} // Namespace
|
||||
#endif
|
||||
|
@ -116,6 +116,8 @@ static std::map<std::string,RecordFactoryEntry> makeFactory()
|
||||
factory["NiColorExtraData"] = {&construct <NiVectorExtraData> , RC_NiColorExtraData };
|
||||
factory["NiFloatExtraData"] = {&construct <NiFloatExtraData> , RC_NiFloatExtraData };
|
||||
factory["NiFloatsExtraData"] = {&construct <NiFloatsExtraData> , RC_NiFloatsExtraData };
|
||||
factory["NiStringPalette"] = {&construct <NiStringPalette> , RC_NiStringPalette };
|
||||
factory["NiBoolData"] = {&construct <NiBoolData> , RC_NiBoolData };
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,9 @@ enum RecordType
|
||||
RC_NiVectorExtraData,
|
||||
RC_NiColorExtraData,
|
||||
RC_NiFloatExtraData,
|
||||
RC_NiFloatsExtraData
|
||||
RC_NiFloatsExtraData,
|
||||
RC_NiStringPalette,
|
||||
RC_NiBoolData
|
||||
};
|
||||
|
||||
/// Base class for all records
|
||||
|
@ -143,6 +143,7 @@ class NiAutoNormalParticlesData;
|
||||
class NiPalette;
|
||||
struct NiParticleModifier;
|
||||
struct NiLinesData;
|
||||
struct NiBoolData;
|
||||
|
||||
using NodePtr = RecordPtrT<Node>;
|
||||
using ExtraPtr = RecordPtrT<Extra>;
|
||||
@ -166,6 +167,7 @@ using NiRotatingParticlesDataPtr = RecordPtrT<NiRotatingParticlesData>;
|
||||
using NiAutoNormalParticlesDataPtr = RecordPtrT<NiAutoNormalParticlesData>;
|
||||
using NiPalettePtr = RecordPtrT<NiPalette>;
|
||||
using NiParticleModifierPtr = RecordPtrT<NiParticleModifier>;
|
||||
using NiBoolDataPtr = RecordPtrT<NiBoolData>;
|
||||
|
||||
using NodeList = RecordListT<Node>;
|
||||
using PropertyList = RecordListT<Property>;
|
||||
|
Loading…
x
Reference in New Issue
Block a user