From 8107af25393ea1a0e2e6d5cf36b76e0427bdd115 Mon Sep 17 00:00:00 2001 From: craftablescience Date: Mon, 4 Dec 2023 14:28:51 -0500 Subject: [PATCH] feat: add version checks --- README.md | 7 ++++++- src/structs/VTX.cpp | 4 ++++ src/structs/VVD.cpp | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b351db12..13dcf60a7 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/structs/VTX.cpp b/src/structs/VTX.cpp index 3938f86c8..d137217b8 100644 --- a/src/structs/VTX.cpp +++ b/src/structs/VTX.cpp @@ -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); diff --git a/src/structs/VVD.cpp b/src/structs/VVD.cpp index c029de1c1..9b0ab6eab 100644 --- a/src/structs/VVD.cpp +++ b/src/structs/VVD.cpp @@ -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(); if (checksum != mdl.checksum) {