diff --git a/CMakeLists.txt b/CMakeLists.txt index d10c1741b..0d0a181a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.13) include(CMake/out_of_tree.cmake) @@ -64,7 +64,7 @@ add_library(Radon STATIC 3rdParty/Radon/Radon/source/Named.cpp 3rdParty/Radon/Radon/source/Section.cpp) -add_library(StormLib STATIC +add_library(StormLib OBJECT 3rdParty/StormLib/src/FileStream.cpp 3rdParty/StormLib/src/SBaseCommon.cpp 3rdParty/StormLib/src/SBaseFileTable.cpp @@ -77,11 +77,11 @@ add_library(StormLib STATIC 3rdParty/StormLib/src/SFileOpenFileEx.cpp 3rdParty/StormLib/src/SFileReadFile.cpp) -add_library(PKWare STATIC +add_library(PKWare OBJECT 3rdParty/PKWare/explode.cpp 3rdParty/PKWare/implode.cpp) -add_library(devilution STATIC +add_library(devilution OBJECT Source/appfat.cpp Source/automap.cpp Source/capture.cpp @@ -183,10 +183,10 @@ add_executable(devilutionx target_include_directories(devilutionx PRIVATE SourceS SourceX 3rdParty/asio/include .) -target_link_libraries(devilution PUBLIC PKWare Threads::Threads) - +target_link_libraries(devilution PRIVATE Threads::Threads) target_link_libraries(devilutionx PRIVATE devilution + PKWare StormLib smacker Radon @@ -215,6 +215,10 @@ if(DIST) target_link_libraries(devilutionx PUBLIC -static-libgcc -static-libstdc++) endif() +if(WIN32) + target_link_libraries(devilutionx PRIVATE wsock32 ws2_32 wininet) +endif() + # Note: In Debug mode, GCC generates spurious memory references that upset Valgrind, # these options fix that. target_compile_options(devilution PUBLIC $<$:-fno-omit-frame-pointer>) diff --git a/SourceS/miniwin.h b/SourceS/miniwin.h index d4cc66db3..664b28e54 100644 --- a/SourceS/miniwin.h +++ b/SourceS/miniwin.h @@ -26,16 +26,6 @@ #define NO_ERROR 0 -// Remove calling conventions (original calling conventions confuse address-sanitizer and aren't supported by all compilers) -#define __cdecl -#define __fastcall -#define __stdcall -#define CALLBACK -#define APIENTRY -#define WINAPI -#define WINAPIV -#define WINUSERAPI - #ifndef _WIN32 #define __int8 char #define __int16 short diff --git a/SourceS/miniwin_popdecl.h b/SourceS/miniwin_popdecl.h new file mode 100644 index 000000000..d9100298e --- /dev/null +++ b/SourceS/miniwin_popdecl.h @@ -0,0 +1,10 @@ +#ifndef DEVILUTION_ENGINE +#pragma pop_macro("__cdecl") +#pragma pop_macro("__fastcall") +#pragma pop_macro("__stdcall") +#pragma pop_macro("CALLBACK") +#pragma pop_macro("APIENTRY") +#pragma pop_macro("WINAPI") +#pragma pop_macro("WINAPIV") +#pragma pop_macro("WINUSERAPI") +#endif diff --git a/SourceS/miniwin_pushdecl.h b/SourceS/miniwin_pushdecl.h new file mode 100644 index 000000000..6408146b2 --- /dev/null +++ b/SourceS/miniwin_pushdecl.h @@ -0,0 +1,19 @@ +#ifndef DEVILUTION_ENGINE +#pragma push_macro("__cdecl") +#pragma push_macro("__fastcall") +#pragma push_macro("__stdcall") +#pragma push_macro("CALLBACK") +#pragma push_macro("APIENTRY") +#pragma push_macro("WINAPI") +#pragma push_macro("WINAPIV") +#pragma push_macro("WINUSERAPI") +#endif + +#define __cdecl +#define __fastcall +#define __stdcall +#define CALLBACK +#define APIENTRY +#define WINAPI +#define WINAPIV +#define WINUSERAPI diff --git a/SourceX/DiabloUI/credits.cpp b/SourceX/DiabloUI/credits.cpp index 85318fd46..1dd681b44 100644 --- a/SourceX/DiabloUI/credits.cpp +++ b/SourceX/DiabloUI/credits.cpp @@ -527,7 +527,7 @@ void credts_Render() } } -BOOL __stdcall UiCreditsDialog(int a1) +BOOL UiCreditsDialog(int a1) { credts_Load(); diff --git a/SourceX/DiabloUI/diabloui.cpp b/SourceX/DiabloUI/diabloui.cpp index 07e0e41ba..3494f047b 100644 --- a/SourceX/DiabloUI/diabloui.cpp +++ b/SourceX/DiabloUI/diabloui.cpp @@ -14,10 +14,10 @@ Art ArtBackground; Art ArtCursor; Art ArtHero; -void(__stdcall *gfnSoundFunction)(char *file); -void(__stdcall *gfnListFocus)(int value); -void(__stdcall *gfnListSelect)(int value); -void(__stdcall *gfnListEsc)(); +void(*gfnSoundFunction)(char *file); +void(*gfnListFocus)(int value); +void(*gfnListSelect)(int value); +void(*gfnListEsc)(); UI_Item *gUiItems; int gUiItemCnt; bool UiItemsWraps; @@ -121,7 +121,7 @@ BOOL SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, return TRUE; } -void __cdecl UiDestroy() +void UiDestroy() { DUMMY(); mem_free_dbg(ArtHero.data); @@ -131,7 +131,7 @@ void __cdecl UiDestroy() font = NULL; } -void UiInitList(int min, int max, void(__stdcall *fnFocus)(int value), void(__stdcall *fnSelect)(int value), void(__stdcall *fnEsc)(), UI_Item *items, int itemCnt, bool itemsWraps) +void UiInitList(int min, int max, void(*fnFocus)(int value), void(*fnSelect)(int value), void(*fnEsc)(), UI_Item *items, int itemCnt, bool itemsWraps) { SelectedItem = min; SelectedItemMin = min; @@ -392,7 +392,7 @@ void UiInitialize() InitFont(); } -int __cdecl UiProfileGetString() +int UiProfileGetString() { DUMMY(); return 0; @@ -400,7 +400,7 @@ int __cdecl UiProfileGetString() char connect_plrinfostr[128]; char connect_categorystr[128]; -void __stdcall UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, DWORD type) +void UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, DWORD type) { DUMMY(); SStrCopy(connect_plrinfostr, infostr, 128); @@ -423,17 +423,17 @@ void __stdcall UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, DWORD type) pInfo->spawned); } -BOOL __stdcall UiCopyProtError(int *pdwResult) +BOOL UiCopyProtError(int *pdwResult) { UNIMPLEMENTED(); } -void __stdcall UiAppActivate(BOOL bActive) +void UiAppActivate(BOOL bActive) { DUMMY(); } -BOOL __fastcall UiValidPlayerName(char *name) +BOOL UiValidPlayerName(char *name) { if (!strlen(name)) return FALSE; @@ -448,59 +448,59 @@ BOOL __fastcall UiValidPlayerName(char *name) return TRUE; } -void __cdecl UiProfileCallback() +void UiProfileCallback() { UNIMPLEMENTED(); } -void __cdecl UiProfileDraw() +void UiProfileDraw() { UNIMPLEMENTED(); } -BOOL __stdcall UiCategoryCallback(int a1, int a2, int a3, int a4, int a5, _DWORD *a6, _DWORD *a7) +BOOL UiCategoryCallback(int a1, int a2, int a3, int a4, int a5, _DWORD *a6, _DWORD *a7) { UNIMPLEMENTED(); } -BOOL __stdcall UiGetDataCallback(int game_type, int data_code, void *a3, int a4, int a5) +BOOL UiGetDataCallback(int game_type, int data_code, void *a3, int a4, int a5) { UNIMPLEMENTED(); } -BOOL __stdcall UiAuthCallback(int a1, char *a2, char *a3, char a4, char *a5, LPSTR lpBuffer, int cchBufferMax) +BOOL UiAuthCallback(int a1, char *a2, char *a3, char a4, char *a5, LPSTR lpBuffer, int cchBufferMax) { UNIMPLEMENTED(); } -BOOL __stdcall UiSoundCallback(int a1, int type, int a3) +BOOL UiSoundCallback(int a1, int type, int a3) { UNIMPLEMENTED(); } -void __stdcall UiMessageBoxCallback(HWND hWnd, char *lpText, LPCSTR lpCaption, UINT uType) +void UiMessageBoxCallback(HWND hWnd, char *lpText, LPCSTR lpCaption, UINT uType) { UNIMPLEMENTED(); } -BOOL __stdcall UiDrawDescCallback(int game_type, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, +BOOL UiDrawDescCallback(int game_type, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, HDC *a8) { UNIMPLEMENTED(); } -BOOL __stdcall UiCreateGameCallback(int a1, int a2, int a3, int a4, int a5, int a6) +BOOL UiCreateGameCallback(int a1, int a2, int a3, int a4, int a5, int a6) { UNIMPLEMENTED(); } -BOOL __stdcall UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, void *pBuffer, +BOOL UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, void *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp) { UNIMPLEMENTED(); } -BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, DWORD mode, char *desc) +BOOL UiCreatePlayerDescription(_uiheroinfo *info, DWORD mode, char *desc) { char format[32] = ""; strncpy(format, (char *)&mode, 4); diff --git a/SourceX/DiabloUI/diabloui.h b/SourceX/DiabloUI/diabloui.h index 5b5875a9d..5ddbddfd4 100644 --- a/SourceX/DiabloUI/diabloui.h +++ b/SourceX/DiabloUI/diabloui.h @@ -96,7 +96,7 @@ constexpr size_t size(T (&)[N]) return N; } -extern void(__stdcall *gfnSoundFunction)(char *file); +extern void(*gfnSoundFunction)(char *file); bool IsInsideRect(const SDL_Event *event, const SDL_Rect *rect); void UiFadeIn(int steps = 16); @@ -113,7 +113,7 @@ void LoadMaskedArtFont(char *pszFile, Art *art, int frames, int mask = 250); void SetMenu(int MenuId); void UiFocusNavigationSelect(); void UiFocusNavigationEsc(); -void UiInitList(int min, int max, void(__stdcall *fnFocus)(int value), void(__stdcall *fnSelect)(int value), void(__stdcall *fnEsc)(), UI_Item *items, int size, bool wraps = false); +void UiInitList(int min, int max, void(*fnFocus)(int value), void(*fnSelect)(int value), void(*fnEsc)(), UI_Item *items, int size, bool wraps = false); void UiRender(); void UiRenderItems(UI_Item *items, int size); void WordWrap(UI_Item *item); diff --git a/SourceX/DiabloUI/mainmenu.cpp b/SourceX/DiabloUI/mainmenu.cpp index 245613f96..75f462d19 100644 --- a/SourceX/DiabloUI/mainmenu.cpp +++ b/SourceX/DiabloUI/mainmenu.cpp @@ -23,7 +23,7 @@ void mainmenu_Esc() UiMainMenuSelect(MAINMENU_EXIT_DIABLO); } -void mainmenu_Load(char *name, void(__stdcall *fnSound)(char *file)) +void mainmenu_Load(char *name, void(*fnSound)(char *file)) { gfnSoundFunction = fnSound; MAINMENU_DIALOG[6].caption = name; @@ -44,7 +44,7 @@ void mainmenu_Free() ArtBackground.data = NULL; } -BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void(__stdcall *fnSound)(char *file), int a4) +BOOL UiMainMenuDialog(char *name, int *pdwResult, void(*fnSound)(char *file), int a4) { mainmenu_Load(name, fnSound); diff --git a/SourceX/DiabloUI/progress.cpp b/SourceX/DiabloUI/progress.cpp index 822de8081..a9dc261df 100644 --- a/SourceX/DiabloUI/progress.cpp +++ b/SourceX/DiabloUI/progress.cpp @@ -68,7 +68,7 @@ void progress_Render(BYTE progress) } } -int __stdcall UiProgressDialog(HWND window, char *msg, int enable, int(__cdecl *fnfunc)(), int rate) +int UiProgressDialog(HWND window, char *msg, int enable, int(*fnfunc)(), int rate) { progress_Load(msg); diff --git a/SourceX/DiabloUI/selconn.cpp b/SourceX/DiabloUI/selconn.cpp index fb35dc168..d1fbae511 100644 --- a/SourceX/DiabloUI/selconn.cpp +++ b/SourceX/DiabloUI/selconn.cpp @@ -98,7 +98,7 @@ void selconn_Select(int value) selconn_Load(); } -int __stdcall UiSelectProvider( +int UiSelectProvider( int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, diff --git a/SourceX/DiabloUI/selgame.cpp b/SourceX/DiabloUI/selgame.cpp index 2f85fddd5..2abcd5215 100644 --- a/SourceX/DiabloUI/selgame.cpp +++ b/SourceX/DiabloUI/selgame.cpp @@ -206,7 +206,7 @@ void selgame_Password_Esc() selgame_GameSelection_Select(selgame_selectedGame); } -int __stdcall UiSelectGame(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, +int UiSelectGame(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, _SNETVERSIONDATA *file_info, int *playerId) { gdwPlayerId = playerId; diff --git a/SourceX/DiabloUI/selhero.cpp b/SourceX/DiabloUI/selhero.cpp index 8b2e10fd6..99525ba9a 100644 --- a/SourceX/DiabloUI/selhero.cpp +++ b/SourceX/DiabloUI/selhero.cpp @@ -15,9 +15,9 @@ int selhero_result; bool selhero_endMenu; bool isMultiPlayer; -BOOL(__stdcall *gfnHeroStats) +BOOL(*gfnHeroStats) (unsigned int, _uidefaultstats *); -BOOL(__stdcall *gfnHeroCreate) +BOOL(*gfnHeroCreate) (_uiheroinfo *); UI_Item SELHERO_DIALOG[] = { @@ -212,7 +212,7 @@ void selhero_Load_Select(int value) selhero_result = NEW_GAME; } -BOOL __stdcall SelHero_GetHeroInfo(_uiheroinfo *pInfo) +BOOL SelHero_GetHeroInfo(_uiheroinfo *pInfo) { heros[selhero_SaveCount] = *pInfo; selhero_SaveCount++; @@ -221,9 +221,9 @@ BOOL __stdcall SelHero_GetHeroInfo(_uiheroinfo *pInfo) } BOOL UiSelHeroDialog( - BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *)), - BOOL(__stdcall *fncreate)(_uiheroinfo *), - BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *), + BOOL(*fninfo)(BOOL(*fninfofunc)(_uiheroinfo *)), + BOOL(*fncreate)(_uiheroinfo *), + BOOL(*fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, char *name) { @@ -255,11 +255,11 @@ BOOL UiSelHeroDialog( return TRUE; } -BOOL __stdcall UiSelHeroSingDialog( - BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *)), - BOOL(__stdcall *fncreate)(_uiheroinfo *), - BOOL(__stdcall *fnremove)(_uiheroinfo *), - BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *), +BOOL UiSelHeroSingDialog( + BOOL(*fninfo)(BOOL(*fninfofunc)(_uiheroinfo *)), + BOOL(*fncreate)(_uiheroinfo *), + BOOL(*fnremove)(_uiheroinfo *), + BOOL(*fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, char *name, int *difficulty) @@ -268,11 +268,11 @@ BOOL __stdcall UiSelHeroSingDialog( return UiSelHeroDialog(fninfo, fncreate, fnstats, dlgresult, name); } -BOOL __stdcall UiSelHeroMultDialog( - BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *)), - BOOL(__stdcall *fncreate)(_uiheroinfo *), - BOOL(__stdcall *fnremove)(_uiheroinfo *), - BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *), +BOOL UiSelHeroMultDialog( + BOOL(*fninfo)(BOOL(*fninfofunc)(_uiheroinfo *)), + BOOL(*fncreate)(_uiheroinfo *), + BOOL(*fnremove)(_uiheroinfo *), + BOOL(*fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, BOOL *hero_is_created, char *name) diff --git a/SourceX/DiabloUI/title.cpp b/SourceX/DiabloUI/title.cpp index c5c7a3c7c..64857e662 100644 --- a/SourceX/DiabloUI/title.cpp +++ b/SourceX/DiabloUI/title.cpp @@ -16,7 +16,7 @@ void title_Free() ArtLogos[LOGO_BIG].data = NULL; } -BOOL __stdcall UiTitleDialog(int a1) +BOOL UiTitleDialog(int a1) { UI_Item TITLESCREEN_DIALOG[] = { { { 0, 0, 640, 480 }, UI_IMAGE, 0, 0, NULL, &ArtBackground }, diff --git a/SourceX/dvlnet/abstract_net.h b/SourceX/dvlnet/abstract_net.h index b4a2eb96b..36c7f96dc 100644 --- a/SourceX/dvlnet/abstract_net.h +++ b/SourceX/dvlnet/abstract_net.h @@ -9,7 +9,7 @@ namespace dvl { namespace net { typedef std::vector buffer_t; - typedef void(__stdcall *snet_event_func)(struct _SNETEVENT*); + typedef void(*snet_event_func)(struct _SNETEVENT*); typedef unsigned long provider_t; class dvlnet_exception : public std::exception {}; diff --git a/SourceX/dvlnet/tcp_client.cpp b/SourceX/dvlnet/tcp_client.cpp index a764bfe0f..ed683d12d 100644 --- a/SourceX/dvlnet/tcp_client.cpp +++ b/SourceX/dvlnet/tcp_client.cpp @@ -1,12 +1,11 @@ #include "dvlnet/tcp_client.h" #include -#include -#include #include #include #include #include +#include namespace dvl { namespace net { @@ -51,7 +50,7 @@ int tcp_client::join(std::string addrstr, std::string passwd) } if (plr_self != PLR_BROADCAST) break; // join successful - std::this_thread::sleep_for(std::chrono::milliseconds(ms_sleep)); + SDL_Delay(ms_sleep); } } return (plr_self == PLR_BROADCAST ? -1 : plr_self); diff --git a/SourceX/dx.cpp b/SourceX/dx.cpp index 16a04386e..8ce26cc3d 100644 --- a/SourceX/dx.cpp +++ b/SourceX/dx.cpp @@ -35,7 +35,7 @@ bool surface_dirty; // DirectDraw COM interface stub implementations // -#define METHOD virtual __stdcall +#define METHOD virtual class StubSurface : public IDirectDrawSurface { METHOD HRESULT QueryInterface(DVL_REFIID refiid, LPVOID *lpvoid) @@ -358,7 +358,7 @@ static StubPalette stub_palette; // Main functions // -void __fastcall dx_init(HWND hWnd) +void dx_init(HWND hWnd) { DUMMY(); renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC); @@ -415,7 +415,7 @@ void __fastcall dx_init(HWND hWnd) palette_init(); } -void __cdecl dx_cleanup() +void dx_cleanup() { DUMMY(); } @@ -449,12 +449,12 @@ void sdl_present_surface() surface_dirty = false; } -void __fastcall j_lock_buf_priv(BYTE idx) +void j_lock_buf_priv(BYTE idx) { j_unlock_buf_priv(idx); // what is idx? } -void __fastcall j_unlock_buf_priv(BYTE idx) +void j_unlock_buf_priv(BYTE idx) { gpBufEnd -= (uintptr_t)gpBufEnd; @@ -465,7 +465,7 @@ void __fastcall j_unlock_buf_priv(BYTE idx) sdl_present_surface(); } -void __cdecl dx_reinit() +void dx_reinit() { UNIMPLEMENTED(); } @@ -474,7 +474,7 @@ void __cdecl dx_reinit() // Storm functions // -BOOL STORMAPI SDrawUpdatePalette(unsigned int firstentry, unsigned int numentries, PALETTEENTRY *pPalEntries, int a4) +BOOL SDrawUpdatePalette(unsigned int firstentry, unsigned int numentries, PALETTEENTRY *pPalEntries, int a4) { assert(firstentry == 0); assert(numentries == 256); @@ -507,7 +507,7 @@ BOOL STORMAPI SDrawUpdatePalette(unsigned int firstentry, unsigned int numentrie // Windows API functions // -WINBOOL WINAPI SetCursorPos(int X, int Y) +WINBOOL SetCursorPos(int X, int Y) { assert(renderer); assert(window); @@ -526,14 +526,14 @@ WINBOOL WINAPI SetCursorPos(int X, int Y) return TRUE; } -int WINAPI ShowCursor(WINBOOL bShow) +int ShowCursor(WINBOOL bShow) { SDL_ShowCursor(bShow ? SDL_ENABLE : SDL_DISABLE); return bShow; } -WINBOOL WINAPI TextOutA(HDC hdc, int x, int y, LPCSTR lpString, int c) +WINBOOL TextOutA(HDC hdc, int x, int y, LPCSTR lpString, int c) { DUMMY_ONCE(); diff --git a/SourceX/miniwin.cpp b/SourceX/miniwin.cpp index 362fb6806..05483a6ec 100644 --- a/SourceX/miniwin.cpp +++ b/SourceX/miniwin.cpp @@ -7,17 +7,17 @@ namespace dvl { DWORD last_error; -DWORD WINAPI GetLastError() +DWORD GetLastError() { return last_error; } -void WINAPI SetLastError(DWORD dwErrCode) +void SetLastError(DWORD dwErrCode) { last_error = dwErrCode; } -char __cdecl *_strlwr(char *str) +char *_strlwr(char *str) { for (char *p = str; *p; ++p) { *p = tolower(*p); @@ -25,24 +25,24 @@ char __cdecl *_strlwr(char *str) return str; } -int WINAPIV wsprintfA(LPSTR dest, LPCSTR format, ...) +int wsprintfA(LPSTR dest, LPCSTR format, ...) { va_list args; va_start(args, format); return vsprintf(dest, format, args); } -int WINAPIV wvsprintfA(LPSTR dest, LPCSTR format, va_list arglist) +int wvsprintfA(LPSTR dest, LPCSTR format, va_list arglist) { return vsnprintf(dest, 256, format, arglist); } -int __cdecl _strcmpi(const char *_Str1, const char *_Str2) +int _strcmpi(const char *_Str1, const char *_Str2) { return strcasecmp(_Str1, _Str2); } -char *__cdecl _itoa(int _Value, char *_Dest, int _Radix) +char *_itoa(int _Value, char *_Dest, int _Radix) { switch (_Radix) { case 8: @@ -62,23 +62,23 @@ char *__cdecl _itoa(int _Value, char *_Dest, int _Radix) return _Dest; } -DWORD WINAPI GetTickCount() +DWORD GetTickCount() { return SDL_GetTicks(); } -void WINAPI Sleep(DWORD dwMilliseconds) +void Sleep(DWORD dwMilliseconds) { usleep(dwMilliseconds * 1000); } -HANDLE WINAPI FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData) +HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData) { DUMMY(); return (HANDLE)-1; } -WINBOOL WINAPI FindClose(HANDLE hFindFile) +WINBOOL FindClose(HANDLE hFindFile) { UNIMPLEMENTED(); } @@ -86,7 +86,7 @@ WINBOOL WINAPI FindClose(HANDLE hFindFile) /** * @brief Normally this would get the Windows install, but Diablo uses it to find the old save game folder */ -UINT WINAPI GetWindowsDirectoryA(LPSTR lpBuffer, UINT uSize) +UINT GetWindowsDirectoryA(LPSTR lpBuffer, UINT uSize) { char *name = SDL_GetPrefPath("diasurgical", "devilution"); strncpy(lpBuffer, name, uSize); @@ -99,7 +99,7 @@ UINT WINAPI GetWindowsDirectoryA(LPSTR lpBuffer, UINT uSize) return len - 1; } -WINBOOL WINAPI GetDiskFreeSpaceA(LPCSTR lpRootPathName, LPDWORD lpSectorsPerCluster, LPDWORD lpBytesPerSector, +WINBOOL GetDiskFreeSpaceA(LPCSTR lpRootPathName, LPDWORD lpSectorsPerCluster, LPDWORD lpBytesPerSector, LPDWORD lpNumberOfFreeClusters, LPDWORD lpTotalNumberOfClusters) { #ifndef _WIN32 @@ -126,7 +126,7 @@ WINBOOL WINAPI GetDiskFreeSpaceA(LPCSTR lpRootPathName, LPDWORD lpSectorsPerClus /** * @brief Used for getting save path, by removing up to and including the last "\" */ -DWORD WINAPI GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize) +DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize) { char *name = SDL_GetPrefPath("diasurgical", "devilution"); strncpy(lpFilename, name, nSize); @@ -139,7 +139,7 @@ DWORD WINAPI GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize) return len; } -WINBOOL WINAPI GetComputerNameA(LPSTR lpBuffer, LPDWORD nSize) +WINBOOL GetComputerNameA(LPSTR lpBuffer, LPDWORD nSize) { DUMMY(); strncpy(lpBuffer, "localhost", *nSize); @@ -210,61 +210,61 @@ UINT GetDriveTypeA(LPCSTR lpRootPathName) return DVL_DRIVE_CDROM; } -WINBOOL WINAPI DeleteFileA(LPCSTR lpFileName) +WINBOOL DeleteFileA(LPCSTR lpFileName) { UNIMPLEMENTED(); } -WINBOOL WINAPI CopyFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, WINBOOL bFailIfExists) +WINBOOL CopyFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, WINBOOL bFailIfExists) { UNIMPLEMENTED(); } -HFILE WINAPI OpenFile(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle) +HFILE OpenFile(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle) { DUMMY(); return DVL_HFILE_ERROR; } -HWND WINAPI SetCapture(HWND hWnd) +HWND SetCapture(HWND hWnd) { DUMMY_ONCE(); return hWnd; } -WINBOOL WINAPI ReleaseCapture() +WINBOOL ReleaseCapture() { DUMMY_ONCE(); return TRUE; } -WINBOOL WINAPI DestroyWindow(HWND hWnd) +WINBOOL DestroyWindow(HWND hWnd) { DUMMY(); return TRUE; } -HWND WINAPI GetLastActivePopup(HWND hWnd) +HWND GetLastActivePopup(HWND hWnd) { UNIMPLEMENTED(); } -HWND WINAPI GetTopWindow(HWND hWnd) +HWND GetTopWindow(HWND hWnd) { UNIMPLEMENTED(); } -WINBOOL WINAPI SetForegroundWindow(HWND hWnd) +WINBOOL SetForegroundWindow(HWND hWnd) { UNIMPLEMENTED(); } -HWND WINAPI SetFocus(HWND hWnd) +HWND SetFocus(HWND hWnd) { UNIMPLEMENTED(); } -HWND WINAPI FindWindowA(LPCSTR lpClassName, LPCSTR lpWindowName) +HWND FindWindowA(LPCSTR lpClassName, LPCSTR lpWindowName) { DUMMY_PRINT("class: %s window: %s", nullstr(lpClassName), nullstr(lpWindowName)); return NULL; @@ -331,7 +331,7 @@ BOOL ShowWindow(HWND hWnd, int nCmdShow) return TRUE; } -WINUSERAPI ATOM WINAPI RegisterClassExA(const WNDCLASSEXA *lpwcx) +ATOM RegisterClassExA(const WNDCLASSEXA *lpwcx) { DUMMY(); return 1; @@ -419,13 +419,13 @@ void GetLocalTime(LPSYSTEMTIME lpSystemTime) UNIMPLEMENTED(); } -long __cdecl _findfirst(const char *, struct _finddata_t *) +long _findfirst(const char *, struct _finddata_t *) { UNIMPLEMENTED(); return -1; } -int __cdecl _findnext(long, struct _finddata_t *) +int _findnext(long, struct _finddata_t *) { UNIMPLEMENTED(); return -1; @@ -434,12 +434,12 @@ int __cdecl _findnext(long, struct _finddata_t *) /** * @brief Used to shutdown a MS Office 95 tool bar */ -HWND WINAPI GetForegroundWindow() +HWND GetForegroundWindow() { return NULL; } -LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter) +LPTOP_LEVEL_EXCEPTION_FILTER SetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter) { DUMMY(); return lpTopLevelExceptionFilter; @@ -505,26 +505,26 @@ BOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData) return FALSE; } -void WINAPI GetSystemInfo(LPSYSTEM_INFO lpSystemInfo) +void GetSystemInfo(LPSYSTEM_INFO lpSystemInfo) { DUMMY(); memset(lpSystemInfo, 0, sizeof(*lpSystemInfo)); lpSystemInfo->dwPageSize = 4096; } -HDC WINAPI GetDC(HWND hWnd) +HDC GetDC(HWND hWnd) { DUMMY(); return NULL; } -int WINAPI ReleaseDC(HWND hWnd, HDC hDC) +int ReleaseDC(HWND hWnd, HDC hDC) { DUMMY(); return 0; } -int WINAPI GetDeviceCaps(HDC hdc, int index) +int GetDeviceCaps(HDC hdc, int index) { SDL_DisplayMode current; @@ -557,7 +557,7 @@ BOOL GetWindowRect(HWND hDlg, tagRECT *Rect) return TRUE; } -UINT WINAPI GetSystemPaletteEntries(HDC hdc, UINT iStart, UINT cEntries, LPPALETTEENTRY pPalEntries) +UINT GetSystemPaletteEntries(HDC hdc, UINT iStart, UINT cEntries, LPPALETTEENTRY pPalEntries) { DUMMY(); return 0; @@ -576,7 +576,7 @@ void lstrcpynA(LPSTR lpString1, LPCSTR lpString2, int iMaxLength) strncpy(lpString1, lpString2, iMaxLength); } -WINBOOL WINAPI CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, +WINBOOL CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, WINBOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation) @@ -585,18 +585,18 @@ WINBOOL WINAPI CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPS return FALSE; } -void WINAPI ExitProcess(UINT uExitCode) +void ExitProcess(UINT uExitCode) { UNIMPLEMENTED(); } -DWORD WINAPI GetCurrentProcessId() +DWORD GetCurrentProcessId() { UNIMPLEMENTED(); return 0; } -HANDLE WINAPI CreateFileMappingA(HANDLE hFile, LPSECURITY_ATTRIBUTES lpFileMappingAttributes, DWORD flProtect, +HANDLE CreateFileMappingA(HANDLE hFile, LPSECURITY_ATTRIBUTES lpFileMappingAttributes, DWORD flProtect, DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow, LPCSTR lpName) { DUMMY(); @@ -604,33 +604,33 @@ HANDLE WINAPI CreateFileMappingA(HANDLE hFile, LPSECURITY_ATTRIBUTES lpFileMappi return NULL; } -LPVOID WINAPI MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, +LPVOID MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap) { UNIMPLEMENTED(); } -WINBOOL WINAPI UnmapViewOfFile(LPCVOID lpBaseAddress) +WINBOOL UnmapViewOfFile(LPCVOID lpBaseAddress) { UNIMPLEMENTED(); } -DWORD WINAPI WaitForInputIdle(HANDLE hProcess, DWORD dwMilliseconds) +DWORD WaitForInputIdle(HANDLE hProcess, DWORD dwMilliseconds) { UNIMPLEMENTED(); } -HWND WINAPI GetWindow(HWND hWnd, UINT uCmd) +HWND GetWindow(HWND hWnd, UINT uCmd) { UNIMPLEMENTED(); } -DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, LPDWORD lpdwProcessId) +DWORD GetWindowThreadProcessId(HWND hWnd, LPDWORD lpdwProcessId) { UNIMPLEMENTED(); } -DWORD WINAPI GetPrivateProfileStringA(LPCSTR lpAppName, LPCSTR lpKeyName, LPCSTR lpDefault, LPSTR lpReturnedString, +DWORD GetPrivateProfileStringA(LPCSTR lpAppName, LPCSTR lpKeyName, LPCSTR lpDefault, LPSTR lpReturnedString, DWORD nSize, LPCSTR lpFileName) { if (!SRegLoadString(lpAppName, lpKeyName, 0, lpReturnedString, nSize)) { diff --git a/SourceX/miniwin_io.cpp b/SourceX/miniwin_io.cpp index 3b29527ff..1549bee2c 100644 --- a/SourceX/miniwin_io.cpp +++ b/SourceX/miniwin_io.cpp @@ -15,7 +15,7 @@ extern "C" void TranslateFileName(char *dst, int dstLen, const char *src) static std::set files; -HANDLE WINAPI CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, +HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) { @@ -41,7 +41,7 @@ HANDLE WINAPI CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShar return fd; } -WINBOOL WINAPI ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, +WINBOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped) { DUMMY_ONCE(); @@ -53,7 +53,7 @@ WINBOOL WINAPI ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRea return TRUE; } -DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh) +DWORD GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh) { DUMMY_ONCE(); @@ -64,7 +64,7 @@ DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh) return s.st_size; } -WINBOOL WINAPI WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, +WINBOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped) { DUMMY_ONCE(); @@ -79,7 +79,7 @@ WINBOOL WINAPI WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToW return TRUE; } -DWORD WINAPI SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod) +DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod) { DUMMY_ONCE(); @@ -96,7 +96,7 @@ DWORD WINAPI SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistance return (DWORD)ret; } -WINBOOL WINAPI SetEndOfFile(HANDLE hFile) +WINBOOL SetEndOfFile(HANDLE hFile) { DUMMY_ONCE(); @@ -107,7 +107,7 @@ WINBOOL WINAPI SetEndOfFile(HANDLE hFile) return TRUE; } -DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName) +DWORD GetFileAttributesA(LPCSTR lpFileName) { char name[260]; TranslateFileName(name, sizeof(name), lpFileName); @@ -125,13 +125,13 @@ DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName) return 0x80; } -WINBOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes) +WINBOOL SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes) { DUMMY_PRINT("file: %s", lpFileName); return TRUE; } -WINBOOL WINAPI CloseHandle(HANDLE hObject) +WINBOOL CloseHandle(HANDLE hObject) { if (files.find(hObject) != files.end()) { int ret = close((intptr_t)hObject); diff --git a/SourceX/miniwin_msg_sdl.cpp b/SourceX/miniwin_msg_sdl.cpp index 065a9914b..15cd938ee 100644 --- a/SourceX/miniwin_msg_sdl.cpp +++ b/SourceX/miniwin_msg_sdl.cpp @@ -97,7 +97,7 @@ static WINBOOL false_avail() return FALSE; } -WINBOOL WINAPI PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg) +WINBOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg) { if (wMsgFilterMin != 0) UNIMPLEMENTED(); @@ -192,7 +192,7 @@ WINBOOL WINAPI PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMs return TRUE; } -WINBOOL WINAPI TranslateMessage(CONST MSG *lpMsg) +WINBOOL TranslateMessage(CONST MSG *lpMsg) { assert(lpMsg->hwnd == 0); if (lpMsg->message == WM_KEYDOWN) { @@ -267,14 +267,14 @@ WINBOOL WINAPI TranslateMessage(CONST MSG *lpMsg) return TRUE; } -SHORT WINAPI GetAsyncKeyState(int vKey) +SHORT GetAsyncKeyState(int vKey) { DUMMY_ONCE(); // TODO: Not handled yet. return 0; } -LRESULT WINAPI DispatchMessageA(CONST MSG *lpMsg) +LRESULT DispatchMessageA(CONST MSG *lpMsg) { DUMMY_ONCE(); assert(lpMsg->hwnd == 0); @@ -284,7 +284,7 @@ LRESULT WINAPI DispatchMessageA(CONST MSG *lpMsg) return CurrentProc(lpMsg->hwnd, lpMsg->message, lpMsg->wParam, lpMsg->lParam); } -WINBOOL WINAPI PostMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) +WINBOOL PostMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { DUMMY(); diff --git a/SourceX/miniwin_thread.cpp b/SourceX/miniwin_thread.cpp index 6d4acad01..2a0cd2008 100644 --- a/SourceX/miniwin_thread.cpp +++ b/SourceX/miniwin_thread.cpp @@ -10,7 +10,7 @@ struct event_emul { SDL_cond *cond; }; -uintptr_t __cdecl _beginthreadex(void *_Security, unsigned _StackSize, unsigned(__stdcall *_StartAddress)(void *), +uintptr_t _beginthreadex(void *_Security, unsigned _StackSize, unsigned(*_StartAddress)(void *), void *_ArgList, unsigned _InitFlag, unsigned *_ThrdAddr) { if (_Security != NULL) @@ -26,47 +26,47 @@ uintptr_t __cdecl _beginthreadex(void *_Security, unsigned _StackSize, unsigned( return (uintptr_t)ret; } -DWORD WINAPI GetCurrentThreadId() +DWORD GetCurrentThreadId() { // DWORD is compatible with SDL_threadID return SDL_GetThreadID(NULL); } -HANDLE WINAPI GetCurrentThread() +HANDLE GetCurrentThread() { // Only used for SetThreadPriority, which is unimplemented return NULL; } -WINBOOL WINAPI SetThreadPriority(HANDLE hThread, int nPriority) +WINBOOL SetThreadPriority(HANDLE hThread, int nPriority) { // SDL cannot set the priority of the non-current thread // (and e.g. unprivileged processes on Linux cannot increase it) return TRUE; } -void WINAPI InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection) +void InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { SDL_mutex *m = SDL_CreateMutex(); *lpCriticalSection = m; } -void WINAPI EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) +void EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { SDL_LockMutex(*((SDL_mutex **)lpCriticalSection)); } -void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection) +void LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { SDL_UnlockMutex(*((SDL_mutex **)lpCriticalSection)); } -void WINAPI DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection) +void DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { SDL_DestroyMutex(*((SDL_mutex **)lpCriticalSection)); } -HANDLE WINAPI CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, WINBOOL bManualReset, WINBOOL bInitialState, +HANDLE CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, WINBOOL bManualReset, WINBOOL bInitialState, LPCSTR lpName) { if (lpName != NULL && !strcmp(lpName, "DiabloEvent")) { @@ -91,7 +91,7 @@ HANDLE WINAPI CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, WINBOOL bMan return ret; } -BOOL WINAPI SetEvent(HANDLE hEvent) +BOOL SetEvent(HANDLE hEvent) { struct event_emul *e = (struct event_emul *)hEvent; SDL_LockMutex(e->mutex); @@ -100,7 +100,7 @@ BOOL WINAPI SetEvent(HANDLE hEvent) return 1; } -BOOL WINAPI ResetEvent(HANDLE hEvent) +BOOL ResetEvent(HANDLE hEvent) { struct event_emul *e = (struct event_emul *)hEvent; SDL_LockMutex(e->mutex); @@ -132,7 +132,7 @@ static DWORD wait_for_sdl_thread(HANDLE hHandle, DWORD dwMilliseconds) return 0; } -DWORD WINAPI WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) +DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) { // return value different from WinAPI if (threads.find((uintptr_t)hHandle) != threads.end()) diff --git a/SourceX/sound.cpp b/SourceX/sound.cpp index 0d2884a74..6ce8ac71b 100644 --- a/SourceX/sound.cpp +++ b/SourceX/sound.cpp @@ -35,7 +35,7 @@ char unk_volume[4][2] = { { 30, -31 } }; -void __fastcall snd_update(BOOL bStopAll) +void snd_update(BOOL bStopAll) { DWORD error_code, i; @@ -45,14 +45,14 @@ void __fastcall snd_update(BOOL bStopAll) Mix_HaltChannel(-1); } -void __fastcall snd_stop_snd(TSnd *pSnd) +void snd_stop_snd(TSnd *pSnd) { DUMMY_ONCE(); if (pSnd && pSnd->DSB) Mix_HaltChannel(-1); } -BOOL __fastcall snd_playing(TSnd *pSnd) +BOOL snd_playing(TSnd *pSnd) { DWORD error_code; // TODO should probably be HRESULT @@ -67,7 +67,7 @@ BOOL __fastcall snd_playing(TSnd *pSnd) return FALSE; } -void __fastcall snd_play_snd(TSnd *pSnd, int lVolume, int lPan) +void snd_play_snd(TSnd *pSnd, int lVolume, int lPan) { LPDIRECTSOUNDBUFFER DSB; DWORD tc; @@ -111,7 +111,7 @@ void __fastcall snd_play_snd(TSnd *pSnd, int lVolume, int lPan) pSnd->start_tc = tc; } -LPDIRECTSOUNDBUFFER __fastcall sound_dup_channel(LPDIRECTSOUNDBUFFER DSB) +LPDIRECTSOUNDBUFFER sound_dup_channel(LPDIRECTSOUNDBUFFER DSB) { DWORD i; @@ -126,7 +126,7 @@ LPDIRECTSOUNDBUFFER __fastcall sound_dup_channel(LPDIRECTSOUNDBUFFER DSB) return NULL; } -BOOL __fastcall sound_file_reload(TSnd *sound_file, LPDIRECTSOUNDBUFFER DSB) +BOOL sound_file_reload(TSnd *sound_file, LPDIRECTSOUNDBUFFER DSB) { HANDLE file; LPVOID buf1, buf2; @@ -145,7 +145,7 @@ BOOL __fastcall sound_file_reload(TSnd *sound_file, LPDIRECTSOUNDBUFFER DSB) return rv; } -TSnd *__fastcall sound_file_load(char *path) +TSnd *sound_file_load(char *path) { HANDLE file; BYTE *wave_file; @@ -184,7 +184,7 @@ TSnd *__fastcall sound_file_load(char *path) } // 456F07: could not find valid save-restore pair for esi -void __fastcall sound_CreateSoundBuffer(TSnd *sound_file) +void sound_CreateSoundBuffer(TSnd *sound_file) { DUMMY_ONCE(); DSBUFFERDESC DSB; @@ -197,7 +197,7 @@ void __fastcall sound_CreateSoundBuffer(TSnd *sound_file) DSB.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_STATIC; } -void __fastcall sound_file_cleanup(TSnd *sound_file) +void sound_file_cleanup(TSnd *sound_file) { if (sound_file) { if (sound_file->DSB) { @@ -210,7 +210,7 @@ void __fastcall sound_file_cleanup(TSnd *sound_file) } } -void __fastcall snd_init(HWND hWnd) +void snd_init(HWND hWnd) { DUMMY(); sound_load_volume("Sound Volume", &sglSoundVolume); @@ -231,7 +231,7 @@ void __fastcall snd_init(HWND hWnd) gbSndInited = true; } -void __fastcall sound_load_volume(char *value_name, int *value) +void sound_load_volume(char *value_name, int *value) { int v = *value; if (!SRegLoadValue("Diablo", value_name, 0, &v)) { @@ -247,7 +247,7 @@ void __fastcall sound_load_volume(char *value_name, int *value) *value -= *value % 100; } -void __fastcall sound_create_primary_buffer(HANDLE music_track) +void sound_create_primary_buffer(HANDLE music_track) { DUMMY(); HRESULT error_code; @@ -301,10 +301,10 @@ void __fastcall sound_create_primary_buffer(HANDLE music_track) } // 69F100: using guessed type int sglpDSB; -HRESULT __fastcall sound_DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter) +HRESULT sound_DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter) { UNIMPLEMENTED(); - HRESULT(WINAPI * DirectSoundCreate) + HRESULT(* DirectSoundCreate) (LPGUID lpGuid, LPDIRECTSOUND * ppDS, LPUNKNOWN pUnkOuter); if (hDsound_dll == NULL) { @@ -319,7 +319,7 @@ HRESULT __fastcall sound_DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND *ppDS, L return DirectSoundCreate(lpGuid, ppDS, pUnkOuter); } -void __cdecl sound_cleanup() +void sound_cleanup() { snd_update(TRUE); SVidDestroy(); @@ -337,12 +337,12 @@ void __cdecl sound_cleanup() } } -void __fastcall sound_store_volume(char *key, int value) +void sound_store_volume(char *key, int value) { SRegSaveValue("Diablo", key, 0, value); } -void __cdecl music_stop() +void music_stop() { if (sgpMusicTrack) { Mix_HaltMusic(); @@ -352,7 +352,7 @@ void __cdecl music_stop() } } -void __fastcall music_start(int nTrack) +void music_start(int nTrack) { BOOL success; @@ -384,7 +384,7 @@ void __fastcall music_start(int nTrack) } } -void __fastcall sound_disable_music(BOOL disable) +void sound_disable_music(BOOL disable) { if (disable) { music_stop(); @@ -393,7 +393,7 @@ void __fastcall sound_disable_music(BOOL disable) } } -int __fastcall sound_get_or_set_music_volume(int volume) +int sound_get_or_set_music_volume(int volume) { if (volume == 1) return sglMusicVolume; @@ -406,7 +406,7 @@ int __fastcall sound_get_or_set_music_volume(int volume) return sglMusicVolume; } -int __fastcall sound_get_or_set_sound_volume(int volume) +int sound_get_or_set_sound_volume(int volume) { if (volume == 1) return sglSoundVolume; diff --git a/SourceX/storm.cpp b/SourceX/storm.cpp index 6a67a49f1..130369a16 100644 --- a/SourceX/storm.cpp +++ b/SourceX/storm.cpp @@ -18,17 +18,17 @@ std::string getIniPath() radon::File ini(getIniPath()); -// BOOL STORMAPI SFileCloseArchive(HANDLE hArchive) +// BOOL SFileCloseArchive(HANDLE hArchive) // { // UNIMPLEMENTED(); // } -// BOOL STORMAPI SFileCloseFile(HANDLE hFile) +// BOOL SFileCloseFile(HANDLE hFile) // { // UNIMPLEMENTED(); // } -BOOL STORMAPI SFileDdaBeginEx(HANDLE directsound, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, +BOOL SFileDdaBeginEx(HANDLE directsound, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, signed __int32 volume, signed int pan, int a7) { DUMMY(); // Todo track when the sound can be released, see sfx_stop() @@ -48,54 +48,54 @@ BOOL STORMAPI SFileDdaBeginEx(HANDLE directsound, DWORD flags, DWORD mask, unsig return 1; } -BOOL STORMAPI SFileDdaDestroy() +BOOL SFileDdaDestroy() { DUMMY(); return 0; } -BOOL STORMAPI SFileDdaEnd(HANDLE directsound) +BOOL SFileDdaEnd(HANDLE directsound) { DUMMY(); return 0; } -BOOL STORMAPI SFileDdaGetPos(HANDLE directsound, int a2, int a3) +BOOL SFileDdaGetPos(HANDLE directsound, int a2, int a3) { DUMMY_ONCE(); return TRUE; } -BOOL STORMAPI SFileDdaInitialize(HANDLE directsound) +BOOL SFileDdaInitialize(HANDLE directsound) { DUMMY(); return 0; } -BOOL STORMAPI SFileDdaSetVolume(HANDLE directsound, signed int bigvolume, signed int volume) +BOOL SFileDdaSetVolume(HANDLE directsound, signed int bigvolume, signed int volume) { Mix_VolumeMusic(MIX_MAX_VOLUME - MIX_MAX_VOLUME * bigvolume / VOLUME_MIN); return TRUE; } -BOOL STORMAPI SFileGetFileArchive(HANDLE hFile, HANDLE *archive) +BOOL SFileGetFileArchive(HANDLE hFile, HANDLE *archive) { UNIMPLEMENTED(); } -// LONG STORMAPI SFileGetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh) +// LONG SFileGetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh) // { // UNIMPLEMENTED(); // } -// BOOL STORMAPI SFileOpenArchive(const char *szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE +// BOOL SFileOpenArchive(const char *szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE // *phMpq) // { // UNIMPLEMENTED(); // } -BOOL STORMAPI SFileOpenFile(const char *filename, HANDLE *phFile) +BOOL SFileOpenFile(const char *filename, HANDLE *phFile) { //eprintf("%s: %s\n", __FUNCTION__, filename); @@ -112,19 +112,19 @@ BOOL STORMAPI SFileOpenFile(const char *filename, HANDLE *phFile) return result; } -// BOOL STORMAPI SFileOpenFileEx(HANDLE hMpq, const char *szFileName, DWORD dwSearchScope, HANDLE +// BOOL SFileOpenFileEx(HANDLE hMpq, const char *szFileName, DWORD dwSearchScope, HANDLE // *phFile) // { // UNIMPLEMENTED(); // } -// BOOL STORMAPI SFileReadFile(HANDLE hFile, void *buffer, DWORD nNumberOfBytesToRead, DWORD *read, +// BOOL SFileReadFile(HANDLE hFile, void *buffer, DWORD nNumberOfBytesToRead, DWORD *read, // LONG lpDistanceToMoveHigh) // { // UNIMPLEMENTED(); // } -BOOL __stdcall SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, BYTE *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *dwHeight, DWORD *pdwBpp) +BOOL SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, BYTE *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *dwHeight, DWORD *pdwBpp) { HANDLE hFile; size_t size; @@ -232,32 +232,32 @@ BOOL __stdcall SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, BY return true; } -// int __stdcall SFileSetFilePointer(HANDLE, int, HANDLE, int) +// int SFileSetFilePointer(HANDLE, int, HANDLE, int) // { // UNIMPLEMENTED(); // } -HWND STORMAPI SDrawGetFrameWindow(HWND *sdraw_framewindow) +HWND SDrawGetFrameWindow(HWND *sdraw_framewindow) { DUMMY(); return NULL; } -// BOOL STORMAPI SDrawManualInitialize(HWND hWnd, LPDIRECTDRAW ddInterface, LPDIRECTDRAWSURFACE +// BOOL SDrawManualInitialize(HWND hWnd, LPDIRECTDRAW ddInterface, LPDIRECTDRAWSURFACE // primarySurface, LPDIRECTDRAWSURFACE surface2, LPDIRECTDRAWSURFACE surface3, LPDIRECTDRAWSURFACE // backSurface, LPDIRECTDRAWPALETTE ddPalette, HPALETTE hPalette) //{ // UNIMPLEMENTED(); //} -void *STORMAPI SMemAlloc(unsigned int amount, char *logfilename, int logline, char defaultValue) +void *SMemAlloc(unsigned int amount, char *logfilename, int logline, char defaultValue) { // fprintf(stderr, "%s: %d (%s:%d)\n", __FUNCTION__, amount, logfilename, logline); assert(amount != -1u); return malloc(amount); } -BOOL STORMAPI SMemFree(void *location, char *logfilename, int logline, char defaultValue) +BOOL SMemFree(void *location, char *logfilename, int logline, char defaultValue) { // fprintf(stderr, "%s: (%s:%d)\n", __FUNCTION__, logfilename, logline); assert(location); @@ -265,7 +265,7 @@ BOOL STORMAPI SMemFree(void *location, char *logfilename, int logline, char defa return TRUE; } -void *STORMAPI SMemReAlloc(void *location, unsigned int amount, char *logfilename, int logline, char defaultValue) +void *SMemReAlloc(void *location, unsigned int amount, char *logfilename, int logline, char defaultValue) { UNIMPLEMENTED(); } @@ -310,17 +310,17 @@ void setIniValue(const char *sectionName, const char *keyName, char *value, int ini.saveToFile(); } -BOOL STORMAPI SRegLoadData(const char *keyname, const char *valuename, int size, LPBYTE lpData, BYTE flags, LPDWORD lpcbData) +BOOL SRegLoadData(const char *keyname, const char *valuename, int size, LPBYTE lpData, BYTE flags, LPDWORD lpcbData) { return getIniValue(keyname, valuename, (char *)lpData, size, (int *)lpcbData); } -BOOL STORMAPI SRegLoadString(const char *keyname, const char *valuename, BYTE flags, char *buffer, unsigned int buffersize) +BOOL SRegLoadString(const char *keyname, const char *valuename, BYTE flags, char *buffer, unsigned int buffersize) { return getIniValue(keyname, valuename, buffer, buffersize); } -BOOL STORMAPI SRegLoadValue(const char *keyname, const char *valuename, BYTE flags, int *value) +BOOL SRegLoadValue(const char *keyname, const char *valuename, BYTE flags, int *value) { char string[10]; if (getIniValue(keyname, valuename, string, 10)) { @@ -331,21 +331,21 @@ BOOL STORMAPI SRegLoadValue(const char *keyname, const char *valuename, BYTE fla return FALSE; } -BOOL STORMAPI SRegSaveData(const char *keyname, const char *valuename, int size, BYTE *lpData, DWORD cbData) +BOOL SRegSaveData(const char *keyname, const char *valuename, int size, BYTE *lpData, DWORD cbData) { setIniValue(keyname, valuename, (char *)lpData, cbData); return TRUE; } -BOOL STORMAPI SRegSaveString(const char *keyname, const char *valuename, BYTE flags, char *string) +BOOL SRegSaveString(const char *keyname, const char *valuename, BYTE flags, char *string) { setIniValue(keyname, valuename, string); return TRUE; } -BOOL STORMAPI SRegSaveValue(const char *keyname, const char *valuename, BYTE flags, DWORD result) +BOOL SRegSaveValue(const char *keyname, const char *valuename, BYTE flags, DWORD result) { char str[10]; sprintf(str, "%d", result); @@ -354,13 +354,13 @@ BOOL STORMAPI SRegSaveValue(const char *keyname, const char *valuename, BYTE fla return TRUE; } -BOOL STORMAPI SVidInitialize(HANDLE video) +BOOL SVidInitialize(HANDLE video) { DUMMY(); return TRUE; } -BOOL STORMAPI SVidDestroy() +BOOL SVidDestroy() { DUMMY(); return TRUE; @@ -376,7 +376,7 @@ SDL_Surface *SVidSurface; BYTE *SVidBuffer; SDL_AudioDeviceID deviceId; -BOOL STORMAPI SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HANDLE *video) +BOOL SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HANDLE *video) { if (flags & 0x10000 || flags & 0x20000000) { return FALSE; @@ -471,7 +471,7 @@ BOOL SVidLoadNextFrame() return TRUE; } -BOOL __cdecl SVidPlayContinue(void) +BOOL SVidPlayContinue(void) { if (smk_palette_updated(SVidSMK)) { SDL_Color colors[256]; @@ -525,7 +525,7 @@ BOOL __cdecl SVidPlayContinue(void) return SVidLoadNextFrame(); } -BOOL STORMAPI SVidPlayEnd(HANDLE video) +BOOL SVidPlayEnd(HANDLE video) { if (deviceId) { SDL_ClearQueuedAudio(deviceId); @@ -555,92 +555,92 @@ BOOL STORMAPI SVidPlayEnd(HANDLE video) return TRUE; } -BOOL STORMAPI SErrDisplayError(DWORD dwErrMsg, const char *logfilename, int logline, const char *message, +BOOL SErrDisplayError(DWORD dwErrMsg, const char *logfilename, int logline, const char *message, BOOL allowOption, int exitCode) { UNIMPLEMENTED(); } -BOOL STORMAPI SErrGetErrorStr(DWORD dwErrCode, char *buffer, unsigned int bufferchars) +BOOL SErrGetErrorStr(DWORD dwErrCode, char *buffer, unsigned int bufferchars) { DUMMY(); return FALSE; } -DWORD STORMAPI SErrGetLastError() +DWORD SErrGetLastError() { return nLastError; } -void STORMAPI SErrSetLastError(DWORD dwErrCode) +void SErrSetLastError(DWORD dwErrCode) { nLastError = dwErrCode; } -void STORMAPI SMemCopy(void *dest, const void *source, unsigned int size) +void SMemCopy(void *dest, const void *source, unsigned int size) { UNIMPLEMENTED(); } -void STORMAPI SMemFill(void *location, unsigned int length, char fillWith) +void SMemFill(void *location, unsigned int length, char fillWith) { UNIMPLEMENTED(); } -void STORMAPI SMemZero(void *location, DWORD length) +void SMemZero(void *location, DWORD length) { UNIMPLEMENTED(); } -int STORMAPI SMemCmp(void *location1, void *location2, DWORD size) +int SMemCmp(void *location1, void *location2, DWORD size) { UNIMPLEMENTED(); } -int STORMAPI SStrCopy(char *dest, const char *src, int max_length) +int SStrCopy(char *dest, const char *src, int max_length) { strncpy(dest, src, max_length); return strlen(dest); } -int STORMAPI SStrCmp(const char *string1, const char *string2, unsigned int size) +int SStrCmp(const char *string1, const char *string2, unsigned int size) { UNIMPLEMENTED(); } -int STORMAPI SStrCmpI(const char *string1, const char *string2, unsigned int size) +int SStrCmpI(const char *string1, const char *string2, unsigned int size) { UNIMPLEMENTED(); } -void __stdcall SDrawMessageBox(char *Text, char *Title, int Flags) +void SDrawMessageBox(char *Text, char *Title, int Flags) { MessageBoxA(NULL, Text, Title, Flags); } -// void __cdecl SDrawDestroy(void) +// void SDrawDestroy(void) //{ // UNIMPLEMENTED(); //} -BOOLEAN __cdecl StormDestroy(void) +BOOLEAN StormDestroy(void) { DUMMY(); return TRUE; } -BOOLEAN __stdcall SFileSetBasePath(char *) +BOOLEAN SFileSetBasePath(char *) { DUMMY(); return TRUE; } -void __cdecl SDrawRealizePalette(void) +void SDrawRealizePalette(void) { DUMMY(); } -BOOL __stdcall SFileEnableDirectAccess(BOOL enable) +BOOL SFileEnableDirectAccess(BOOL enable) { DUMMY(); return TRUE; diff --git a/SourceX/storm_net.cpp b/SourceX/storm_net.cpp index 2d853d72e..48ce0b258 100644 --- a/SourceX/storm_net.cpp +++ b/SourceX/storm_net.cpp @@ -5,7 +5,7 @@ namespace dvl { static std::unique_ptr dvlnet_inst; -BOOL STORMAPI SNetReceiveMessage(int *senderplayerid, char **data, int *databytes) +BOOL SNetReceiveMessage(int *senderplayerid, char **data, int *databytes) { if (!dvlnet_inst->SNetReceiveMessage(senderplayerid, data, databytes)) { SErrSetLastError(STORM_ERROR_NO_MESSAGES_WAITING); @@ -14,12 +14,12 @@ BOOL STORMAPI SNetReceiveMessage(int *senderplayerid, char **data, int *databyte return TRUE; } -BOOL STORMAPI SNetSendMessage(int playerID, void *data, unsigned int databytes) +BOOL SNetSendMessage(int playerID, void *data, unsigned int databytes) { return dvlnet_inst->SNetSendMessage(playerID, data, databytes); } -BOOL STORMAPI SNetReceiveTurns(int a1, int arraysize, char **arraydata, unsigned int *arraydatabytes, +BOOL SNetReceiveTurns(int a1, int arraysize, char **arraydata, unsigned int *arraydatabytes, DWORD *arrayplayerstatus) { if (a1 != 0) @@ -33,49 +33,49 @@ BOOL STORMAPI SNetReceiveTurns(int a1, int arraysize, char **arraydata, unsigned return TRUE; } -BOOL STORMAPI SNetSendTurn(char *data, unsigned int databytes) +BOOL SNetSendTurn(char *data, unsigned int databytes) { return dvlnet_inst->SNetSendTurn(data, databytes); } -int __stdcall SNetGetProviderCaps(struct _SNETCAPS *caps) +int SNetGetProviderCaps(struct _SNETCAPS *caps) { return dvlnet_inst->SNetGetProviderCaps(caps); } -void *__stdcall SNetUnregisterEventHandler(int evtype, void(__stdcall *func)(struct _SNETEVENT *)) +void *SNetUnregisterEventHandler(int evtype, void(*func)(struct _SNETEVENT *)) { return dvlnet_inst->SNetUnregisterEventHandler(*(event_type *)&evtype, func); } -void *__stdcall SNetRegisterEventHandler(int evtype, void(__stdcall *func)(struct _SNETEVENT *)) +void *SNetRegisterEventHandler(int evtype, void(*func)(struct _SNETEVENT *)) { return dvlnet_inst->SNetRegisterEventHandler(*(event_type *)&evtype, func); } -BOOL STORMAPI SNetDestroy() +BOOL SNetDestroy() { DUMMY(); return TRUE; } -BOOL STORMAPI SNetDropPlayer(int playerid, DWORD flags) +BOOL SNetDropPlayer(int playerid, DWORD flags) { return dvlnet_inst->SNetDropPlayer(playerid, flags); } -BOOL STORMAPI SNetGetGameInfo(int type, void *dst, unsigned int length, unsigned int *byteswritten) +BOOL SNetGetGameInfo(int type, void *dst, unsigned int length, unsigned int *byteswritten) { DUMMY(); return TRUE; } -BOOL STORMAPI SNetLeaveGame(int type) +BOOL SNetLeaveGame(int type) { return dvlnet_inst->SNetLeaveGame(type); } -BOOL STORMAPI SNetSendServerChatCommand(const char *command) +BOOL SNetSendServerChatCommand(const char *command) { DUMMY(); return TRUE; @@ -86,7 +86,7 @@ BOOL STORMAPI SNetSendServerChatCommand(const char *command) * @param provider BNET, IPXN, MODM, SCBL or UDPN * @param fileinfo Ignore */ -int __stdcall SNetInitializeProvider(unsigned long provider, struct _SNETPROGRAMDATA *client_info, +int SNetInitializeProvider(unsigned long provider, struct _SNETPROGRAMDATA *client_info, struct _SNETPLAYERDATA *user_info, struct _SNETUIDATA *ui_info, struct _SNETVERSIONDATA *fileinfo) { @@ -97,7 +97,7 @@ int __stdcall SNetInitializeProvider(unsigned long provider, struct _SNETPROGRAM /** * @brief Called by engine for single, called by ui for multi */ -BOOL STORMAPI SNetCreateGame(const char *pszGameName, const char *pszGamePassword, const char *pszGameStatString, +BOOL SNetCreateGame(const char *pszGameName, const char *pszGamePassword, const char *pszGameStatString, DWORD dwGameType, char *GameTemplateData, int GameTemplateSize, int playerCount, char *creatorName, char *a11, int *playerID) { @@ -112,7 +112,7 @@ BOOL STORMAPI SNetCreateGame(const char *pszGameName, const char *pszGamePasswor return *playerID != -1; } -BOOL STORMAPI SNetJoinGame(int id, char *pszGameName, char *pszGamePassword, char *playerName, char *userStats, int *playerID) +BOOL SNetJoinGame(int id, char *pszGameName, char *pszGamePassword, char *playerName, char *userStats, int *playerID) { *playerID = dvlnet_inst->join(pszGameName, pszGamePassword); return *playerID != -1; @@ -121,12 +121,12 @@ BOOL STORMAPI SNetJoinGame(int id, char *pszGameName, char *pszGamePassword, cha /** * @brief Is this the mirror image of SNetGetTurnsInTransit? */ -BOOL __stdcall SNetGetOwnerTurnsWaiting(DWORD *turns) +BOOL SNetGetOwnerTurnsWaiting(DWORD *turns) { return dvlnet_inst->SNetGetOwnerTurnsWaiting(turns); } -BOOL STORMAPI SNetGetTurnsInTransit(int *turns) +BOOL SNetGetTurnsInTransit(int *turns) { return dvlnet_inst->SNetGetTurnsInTransit(turns); } @@ -134,7 +134,7 @@ BOOL STORMAPI SNetGetTurnsInTransit(int *turns) /** * @brief engine calls this only once with argument 1 */ -BOOLEAN __stdcall SNetSetBasePlayer(int) +BOOLEAN SNetSetBasePlayer(int) { return TRUE; } @@ -142,7 +142,7 @@ BOOLEAN __stdcall SNetSetBasePlayer(int) /** * @brief since we never signal STORM_ERROR_REQUIRES_UPGRADE the engine will not call this function */ -BOOL STORMAPI SNetPerformUpgrade(DWORD *upgradestatus) +BOOL SNetPerformUpgrade(DWORD *upgradestatus) { UNIMPLEMENTED(); } @@ -150,7 +150,7 @@ BOOL STORMAPI SNetPerformUpgrade(DWORD *upgradestatus) /** * @brief not called from engine */ -BOOL STORMAPI SNetSetGameMode(DWORD modeFlags, bool makePublic) +BOOL SNetSetGameMode(DWORD modeFlags, bool makePublic) { UNIMPLEMENTED(); return TRUE; diff --git a/types.h b/types.h index 540dfea9c..b22efff14 100644 --- a/types.h +++ b/types.h @@ -47,6 +47,7 @@ #define DEVILUTION_BEGIN_NAMESPACE namespace dvl { #define DEVILUTION_END_NAMESPACE } +#include "miniwin_pushdecl.h" #include "miniwin.h" #endif @@ -153,6 +154,7 @@ DEVILUTION_BEGIN_NAMESPACE //} //#endif +#include "miniwin_popdecl.h" DEVILUTION_END_NAMESPACE #endif