diff --git a/.gitignore b/.gitignore
index 9491a2f..21dd653 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,9 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+# Project specific
+*.esm
+
# User-specific files
*.rsuser
*.suo
diff --git a/Navmesher/Navmesher.vcxproj b/Navmesher/Navmesher.vcxproj
index d46de5b..08d21a6 100644
--- a/Navmesher/Navmesher.vcxproj
+++ b/Navmesher/Navmesher.vcxproj
@@ -134,6 +134,7 @@
+
diff --git a/Navmesher/Navmesher.vcxproj.filters b/Navmesher/Navmesher.vcxproj.filters
index f460f1b..b8424dd 100644
--- a/Navmesher/Navmesher.vcxproj.filters
+++ b/Navmesher/Navmesher.vcxproj.filters
@@ -21,6 +21,9 @@
Source Files
+
+ Source Files
+
diff --git a/Navmesher/esx_reader.cpp b/Navmesher/esx_reader.cpp
new file mode 100644
index 0000000..53a59c6
--- /dev/null
+++ b/Navmesher/esx_reader.cpp
@@ -0,0 +1,4 @@
+#include "esx_reader.hpp"
+
+
+
diff --git a/Navmesher/esx_reader.hpp b/Navmesher/esx_reader.hpp
index 31cf7c4..6cac197 100644
--- a/Navmesher/esx_reader.hpp
+++ b/Navmesher/esx_reader.hpp
@@ -7,6 +7,7 @@
#include
#include
#include
+#include
#include "utility.hpp"
@@ -62,11 +63,13 @@ using Node = std::variant;
// Aggregate types
//
+#pragma warning( push )
+#pragma warning( disable : 4514 )
struct FourCC : utility::Store {
constexpr FourCC() noexcept = default;
explicit constexpr FourCC(const char(&str)[5]) noexcept : Store{ utility::fourcc_lit_to_val(str) } { }
};
-static_assert(std::is_trivial_v);
+#pragma warning( pop )
struct FormID : utility::Store { };
struct Timestamp : utility::Store { };
@@ -117,7 +120,6 @@ struct GroupHeader {
VCInfo version_control_information;
uint32_t unknown;
};
-static_assert(sizeof(GroupHeader) == 24);
struct RecordHeader {
struct Flags : utility::Store { };
@@ -132,7 +134,6 @@ struct RecordHeader {
Version version;
uint16_t unknown;
};
-static_assert(sizeof(RecordHeader) == 24);
//
// Classes
diff --git a/Navmesher/main.cpp b/Navmesher/main.cpp
index 2d6fa4d..771345c 100644
--- a/Navmesher/main.cpp
+++ b/Navmesher/main.cpp
@@ -1,7 +1,33 @@
-#include
#include "esx_reader.hpp"
+#include
+#include
+#include
+
+static constexpr auto esm_name = "Skyrim.esm";
+
+/* Propagated Exceptions:
+ * - std::bad_alloc
+ * - std::filesystem::filesystem_error
+ * - std::ios_base::failure
+ */
+[[nodiscard]] static std::ifstream open_esm(void)
+{
+ std::filesystem::path cwd = std::filesystem::current_path();
+ auto esm_path = cwd / esm_name;
+ auto esm_fs = std::ifstream(esm_path, std::ios::binary);
+ if (esm_fs.fail())
+ throw std::ios_base::failure("Could not open the esm file for reading.");
+ return esm_fs;
+}
+
int main()
{
- std::cout << esxr::flag_to_description({ esxr::RecordType::TES4, 0 }).value() << std::endl;
+ auto esm_fs = open_esm();
+ std::array fourcc{};
+ esm_fs.read(fourcc.data(), static_cast(fourcc.size()));
+ for (auto c : fourcc)
+ std::cout << c;
+ std::cout << '\n';
+ return 0;
}
\ No newline at end of file
diff --git a/Navmesher/utility.hpp b/Navmesher/utility.hpp
index 6dc56cc..bb041d5 100644
--- a/Navmesher/utility.hpp
+++ b/Navmesher/utility.hpp
@@ -15,7 +15,7 @@ struct Store {
friend constexpr auto operator<=>(const Store &, const Store &) noexcept = default;
};
-// Convert a fourcc literal (e.g. "LITR" to a uint32_t)
+// Convert a fourcc literal (e.g. "LITR") to a uint32_t
constexpr uint32_t fourcc_lit_to_val(const char(&a)[5]) noexcept
{
char temp[4] = { a[0], a[1], a[2], a[3] };
@@ -31,6 +31,7 @@ constexpr std::array array_builtin_to_std(const T(&builtin)[N]) noexcept
return array;
}
+// Convert a std::array of std::pairs to a std::pair of std::arrays
template
constexpr std::pair, std::array> map_to_soa(std::array, N> map) noexcept
{
@@ -50,7 +51,7 @@ constexpr std::optional soa_first_to_second(const std::pair(index)] };
}
template
@@ -60,7 +61,7 @@ constexpr std::optional soa_second_to_first(const std::pair(index)] };
}
// Used to inspect type sizes and values at compile time. Example: