Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:

windows:
name: "Windows"
runs-on: 'windows-latest'
runs-on: 'windows-2022'
steps:
- uses: 'actions/checkout@v3'
with:
Expand All @@ -67,4 +67,4 @@ jobs:
run: 'cmake --build build --config Release -j 2'
- name: 'Test'
working-directory: 'build/'
run: ctest -C Release --output-on-failure -E 'Material.dump'
run: ctest -C Release --output-on-failure -E 'Material.dump'
7 changes: 5 additions & 2 deletions src/ModelScriptDsl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace zenkit {
// registerMesh ("Some_File Name.ASC)
// registerMesh ("Some_File Name.ASC
unsigned char prev = '\0';
while (chr != '"' && chr != '\n') {
while (chr != '"' && chr != '\n' && chr != '\r') {
if (!std::isspace(chr)) prev = chr;
_m_value.push_back(static_cast<char>(chr));
chr = static_cast<unsigned char>(_m_buffer->read_char());
Expand Down Expand Up @@ -373,7 +373,10 @@ namespace zenkit {
into.model_tags.push_back(this->parse_modelTag());
} else {
auto const loc = _m_stream.format_location();
ZKLOGW("ModelScript", "Syntax error (%s): invalid keyword in `aniEnum` block: %s", loc.c_str(), kw.c_str());
ZKLOGW("ModelScript",
"Syntax error (%s): invalid keyword in `aniEnum` block: %s",
loc.c_str(),
kw.c_str());
this->_m_stream.next_line();
}
}
Expand Down
17 changes: 11 additions & 6 deletions src/Stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include <cstring>
#include <fstream>
#ifdef _ZK_WITH_ZIPPED_VDF
#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES
#include <miniz.h>
#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES
#include <miniz.h>
#endif

namespace zenkit {
Expand Down Expand Up @@ -580,8 +580,11 @@ namespace zenkit {
// and a non-zero block size.
if (_m_header.blocks_count == 0 || _m_header.block_size == 0 ||
_m_header.length_uncompressed == 0) {
ZKLOGE("ReadZipped", "Invalid ZippedStream header: length=%u, block_size=%u, blocks_count=%u",
_m_header.length_uncompressed, _m_header.block_size, _m_header.blocks_count);
ZKLOGE("ReadZipped",
"Invalid ZippedStream header: length=%u, block_size=%u, blocks_count=%u",
_m_header.length_uncompressed,
_m_header.block_size,
_m_header.blocks_count);
return false;
}

Expand All @@ -591,8 +594,10 @@ namespace zenkit {
uint32_t expected_blocks =
(_m_header.length_uncompressed + _m_header.block_size - 1) / _m_header.block_size;
if (_m_header.blocks_count != expected_blocks) {
ZKLOGE("ReadZipped", "Block count mismatch: expected %u, got %u", expected_blocks,
_m_header.blocks_count);
ZKLOGE("ReadZipped",
"Block count mismatch: expected %u, got %u",
expected_blocks,
_m_header.blocks_count);
return false;
}

Expand Down
7 changes: 4 additions & 3 deletions src/Vfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "zenkit/Stream.hh"

#ifdef _ZK_WITH_ZIPPED_VDF
#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES
#include <miniz.h>
#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES
#include <miniz.h>
#endif

#include <algorithm>
Expand Down Expand Up @@ -600,7 +600,8 @@ namespace zenkit {
#ifdef _ZK_WITH_ZIPPED_VDF
zipped = true;
#else
throw VfsBrokenDiskError {"Detected compressed VDF (build ZenKit with ZK_ENABLE_ZIPPED_VDF=ON to enable support)"};
throw VfsBrokenDiskError {
"Detected compressed VDF (build ZenKit with ZK_ENABLE_ZIPPED_VDF=ON to enable support)"};
#endif
} else {
ZKLOGW("Vfs", "Unknown volume flags: 0x%X (%u), assuming uncompressed", volume_flags, volume_flags);
Expand Down
22 changes: 21 additions & 1 deletion tests/TestModelScript.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,28 @@
#include <zenkit/ModelScript.hh>
#include <zenkit/Stream.hh>

#include <sstream>

TEST_SUITE("ModelScript") {
TEST_CASE("ModelScript.load line endings") {
for (std::string const eol : {"\n", "\r\n"}) {
CAPTURE(eol.size());
std::istringstream source {"Model (\"test\") {" + eol + "registerMesh(\"Some File(1).asc\")" + eol +
"registerMesh(\"MissingQuote.asc" + eol +
"registerMesh(\"MissingQuoteAndParen.asc)" + eol +
"registerMesh(\"After.asc\")" + eol + "}" + eol};
auto r = zenkit::Read::from(&source);
zenkit::ModelScript script {};
script.load(r.get());

REQUIRE_EQ(script.meshes.size(), 4);
CHECK_EQ(script.meshes[0], "Some File(1).asc");
CHECK_EQ(script.meshes[1], "MissingQuote.asc");
CHECK_EQ(script.meshes[2], "MissingQuoteAndParen.asc");
CHECK_EQ(script.meshes[3], "After.asc");
}
}

TEST_CASE("ModelScript.load(GOTHIC?)") {
zenkit::Logger::set_default(zenkit::LogLevel::INFO);
auto r = zenkit::Read::from("./samples/waran.mds");
Expand Down Expand Up @@ -147,7 +168,6 @@ TEST_SUITE("ModelScript") {
CHECK_EQ(script.animations[2].sfx_ground[0].name, "sfxGrndName");
CHECK_EQ(script.animations[2].sfx_ground[0].empty_slot, false);


CHECK_EQ(script.blends.size(), 3);
CHECK_EQ(script.blends[0].name, "blendName1");
CHECK_EQ(script.blends[0].next, "blendNext1");
Expand Down
Loading