*: "Support" MSVC
For Windows builds of EuropaTools. For now I'm using MSVC since clang completely barfs.
This commit is contained in:
parent
6faa960753
commit
f5d03cfdeb
6 changed files with 38 additions and 5 deletions
|
@ -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()
|
||||
|
|
|
@ -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<PakHeader_V4, PakVersion::Ver4> {
|
||||
using PakHeader_Impl<PakHeader_V4, PakVersion::Ver4>::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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<std::uint32_t>(os.tellp());
|
||||
});
|
||||
|
||||
// For sector alignment.
|
||||
if constexpr(THeader::VERSION == structs::PakVersion::Ver5) {
|
||||
if(sectorAlignment == SectorAlignment::Align) {
|
||||
auto& toc = file.GetTOCEntry<structs::PakHeader_V5::TocEntry_SectorAligned>();
|
||||
toc.startLBA = (os.tellp() / util::kCDSectorSize);
|
||||
toc.startLBA = static_cast<std::uint32_t>((os.tellp() / util::kCDSectorSize));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ namespace europa::io::pak {
|
|||
filename });
|
||||
}
|
||||
|
||||
pakHeader.tocOffset = os.tellp();
|
||||
pakHeader.tocOffset = static_cast<std::uint32_t>(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<std::uint32_t>(sortedFiles.size());
|
||||
pakHeader.tocSize = static_cast<std::uint32_t>(os.tellp()) - (pakHeader.tocOffset - 1);
|
||||
|
||||
// Timestamp.
|
||||
|
|
|
@ -246,10 +246,15 @@ namespace eupak {
|
|||
|
||||
// Setup other stuff like modtime
|
||||
file.VisitTocEntry([&](auto& tocEntry) {
|
||||
#ifdef _WIN32
|
||||
auto seconds = std::chrono::time_point_cast<std::chrono::seconds>(lastModified);
|
||||
tocEntry.creationUnixTime = static_cast<std::uint32_t>(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<std::chrono::seconds>(sys);
|
||||
tocEntry.creationUnixTime = static_cast<std::uint32_t>(seconds.time_since_epoch().count());
|
||||
#endif
|
||||
});
|
||||
|
||||
files.emplace_back(std::make_pair(relativePathName, std::move(file)));
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue