Skip to content

Commit

Permalink
TXTFile endian fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
afritz1 committed Dec 21, 2024
1 parent 8f20a76 commit 841a395
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions OpenTESArena/src/Assets/TXTFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "TXTFile.h"

#include "components/debug/Debug.h"
#include "components/utilities/Bytes.h"
#include "components/vfs/manager.hpp"

bool TXTFile::init(const char *filename)
Expand All @@ -22,10 +23,14 @@ bool TXTFile::init(const char *filename)
return false;
}

const uint16_t *srcPixels = reinterpret_cast<const uint16_t*>(src.begin());
const uint8_t *srcPixels = reinterpret_cast<const uint8_t*>(src.begin());

this->pixels.init(TXTFile::WIDTH, TXTFile::HEIGHT);
std::copy(srcPixels, srcPixels + srcPixelCount, this->pixels.begin());
uint16_t *dstPixels = this->pixels.begin();
for (int i = 0; i < srcPixelCount; i++)
{
dstPixels[i] = Bytes::getLE16(srcPixels + (i * 2));
}

return true;
}
Expand Down

0 comments on commit 841a395

Please sign in to comment.