diff --git a/cmake/CompilerFlags.cmake b/cmake/CompilerFlags.cmake index 887923a..256f730 100644 --- a/cmake/CompilerFlags.cmake +++ b/cmake/CompilerFlags.cmake @@ -13,5 +13,6 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") include(CompilerFlags-GNU) else() - message(FATAL_ERROR "Unsupported (for now?) compiler ${CMAKE_CXX_COMPILER_ID}") + message(WARNING "Unsupported (for now?) compiler ${CMAKE_CXX_COMPILER_ID}. Configuration will continue," + "however this configuration may break at any time.") endif() diff --git a/include/europa/structs/Pak.hpp b/include/europa/structs/Pak.hpp index f216148..33d4833 100644 --- a/include/europa/structs/Pak.hpp +++ b/include/europa/structs/Pak.hpp @@ -25,6 +25,11 @@ namespace europa::structs { Ver5 = 0x5 }; + +#ifdef _MSC_VER + #pragma pack(push, 1) +#endif + struct [[gnu::packed]] PakHeader_Common { char magic[16]; // "Europa Packfile\0" @@ -99,6 +104,7 @@ namespace europa::structs { u32 reservedPad {}; }; + struct [[gnu::packed]] PakHeader_V4 : public PakHeader_Impl { using PakHeader_Impl::PakHeader_Impl; @@ -162,6 +168,11 @@ namespace europa::structs { u8 pad2; }; + +#ifdef _MSC_VER + #pragma pack(pop) +#endif + using PakHeaderVariant = std::variant< structs::PakHeader_V3, structs::PakHeader_V4, diff --git a/include/europa/structs/Yatf.hpp b/include/europa/structs/Yatf.hpp index 598b485..a6beaae 100644 --- a/include/europa/structs/Yatf.hpp +++ b/include/europa/structs/Yatf.hpp @@ -15,6 +15,10 @@ namespace europa::structs { +#ifdef _MSC_VER + #pragma pack(push, 1) +#endif + struct [[gnu::packed]] YatfHeader { enum class TextureFormat : u8 { // V1 formats. @@ -52,6 +56,10 @@ namespace europa::structs { } }; +#ifdef _MSC_VER + #pragma pack(pop) +#endif + } // namespace europa::structs #endif // EUROPA_STRUCTS_YATF_H diff --git a/src/libeuropa/io/pak/Writer.cpp b/src/libeuropa/io/pak/Writer.cpp index ea71382..3268b73 100644 --- a/src/libeuropa/io/pak/Writer.cpp +++ b/src/libeuropa/io/pak/Writer.cpp @@ -86,14 +86,14 @@ namespace europa::io::pak { // Update the offset to where we currently are, since we will be writing the file there file.VisitTocEntry([&](auto& tocEntry) { - tocEntry.offset = os.tellp(); + tocEntry.offset = static_cast(os.tellp()); }); // For sector alignment. if constexpr(THeader::VERSION == structs::PakVersion::Ver5) { if(sectorAlignment == SectorAlignment::Align) { auto& toc = file.GetTOCEntry(); - toc.startLBA = (os.tellp() / util::kCDSectorSize); + toc.startLBA = static_cast((os.tellp() / util::kCDSectorSize)); } } @@ -132,7 +132,7 @@ namespace europa::io::pak { filename }); } - pakHeader.tocOffset = os.tellp(); + pakHeader.tocOffset = static_cast(os.tellp()); sink.OnEvent({ WriterProgressReportSink::PakEvent::EventCode::WritingToc }); @@ -156,7 +156,7 @@ namespace europa::io::pak { sink.OnEvent({ WriterProgressReportSink::PakEvent::EventCode::FillInHeader }); // Fill out the rest of the header. - pakHeader.fileCount = sortedFiles.size(); + pakHeader.fileCount = static_cast(sortedFiles.size()); pakHeader.tocSize = static_cast(os.tellp()) - (pakHeader.tocOffset - 1); // Timestamp. diff --git a/src/tools/eupak/CreateCommand.cpp b/src/tools/eupak/CreateCommand.cpp index 23057f8..3d0f9ed 100644 --- a/src/tools/eupak/CreateCommand.cpp +++ b/src/tools/eupak/CreateCommand.cpp @@ -246,10 +246,15 @@ namespace eupak { // Setup other stuff like modtime file.VisitTocEntry([&](auto& tocEntry) { +#ifdef _WIN32 + auto seconds = std::chrono::time_point_cast(lastModified); + tocEntry.creationUnixTime = static_cast(seconds.time_since_epoch().count()); +#else // Kinda stupid but works auto sys = std::chrono::file_clock::to_sys(lastModified); auto seconds = std::chrono::time_point_cast(sys); tocEntry.creationUnixTime = static_cast(seconds.time_since_epoch().count()); +#endif }); files.emplace_back(std::make_pair(relativePathName, std::move(file))); diff --git a/src/tools/eupak/Utils.cpp b/src/tools/eupak/Utils.cpp index d786ca6..7c644ca 100644 --- a/src/tools/eupak/Utils.cpp +++ b/src/tools/eupak/Utils.cpp @@ -48,7 +48,15 @@ namespace eupak { char buf[1024]{}; tm tmObject{}; +#ifdef _MSC_VER + // All I will choose to say is: Why didn't Microsoft + // just implement _r versions. This is nearly exactly + // the same as those! ... This is why I hate cross-platform + // software development sometimes + localtime_s(&tmObject, &time); +#else localtime_r(&time, &tmObject); +#endif auto count = std::strftime(&buf[0], sizeof(buf), format.data(), &tmObject);