Browse Source

Fix loading alignment

pull/557/head
Anders Jenbo 6 years ago
parent
commit
5ff5b4893c
  1. 37
      Source/loadsave.cpp
  2. 3
      SourceX/miniwin/misc_io.cpp

37
Source/loadsave.cpp

@ -221,42 +221,49 @@ void CopyChar(const void *src, void *dst)
void CopyShort(const void *src, void *dst)
{
*(unsigned short*)dst = SwapLE16(*(unsigned short*)src);
unsigned short buf;
memcpy(&buf, src, 2);
tbuff += 2;
buf = SwapLE16(buf);
memcpy(dst, &buf, 2);
}
void CopyShorts(const void *src, const int n, void *dst)
{
unsigned short *s=src, *d=dst;
int i=n;
tbuff += 2*n;
while(i) {
*d = SwapLE16(*s);
++d; ++s; --i;
const auto *s = reinterpret_cast<const unsigned short *>(src);
auto *d = reinterpret_cast<unsigned short *>(dst);
for(int i = 0; i < n; i++) {
CopyShort(s, d);
++d; ++s;
}
}
void CopyInt(const void *src, void *dst)
{
*(unsigned int*)dst = SwapLE32(*(unsigned int*)src);
unsigned int buf;
memcpy(&buf, src, 4);
tbuff += 4;
buf = SwapLE32(buf);
memcpy(dst, &buf, 4);
}
void CopyInts(const void *src, const int n, void *dst)
{
unsigned int *s=src, *d=dst;
int i=n;
tbuff += 4*n;
while(i) {
*d = SwapLE32(*s);
++d; ++s; --i;
const auto *s = reinterpret_cast<const unsigned int *>(src);
auto *d = reinterpret_cast<unsigned int *>(dst);
for(int i = 0; i < n; i++) {
CopyInt(s, d);
++d; ++s;
}
}
void CopyInt64(const void *src, void *dst)
{
*(unsigned long long*)dst = SDL_SwapLE64(*(unsigned long long*)src);
unsigned long long buf;
memcpy(&buf, src, 8);
tbuff += 8;
buf = SDL_SwapLE64(buf);
memcpy(dst, &buf, 8);
}
void LoadPlayer(int i)

3
SourceX/miniwin/misc_io.cpp

@ -91,7 +91,8 @@ DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveH
} else if (dwMoveMethod == DVL_FILE_CURRENT) {
file->pos += lDistanceToMove;
} else {
UNIMPLEMENTED();
UNIMPLEMENTED();
}
if (file->buf.size() < file->pos + 1)
file->buf.resize(file->pos + 1);

Loading…
Cancel
Save