BSPParser
Simple and modern library for parsing the Valve BSP format
Loading...
Searching...
No Matches
prop-accessors.hpp
1#pragma once
2
3#include "../bsp.hpp"
4#include <functional>
5
6namespace BspParser::Accessors {
7 template <typename Visitor>
8 concept StaticPropIteratee = requires(Visitor visitor) {
9 { visitor(std::declval<const Structs::StaticPropV4&>(), std::declval<const char*>()) };
10 { visitor(std::declval<const Structs::StaticPropV5&>(), std::declval<const char*>()) };
11 { visitor(std::declval<const Structs::StaticPropV6&>(), std::declval<const char*>()) };
12 { visitor(std::declval<const Structs::StaticPropV7Multiplayer2013&>(), std::declval<const char*>()) };
13 };
14
21 template <StaticPropIteratee Iteratee> void iterateStaticProps(const Bsp& bsp, Iteratee iteratee) {
22 if (!bsp.staticProps.has_value() || !bsp.staticPropDictionary.has_value()) {
23 return;
24 }
25
26 std::visit(
27 [&bsp, &iteratee](const auto props) {
28 for (const auto& prop : props) {
29 const auto dictionaryIndex = prop.propType;
30 if (dictionaryIndex >= bsp.staticPropDictionary->size()) {
31 // TODO: Generate warning for out of range dictionary indices
32 continue;
33 }
34
35 const auto* const modelPath = bsp.staticPropDictionary.value()[dictionaryIndex].modelName.data();
36 iteratee(prop, modelPath);
37 }
38 },
39 bsp.staticProps.value()
40 );
41 }
42}
Definition: BSPParser.hpp:12
void iterateStaticProps(const Bsp &bsp, Iteratee iteratee)
Definition: prop-accessors.hpp:21
Definition: bsp.hpp:29