diff --git a/SourceX/DiabloUI/diabloui.cpp b/SourceX/DiabloUI/diabloui.cpp index bedfd4547..111ee81f9 100644 --- a/SourceX/DiabloUI/diabloui.cpp +++ b/SourceX/DiabloUI/diabloui.cpp @@ -15,7 +15,7 @@ Art ArtHero; void(__stdcall *gfnSoundFunction)(char *file); void(__stdcall *gfnListFocus)(int value); void(__stdcall *gfnListSelect)(int value); -void(__stdcall *gfnListEsc)(int value); +void(__stdcall *gfnListEsc)(); UI_Item *gUiItems; int gUiItemCnt; bool UiItemsWraps; @@ -48,7 +48,7 @@ char *errorMessages[] = { "Diablo was unable to find the file \"dsound.dll\", which is a component of Microsoft DirectX.\nPlease run the program \"SETUP.EXE\" on the Diablo CD-ROM and install Microsoft DirectX.\n\nIf you continue to have problems with DirectX, please contact Microsoft's Technical Support at:\n\n USA telephone: 1-800-426-9400\n International telephone: 206-882-8080\n http://www.microsoft.com\n\n\nThe error encountered while trying to initialize DirectX was:\n\n %s", "Diablo requires at least 10 megabytes of free disk space to run properly.\nThe disk:\n\n%s\n\nhas less than 10 megabytes of free space left.\n\nPlease free some space on your drive and run Diablo again.", "Diablo was unable to switch video modes.\nThis is a common problem for computers with more than one video card.\nTo correct this problem, please set your video resolution to 640 x 480 and try running Diablo again.\n\nFor Windows 95 and Windows NT\n Select \"Settings - Control Panel\" from the \"Start\" menu\n Run the \"Display\" control panel applet\n Select the \"Settings\" tab\n Set the \"Desktop Area\" to \"640 x 480 pixels\"\n\n\nThe error encountered while trying to switch video modes was:\n\n %s", - "Diablo cannot read a required data file.\nYour diabdat.mpq may not be in the Deviluition folder and not read-only.\nPlease ensure that the filename is in all lower case and try again.\n %s", + "Diablo cannot read a required data file.\nYour diabdat.mpq may not be in the Devilution folder and not read-only.\nPlease ensure that the filename is in all lower case and try again.\n %s", "In order to install, play or patch Diablo using the Windows 2000 operating system,\nyou will need to log in as either an Administrator or as a Power User.\n\nUsers, also known as Restricted Users, do not have sufficient access to install or play the game properly.\n\nIf you have further questions regarding User Rights in Windows 2000, please refer to your Windows 2000 documentation or contact your system administrator.", "Diablo is being run from:\n\n %s\n\n\nDiablo or the current user does not seem to have write privilages in this directory. Contact your system administrator.\n\nNote that Windows 2000 Restricted Users can not write to the Windows or Program Files directory hierarchies.", }; @@ -303,7 +303,7 @@ void UiFocusNavigationEsc() UiTextInputLen = 0; } if (gfnListEsc) - gfnListEsc(SelectedItem); + gfnListEsc(); } bool IsInsideRect(const SDL_Event *event, const SDL_Rect *rect) @@ -544,12 +544,12 @@ int GetCenterOffset(int w, int bw) return bw / 2 - w / 2; } -int GetStrWidth(BYTE *str, int size) +int GetStrWidth(char *str, int size) { int strWidth = 0; for (int i = 0; i < strlen((char *)str); i++) { - BYTE w = FontTables[size][str[i] + 2]; + BYTE w = FontTables[size][*(BYTE *)&str[i] + 2]; if (w) strWidth += w; else @@ -644,7 +644,7 @@ void DrawArtStr(UI_Item *item) sy += ArtFonts[size][color].height; continue; } - BYTE w = FontTables[size][item->caption[i] + 2] ?: FontTables[size][0]; + BYTE w = FontTables[size][*(BYTE *)&item->caption[i] + 2] ?: FontTables[size][0]; DrawArt(sx, sy, &ArtFonts[size][color], *(BYTE *)&item->caption[i], w); sx += w; } diff --git a/SourceX/DiabloUI/diabloui.h b/SourceX/DiabloUI/diabloui.h index 7cccbd51b..323e451c2 100644 --- a/SourceX/DiabloUI/diabloui.h +++ b/SourceX/DiabloUI/diabloui.h @@ -36,20 +36,20 @@ typedef enum UiTypes { } UiTypes; typedef enum UiFlags { - UIS_SMALL = 0x1, - UIS_MED = 0x10, - UIS_BIG = 0x100, - UIS_HUGE = 0x1000, - UIS_CENTER = 0x10000, - UIS_RIGHT = 0x100000, - UIS_VCENTER = 0x1000000, - UIS_SILVER = 0x10000000, - UIS_GOLD = 0x100000000, - UIS_SML1 = 0x1000000000, - UIS_SML2 = 0x10000000000, - UIS_LIST = 0x100000000000, - UIS_DISABLED = 0x1000000000000, - UIS_HIDDEN = 0x10000000000000, + UIS_SMALL = 1 << 0, + UIS_MED = 1 << 1, + UIS_BIG = 1 << 2, + UIS_HUGE = 1 << 3, + UIS_CENTER = 1 << 4, + UIS_RIGHT = 1 << 5, + UIS_VCENTER = 1 << 6, + UIS_SILVER = 1 << 7, + UIS_GOLD = 1 << 8, + UIS_SML1 = 1 << 9, + UIS_SML2 = 1 << 10, + UIS_LIST = 1 << 11, + UIS_DISABLED = 1 << 12, + UIS_HIDDEN = 1 << 13, } UiFlags; typedef struct Art { @@ -63,9 +63,9 @@ typedef struct Art { typedef struct UI_Item { SDL_Rect rect; UiTypes type; - UiFlags flags; + int flags; int value; - BYTE *caption; + char *caption; void *context; } UI_Item; diff --git a/SourceX/dx.cpp b/SourceX/dx.cpp index c41230c3c..2821d22ad 100644 --- a/SourceX/dx.cpp +++ b/SourceX/dx.cpp @@ -391,7 +391,7 @@ void __fastcall dx_init(HWND hWnd) const int pitch = 64 + SCREEN_WIDTH + 64; gpBuffer = (Screen *)malloc(sizeof(Screen)); - gpBufEnd += (unsigned int)gpBuffer; + gpBufEnd += (uintptr_t)gpBuffer; pal_surface = SDL_CreateRGBSurfaceFrom(gpBuffer, pitch, 160 + SCREEN_HEIGHT + 16, 8, pitch, 0, 0, 0, 0); if (pal_surface == NULL) { @@ -454,7 +454,7 @@ void __fastcall j_lock_buf_priv(BYTE idx) void __fastcall j_unlock_buf_priv(BYTE idx) { - gpBufEnd -= (unsigned int)gpBufEnd; + gpBufEnd -= (uintptr_t)gpBufEnd; if (!surface_dirty) { return; diff --git a/SourceX/miniwin.cpp b/SourceX/miniwin.cpp index 69989d488..6883344af 100644 --- a/SourceX/miniwin.cpp +++ b/SourceX/miniwin.cpp @@ -518,7 +518,7 @@ int WINAPI GetDeviceCaps(HDC hdc, int index) BOOL GetWindowRect(HWND hDlg, tagRECT *Rect) { int x, y, w, h; - SDL_SetWindowPosition(window, &x, &y); + SDL_GetWindowPosition(window, &x, &y); SDL_GetWindowSize(window, &w, &h); Rect->right = x; @@ -669,7 +669,7 @@ void PostQuitMessage(int nExitCode) LRESULT DefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { - DUMMY(); + DUMMY_ONCE(); return NULL; } diff --git a/SourceX/miniwin_io.cpp b/SourceX/miniwin_io.cpp index edcb5c329..566219785 100644 --- a/SourceX/miniwin_io.cpp +++ b/SourceX/miniwin_io.cpp @@ -45,7 +45,7 @@ WINBOOL WINAPI ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRea DUMMY_ONCE(); assert(!lpOverlapped); - int len = read((int)hFile, lpBuffer, nNumberOfBytesToRead); + int len = read((intptr_t)hFile, lpBuffer, nNumberOfBytesToRead); assert(len != -1); *lpNumberOfBytesRead = len; return TRUE; @@ -57,7 +57,7 @@ DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh) assert(!lpFileSizeHigh); struct stat s; - int ret = fstat((int)hFile, &s); + int ret = fstat((intptr_t)hFile, &s); assert(ret == 0); return s.st_size; } @@ -68,7 +68,7 @@ WINBOOL WINAPI WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToW DUMMY_ONCE(); assert(!lpOverlapped); - ssize_t len = write((int)hFile, lpBuffer, nNumberOfBytesToWrite); + ssize_t len = write((intptr_t)hFile, lpBuffer, nNumberOfBytesToWrite); if (len == -1) { *lpNumberOfBytesWritten = 0; return FALSE; @@ -90,7 +90,7 @@ DWORD WINAPI SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistance } else { UNIMPLEMENTED(); } - off_t ret = lseek((int)hFile, lDistanceToMove, whence); + off_t ret = lseek((intptr_t)hFile, lDistanceToMove, whence); return (DWORD)ret; } @@ -98,9 +98,9 @@ WINBOOL WINAPI SetEndOfFile(HANDLE hFile) { DUMMY_ONCE(); - off_t cur = lseek((int)hFile, 0, SEEK_CUR); + off_t cur = lseek((intptr_t)hFile, 0, SEEK_CUR); assert(cur != -1); - int res = ftruncate((int)hFile, cur); + int res = ftruncate((intptr_t)hFile, cur); assert(res == 0); return TRUE; } @@ -131,8 +131,8 @@ WINBOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes) WINBOOL WINAPI CloseHandle(HANDLE hObject) { - if(files.find(hObject) != files.end()) { - int ret = close((int)hObject); + if (files.find(hObject) != files.end()) { + int ret = close((intptr_t)hObject); assert(ret == 0); files.erase(hObject); } diff --git a/SourceX/miniwin_thread.cpp b/SourceX/miniwin_thread.cpp index 95f70d14d..fe3e5bf81 100644 --- a/SourceX/miniwin_thread.cpp +++ b/SourceX/miniwin_thread.cpp @@ -1,7 +1,7 @@ #include "pch.h" -static std::set threads; -static std::set events; +static std::set threads; +static std::set events; struct event_emul { SDL_mutex *mutex; @@ -20,7 +20,7 @@ uintptr_t __cdecl _beginthreadex(void *_Security, unsigned _StackSize, unsigned( // WARNING: wrong return type of _StartAddress SDL_Thread *ret = SDL_CreateThread((SDL_ThreadFunction)_StartAddress, NULL, _ArgList); *_ThrdAddr = SDL_GetThreadID(ret); - threads.insert((HANDLE)ret); + threads.insert((uintptr_t)ret); return (uintptr_t)ret; } @@ -51,17 +51,17 @@ VOID WINAPI InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection) VOID WINAPI EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { - SDL_LockMutex(*lpCriticalSection); + SDL_LockMutex(*((SDL_mutex **)lpCriticalSection)); } VOID WINAPI LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { - SDL_UnlockMutex(*lpCriticalSection); + SDL_UnlockMutex(*((SDL_mutex **)lpCriticalSection)); } VOID WINAPI DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { - SDL_DestroyMutex(*lpCriticalSection); + SDL_DestroyMutex(*((SDL_mutex **)lpCriticalSection)); } HANDLE WINAPI CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, WINBOOL bManualReset, WINBOOL bInitialState, @@ -85,7 +85,7 @@ HANDLE WINAPI CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, WINBOOL bMan ret = (struct event_emul *)malloc(sizeof(struct event_emul)); ret->mutex = SDL_CreateMutex(); ret->cond = SDL_CreateCond(); - events.insert((HANDLE *)ret); + events.insert((uintptr_t)ret); return ret; } @@ -133,9 +133,9 @@ static DWORD wait_for_sdl_thread(HANDLE hHandle, DWORD dwMilliseconds) DWORD WINAPI WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) { // return value different from WinAPI - if (threads.find(hHandle) != threads.end()) + if (threads.find((uintptr_t)hHandle) != threads.end()) return wait_for_sdl_thread(hHandle, dwMilliseconds); - if (events.find(hHandle) != threads.end()) + if (events.find((uintptr_t)hHandle) != threads.end()) return wait_for_sdl_cond(hHandle, dwMilliseconds); UNIMPLEMENTED(); } diff --git a/SourceX/sound.cpp b/SourceX/sound.cpp index 99323be7b..c26a5a277 100644 --- a/SourceX/sound.cpp +++ b/SourceX/sound.cpp @@ -52,28 +52,28 @@ BOOL __fastcall snd_playing(TSnd *pSnd) void __fastcall snd_play_snd(TSnd *pSnd, int lVolume, int lPan) { - Mix_PlayChannel(-1, (void *)(pSnd->DSB), 0); + Mix_PlayChannel(-1, (Mix_Chunk *)(pSnd->DSB), 0); } TSnd *__fastcall sound_file_load(char *path) { int bytestoread; int nrread; - void *file; + HANDLE file; //This opens the file and reads it, makes Mix_chunk pointer to it. //Once this is done the pointer is stored TSnd Struct SFileOpenFile(path, &file); bytestoread = (int)SFileGetFileSize((HANDLE)file, 0); - char *MSFXBuffer = DiabloAllocPtr(bytestoread); + unsigned char *MSFXBuffer = DiabloAllocPtr(bytestoread); SFileReadFile(file, MSFXBuffer, bytestoread, (LPDWORD)&nrread, 0); SDL_RWops *rw = SDL_RWFromMem(MSFXBuffer, bytestoread); Mix_Chunk *SoundFX = Mix_LoadWAV_RW(rw, 1); TSnd *fx = (TSnd *)malloc(sizeof(TSnd)); memset(fx, 0, sizeof(TSnd)); - fx->DSB = (void *)SoundFX; + fx->DSB = (LPDIRECTSOUNDBUFFER)SoundFX; fx->start_tc = 0; fx->sound_path = NULL; diff --git a/SourceX/storm.cpp b/SourceX/storm.cpp index f6695cd4d..f37ed75b8 100644 --- a/SourceX/storm.cpp +++ b/SourceX/storm.cpp @@ -33,7 +33,6 @@ BOOL STORMAPI SFileDdaBeginEx(HANDLE directsound, DWORD flags, DWORD mask, unsig int bytestoread; int nrread; void *SFXbuffer; - SFXbuffer = directsound; bytestoread = (int)SFileGetFileSize(directsound, 0); SFXbuffer = DiabloAllocPtr(bytestoread); @@ -310,7 +309,7 @@ void setIniValue(const char *sectionName, const char *keyName, char *value, int BOOL STORMAPI SRegLoadData(const char *keyname, const char *valuename, int size, LPBYTE lpData, BYTE flags, LPDWORD lpcbData) { - return getIniValue(keyname, valuename, lpData, size, 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) @@ -471,7 +470,7 @@ BOOL __cdecl SVidPlayContinue(void) { if (smk_palette_updated(SVidSMK)) { SDL_Color colors[256]; - unsigned char *palette_data = smk_get_palette(SVidSMK); + const unsigned char *palette_data = smk_get_palette(SVidSMK); for (int i = 0; i < 256; i++) { colors[i].r = palette_data[i * 3 + 0]; @@ -496,7 +495,6 @@ BOOL __cdecl SVidPlayContinue(void) return SVidLoadNextFrame(); // Skip video and audio if the system is to slow } - printf("oiasjdf %d\n", deviceId); if (deviceId && SDL_QueueAudio(deviceId, smk_get_audio(SVidSMK, 0), smk_get_audio_size(SVidSMK, 0)) == -1) { SDL_Log("SDL_QueueAudio: %s\n", SDL_GetError()); return FALSE;