Browse Source

Unify including ../types.h everywhere; more fixes

pull/25/head
Xadhoom 7 years ago
parent
commit
0332d81091
  1. 3
      Stub/appfat.cpp
  2. 1
      Stub/capture.cpp
  3. 4
      Stub/diabloui.cpp
  4. 22
      Stub/dthread.cpp
  5. 6
      Stub/dx.cpp
  6. 9
      Stub/dx_stub.h
  7. 2
      Stub/fault.cpp
  8. 4
      Stub/init.cpp
  9. 3
      Stub/main.cpp
  10. 8
      Stub/miniwin.cpp
  11. 18
      Stub/miniwin.h
  12. 7
      Stub/miniwin_io.cpp
  13. 6
      Stub/miniwin_msg_sdl.cpp
  14. 4
      Stub/miniwin_rand.cpp
  15. 13
      Stub/miniwin_sdl.h
  16. 33
      Stub/miniwin_thread.cpp
  17. 1
      Stub/movie.cpp
  18. 80
      Stub/nthread.cpp
  19. 1
      Stub/restrict.cpp
  20. 2
      Stub/sdlrender.cpp
  21. 2
      Stub/sdlrender.h
  22. 6
      Stub/sound.cpp
  23. 1
      Stub/storm.cpp
  24. 4
      Stub/storm_net.cpp
  25. 4
      Stub/stubs.h
  26. 0
      Unused/main_test.cpp
  27. 12
      types.h

3
Stub/appfat.cpp

@ -1,7 +1,4 @@
#include <stdarg.h>
#include "../types.h"
#include "stubs.h"
char empty_string = 0;

1
Stub/capture.cpp

@ -1,5 +1,4 @@
#include "../types.h"
#include "stubs.h"
void __cdecl CaptureScreen()
{

4
Stub/diabloui.cpp

@ -1,8 +1,4 @@
#include <vector>
#include "../types.h"
#include "sdlrender.h"
#include "stubs.h"
char chr_name_str[16];
char hero_names[MAX_CHARACTERS][PLR_NAME_LEN];

22
Stub/dthread.cpp

@ -1,22 +0,0 @@
#include "../types.h"
#include "stubs.h"
void __cdecl dthread_start()
{
DUMMY();
}
void __cdecl dthread_cleanup()
{
DUMMY();
}
void __fastcall dthread_send_delta(int pnum, char cmd, void *pbSrc, int dwLen)
{
DUMMY();
}
void __fastcall dthread_remove_player(int pnum)
{
UNIMPLEMENTED();
}

6
Stub/dx.cpp

@ -1,10 +1,5 @@
#include "dx_stub.h"
#include "miniwin_sdl.h"
#include "../types.h"
#include "stubs.h"
#ifndef NO_GLOBALS
Screen *gpBuffer;
IDirectDraw *lpDDInterface;
@ -14,7 +9,6 @@ IDirectDrawPalette *lpDDPalette;
char gbBackBuf; // unread
char gbEmulate; // unread
#endif
SDL_Window *window;
SDL_Renderer *renderer;

9
Stub/dx_stub.h

@ -1,9 +0,0 @@
#pragma once
/*
extern SDL_Window *window;
extern SDL_Renderer *renderer;
extern SDL_Texture *texture;
extern SDL_Surface *surface;
*/
void sdl_present_surface();

2
Stub/fault.cpp

@ -1,7 +1,5 @@
#include "../types.h"
#include "stubs.h"
LPTOP_LEVEL_EXCEPTION_FILTER __cdecl exception_get_filter()
{
DUMMY();

4
Stub/init.cpp

@ -1,8 +1,4 @@
#include <dirent.h>
#include <string>
#include "../types.h"
#include "stubs.h"
#ifndef NO_GLOBALS
void *diabdat_mpq;

3
Stub/main.cpp

@ -1,7 +1,4 @@
#include <string>
#include "../types.h"
#include "stubs.h"
static std::string build_cmdline(int argc, char **argv)
{

8
Stub/miniwin.cpp

@ -1,10 +1,4 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include "miniwin.h"
#include "stubs.h"
#include "../types.h"
DWORD last_error;

18
Stub/miniwin.h

@ -1,9 +1,10 @@
#pragma once
#include <vector>
#include <ctype.h>
#include <math.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
@ -12,8 +13,7 @@
#include <time.h>
// For _rotr()
#include <x86intrin.h>
#include <SDL_mutex.h>
#include <vector>
// Constants
#define CONST const
@ -286,7 +286,7 @@ typedef struct _LIST_ENTRY {
struct _LIST_ENTRY *Blink;
} LIST_ENTRY, *PLIST_ENTRY;
#if 0
#if 0 //replaced
typedef struct _RTL_CRITICAL_SECTION_DEBUG {
WORD Type;
WORD CreatorBackTraceIndex;
@ -307,14 +307,12 @@ typedef struct {
HANDLE LockSemaphore;
ULONG_PTR SpinCount;
} CRITICAL_SECTION, *LPCRITICAL_SECTION;
#else
typedef SDL_mutex *CRITICAL_SECTION, **LPCRITICAL_SECTION;
#endif
VOID WINAPI InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
VOID WINAPI EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
VOID WINAPI LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
VOID WINAPI DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
#endif
DWORD WINAPI GetTickCount(VOID);
@ -363,6 +361,8 @@ HWND WINAPI FindWindowA(LPCSTR lpClassName, LPCSTR lpWindowName);
#define THREAD_PRIORITY_HIGHEST THREAD_BASE_PRIORITY_MAX
#define THREAD_PRIORITY_ABOVE_NORMAL (THREAD_PRIORITY_HIGHEST - 1)
uintptr_t __cdecl _beginthreadex(void *_Security, unsigned _StackSize, unsigned(__stdcall *_StartAddress)(void *),
void *_ArgList, unsigned _InitFlag, unsigned *_ThrdAddr);
HANDLE WINAPI GetCurrentThread(VOID);
DWORD WINAPI GetCurrentThreadId(VOID);
WINBOOL WINAPI SetThreadPriority(HANDLE hThread, int nPriority);
@ -379,8 +379,6 @@ WINBOOL WINAPI TextOutA(HDC hdc, int x, int y, LPCSTR lpString, int c);
int WINAPI GetDeviceCaps(HDC hdc, int index);
UINT WINAPI GetSystemPaletteEntries(HDC hdc, UINT iStart, UINT cEntries, LPPALETTEENTRY pPalEntries);
uintptr_t __cdecl _beginthreadex(void *_Security, unsigned _StackSize, unsigned(__stdcall *_StartAddress)(void *),
void *_ArgList, unsigned _InitFlag, unsigned *_ThrdAddr);
int WINAPIV wsprintfA(LPSTR, LPCSTR, ...);
#define wsprintf wsprintfA
int __cdecl _strcmpi(const char *_Str1, const char *_Str2);

7
Stub/miniwin_io.cpp

@ -1,9 +1,4 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include "miniwin.h"
#include "stubs.h"
#include "../types.h"
void TranslateFileName(char *dst, int dstLen, const char *src)
{

6
Stub/miniwin_msg_sdl.cpp

@ -2,13 +2,7 @@
* *
* Windows message handling and keyboard event conversion for SDL.
*/
#include <deque>
#include "miniwin_sdl.h"
#include "../types.h"
#include "stubs.h"
PlayerStruct *PlayerS;

4
Stub/miniwin_rand.cpp

@ -2,9 +2,7 @@
*
* An implementation of the MSVCRT random number generator for codec_encode().
*/
#include "miniwin.h"
#include "stubs.h"
#include "../types.h"
unsigned int rand_state = 1;

13
Stub/miniwin_sdl.h

@ -1,7 +1,14 @@
#pragma once
#include <assert.h>
#include <stdarg.h>
#include <dirent.h>
#include <vector>
#include <deque>
#include <string>
#include <functional>
#include <iostream>
#include <utility>
#include <SDL2/SDL.h>
//#include <SDL_image.h>
@ -9,6 +16,12 @@
#include <SDL_thread.h>
//#include "SDL_FontCache.h"
typedef SDL_mutex *CRITICAL_SECTION, **LPCRITICAL_SECTION;
VOID WINAPI InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
VOID WINAPI EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
VOID WINAPI LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
VOID WINAPI DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
#define SDL_CHECK(e) assert(e == 0)
extern SDL_Window *window;

33
Stub/miniwin_thread.cpp

@ -1,7 +1,4 @@
#include "miniwin_sdl.h"
#include "../types.h"
#include "stubs.h"
struct event_emul {
SDL_mutex *mutex;
@ -23,20 +20,22 @@ uintptr_t __cdecl _beginthreadex(void *_Security, unsigned _StackSize, unsigned(
return (uintptr_t)ret;
}
HANDLE WINAPI GetCurrentThread(VOID)
DWORD WINAPI GetCurrentThreadId(VOID)
{
DUMMY_ONCE();
return NULL;
// DWORD is compatible with SDL_threadID
return SDL_GetThreadID(NULL);
}
DWORD WINAPI GetCurrentThreadId(VOID)
HANDLE WINAPI GetCurrentThread(VOID)
{
return SDL_GetThreadID(NULL);
// Only used for SetThreadPriority, which is unimplemented
return NULL;
}
WINBOOL WINAPI SetThreadPriority(HANDLE hThread, int nPriority)
{
DUMMY_ONCE();
// SDL cannot set the priority of the non-current thread
// (and e.g. unprivileged processes on Linux cannot increase it)
return TRUE;
}
@ -64,14 +63,16 @@ VOID WINAPI DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
HANDLE WINAPI CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, WINBOOL bManualReset, WINBOOL bInitialState,
LPCSTR lpName)
{
if(lpEventAttributes != NULL)
UNIMPLEMENTED();
if(bManualReset != TRUE) {
// This is used by diablo.cc to check whether
// the game is already running.
// We allow multiple instances anyway.
if(lpName != NULL && !strcmp(lpName, "DiabloEvent")) {
// This is used by diablo.cpp to check whether
// the game is already running
// (we do not want to replicate this behaviour anyway)
return NULL;
}
if(lpEventAttributes != NULL)
UNIMPLEMENTED();
if(bManualReset != TRUE)
UNIMPLEMENTED();
if(bInitialState != FALSE)
UNIMPLEMENTED();
if(lpName != NULL)
@ -112,6 +113,6 @@ DWORD WINAPI WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
ret = SDL_CondWaitTimeout(e->cond, e->mutex, dwMilliseconds);
SDL_CondSignal(e->cond);
SDL_UnlockMutex(e->mutex);
return ret; // return value not meaningful
return ret; // return value different from WinAPI
}

1
Stub/movie.cpp

@ -1,5 +1,4 @@
#include "../types.h"
#include "stubs.h"
#ifndef NO_GLOBALS
BOOL loop_movie;

80
Stub/nthread.cpp

@ -1,80 +0,0 @@
#include <algorithm>
#include "../types.h"
#include "stubs.h"
#ifndef NO_GLOBALS
int gdwNormalMsgSize;
int gdwLargestMsgSize;
int gdwMsgLenTbl[4];
int glpMsgTbl[4];
DWORD gdwTurnsInTransit;
char byte_679704;
#endif
void __fastcall nthread_start(BOOLEAN set_turn_upper_bit)
{
DUMMY();
byte_679704 = 1;
gdwTurnsInTransit = 1;
gdwLargestMsgSize = 496;
gdwNormalMsgSize = 496;
}
void __cdecl nthread_cleanup()
{
DUMMY();
}
void __fastcall nthread_terminate_game(const char *pszFcn)
{
UNIMPLEMENTED();
}
void __fastcall nthread_ignore_mutex(BOOL bStart)
{
DUMMY();
}
BOOL __fastcall nthread_has_500ms_passed(BOOL unused)
{
DUMMY_ONCE();
return TRUE;
}
DWORD last_frame_time = 0;
const int MSEC_PER_FRAME = 1000 / 35;
static void frame_rate_limiter()
{
if (last_frame_time) {
int elapsed = GetTickCount() - last_frame_time;
int remaining = MSEC_PER_FRAME - elapsed;
if (remaining > 0) {
Sleep(std::max(remaining, MSEC_PER_FRAME));
}
}
last_frame_time = GetTickCount();
}
int __fastcall nthread_send_and_recv_turn(int cur_turn, int turn_delta)
{
DUMMY_ONCE();
// DUMMY_PRINT("cur_turn: %d turn_delta: %d", cur_turn, turn_delta);
frame_rate_limiter();
return 1;
}
void __cdecl nthread_set_turn_upper_bit()
{
UNIMPLEMENTED();
}
int __fastcall nthread_recv_turns(int *pfSendAsync)
{
DUMMY_ONCE();
*pfSendAsync = 0;
return TRUE;
}

1
Stub/restrict.cpp

@ -1,5 +1,4 @@
#include "../types.h"
#include "stubs.h"
BOOL __cdecl RestrictedTest()
{

2
Stub/sdlrender.cpp

@ -1,6 +1,4 @@
#include "../types.h"
#include "miniwin_sdl.h"
#include "stubs.h"
int SCREEN_WIDTH = 640;
int SCREEN_HEIGHT = 480;

2
Stub/sdlrender.h

@ -111,5 +111,5 @@ void RenderDefaultStats(int HeroClass);
void DrawPreGameOptions(int HeroClass, int ShowClasses);
void DrawPreGameDifficultySelection(int HeroClass, int ShowClasses);
int GetCenterOffset(int w, int bw = 0);
void DrawPCXString(int x, int y, int w, int h, char *str, BYTE *font, void *pBuff);
void DrawPCXString(int x, int y, int w, int h, BYTE *str, BYTE *font, void *pBuff);
void DrawArtWithMask(int SX, int SY, int SW, int SH, int nFrame, BYTE bMask, void *pBuffer);

6
Stub/sound.cpp

@ -1,10 +1,4 @@
#include "../types.h"
#include "stubs.h"
//#include <SDL_image.h>
#include <SDL_mixer.h>
#include <functional>
#include <iostream>
#include <utility>
/*
#ifndef NO_GLOBALS

1
Stub/storm.cpp

@ -1,5 +1,4 @@
#include "../types.h"
#include "stubs.h"
DWORD nLastError = 0;

4
Stub/storm_net.cpp

@ -2,11 +2,7 @@
*
* A minimal implementation of the Storm network stack necessary for local play.
*/
#include <deque>
#include <string>
#include "../types.h"
#include "stubs.h"
struct StubMessage {
int playerid;

4
Stub/stubs.h

@ -1,9 +1,7 @@
#pragma once
#include "miniwin_sdl.h"
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

0
Stub/main_test.cpp → Unused/main_test.cpp

12
types.h

@ -7,14 +7,10 @@
#ifdef MINIWIN
#include "miniwin.h"
#include <SDL2/SDL.h>
#include <SDL_mixer.h>
#endif
#ifdef ANDROID
#include "miniwin.h"
#include <SDL.h>
#include <SDL_mixer.h>
#include "miniwin_sdl.h"
#include "stubs.h"
#include "sdlrender.h"
#include "sound.h"
#endif
#ifdef __WIN32__

Loading…
Cancel
Save