Skip to content

Commit

Permalink
feat: add version checks
Browse files Browse the repository at this point in the history
  • Loading branch information
craftablescience committed Dec 4, 2023
1 parent a7e1dff commit 8107af2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# studiomodelpp
A modern C++ library for sanely parsing Valve's studiomodel formats
A modern C++ library for sanely parsing Valve's studiomodel formats.

Currently supports:
- MDL v44-v49
- VTX v7
- VVD v4
4 changes: 4 additions & 0 deletions src/structs/VTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ bool VTX::open(const std::byte* data, std::size_t size, const MDL::MDL& mdl) {
BufferStream stream{data, size};

stream.read(this->version);
if (this->version != 7) {
return false;
}

stream.read(this->vertexCacheSize);
stream.read(this->maxBonesPerStrip);
stream.read(this->maxBonesPerTriangle);
Expand Down
3 changes: 3 additions & 0 deletions src/structs/VVD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ bool VVD::open(const std::byte* data, std::size_t size, const MDL::MDL& mdl) {
}

stream.read(this->version);
if (this->version != 4) {
return false;
}

int checksum = stream.read<int>();
if (checksum != mdl.checksum) {
Expand Down

0 comments on commit 8107af2

Please sign in to comment.