Skip to content

Commit

Permalink
Fix x86 compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
Soreepeong committed Dec 30, 2021
1 parent 167ce60 commit 927ad74
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ScratchProject/Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ std::shared_ptr<Sqex::Sqpack::EntryProvider> ToDecompressedEntryProvider(std::sh
}

uint64_t StreamToFile(const Sqex::RandomAccessStream& stream, const Utils::Win32::Handle& file, std::vector<uint8_t>& buffer, uint64_t offset = 0, const std::string& progressPrefix = {}) {
for (size_t pos = 0, pos_ = stream.StreamSize(); pos < pos_;) {
for (uint64_t pos = 0, pos_ = stream.StreamSize(); pos < pos_;) {
std::cout << std::format("{} Save: {:>6.02f}%: {} / {}\n", progressPrefix, pos * 100. / pos_, pos, pos_);
const auto read = stream.ReadStreamPartial(pos, &buffer[0], buffer.size());
const auto read = static_cast<size_t>(stream.ReadStreamPartial(pos, &buffer[0], buffer.size()));
file.Write(offset, std::span(buffer).subspan(0, read));
pos += read;
offset += read;
Expand Down
6 changes: 3 additions & 3 deletions XivAlexanderCommon/Sqex_Sqpack_EntryProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ uint64_t Sqex::Sqpack::LazyFileOpeningEntryProvider::ReadStreamPartial(uint64_t

auto target = std::span(static_cast<char*>(buf), static_cast<size_t>(length));
if (offset < size) {
const auto read = ReadStreamPartial(*m_stream, offset, &target[0], std::min<uint64_t>(size - offset, target.size()));
const auto read = static_cast<size_t>(ReadStreamPartial(*m_stream, offset, &target[0], std::min<uint64_t>(size - offset, target.size())));
target = target.subspan(read);
}
// size ... estimate
const auto remaining = std::min<uint64_t>(estimate - size, target.size());
const auto remaining = static_cast<size_t>(std::min<uint64_t>(estimate - size, target.size()));
std::ranges::fill(target.subspan(0, remaining), 0);
return length - (target.size() - remaining);
}
Expand Down Expand Up @@ -829,7 +829,7 @@ uint64_t Sqex::Sqpack::HotSwappableEntryProvider::ReadStreamPartial(uint64_t off

if (offset < underlyingStreamLength) {
const auto dataTarget = target.subspan(0, static_cast<SSIZE_T>(dataLength));
const auto readLength = underlyingStream.ReadStreamPartial(offset, &dataTarget[0], dataTarget.size_bytes());
const auto readLength = static_cast<size_t>(underlyingStream.ReadStreamPartial(offset, &dataTarget[0], dataTarget.size_bytes()));
if (readLength != dataTarget.size_bytes())
throw std::logic_error(std::format("HotSwappableEntryProvider underlying data read fail: {}", underlyingStream.DescribeState()));
target = target.subspan(readLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ uint64_t Sqex::Texture::ModifiableTextureStream::ReadStreamPartial(uint64_t offs

const auto padInfo = Align(mipmapStream.StreamSize());
if (relativeOffset < mipmapStream.StreamSize()) {
const auto available = std::min(out.size_bytes(), mipmapStream.StreamSize() - relativeOffset);
const auto available = static_cast<size_t>(std::min<uint64_t>(out.size_bytes(), mipmapStream.StreamSize() - relativeOffset));
mipmapStream.ReadStream(relativeOffset, out.data(), available);
out = out.subspan(available);
relativeOffset = 0;
Expand Down

0 comments on commit 927ad74

Please sign in to comment.