Browse Source

Remove more old save game format code

Multiplayer save games from before 1.08 where using the system name as
the password, so they would need to be converted on the original machine
by 1.08-1.09b before they can be transfered to another system.
pull/523/head
Anders Jenbo 6 years ago
parent
commit
e577f9bdc7
  1. 25
      Source/pfile.cpp
  2. 1
      SourceS/miniwin.h
  3. 5
      SourceS/miniwin/com.h
  4. 12
      SourceS/miniwin/com_macro.h
  5. 2
      SourceS/miniwin/misc.h
  6. 2
      SourceS/miniwin/misc_macro.h
  7. 1
      SourceX/dx.cpp
  8. 8
      SourceX/miniwin/misc.cpp
  9. 6
      SourceX/miniwin/thread.cpp

25
Source/pfile.cpp

@ -216,7 +216,6 @@ BOOL pfile_ui_set_hero_infos(BOOL(*ui_add_hero_info)(_uiheroinfo *))
BOOL pfile_read_hero(HANDLE archive, PkPlayerStruct *pPack)
{
HANDLE file;
BOOL decoded;
DWORD dwlen, nSize;
BYTE *buf;
@ -235,16 +234,8 @@ BOOL pfile_read_hero(HANDLE archive, PkPlayerStruct *pPack)
DWORD read;
buf = DiabloAllocPtr(dwlen);
if (SFileReadFile(file, buf, dwlen, &read, NULL)) {
decoded = TRUE;
read = codec_decode(buf, dwlen, password);
if (!read && gbMaxPlayers > 1) {
GetComputerName(password, &nSize);
if (SFileSetFilePointer(file, 0, NULL, FILE_BEGIN) || !SFileReadFile(file, buf, dwlen, &read, NULL))
decoded = FALSE;
else
read = codec_decode(buf, dwlen, password);
}
if (decoded && read == sizeof(*pPack)) {
if (read == sizeof(*pPack)) {
memcpy(pPack, buf, sizeof(*pPack));
ret = TRUE;
}
@ -571,19 +562,7 @@ BYTE *pfile_read(const char *pszName, DWORD *pdwLen)
*pdwLen = codec_decode(buf, *pdwLen, password);
if (*pdwLen == 0) {
// BUGFIFX: *pdwLen has already been overwritten with zero and the savefile has been closed
// there is no way this can work correctly
if (gbMaxPlayers > 1) {
GetComputerName(password, &nSize);
if (SFileSetFilePointer(save, 0, NULL, FILE_BEGIN))
app_fatal("Unable to read save file");
if (!SFileReadFile(save, buf, *pdwLen, &nread, NULL))
app_fatal("Unable to read save file");
*pdwLen = codec_decode(buf, *pdwLen, password);
}
if (*pdwLen == 0)
app_fatal("Invalid save file");
app_fatal("Invalid save file");
}
}
return buf;

1
SourceS/miniwin.h

@ -33,5 +33,4 @@
#endif
#ifdef DEVILUTION_ENGINE
#include "miniwin/misc_macro.h"
#include "miniwin/com_macro.h"
#endif

5
SourceS/miniwin/com.h

@ -12,11 +12,6 @@ struct IDirectSoundBuffer {
typedef IDirectSoundBuffer *LPDIRECTSOUNDBUFFER;
const auto DVL_DS_OK = 0;
const auto DVL_ERROR_SUCCESS = 0L;
const auto DVL_DSBSTATUS_PLAYING = 0x00000001;
constexpr auto DVL_SW_HIDE = 0;
constexpr auto DVL_SW_SHOWNORMAL = 1;
} // namespace dvl

12
SourceS/miniwin/com_macro.h

@ -1,12 +0,0 @@
#pragma once
#define SW_HIDE DVL_SW_HIDE
#define SW_SHOWNORMAL DVL_SW_SHOWNORMAL
#define E_FAIL DVL_E_FAIL
#define S_OK DVL_S_OK
#define DDBLTFAST_WAIT 0x00000010
#define ERROR_SUCCESS DVL_ERROR_SUCCESS
#define DS_OK DVL_DS_OK

2
SourceS/miniwin/misc.h

@ -204,7 +204,6 @@ bool SpawnWindow(LPCSTR lpWindowName, int nWidth, int nHeight);
uintptr_t DVL_beginthreadex(void *_Security, unsigned _StackSize, unsigned(*_StartAddress)(void *),
void *_ArgList, unsigned _InitFlag, unsigned *_ThrdAddr);
HANDLE GetCurrentThread();
DWORD GetCurrentThreadId();
WINBOOL SetThreadPriority(HANDLE hThread, int nPriority);
void Sleep(DWORD dwMilliseconds);
@ -330,7 +329,6 @@ HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
WINBOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverlapped);
DWORD GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh);
WINBOOL GetComputerNameA(LPSTR lpBuffer, LPDWORD nSize);
WINBOOL DeleteFileA(LPCSTR lpFileName);
typedef struct _CONTEXT {

2
SourceS/miniwin/misc_macro.h

@ -50,6 +50,7 @@
#define OPEN_EXISTING DVL_OPEN_EXISTING
#define OPEN_ALWAYS 4
#define ERROR_FILE_NOT_FOUND DVL_ERROR_FILE_NOT_FOUND
#define ERROR_SUCCESS DVL_ERROR_SUCCESS
#define FILE_ATTRIBUTE_NORMAL 128
#define FILE_ATTRIBUTE_HIDDEN 0x00000002
#define FILE_ATTRIBUTE_SYSTEM 0x00000004
@ -94,7 +95,6 @@
#define GetFileAttributes GetFileAttributesA
#define SetFileAttributes SetFileAttributesA
#define CreateFile CreateFileA
#define GetComputerName GetComputerNameA
#define DeleteFile DeleteFileA
#define GWL_STYLE (-16)

1
SourceX/dx.cpp

@ -1,7 +1,6 @@
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
#include "miniwin/ddraw.h"
#include "miniwin/com_macro.h"
#include <SDL.h>
namespace dvl {

8
SourceX/miniwin/misc.cpp

@ -92,14 +92,6 @@ void Sleep(DWORD dwMilliseconds)
SDL_Delay(dwMilliseconds);
}
WINBOOL GetComputerNameA(LPSTR lpBuffer, LPDWORD nSize)
{
DUMMY();
strncpy(lpBuffer, "localhost", *nSize);
*nSize = strlen(lpBuffer);
return true;
}
WINBOOL DeleteFileA(LPCSTR lpFileName)
{
char name[DVL_MAX_PATH];

6
SourceX/miniwin/thread.cpp

@ -57,12 +57,6 @@ DWORD GetCurrentThreadId()
return SDL_GetThreadID(NULL);
}
HANDLE GetCurrentThread()
{
// Only used for SetThreadPriority, which is unimplemented
return NULL;
}
WINBOOL SetThreadPriority(HANDLE hThread, int nPriority)
{
// SDL cannot set the priority of the non-current thread

Loading…
Cancel
Save