diff --git a/3rdParty/Storm/Source/StdAfx.cpp b/3rdParty/Storm/Source/StdAfx.cpp new file mode 100644 index 0000000..750ee6c --- /dev/null +++ b/3rdParty/Storm/Source/StdAfx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// storm.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/3rdParty/Storm/Source/StdAfx.h b/3rdParty/Storm/Source/StdAfx.h new file mode 100644 index 0000000..4e0398e --- /dev/null +++ b/3rdParty/Storm/Source/StdAfx.h @@ -0,0 +1,24 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__2197EABE_2E6C_4E93_90B8_DA67E0A2C425__INCLUDED_) +#define AFX_STDAFX_H__2197EABE_2E6C_4E93_90B8_DA67E0A2C425__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +// Insert your headers here +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +#include + +// TODO: reference additional headers your program requires here + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__2197EABE_2E6C_4E93_90B8_DA67E0A2C425__INCLUDED_) diff --git a/3rdParty/Storm/Source/_storm.h b/3rdParty/Storm/Source/_storm.h new file mode 100644 index 0000000..ea544c9 --- /dev/null +++ b/3rdParty/Storm/Source/_storm.h @@ -0,0 +1,1298 @@ +#pragma once + +#ifndef __BLIZZARD_STORM_HEADER +#define __BLIZZARD_STORM_HEADER + +#include +#include +#include +#include + +// Note to self: Linker error => forgot a return value in cpp + +// Storm API definition +#ifndef STORMAPI +#define STORMAPI __stdcall +#endif + +#ifndef __STORM_SMAX +#define __STORM_SMAX(x,y) (x < y ? y : x) +#endif + +#ifndef __STORM_SSIZEMAX +#define __STORM_SSIZEMAX(x,y) (__STORM_SMAX(sizeof(x),sizeof(y))) +#endif + +#ifndef __STORM_SMIN +#define __STORM_SMIN(x,y) (x < y ? x : y) +#endif + +#ifndef __STORM_SSIZEMIN +#define __STORM_SSIZEMIN(x,y) (__STORM_SMIN(sizeof(x),sizeof(y))) +#endif + +typedef struct _WRECT +{ + WORD left; + WORD top; + WORD right; + WORD bottom; +} WRECT, *PWRECT; + +typedef struct _WPOINT +{ + WORD x; + WORD y; +} WPOINT, *PWPOINT; + +typedef struct _WSIZE +{ + WORD cx; + WORD cy; +} WSIZE, *PWSIZE; + + + +// Game states +#define GAMESTATE_PRIVATE 0x01 +#define GAMESTATE_FULL 0x02 +#define GAMESTATE_ACTIVE 0x04 +#define GAMESTATE_STARTED 0x08 +#define GAMESTATE_REPLAY 0x80 + + +BOOL STORMAPI SNetCreateGame(const char *pszGameName, const char *pszGamePassword, const char *pszGameStatString, DWORD dwGameType, char *GameTemplateData, int GameTemplateSize, int playerCount, char *creatorName, char *a11, int *playerID); +BOOL STORMAPI SNetDestroy(); +BOOL STORMAPI SNetEnumProviders(int (STORMAPI *callback)(DWORD, DWORD, DWORD, DWORD), int mincaps); + +BOOL STORMAPI SNetEnumGames(int (STORMAPI *callback)(DWORD, DWORD, DWORD), int *hintnextcall); + +/* SNetDropPlayer @ 106 + * + * Drops a player from the current game. + * + * playerid: The player ID for the player to be dropped. + * flags: + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetDropPlayer( + int playerid, + DWORD flags); + +/* SNetGetGameInfo @ 107 + * + * Retrieves specific game information from Storm, such as name, password, + * stats, mode, game template, and players. + * + * type: The type of data to retrieve. See GAMEINFO_ flags. + * dst: The destination buffer for the data. + * length: The maximum size of the destination buffer. + * byteswritten: The number of bytes written to the destination buffer. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetGetGameInfo( + int type, + void *dst, + size_t length, + size_t *byteswritten = NULL); + + +#define SNGetGameInfo(typ,dst) SNetGetGameInfo(typ, &dst, sizeof(dst)) + + + +// Game info fields +#define GAMEINFO_NAME 1 +#define GAMEINFO_PASSWORD 2 +#define GAMEINFO_STATS 3 +#define GAMEINFO_MODEFLAG 4 +#define GAMEINFO_GAMETEMPLATE 5 +#define GAMEINFO_PLAYERS 6 + + +BOOL STORMAPI SNetGetNumPlayers(int *firstplayerid, int *lastplayerid, int *activeplayers); + + +typedef struct _CAPS +{ + DWORD dwSize; // Size of this structure // sizeof(CAPS) + DWORD dwUnk_0x04; // Some flags? + DWORD maxmessagesize; // Size of the packet buffer, must be beteen 128 and 512 + DWORD dwUnk_0x0C; // Unknown + DWORD dwDisplayedPlayerCount; // Displayed player count in the mode selection list + DWORD dwUnk_0x14; // some kind of timeout or timer related + DWORD dwPlayerLatency; // ... latency? + DWORD dwPlayerCount; // the number of players that can participate, must be between 1 and 20 + DWORD dwCallDelay; // the number of calls before data is sent over the network // between 2 and 8; single player is set to 1 +} CAPS, *PCAPS; + + +BOOL STORMAPI SNetGetPlayerCaps(char playerid, PCAPS playerCaps); + +/* SNetGetPlayerName @ 113 + * + * Retrieves the name of a player given their player ID. + * + * playerid: The player's ID. + * buffer: The buffer that will receive the name. + * buffersize: The maximum size of buffer. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetGetPlayerName( + int playerid, + char *buffer, + size_t buffersize); + +/* SNetGetProviderCaps @ 114 + * + * Retrieves network provider capacity information. + * + * providerCaps: A pointer to a CAPS structure that will receive the information. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetGetProviderCaps( + _SNETCAPS *providerCaps); + +/* SNetGetTurnsInTransit @ 115 + * + * Retrieves the number of turns (buffers) that have been queued + * before sending them over the network. + * + * turns: A pointer to an integer that will receive the value. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetGetTurnsInTransit( + int *turns); + + +BOOL STORMAPI SNetInitializeDevice(int a1, int a2, int a3, int a4, int *a5); + +// Network provider structures +typedef struct _client_info +{ + DWORD dwSize; // 60 + char *pszName; + char *pszVersion; + DWORD dwProduct; + DWORD dwVerbyte; + DWORD dwUnk5; + DWORD dwMaxPlayers; + DWORD dwUnk7; + DWORD dwUnk8; + DWORD dwUnk9; + DWORD dwUnk10; // 0xFF + char *pszCdKey; + char *pszCdOwner; + DWORD dwIsShareware; + DWORD dwLangId; +} client_info; + +typedef struct _user_info +{ + DWORD dwSize; // 16 + char *pszPlayerName; + char *pszUnknown; + DWORD dwUnknown; +} user_info; + +typedef struct _battle_info +{ + DWORD dwSize; // 92 + DWORD dwUnkType; + HWND hFrameWnd; + void *pfnBattleGetResource; + void *pfnBattleGetErrorString; + void *pfnBattleMakeCreateGameDialog; + void *pfnBattleUpdateIcons; + DWORD dwUnk_07; + void *pfnBattleErrorDialog; + void *pfnBattlePlaySound; + DWORD dwUnk_10; + void *pfnBattleGetCursorLink; + DWORD dwUnk_12; + void *pfnUnk_13; + DWORD dwUnk_14; + void *pfnBattleMakeProfileDialog; + char *pszProfileStrings; + void *pfnBattleDrawProfileInfo; + void *pfnUnk_18; + DWORD dwUnk_19; + void *pfnUnk_20; + void *pfnUnk_21; + void *pfnBattleSetLeagueName; +} battle_info; + +typedef struct _module_info +{ + DWORD dwSize; // 20 + char *pszVersionString; + char *pszModuleName; + char *pszMainArchive; + char *pszPatchArchive; +} module_info; + +typedef struct _game +{ + DWORD dwIndex; + DWORD dwGameState; + DWORD dwUnk_08; + SOCKADDR saHost; + DWORD dwUnk_1C; + DWORD dwTimer; + DWORD dwUnk_24; + char szGameName[128]; + char szGameStatString[128]; + _game *pNext; + void *pExtra; + DWORD dwExtraBytes; + DWORD dwProduct; + DWORD dwVersion; +} game; + +typedef struct _storm_head +{ + WORD wChecksum; + WORD wLength; + WORD wSent; + WORD wReceived; + BYTE bCommandClass; + BYTE bCommandType; + BYTE bPlayerId; + BYTE bFlags; +} storm_head; + + +// Traffic flags +#define STRAFFIC_NORMAL 0 +#define STRAFFIC_VERIFY 1 +#define STRAFFIC_RESEND 2 +#define STRAFFIC_REPLY 4 + + +/* SNetInitializeProvider @ 117 + * + * Initializes a provider by storing the provider callbacks, and calling + * spiInitialize() using the parameters passed to this function. + * Note: The use of the parameters is determined by the network + * module. + * + * providerName: The provider's identifier. Example: 'TENB' (BNET). + * gameClientInfo: A pointer to a clientInfo structure containing + * information about the game client. + * userData: A pointer to a userInfo structure containing information + * about the player. + * bnCallbacks: A pointer to a battleInfo structure containing callbacks + * and other information that is specific to Battle.net. + * moduleData: A pointer to a moduleInfo structure containing the + * executable information and paths to MPQ archives. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetInitializeProvider( + DWORD providerName, + _SNETPROGRAMDATA *gameClientInfo, + _SNETPLAYERDATA *userData, + _SNETUIDATA *bnCallbacks, + _SNETVERSIONDATA *moduleData); + + +BOOL STORMAPI SNetJoinGame(int id, char *gameName, char *gamePassword, char *playerName, char *userStats, int *playerid); + +/* SNetLeaveGame @ 119 + * + * Notifies Storm that the player has left the game. Storm will + * notify all connected peers through the network provider. + * + * type: The leave type. It doesn't appear to be important, no documentation available. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetLeaveGame( + int type); + +BOOL STORMAPI SNetPerformUpgrade(DWORD *upgradestatus); +BOOL STORMAPI SNetReceiveMessage(int *senderplayerid, char **data, int *databytes); +BOOL STORMAPI SNetReceiveTurns(int a1, int arraysize, char **arraydata, unsigned int *arraydatabytes, DWORD *arrayplayerstatus); + +// Values for arrayplayerstatus +#define SNET_PS_OK 0 +#define SNET_PS_WAITING 2 +#define SNET_PS_NOTRESPONDING 3 +#define SNET_PS_UNKNOWN default + + +// Event structure +typedef struct _s_evt +{ + DWORD dwFlags; + int dwPlayerId; + void *pData; + DWORD dwSize; +} S_EVT, *PS_EVT; + + +// @TODO: "type" is unknown. +HANDLE STORMAPI SNetRegisterEventHandler(int type, void (STORMAPI *sEvent)(_SNETEVENT *)); +HANDLE STORMAPI SNetUnregisterEventHandler(int type, void (STORMAPI *sEvent)(_SNETEVENT *)); + +int STORMAPI SNetSelectGame(int a1, int a2, int a3, int a4, int a5, int *playerid); + +/* SNetSendMessage @ 127 + * + * Sends a message to a player given their player ID. Network message + * is sent using class 01 and is retrieved by the other client using + * SNetReceiveMessage(). + * + * playerID: The player index of the player to receive the data. + * Conversely, this field can be one of the following constants: + * SNPLAYER_ALL | Sends the message to all players, including oneself. + * SNPLAYER_OTHERS | Sends the message to all players, except for oneself. + * data: A pointer to the data. + * databytes: The amount of bytes that the data pointer contains. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetSendMessage( + int playerID, + void *data, + size_t databytes); + + +// Macro values to target specific players +#define SNPLAYER_ALL -1 +#define SNPLAYER_OTHERS -2 + + +/* SNetSendTurn @ 128 + * + * Sends a turn (data packet) to all players in the game. Network data + * is sent using class 02 and is retrieved by the other client using + * SNetReceiveTurns(). + * + * data: A pointer to the data. + * databytes: The amount of bytes that the data pointer contains. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetSendTurn( + char *data, + size_t databytes); + +/* SNetSetGameMode @ 130 + * + * Set's the game's mode flags, notifying the network + * provider that the state of the game has changed. + * For example: notifies Battle.net when the game is + * full. + * + * You should first call SNetGetGameInfo to retrieve + * the existing mode flags. + * + * modeFlags: The new flags for the game mode. + * GAMESTATE_PRIVATE | The game is passworded. + * GAMESTATE_FULL | The game is full. + * GAMESTATE_ACTIVE | The game is available. + * GAMESTATE_STARTED | The game is in progress. + * GAMESTATE_REPLAY | The game is a replay. + * makePublic: Used to make the game a public game, removing the GAMESTATE_PRIVATE flag. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetSetGameMode( + DWORD modeFlags, + bool makePublic = false); + +#define SNMakeGamePublic() SNetSetGameMode( (DWORD mode, SNetGetGameInfo(GAMEINFO_MODEFLAGS, &mode, 4), mode), true) + +BOOL STORMAPI SNetEnumGamesEx(int a1, int a2, int (__fastcall *callback)(DWORD, DWORD, DWORD), int *hintnextcall); +BOOL STORMAPI SNetSendServerChatCommand(const char *command); + +BOOL STORMAPI SNetDisconnectAll(DWORD flags); +BOOL STORMAPI SNetCreateLadderGame(const char *pszGameName, const char *pszGamePassword, const char *pszGameStatString, DWORD dwGameType, DWORD dwGameLadderType, DWORD dwGameModeFlags, char *GameTemplateData, int GameTemplateSize, int playerCount, char *creatorName, char *a11, int *playerID); + +#define SNET_GAME_RESULT_WIN 1 +#define SNET_GAME_RESULT_LOSS 2 +#define SNET_GAME_RESULT_DRAW 3 +#define SNET_GAME_RESULT_DISCONNECT 4 + +BOOL STORMAPI SNetReportGameResult(unsigned a1, int size, int *results, const char* headerInfo, const char* detailInfo); + +int STORMAPI SNetSendLeagueCommand(char *cmd, char *callback); +int STORMAPI SNetSendReplayPath(int a1, int a2, char *replayPath); +int STORMAPI SNetGetLeagueName(int leagueID); +BOOL STORMAPI SNetGetPlayerNames(char **names); +int STORMAPI SNetLeagueLogout(char *bnetName); +int STORMAPI SNetGetLeaguePlayerName(char *curPlayerLeageName, size_t nameSize); + +HGDIOBJ STORMAPI SDlgDefDialogProc(HWND hDlg, signed int DlgType, HDC textLabel, HWND hWnd); + +HANDLE STORMAPI SDlgDialogBoxIndirectParam(HMODULE hModule, LPCSTR lpName, HWND hWndParent, LPVOID lpParam, LPARAM lParam); + +BOOL STORMAPI SDlgEndDialog(HWND hDlg, HANDLE nResult); + +BOOL STORMAPI SDlgSetControlBitmaps(HWND parentwindow, int *id, int a3, char *buffer2, char *buffer, int flags, int mask); + +/* +// lpCursorName can only be IDC_ARROW +BOOL STORMAPI SDlgSetSystemCursor(void *lpSrcBuffer, void *p_a2, LPSIZE lpSize, LPCSTR lpCursorName); +*/ + +BOOL STORMAPI SDlgBltToWindowE(HWND hWnd, HRGN a2, char *a3, int a4, void *buffer, RECT *rct, SIZE *size, int a8, int a9, DWORD rop); +BOOL STORMAPI SDlgSetBitmapE(HWND hWnd, int a2, char *src, int mask1, int flags, int a6, int a7, int width, int a9, int mask2); + +int STORMAPI Ordinal224(int a1); + +BOOL STORMAPI SFileCloseArchive(HANDLE hArchive); +BOOL STORMAPI SFileCloseFile(HANDLE hFile); + +BOOL STORMAPI SFileDdaBeginEx(HANDLE directsound, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, signed __int32 volume, signed int a6, int a7); +BOOL STORMAPI SFileDdaDestroy(); +BOOL STORMAPI SFileDdaEnd(HANDLE directsound); +BOOL STORMAPI SFileDdaGetPos(HANDLE directsound, int a2, int a3); + +BOOL STORMAPI SFileDdaInitialize(HANDLE directsound); +BOOL STORMAPI SFileDdaSetVolume(HANDLE directsound, signed int bigvolume, signed int volume); +BOOL STORMAPI SFileDestroy(); + +BOOL STORMAPI SFileGetFileArchive(HANDLE hFile, HANDLE archive); +LONG STORMAPI SFileGetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh); +BOOL STORMAPI SFileOpenArchive(const char *szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE *phMpq); + +// values for dwFlags +enum MPQFlags +{ + MPQ_NO_LISTFILE = 0x0010, + MPQ_NO_ATTRIBUTES = 0x0020, + MPQ_FORCE_V1 = 0x0040, + MPQ_CHECK_SECTOR_CRC = 0x0080 +}; + + +BOOL STORMAPI SFileOpenFile(const char *filename, HANDLE *phFile); +BOOL STORMAPI SFileOpenFileEx(HANDLE hMpq, const char *szFileName, DWORD dwSearchScope, HANDLE *phFile); + +// values for dwSearchScope +enum SFileFlags +{ + SFILE_FROM_MPQ = 0x00000000, + SFILE_FROM_ABSOLUTE = 0x00000001, + SFILE_FROM_RELATIVE = 0x00000002, + SFILE_FROM_DISK = 0x00000004 +}; + +BOOL STORMAPI SFileReadFile(HANDLE hFile, void *buffer, DWORD nNumberOfBytesToRead, DWORD *read, LONG lpDistanceToMoveHigh); + +void STORMAPI SFileSetLocale(LCID lcLocale); + +// mode: 0 - Silent (callback is NULL) +// 1 - Application Defined +// 2 - Handled by storm (callback is NULL) +// BOOL STORMAPI callback(const char *pszFilename, DWORD dwErrCode, DWORD dwErrCount) +BOOL STORMAPI SFileSetIoErrorMode(DWORD mode, BOOL (STORMAPI *callback)(const char*,DWORD,DWORD) ); + +BOOL STORMAPI SFileGetArchiveName(HANDLE hArchive, char *name, int length); +BOOL STORMAPI SFileGetFileName(HANDLE hFile, char *buffer, int length); + +BOOL STORMAPI SFileLoadFile(char *filename, void *buffer, int buffersize, int a4, int a5); +BOOL STORMAPI SFileUnloadFile(HANDLE hFile); +BOOL STORMAPI SFileLoadFileEx(void *hArchive, char *filename, int a3, int a4, int a5, DWORD searchScope, struct _OVERLAPPED *lpOverlapped); + +// Options are DWORD except for #6 +// 1: [TRUE|FALSE] - If true, reports resource leaks (SErrReportResourceLeak/SErrReportNamedResourceLeak) to the attached debugger instead of a message box. +// 2: This option is unused. +// 3: [TRUE|FALSE] - If true, reports general memory leaks to the attached debugger instead of a message box. +// 4: This option is unused. +// 5: [TRUE|FALSE] - If true, reports log messages and log dumps to the attached debugger. +// 6: { DWORD blocks_allocated; DWORD blocks_freed; } Used to determine the amount of memory/heap blocks that have been allocated and freed by storm. +// Can also be used for custom allocations outside of storm. +// +//BOOL STORMAPI StormGetOption(int type, void *pValue, size_t *pSize); +//BOOL STORMAPI StormSetOption(int type, void *pValue, size_t size); + +BOOL STORMAPI SBltROP3(void *lpDstBuffer, void *lpSrcBuffer, int srcDrawWidth, int srcDrawHeight, int dstWidth, int srcWidth, int a7, DWORD rop); +BOOL STORMAPI SBltROP3Clipped(void *lpDstBuffer, RECT *lpDstRect, POINT *lpDstPt, int a4, void *lpSrcBuffer, RECT *lpSrcRect, POINT *lpSrcPt, int a8, int a9, DWORD rop); + +#define SBMP_DEFAULT 0 +#define SBMP_BMP 1 +#define SBMP_PCX 2 +#define SBMP_TGA 3 + + +/* SBmpDecodeImage @ 321 + * + * Decodes an image that has already been loaded into a buffer. + * + * dwImgType: Optional, the image type. See SBMP_ macros. + * pSrcBuffer: A pointer to the source buffer. + * dwSrcBuffersize: The size of the data in the source buffer. + * pPalette: An optional buffer that receives the image palette. + * pDstBuffer: A buffer that receives the image data. + * dwDstBuffersize: The size of the specified image buffer. If the size of the + * destination buffer is 0, then the destination buffer is not used. + * pdwWidth: An optional variable that receives the image width. + * pdwHeight: An optional variable that receives the image height. + * pdwBpp: An optional variable that receives the image bits per pixel. + * + * Returns TRUE if the image was supported and decoded correctly, FALSE otherwise. + */ +BOOL +STORMAPI +SBmpDecodeImage( + DWORD dwImgType, + void *pSrcBuffer, + DWORD dwSrcBuffersize, + PALETTEENTRY *pPalette = NULL, + void *pDstBuffer = NULL, + DWORD dwDstBuffersize = 0, + DWORD *pdwWidth = NULL, + DWORD *pdwHeight = NULL, + DWORD *pdwBpp = NULL); + + +/* SBmpLoadImage @ 323 + * + * Load an image from an available archive into a buffer. + * + * pszFileName: The name of the graphic in an active archive. + * pPalette: An optional buffer that receives the image palette. + * pBuffer: A buffer that receives the image data. + * dwBuffersize: The size of the specified image buffer. + * pdwWidth: An optional variable that receives the image width. + * pdwHeight: An optional variable that receives the image height. + * pdwBpp: An optional variable that receives the image bits per pixel. + * + * Returns TRUE if the image was supported and loaded correctly, FALSE otherwise. + */ +BOOL +STORMAPI +SBmpLoadImage( + const char *pszFileName, + PALETTEENTRY *pPalette = NULL, + void *pBuffer = NULL, + DWORD dwBuffersize = 0, + DWORD *pdwWidth = NULL, + DWORD *pdwHeight = NULL, + DWORD *pdwBpp = NULL); + +/* SBmpSaveImage @ 324 + * + * Save an image from a buffer to a file. The image format is determined + * from the filename and is either .gif, .pcx, .tga, or .bmp being the default. + * + * pszFileName: The name of the file to create. + * pPalette: A pointer to a palette array containing 256 entries. + * pBuffer: A buffer containing the image data. + * pdwWidth: The width of the image. + * pdwHeight: The height of the image. + * pdwBpp: The bits per pixel. + * + * Returns TRUE if the image was saved correctly, FALSE otherwise. + */ +BOOL +STORMAPI +SBmpSaveImage( + const char *pszFileName, + PALETTEENTRY *pPalette, + void *pBuffer, + DWORD dwWidth, + DWORD dwHeight, + DWORD dwBpp = 8); + + +HANDLE STORMAPI SBmpAllocLoadImage(const char *fileName, PALETTEENTRY *palette, void **buffer, int *width, int *height, int unused6, int unused7, void *(STORMAPI *allocFunction)(DWORD)); + +BOOL STORMAPI SCodeCompile(char *directives1, char *directives2, char *loopstring, unsigned int maxiterations, unsigned int flags, HANDLE handle); +BOOL STORMAPI SCodeDelete(HANDLE handle); + +int STORMAPI SCodeExecute(HANDLE handle, int a2); + +BOOL STORMAPI SDrawAutoInitialize(HINSTANCE hInst, LPCSTR lpClassName, LPCSTR lpWindowName, WNDPROC pfnWndProc, int nMode, int nWidth, int nHeight, int nBits); + + +/* SDrawCaptureScreen @ 342 + * + * Saves a screenshot from the primary surface being handled by Storm. + * + * pszOutput: The name of the output file. The save format is automatically set by the extension. + * The extensions supported are .gif, .pcx, .tga, and .bmp. It will write a bitmap by default. + * + * Returns TRUE if successful and FALSE otherwise. + */ +BOOL +STORMAPI +SDrawCaptureScreen( + const char *pszOutput); + + +/* SDrawGetFrameWindow @ 346 + * + * Retrieves the window handle that was specified in + * SDrawManualInitialize or created in SDrawAutoInitialize. + * + * sdraw_framewindow: Optional variable that receives the returned handle. + * + * Returns the handle of the window. + */ +HWND +STORMAPI +SDrawGetFrameWindow( + HWND *sdraw_framewindow = NULL); + + +/* SDrawGetObjects @ 347 + * + * Retrieves the object information that was initialized using + * SDrawManualInitialize or SDrawAutoInitialize. + * + * ddInterface: The DirectDraw interface. + * primarySurface: The primary DirectDraw surface. + * surface2: A second unknown surface. + * surface3: A third unknown surface. + * backSurface: The back DirectDraw surface. + * ddPalette: The DirectDraw palette. + * hPalette: The palette handle. + * + * Returns FALSE if the direct draw interface has not been initialized. + */ +BOOL +STORMAPI +SDrawGetObjects( + LPDIRECTDRAW *ddInterface = NULL, + LPDIRECTDRAWSURFACE *primarySurface = NULL, + LPDIRECTDRAWSURFACE *surface2 = NULL, + LPDIRECTDRAWSURFACE *surface3 = NULL, + LPDIRECTDRAWSURFACE *backSurface = NULL, + LPDIRECTDRAWPALETTE *ddPalette = NULL, + HPALETTE *hPalette = NULL); + + +/* SDrawGetScreenSize @ 348 + * + * Obtains information for the current screen resolution. + * + * pdwWidth: Optional variable that receives the screen width. + * pdwHeight: Optional variable that receives the screen height. + * pdwBpp: Optional variable that receives the bits per pixel. + * + * Returns FALSE if no variables were specified. + */ +BOOL +STORMAPI +SDrawGetScreenSize( + DWORD *pdwWidth, + DWORD *pdwHeight, + DWORD *pdwBpp); + + +// undefined +BOOL STORMAPI SDrawLockSurface(int surfacenumber, RECT *lpDestRect, void **lplpSurface, int *lpPitch, int arg_unused); + + +/* SDrawManualInitialize @ 351 + * + * Sets the DirectDraw variables to be referenced in Storm. + * + * hWnd: The handle of the DirectDraw window. + * ddInterface: The DirectDraw interface. + * primarySurface: The first and primary surface. + * surface2: A second surface. Behaviour not completely known. + * surface3: A third surface. Behaviour not completely known. + * backSurface: The fourth and final surface. The back surface. + * ddPalette: The DirectDraw palette if the application requires it. + * hPalette: The palette handle that belongs to the window. + * If this is NULL and ddPalette is specified, then it + * will be created automatically. A palette can be created + * using the CreatePalette WinAPI function. + * + * Returns FALSE if no variables were specified. + */ +BOOL +STORMAPI +SDrawManualInitialize( + HWND hWnd = NULL, + LPDIRECTDRAW ddInterface = NULL, + LPDIRECTDRAWSURFACE primarySurface = NULL, + LPDIRECTDRAWSURFACE surface2 = NULL, + LPDIRECTDRAWSURFACE surface3 = NULL, + LPDIRECTDRAWSURFACE backSurface = NULL, + LPDIRECTDRAWPALETTE ddPalette = NULL, + HPALETTE hPalette = NULL); + + +/* SDrawPostClose @ 353 + * + * Posts a WM_QUIT message to the active drawing window specified + * in SDrawManualInitialize or created in SDrawAutoInitialize. + * + * Returns TRUE if successful and FALSE otherwise. + */ +BOOL +STORMAPI +SDrawPostClose(); + + +// undefined +//BOOL STORMAPI SDrawRealizePalette(); + +BOOL STORMAPI SDrawUnlockSurface(int surfacenumber, void *lpSurface, int a3, RECT *lpRect); +BOOL STORMAPI SDrawUpdatePalette(unsigned int firstentry, unsigned int numentries, PALETTEENTRY *pPalEntries, int a4); + +BOOL STORMAPI SEvtDispatch(DWORD dwMessageID, DWORD dwFlags, int type, PS_EVT pEvent); + +BOOL STORMAPI SGdiDeleteObject(HANDLE handle); + +BOOL STORMAPI SGdiExtTextOut(int a1, int a2, int a3, int a4, unsigned int a8, signed int a6, signed int a7, const char *pszString, unsigned int arg20); +BOOL STORMAPI SGdiImportFont(HGDIOBJ handle, int windowsfont); + +BOOL STORMAPI SGdiSelectObject(int handle); +BOOL STORMAPI SGdiSetPitch(int pitch); + +BOOL STORMAPI Ordinal393(char *pszString, int, int); + + +/* SMemAlloc @ 401 + * + * Allocates a block of memory. This block is different + * from the standard malloc by including a header containing + * information about the block. + * + * amount: The amount of memory to allocate, in bytes. + * logfilename: The name of the file or object that this call belongs to. + * logline: The line in the file or one of the SLOG_ macros. + * defaultValue: The default value of a byte in the allocated memory. + * + * Returns a pointer to the allocated memory. This pointer does NOT include + * the additional storm header. + */ +void* +STORMAPI +SMemAlloc( + size_t amount, + char *logfilename, + int logline, + char defaultValue = 0); + +#define SMAlloc(amount) SMemAlloc((amount), __FILE__, __LINE__) + + +/* SMemFree @ 403 + * + * Frees a block of memory that was created using SMemAlloc, + * includes the log file and line for debugging purposes. + * + * location: The memory location to be freed. + * logfilename: The name of the file or object that this call belongs to. + * logline: The line in the file or one of the SLOG_ macros. + * defaultValue: + * + * Returns TRUE if the call was successful and FALSE otherwise. + */ +BOOL +STORMAPI +SMemFree( + void *location, + char *logfilename, + int logline, + char defaultValue = 0); + +#define SMFree(loc) SMemFree((loc), __FILE__, __LINE__) + + +/* SMemReAlloc @ 405 + * + * Reallocates a block of memory that was created using SMemAlloc, + * includes the log file and line for debugging purposes. + * + * location: The memory location to be re-allocated. If this parameter + * is NULL, then SMemAlloc is called with the remaining parameters. + * amount: The amount of memory to re-allocate. + * logfilename: The name of the file or object that this call belongs to. + * logline: The line in the file or one of the SLOG_ macros. + * defaultValue: + * + * Returns a pointer to the re-allocated memory. This pointer does NOT include + * the additional storm header. + */ +void* +STORMAPI +SMemReAlloc( + void *location, + size_t amount, + char *logfilename, + int logline, + char defaultValue = 0); + +#define SMReAlloc(loc,s) SMemReAlloc((loc),(s), __FILE__, __LINE__) + +// Can be provided instead of logline/__LINE__ parameter to indicate different errors. +#define SLOG_EXPRESSION 0 +#define SLOG_FUNCTION -1 +#define SLOG_OBJECT -2 +#define SLOG_HANDLE -3 +#define SLOG_FILE -4 +#define SLOG_EXCEPTION -5 + + +BOOL STORMAPI SRegLoadData(const char *keyname, const char *valuename, int size, LPBYTE lpData, BYTE flags, LPDWORD lpcbData); +BOOL STORMAPI SRegLoadString(const char *keyname, const char *valuename, BYTE flags, char *buffer, size_t buffersize); +BOOL STORMAPI SRegLoadValue(const char *keyname, const char *valuename, BYTE flags, int *value); +BOOL STORMAPI SRegSaveData(const char *keyname, const char *valuename, int size, BYTE *lpData, DWORD cbData); +BOOL STORMAPI SRegSaveString(const char *keyname, const char *valuename, BYTE flags, char *string); +BOOL STORMAPI SRegSaveValue(const char *keyname, const char *valuename, BYTE flags, DWORD result); + +BOOL STORMAPI SRegDeleteValue(const char *keyname, const char *valuename, BYTE flags); + +// Flags for SReg functions + +// Default behaviour checks both HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER +// relative to the "Software\\Blizzard Entertainment\\" key in both hives. +#define SREG_NONE 0x00000000 +#define SREG_EXCLUDE_LOCAL_MACHINE 0x00000001 // excludes checking the HKEY_LOCAL_MACHINE hive +#define SREG_BATTLE_NET 0x00000002 // sets the relative key to "Software\\Battle.net\\" instead +#define SREG_EXCLUDE_CURRENT_USER 0x00000004 // excludes checking the HKEY_CURRENT_USER hive +#define SREG_ABSOLUTE 0x00000010 // specifies that the key is not a relative key + +BOOL STORMAPI STransBlt(void *lpSurface, int x, int y, int width, HANDLE hTrans); +BOOL STORMAPI STransBltUsingMask(void *lpDest, void *lpSource, int pitch, int width, HANDLE hTrans); + +BOOL STORMAPI STransDelete(HANDLE hTrans); + +BOOL STORMAPI STransDuplicate(HANDLE hTransSource, HANDLE hTransDest); +BOOL STORMAPI STransIntersectDirtyArray(HANDLE hTrans, char * dirtyarraymask, unsigned flags, HANDLE * phTransResult); +BOOL STORMAPI STransInvertMask(HANDLE hTrans, HANDLE * phTransResult); + +BOOL STORMAPI STransSetDirtyArrayInfo(int width, int height, int depth, int bits); + +BOOL STORMAPI STransPointInMask(HANDLE hTrans, int x, int y); // Name is a pure guess +BOOL STORMAPI STransCombineMasks(HANDLE hTransA, HANDLE hTransB, int left, int top, int flags, HANDLE * phTransResult); + +BOOL STORMAPI STransCreateE(void *pBuffer, int width, int height, int bpp, int a5, int bufferSize, HANDLE *phTransOut); + +BOOL STORMAPI SVidDestroy(); +BOOL STORMAPI SVidGetSize(HANDLE video, int width, int height, int zero); +BOOL STORMAPI SVidInitialize(HANDLE video); +BOOL STORMAPI SVidPlayBegin(char *filename, int arg4, int a3, int a4, int a5, int a6, HANDLE* video); + +BOOL STORMAPI SVidPlayContinueSingle(HANDLE video, int a2, int a3); +BOOL STORMAPI SVidPlayEnd(HANDLE video); + +/* SErrDisplayError @ 461 + * + * Displays a formatted error message. The message is detailed and flexible for many applications. + * The message will be different if there is a debugger attached. Will typically terminate the application + * unless the option to continue is given. + * + * dwErrMessage: The error code. See SErrGetLastError and GetLastError. + * logfilename: The name of the file or object that this call belongs to. + * logline: The line in the file or one of the SLOG_ macros. + * message: A message or expression with additional information. + * allowOption: If TRUE, allows the user the option to continue execution, otherwise the program will terminate. + * exitCode: The exit code used for program termination. + * + * Returns TRUE if the user chose to continue execution, FALSE otherwise. + */ +BOOL +STORMAPI +SErrDisplayError( + DWORD dwErrMsg, + const char *logfilename, + int logline, + const char *message = NULL, + BOOL allowOption = FALSE, + int exitCode = 1); + +#define SAssert(x) { if ( !(x) ) SErrDisplayError(STORM_ERROR_ASSERTION, __FILE__, __LINE__, #x) } + +#define SEDisplayError(err) SErrDisplayError(e, __FILE__, __LINE__) + +/* SErrGetErrorStr @ 462 + * + * Retrieves a string that describes the specified error code for + * the system, Storm, DirectDraw, or DirectSound. + * + * dwErrCode: The error code to look up. + * buffer: The destination buffer to receive the string. + * bufferchars: The size of the destination buffer. + * + * Returns TRUE if the call was successful and FALSE otherwise. + */ +BOOL +STORMAPI +SErrGetErrorStr( + DWORD dwErrCode, + char *buffer, + size_t bufferchars); + +#define SEGetErrorStr(e,b) SErrGetErrorStr(e,b,sizeof(b)) + + +/* SErrGetLastError @ 463 + * + * Retrieves the last error that was specifically + * set for the Storm library. + * + * Returns the last error set within the Storm library. + */ +DWORD +STORMAPI +SErrGetLastError(); + + +// Registers a module as a message source for SErrGetErrorStr, always returns TRUE +// groupID is a group in a MessageTable entry for example in STORM_ERROR_BAD_ARGUMENT 0x85100065, 0x510 is the group. +// BOOL STORMAPI SErrRegisterMessageSource(WORD groupID, HMODULE hSourceModule, int a3) + + +/* SErrSetLastError @ 465 + * + * Sets the last error for the Storm library and the Kernel32 library. + * + * dwErrCode: The error code that will be set. + */ +void +STORMAPI +SErrSetLastError( + DWORD dwErrCode = NO_ERROR); + +// +// void STORMAPI SErrReportNamedResourceLeak(const char *pszMsg, const char *pszSubMsg = nullptr) +// void STORMAPI SErrReportResourceLeak(const char *pszMsg) + +void STORMAPI SErrSuppressErrors(BOOL suppressErrors); + +// Values for dwErrCode +#define STORM_ERROR_ASSERTION 0x85100000 +#define STORM_ERROR_BAD_ARGUMENT 0x85100065 +#define STORM_ERROR_GAME_ALREADY_STARTED 0x85100066 +#define STORM_ERROR_GAME_FULL 0x85100067 +#define STORM_ERROR_GAME_NOT_FOUND 0x85100068 +#define STORM_ERROR_GAME_TERMINATED 0x85100069 +#define STORM_ERROR_INVALID_PLAYER 0x8510006a +#define STORM_ERROR_NO_MESSAGES_WAITING 0x8510006b +#define STORM_ERROR_NOT_ARCHIVE 0x8510006c +#define STORM_ERROR_NOT_ENOUGH_ARGUMENTS 0x8510006d +#define STORM_ERROR_NOT_IMPLEMENTED 0x8510006e +#define STORM_ERROR_NOT_IN_ARCHIVE 0x8510006f +#define STORM_ERROR_NOT_IN_GAME 0x85100070 +#define STORM_ERROR_NOT_INITIALIZED 0x85100071 +#define STORM_ERROR_NOT_PLAYING 0x85100072 +#define STORM_ERROR_NOT_REGISTERED 0x85100073 +#define STORM_ERROR_REQUIRES_CODEC1 0x85100074 +#define STORM_ERROR_REQUIRES_CODEC2 0x85100075 +#define STORM_ERROR_REQUIRES_CODEC3 0x85100076 +#define STORM_ERROR_REQUIRES_UPGRADE 0x85100077 +#define STORM_ERROR_STILL_ACTIVE 0x85100078 +#define STORM_ERROR_VERSION_MISMATCH 0x85100079 +#define STORM_ERROR_MEM_NOT_ALLOCATED 0x8510007a +#define STORM_ERROR_MEM_CORRUPTED 0x8510007b +#define STORM_ERROR_MEM_INVALID 0x8510007c +#define STORM_ERROR_MEM_MANAGER_NOT_INITIALIZED 0x8510007d +#define STORM_ERROR_MEM_NOT_FREED 0x8510007e +#define STORM_ERROR_RESOURCES_NOT_RELEASED 0x8510007f +#define STORM_ERROR_OUT_OF_BOUNDS 0x85100080 +#define STORM_ERROR_NULL_POINTER 0x85100081 +#define STORM_ERROR_CDKEY_MISMATCH 0x85100082 +#define STORM_ERROR_FILE_CORRUPTED 0x85100083 +#define STORM_ERROR_FATAL 0x85100084 +#define STORM_ERROR_GAMETYPE_UNAVAILABLE 0x85100085 + + +/* SMemCopy @ 491 + * + * Copies a block of memory from source to destination. + * This function immediately calls memcpy. See online documentation + * of memcpy for more details. + * + * dest: The destination buffer. + * source: The source buffer. + * size: The number of bytes to copy. + */ +void +STORMAPI +SMemCopy( + void *dest, + const void *source, + size_t size); + +#define SMCopy(d,s) ( SMemCopy(d, s, __STORM_SSIZEMIN(s,d)) ) + +/* SMemFill @ 492 + * + * Fills a block of memory with the specified character. + * This function immediately calls memset. See online documentation + * of memset for more details. + * + * dest: The destination buffer. + * source: The size of the destination buffer. + * size: The format to use. + */ +void +STORMAPI +SMemFill( + void *location, + size_t length, + char fillWith = 0); + +#define SMFill(l,f) (SMemFill(l, sizeof(l), f)) + +/* SMemZero @ 494 + * + * Fills a block of memory with the integer 0x00 (Zero). + * + * location: The location to write at. + * length: The amount of bytes to write. + */ +void +STORMAPI +SMemZero( + void *location, + size_t length); + +#define SMZero(l) (SMemZero(l, sizeof(l))) + + +int STORMAPI SMemCmp(void *location1, void *location2, DWORD size); + +#define SMCmp(l,x) ( SMemCmp(l, x, __STORM_SSIZEMIN(x,l)) ) + +/* SStrCopy @ 501 + * + * Copies a string from src to dest (including NULL terminator) + * until the max_length is reached. + * + * dest: The destination array. + * src: The source array. + * max_length: The maximum length of dest. + * + * Returns the number of characters copied. + */ +int +STORMAPI +SStrCopy( + char *dest, + const char *src, + int max_length = 0x7FFFFFFF); + +#define SSCopy(d,s) (SStrCopy(d, s, sizeof(d))) + +#define STORM_HASH_ABSOLUTE 1 + +/* SStrHash @ 502 + * + * Creates a simple hash for the string. This function + * should NOT be used for sensitive information. + * + * string: The input string. + * flags: If STORM_HASH_ABSOLUTE is set then this + function uses the absolute string, otherwise + it will convert backslashes to forward + slashes and some other processing. + * seed: The hash seed. If this value is 0 then the + * default value 0x7FED7FED will be used. + * + * Returns the 32-bit hash of the string. + */ +DWORD +STORMAPI +SStrHash( + const char *string, + DWORD flags = 0, + DWORD Seed = 0); + +int STORMAPI SStrNCat(char *dest, const char *src, DWORD max_length); + +/* SStrLen @ 506 + * + * Retrieves the length of a string. + * + * string: The input string of which to obtain a + * length for. + * + * Returns the length of the string. + */ +int +STORMAPI +SStrLen( + const char *string); + +/* SStrCmp @ 508 + * + * Compares two strings case sensitive. + * + * string1: The first string. + * string2: The second string. + * size: The maximum amount of characters to compare. + * + * Returns 0 if strings are equal. See strcmp documentation for more details. + */ +int +STORMAPI +SStrCmp( + const char *string1, + const char *string2, + size_t size); + +#define SSCmp(s,x) ( SStrCmp(s,x,__STORM_SSIZEMIN(s,x)) ) + +/* SStrCmpI @ 509 + * + * Compares two strings case insensitive. + * + * string1: The first string. + * string2: The second string. + * size: The maximum amount of characters to compare. + * + * Returns 0 if strings are equal. See strcmpi documentation for more details. + */ +int +STORMAPI +SStrCmpI( + const char *string1, + const char *string2, + size_t size); + +#define SSCmpI(s,x) ( SStrCmpI(s,x,__STORM_SSIZEMIN(s,x)) ) + +/* SStrUpper @ 510 + * + * Converts all lower-case alpha characters of a string to upper-case. + * + * string: The string to convert. + * + * Returns the same pointer given in the input. + */ +char* +STORMAPI +SStrUpper( + char* string); + +void STORMAPI SRgn523(HANDLE hRgn, RECT *pRect, int a3, int a4); +void STORMAPI SRgnCreateRegion(HANDLE *hRgn, int a2); +void STORMAPI SRgnDeleteRegion(HANDLE hRgn); + +void STORMAPI SRgn529i(int handle, int a2, int a3); + + +/* SErrDisplayErrorFmt @ 562 + * + * Displays a formatted error message. The message is detailed and flexible for many applications. + * The message will be different if there is a debugger attached. Will typically terminate the application + * unless the option to continue is given. + * + * dwErrMessage: The error code. See SErrGetLastError and GetLastError. + * logfilename: The name of the file or object that this call belongs to. + * logline: The line in the file or one of the SLOG_ macros. + * allowOption: If TRUE, allows the user the option to continue execution, otherwise the program will terminate. + * exitCode: The exit code used for program termination. + * format: Additional message formatting. See printf. + * + * Returns TRUE if the user chose to continue execution, FALSE otherwise. + */ +BOOL +SErrDisplayErrorFmt( + DWORD dwErrMsg, + const char *logfilename, + int logline, + BOOL allowOption, + int exitCode, + const char *format, + ...); + +//#define SEDisplayErrorFmt(err,...) SErrDisplayErrorFmt(err, __FILE__, __LINE__, FALSE, 1, __VA_ARGS__) + +/* SErrCatchUnhandledExceptions @ 567 + * + * Registers a top-level exception filter managed entirely by Storm. + * The registered filter will display formatted exception information by calling SErrDisplayError. + */ +void +STORMAPI +SErrCatchUnhandledExceptions(); + + +/* SStrChr @ 571 + * + * Searches a string for the given character. See + * strchr documentation for more details. + * + * string: The string to search. + * c: The character to search for. + * + * Returns a pointer to the first occurance of the character. + */ +char* +STORMAPI +SStrChr( + const char *string, + char c); + + +char *STORMAPI SStrChrR(const char *string, char c); + + +/* SStrVPrintf @ 578 + * + * Prints a formatted string to a destination buffer. + * This function calls vsnprintf with some extra error handling. + * See online documentation of vsnprintf for more details. + * + * dest: The destination buffer. + * size: The size of the destination buffer. + * format: The format to use. + * + * Returns the number of characters written. + */ +size_t +SStrVPrintf( + char *dest, + size_t size, + const char *format, ...); + + +int STORMAPI SBigDel(void *buffer); + +int STORMAPI SBigFromBinary(void *buffer, const void *str, size_t size); + +int STORMAPI SBigNew(void **buffer); + +int STORMAPI SBigPowMod(void *buffer1, void *buffer2, int a3, int a4); + +int STORMAPI SBigToBinaryBuffer(void *buffer, int length, int a3, int a4); + + +bool StormDestroy(); +void SDrawDestroy(); +bool __stdcall SFileSetBasePath(char *base_dir); +void SDrawRealizePalette(); +bool SVidPlayContinue(); +bool __stdcall SNetGetOwnerTurnsWaiting(int *turns); +bool __stdcall SNetSetBasePlayer(int base_player_num); +int __stdcall SFileSetFilePointer(HANDLE file1, int offset, HANDLE file2, int whence); + +void __stdcall SDrawMessageBox(char *text, char *caption, int type); +#endif diff --git a/3rdParty/Storm/Source/storm.cpp b/3rdParty/Storm/Source/storm.cpp new file mode 100644 index 0000000..be40c9a --- /dev/null +++ b/3rdParty/Storm/Source/storm.cpp @@ -0,0 +1,238 @@ +#include "storm.h" + +#define rBool { return TRUE; } +#define rPVoid { return NULL; } +#define rVoid { return; } +#define rInt { return 0; } + +BOOL STORMAPI SNetCreateGame(const char *pszGameName, const char *pszGamePassword, const char *pszGameStatString, DWORD dwGameType, char *GameTemplateData, int GameTemplateSize, int playerCount, char *creatorName, char *a11, int *playerID) rBool; +BOOL STORMAPI SNetDestroy() rBool; +BOOL STORMAPI SNetEnumProviders(int (STORMAPI *callback)(DWORD, DWORD, DWORD, DWORD), int mincaps) rBool; + +BOOL STORMAPI SNetEnumGames(int (STORMAPI *callback)(DWORD, DWORD, DWORD), int *hintnextcall) rBool; +BOOL STORMAPI SNetDropPlayer(int playerid, DWORD flags) rBool; +BOOL STORMAPI SNetGetGameInfo(int type, void *dst, size_t length, size_t *byteswritten) rBool; + +BOOL STORMAPI SNetGetNumPlayers(int *firstplayerid, int *lastplayerid, int *activeplayers) rBool; + +BOOL STORMAPI SNetGetPlayerCaps(char playerid, PCAPS playerCaps) rBool; +BOOL STORMAPI SNetGetPlayerName(int playerid, char *buffer, size_t buffersize) rBool; +//BOOL STORMAPI SNetGetProviderCaps(PCAPS providerCaps) rBool; +BOOL STORMAPI SNetGetTurnsInTransit(int *turns) rBool; +BOOL STORMAPI SNetInitializeDevice(int a1, int a2, int a3, int a4, int *a5) rBool; +//BOOL STORMAPI SNetInitializeProvider(DWORD providerName, client_info *gameClientInfo, user_info *userData, battle_info *bnCallbacks, module_info *moduleData) rBool; +BOOL STORMAPI SNetJoinGame(int id, char *gameName, char *gamePassword, char *playerName, char *userStats, int *playerid) rBool; +BOOL STORMAPI SNetLeaveGame(int type) rBool; +BOOL STORMAPI SNetPerformUpgrade(DWORD *upgradestatus) rBool; +BOOL STORMAPI SNetReceiveMessage(int *senderplayerid, char **data, int *databytes) rBool; +BOOL STORMAPI SNetReceiveTurns(int a1, int arraysize, char **arraydata, unsigned int *arraydatabytes, DWORD *arrayplayerstatus) rBool; +//HANDLE STORMAPI SNetRegisterEventHandler(int type, void (STORMAPI *sEvent)(PS_EVT)) rPVoid; + +int STORMAPI SNetSelectGame(int a1, int a2, int a3, int a4, int a5, int *playerid) rInt; + +BOOL STORMAPI SNetSendMessage(int playerID, void *data, size_t databytes) rBool; +BOOL STORMAPI SNetSendTurn(char *data, size_t databytes) rBool; + +BOOL STORMAPI SNetSetGameMode(DWORD modeFlags, bool makePublic) rBool; + +BOOL STORMAPI SNetEnumGamesEx(int a1, int a2, int (__fastcall *callback)(DWORD, DWORD, DWORD), int *hintnextcall) rBool; +BOOL STORMAPI SNetSendServerChatCommand(const char *command) rBool; + +BOOL STORMAPI SNetDisconnectAll(DWORD flags) rBool; +BOOL STORMAPI SNetCreateLadderGame(const char *pszGameName, const char *pszGamePassword, const char *pszGameStatString, DWORD dwGameType, DWORD dwGameLadderType, DWORD dwGameModeFlags, char *GameTemplateData, int GameTemplateSize, int playerCount, char *creatorName, char *a11, int *playerID) rBool; +BOOL STORMAPI SNetReportGameResult(unsigned a1, int size, int *results, const char* headerInfo, const char* detailInfo) rBool; + +int STORMAPI SNetSendLeagueCommand(char *cmd, char *callback) rInt; +int STORMAPI SNetSendReplayPath(int a1, int a2, char *replayPath) rInt; +int STORMAPI SNetGetLeagueName(int leagueID) rInt; +BOOL STORMAPI SNetGetPlayerNames(char **names) rBool; +int STORMAPI SNetLeagueLogout(char *bnetName) rInt; +int STORMAPI SNetGetLeaguePlayerName(char *curPlayerLeageName, size_t nameSize) rInt; + +HGDIOBJ STORMAPI SDlgDefDialogProc(HWND hDlg, signed int DlgType, HDC textLabel, HWND hWnd) rPVoid; + +HANDLE STORMAPI SDlgDialogBoxIndirectParam(HMODULE hModule, LPCSTR lpName, HWND hWndParent, LPVOID lpParam, LPARAM lParam) rPVoid; + +BOOL STORMAPI SDlgEndDialog(HWND hDlg, HANDLE nResult) rBool; + +BOOL STORMAPI SDlgSetControlBitmaps(HWND parentwindow, int *id, int a3, char *buffer2, char *buffer, int flags, int mask) rBool; + +BOOL STORMAPI SDlgBltToWindowE(HWND hWnd, HRGN a2, char *a3, int a4, void *buffer, RECT *rct, SIZE *size, int a8, int a9, DWORD rop) rBool; +BOOL STORMAPI SDlgSetBitmapE(HWND hWnd, int a2, char *src, int mask1, int flags, int a6, int a7, int width, int a9, int mask2) rBool; + +int STORMAPI Ordinal224(int a1) rInt; + +BOOL STORMAPI SFileCloseArchive(HANDLE hArchive) rBool; +BOOL STORMAPI SFileCloseFile(HANDLE hFile) rBool; + +BOOL STORMAPI SFileDdaBeginEx(HANDLE directsound, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, signed __int32 volume, signed int a6, int a7) rBool; +BOOL STORMAPI SFileDdaDestroy() rBool; +BOOL STORMAPI SFileDdaEnd(HANDLE directsound) rBool; +BOOL STORMAPI SFileDdaGetPos(HANDLE directsound, int a2, int a3) rBool; + +BOOL STORMAPI SFileDdaInitialize(HANDLE directsound) rBool; +BOOL STORMAPI SFileDdaSetVolume(HANDLE directsound, signed int bigvolume, signed int volume) rBool; +BOOL STORMAPI SFileDestroy() rBool; + +BOOL STORMAPI SFileGetFileArchive(HANDLE hFile, HANDLE archive) rBool; +LONG STORMAPI SFileGetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh) rInt; +BOOL STORMAPI SFileOpenArchive(const char *szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE *phMpq) rBool; +BOOL STORMAPI SFileOpenFile(const char *filename, HANDLE *phFile) rBool; +BOOL STORMAPI SFileOpenFileEx(HANDLE hMpq, const char *szFileName, DWORD dwSearchScope, HANDLE *phFile) rBool; +BOOL STORMAPI SFileReadFile(HANDLE hFile, void *buffer, DWORD nNumberOfBytesToRead, DWORD *read, LONG lpDistanceToMoveHigh) rBool; + +void STORMAPI SFileSetLocale(LCID lcLocale) rVoid; + +BOOL STORMAPI SFileSetIoErrorMode(int mode, BOOL (STORMAPI *callback)(char*,int,int) ) rBool; +BOOL STORMAPI SFileGetArchiveName(HANDLE hArchive, char *name, int length) rBool; +BOOL STORMAPI SFileGetFileName(HANDLE hFile, char *buffer, int length) rBool; + +BOOL STORMAPI SFileLoadFile(char *filename, void *buffer, int buffersize, int a4, int a5) rBool; +BOOL STORMAPI SFileUnloadFile(HANDLE hFile) rBool; +BOOL STORMAPI SFileLoadFileEx(void *hArchive, char *filename, int a3, int a4, int a5, DWORD searchScope, struct _OVERLAPPED *lpOverlapped) rBool; + +BOOL STORMAPI SBltROP3(void *lpDstBuffer, void *lpSrcBuffer, int width, int height, int a5, int a6, int a7, DWORD rop) rBool; +BOOL STORMAPI SBltROP3Clipped(void *lpDstBuffer, RECT *lpDstRect, POINT *lpDstPt, int a4, void *lpSrcBuffer, RECT *lpSrcRect, POINT *lpSrcPt, int a8, int a9, DWORD rop) rBool; + +BOOL STORMAPI SBmpDecodeImage(DWORD dwImgType, void *pSrcBuffer, DWORD dwSrcBuffersize, PALETTEENTRY *pPalette, void *pDstBuffer, DWORD dwDstBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp) rBool; + +BOOL STORMAPI SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, void *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *dwHeight, DWORD *pdwBpp) rBool; + +BOOL STORMAPI SBmpSaveImage(const char*, PALETTEENTRY*, void*, DWORD, DWORD, DWORD) rBool; +HANDLE STORMAPI SBmpAllocLoadImage(const char *fileName, PALETTEENTRY *palette, void **buffer, int *width, int *height, int unused6, int unused7, void *(STORMAPI *allocFunction)(DWORD)) rPVoid; + +BOOL STORMAPI SCodeCompile(char *directives1, char *directives2, char *loopstring, unsigned int maxiterations, unsigned int flags, HANDLE handle) rBool; +BOOL STORMAPI SCodeDelete(HANDLE handle) rBool; + +int STORMAPI SCodeExecute(HANDLE handle, int a2) rInt; + +BOOL STORMAPI SDrawAutoInitialize(HINSTANCE hInst, LPCSTR lpClassName, LPCSTR lpWindowName, WNDPROC pfnWndProc, int nMode, int nWidth, int nHeight, int nBits) rBool; +BOOL STORMAPI SDrawCaptureScreen(const char *source) rBool; + +HWND STORMAPI SDrawGetFrameWindow(HWND *sdraw_framewindow) rPVoid; +BOOL STORMAPI SDrawGetObjects(LPDIRECTDRAW *ddInterface, LPDIRECTDRAWSURFACE *primarySurface, LPDIRECTDRAWSURFACE *surface2, LPDIRECTDRAWSURFACE *surface3, LPDIRECTDRAWSURFACE *backSurface, LPDIRECTDRAWPALETTE *ddPalette, HPALETTE *hPalette) rBool; +BOOL STORMAPI SDrawGetScreenSize(DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp) rBool; + +BOOL STORMAPI SDrawLockSurface(int surfacenumber, RECT *lpDestRect, void **lplpSurface, int *lpPitch, int arg_unused) rBool; +BOOL STORMAPI SDrawManualInitialize(HWND hWnd, LPDIRECTDRAW ddInterface, LPDIRECTDRAWSURFACE primarySurface, LPDIRECTDRAWSURFACE surface2, LPDIRECTDRAWSURFACE surface3, LPDIRECTDRAWSURFACE backSurface, LPDIRECTDRAWPALETTE ddPalette, HPALETTE hPalette) rBool; + +BOOL STORMAPI SDrawPostClose() rBool; +//BOOL STORMAPI SDrawRealizePalette() rBool; + +BOOL STORMAPI SDrawUnlockSurface(int surfacenumber, void *lpSurface, int a3, RECT *lpRect) rBool; +BOOL STORMAPI SDrawUpdatePalette(unsigned int firstentry, unsigned int numentries, PALETTEENTRY *pPalEntries, int a4) rBool; + +BOOL STORMAPI SEvtDispatch(DWORD dwMessageID, DWORD dwFlags, int type, PS_EVT pEvent) rBool; + +BOOL STORMAPI SGdiDeleteObject(HANDLE handle) rBool; + +BOOL STORMAPI SGdiExtTextOut(int a1, int a2, int a3, int a4, unsigned int a8, signed int a6, signed int a7, const char *string, unsigned int arg20) rBool; +BOOL STORMAPI SGdiImportFont(HGDIOBJ handle, int windowsfont) rBool; + +BOOL STORMAPI SGdiSelectObject(int handle) rBool; +BOOL STORMAPI SGdiSetPitch(int pitch) rBool; + +BOOL STORMAPI Ordinal393(char *string, int, int) rBool; + +void* STORMAPI SMemAlloc(size_t amount, char *logfilename, int logline, char defaultValue) rPVoid; + +BOOL STORMAPI SMemFree(void *location, char *logfilename, int logline, char defaultValue) rBool; + +void* STORMAPI SMemReAlloc(void *location, size_t amount, char *logfilename, int logline, char defaultValue) rPVoid; + +BOOL STORMAPI SRegLoadData(const char *keyname, const char *valuename, int size, LPBYTE lpData, BYTE flags, LPDWORD lpcbData) rBool; +BOOL STORMAPI SRegLoadString(const char *keyname, const char *valuename, BYTE flags, char *buffer, size_t buffersize) rBool; +BOOL STORMAPI SRegLoadValue(const char *keyname, const char *valuename, BYTE flags, int *value) rBool; +BOOL STORMAPI SRegSaveData(const char *keyname, const char *valuename, int size, BYTE *lpData, DWORD cbData) rBool; +BOOL STORMAPI SRegSaveString(const char *keyname, const char *valuename, BYTE flags, char *string) rBool; +BOOL STORMAPI SRegSaveValue(const char *keyname, const char *valuename, BYTE flags, DWORD result) rBool; + +BOOL STORMAPI SRegDeleteValue(const char *keyname, const char *valuename, BYTE flags) rBool; + +BOOL STORMAPI STransBlt(void *lpSurface, int x, int y, int width, HANDLE hTrans) rBool; +BOOL STORMAPI STransBltUsingMask(void *lpSurface, void *lpSource, int pitch, int width, HANDLE hTrans) rBool; + +BOOL STORMAPI STransDelete(HANDLE hTrans) rBool; + +BOOL STORMAPI STransDuplicate(HANDLE hTransSource, HANDLE hTransDest) rBool; +BOOL STORMAPI STransIntersectDirtyArray(HANDLE hTrans, char * dirtyarraymask, unsigned flags, HANDLE * phTransResult) rBool; +BOOL STORMAPI STransInvertMask(HANDLE hTrans, HANDLE * phTransResult) rBool; + +BOOL STORMAPI STransSetDirtyArrayInfo(int width, int height, int depth, int bits) rBool; + +BOOL STORMAPI STransPointInMask(HANDLE hTrans, int x, int y) rBool; +BOOL STORMAPI STransCombineMasks(HANDLE hTransA, HANDLE hTransB, int left, int top, int flags, HANDLE * phTransResult) rBool; + +BOOL STORMAPI STransCreateE(void *pBuffer, int width, int height, int bpp, int a5, int bufferSize, HANDLE *phTransOut) rBool; + +BOOL STORMAPI SVidDestroy() rBool; +BOOL STORMAPI SVidGetSize(HANDLE video, int width, int height, int zero) rBool; +BOOL STORMAPI SVidInitialize(HANDLE video) rBool; +BOOL STORMAPI SVidPlayBegin(char *filename, int arg4, int a3, int a4, int a5, int a6, HANDLE* video) rBool; + +BOOL STORMAPI SVidPlayContinueSingle(HANDLE video, int a2, int a3) rBool; +BOOL STORMAPI SVidPlayEnd(HANDLE video) rBool; + +BOOL STORMAPI SErrDisplayError(DWORD dwErrMsg, const char *logfilename, int logline, const char *message, BOOL allowOption, int exitCode) rBool; +BOOL STORMAPI SErrGetErrorStr(DWORD dwErrCode, char *buffer, size_t bufferchars) rBool; +DWORD STORMAPI SErrGetLastError() rInt; + +void STORMAPI SErrSetLastError(DWORD dwErrCode) rVoid; + +void STORMAPI SErrSuppressErrors(BOOL suppressErrors) rVoid; + +void STORMAPI SMemCopy(void *dest, const void *source, size_t size) rVoid; +void STORMAPI SMemFill(void *location, size_t length, char fillWith) rVoid; + +void STORMAPI SMemZero(void *location, DWORD length) rVoid; +int STORMAPI SMemCmp(void *location1, void *location2, DWORD size) rInt; + +int STORMAPI SStrCopy(char *dest, const char *src, int max_length) rInt; +DWORD STORMAPI SStrHash(const char *string, DWORD flags, DWORD Seed) rInt; +int STORMAPI SStrNCat(char *dest, const char *src, DWORD max_length) rInt; + +int STORMAPI SStrLen(const char* string) rInt; + +int STORMAPI SStrCmp(const char *string1, const char *string2, size_t size) rInt; +int STORMAPI SStrCmpI(const char *string1, const char *string2, size_t size) rInt; +char* STORMAPI SStrUpper(char* string) rPVoid; + +void STORMAPI SRgn523(HANDLE hRgn, RECT *pRect, int a3, int a4) rVoid; +void STORMAPI SRgnCreateRegion(HANDLE *hRgn, int a2) rVoid; +void STORMAPI SRgnDeleteRegion(HANDLE hRgn) rVoid; + +void STORMAPI SRgn529i(int handle, int a2, int a3) rVoid; + +BOOL SErrDisplayErrorFmt(DWORD dwErrMsg, const char *logfilename, int logline, BOOL allowOption, int exitCode, const char *format, ...) rBool; + +void STORMAPI SErrCatchUnhandledExceptions() rVoid; + +char* STORMAPI SStrChr(const char *string, char c) rPVoid; +char* STORMAPI SStrChrR(const char *string, char c) rPVoid; + +size_t SStrVPrintf(char *dest, size_t size, const char *format, ...) rInt; + +int STORMAPI SBigDel(void *buffer) rInt; + +int STORMAPI SBigFromBinary(void *buffer, const void *str, size_t size) rInt; + +int STORMAPI SBigNew(void **buffer) rInt; + +int STORMAPI SBigPowMod(void *buffer1, void *buffer2, int a3, int a4) rInt; + +int STORMAPI SBigToBinaryBuffer(void *buffer, int length, int a3, int a4) rInt; +// + +void __stdcall SDrawMessageBox(char *,char *,int) rVoid; +void __cdecl SDrawDestroy(void) rVoid; +bool __cdecl StormDestroy(void) rBool; +bool __stdcall SFileSetBasePath(char *) rBool; +void __cdecl SDrawRealizePalette(void) rVoid; +bool __cdecl SVidPlayContinue(void) rBool; +bool __stdcall SNetGetOwnerTurnsWaiting(int *) rBool; +void * __stdcall SNetUnregisterEventHandler(int,void (__stdcall*)(struct _SNETEVENT *)) rPVoid; +void * __stdcall SNetRegisterEventHandler(int,void (__stdcall*)(struct _SNETEVENT *)) rPVoid; +bool __stdcall SNetSetBasePlayer(int) rBool; +int __stdcall SNetInitializeProvider(unsigned long,struct _SNETPROGRAMDATA *,struct _SNETPLAYERDATA *,struct _SNETUIDATA *,struct _SNETVERSIONDATA *) rInt; +int __stdcall SNetGetProviderCaps(struct _SNETCAPS *) rInt; +int __stdcall SFileSetFilePointer(HANDLE,int,HANDLE,int) rInt; \ No newline at end of file diff --git a/3rdParty/Storm/Source/storm.def b/3rdParty/Storm/Source/storm.def new file mode 100644 index 0000000..fde2f7b --- /dev/null +++ b/3rdParty/Storm/Source/storm.def @@ -0,0 +1,441 @@ +LIBRARY "Storm" + +EXPORTS + SNetCreateGame @101 NONAME + SNetDestroy @102 NONAME + SNetEnumProviders @103 NONAME + ;SNetEnumDevices @104 NONAME + SNetEnumGames @105 NONAME + SNetDropPlayer @106 NONAME + SNetGetGameInfo @107 NONAME + ;SNetGetNetworkLatency @108 NONAME + SNetGetNumPlayers @109 NONAME + SNetGetOwnerTurnsWaiting @110 NONAME + ;SNetGetPerformanceData @111 NONAME + SNetGetPlayerCaps @112 NONAME + SNetGetPlayerName @113 NONAME + SNetGetProviderCaps @114 NONAME + SNetGetTurnsInTransit @115 NONAME + SNetInitializeDevice @116 NONAME + SNetInitializeProvider @117 NONAME + SNetJoinGame @118 NONAME + SNetLeaveGame @119 NONAME + SNetPerformUpgrade @120 NONAME + SNetReceiveMessage @121 NONAME + SNetReceiveTurns @122 NONAME + SNetRegisterEventHandler @123 NONAME + ;SNetResetLatencyMeasurements @124 NONAME + SNetSelectGame @125 NONAME + ;SNetSelectProvider @126 NONAME + SNetSendMessage @127 NONAME + SNetSendTurn @128 NONAME + SNetSetBasePlayer @129 NONAME + SNetSetGameMode @130 NONAME + SNetUnregisterEventHandler @131 NONAME + + SNetEnumGamesEx @133 NONAME + SNetSendServerChatCommand @134 NONAME + ;SNetSendDatagram @135 NONAME + ;SNetReceiveDatagram @136 NONAME + SNetDisconnectAll @137 NONAME + SNetCreateLadderGame @138 NONAME + SNetReportGameResult @139 NONAME + ;SNetCheckDataFile @140 NONAME + SNetSendLeagueCommand @141 NONAME + SNetSendReplayPath @142 NONAME + SNetGetLeagueName @143 NONAME + SNetGetPlayerNames @144 NONAME + SNetLeagueLogout @145 NONAME + SNetGetLeaguePlayerName @146 NONAME + + ;Ordinal150 @150 NONAME + ;Ordinal151 @151 NONAME + + ;SDlgBeginPaint @201 NONAME + ;SDlgBltToWindowI @202 NONAME + ;SDlgCheckTimers @203 NONAME + ;SDlgCreateDialogIndirectParam @204 NONAME + ;SDlgCreateDialogParam @205 NONAME + SDlgDefDialogProc @206 NONAME + + SDlgDialogBoxIndirectParam @208 NONAME + ;SDlgDialogBoxParam @209 NONAME + ;SDlgDrawBitmap @210 NONAME + SDlgEndDialog @211 NONAME + ;SDlgEndPaint @212 NONAME + ;SDlgKillTimer @213 NONAME + ;SDlgSetBaseFont @214 NONAME + ;SDlgSetBitmapI @215 NONAME + SDlgSetControlBitmaps @216 NONAME + ;SDlgSetCursor @217 NONAME + ;SDlgSetSystemCursor @218 NONAME + ;SDlgSetTimer @219 NONAME + ;SDlgUpdateCursor @220 NONAME + SDlgBltToWindowE @221 NONAME + SDlgSetBitmapE @222 NONAME + ;SDlgSetLocale @223 NONAME + Ordinal224 @224 NONAME + + ;SFileAuthenticateArchive @251 NONAME + SFileCloseArchive @252 NONAME + SFileCloseFile @253 NONAME + ;SFileDdaBegin @254 NONAME + SFileDdaBeginEx @255 NONAME + SFileDdaDestroy @256 NONAME + SFileDdaEnd @257 NONAME + SFileDdaGetPos @258 NONAME + ;SFileDdaGetVolume @259 NONAME + SFileDdaInitialize @260 NONAME + SFileDdaSetVolume @261 NONAME + SFileDestroy @262 NONAME + ;SFileEnableDirectAccess @263 NONAME + SFileGetFileArchive @264 NONAME + SFileGetFileSize @265 NONAME + SFileOpenArchive @266 NONAME + SFileOpenFile @267 NONAME + SFileOpenFileEx @268 NONAME + SFileReadFile @269 NONAME + SFileSetBasePath @270 NONAME + SFileSetFilePointer @271 NONAME + SFileSetLocale @272 NONAME + ;SFileGetBasePath @273 NONAME + SFileSetIoErrorMode @274 NONAME + SFileGetArchiveName @275 NONAME + SFileGetFileName @276 NONAME + ;SFileGetArchiveInfo @277 NONAME + ;SFileSetPlatform @278 NONAME + SFileLoadFile @279 NONAME + SFileUnloadFile @280 NONAME + SFileLoadFileEx @281 NONAME + ;SFilePrioritizeRequest @282 NONAME + ;SFileCancelRequest @283 NONAME + ;SFileSetAsyncBudget @284 NONAME + ;SFileSetDataChunkSize @285 NONAME + ;SFileEnableSeekOptimization @286 NONAME + ;SFileReadFileEx @287 NONAME + ;SFileFileExists @288 NONAME + ;SFileFileExistsEx @289 NONAME + ;SFileReadFileEx2 @290 NONAME + ;SFileReadFile2 @291 NONAME + ;SFileLoadFile2 @292 NONAME + ;SFileOpenFileAsArchive @293 NONAME + ;SFileGetLocale @294 NONAME + ;SFileRegisterLoadNotifyProc @295 NONAME + ;SFileGetFileCompressedSize @296 NONAME + ;Ordinal297 @297 NONAME + ;Ordinal298 @298 NONAME + ;SFileAuthenticateArchiveEx @299 NONAME + ;SFileOpenPathAsArchive @300 NONAME + StormDestroy @301 NONAME + ;StormGetInstance @302 NONAME + ;StormGetOption @303 NONAME + ;StormSetOption @304 NONAME + + ;SBltGetSCode @312 NONAME + SBltROP3 @313 NONAME + SBltROP3Clipped @314 NONAME + ;SBltROP3Tiled @315 NONAME + + SBmpDecodeImage @321 NONAME + + SBmpLoadImage @323 NONAME + SBmpSaveImage @324 NONAME + SBmpAllocLoadImage @325 NONAME + ;SBmpSaveImageEx @326 NONAME + + SCodeCompile @331 NONAME + SCodeDelete @332 NONAME + + SCodeExecute @334 NONAME + ;SCodeGetPseudocode @335 NONAME + + SDrawAutoInitialize @341 NONAME + SDrawCaptureScreen @342 NONAME + ;SDrawClearSurface @343 NONAME + SDrawDestroy @344 NONAME + ;SDrawFlipPage @345 NONAME + SDrawGetFrameWindow @346 NONAME + SDrawGetObjects @347 NONAME + SDrawGetScreenSize @348 NONAME + ;SDrawGetServiceLevel @349 NONAME + SDrawLockSurface @350 NONAME + SDrawManualInitialize @351 NONAME + SDrawMessageBox @352 NONAME + SDrawPostClose @353 NONAME + SDrawRealizePalette @354 NONAME + ;SDrawSelectGdiSurface @355 NONAME + SDrawUnlockSurface @356 NONAME + SDrawUpdatePalette @357 NONAME + ;SDrawUpdateScreen @358 NONAME + ;SDrawWaitForVerticalBlank @359 NONAME + + SEvtDispatch @372 NONAME + ;SEvtRegisterHandler @373 NONAME + ;SEvtUnregisterHandler @374 NONAME + ;SEvtUnregisterType @375 NONAME + ;SEvtPopState @376 NONAME + ;SEvtPushState @377 NONAME + ;SEvtBreakHandlerChain @378 NONAME + + ;SGdiBitBlt @381 NONAME + ;SGdiCreateFont @382 NONAME + SGdiDeleteObject @383 NONAME + ;SGdiDestroy @384 NONAME + SGdiExtTextOut @385 NONAME + SGdiImportFont @386 NONAME + ;SGdiLoadFont @387 NONAME + ;SGdiRectangle @388 NONAME + SGdiSelectObject @389 NONAME + SGdiSetPitch @390 NONAME + ;SGdiTextOut @391 NONAME + ;SGdi392 @392 NONAME + Ordinal393 @393 NONAME + + ;SMem399 @399 NONAME + + SMemAlloc @401 NONAME + ;SMemDestroy @402 NONAME + SMemFree @403 NONAME + ;SMemGetSize @404 NONAME + SMemReAlloc @405 NONAME + ;Storm406 @406 NONAME + + ;SMsgDispatchMessage @412 NONAME + ;SMsgDoMessageLoop @413 NONAME + ;SMsgRegisterCommand @414 NONAME + ;SMsgRegisterKeyDown @415 NONAME + ;SMsgRegisterKeyUp @416 NONAME + ;SMsgRegisterMessage @417 NONAME + ;SMsgPopRegisterState @418 NONAME + ;SMsgPushRegisterState @419 NONAME + ;SMsg420 @420 NONAME + SRegLoadData @421 NONAME + SRegLoadString @422 NONAME + SRegLoadValue @423 NONAME + SRegSaveData @424 NONAME + SRegSaveString @425 NONAME + SRegSaveValue @426 NONAME + ;SRegGetBaseKey @427 NONAME + SRegDeleteValue @428 NONAME + ;SReg429 @429 NONAME + ;SReg430 @430 NONAME + STransBlt @431 NONAME + STransBltUsingMask @432 NONAME + ;STransCreateI @433 NONAME + STransDelete @434 NONAME + + STransDuplicate @436 NONAME + STransIntersectDirtyArray @437 NONAME + STransInvertMask @438 NONAME + ;STransLoadI @439 NONAME + STransSetDirtyArrayInfo @440 NONAME + ;STransUpdateDirtyArray @441 NONAME + STransPointInMask @442 NONAME + STransCombineMasks @443 NONAME + ;STransCreateI @444 NONAME + STransCreateE @445 NONAME + ;STrans446 @446 NONAME + ;STransLoadE @447 NONAME + + SVidDestroy @451 NONAME + SVidGetSize @452 NONAME + SVidInitialize @453 NONAME + SVidPlayBegin @454 NONAME + ;SVidPlayBeginFromMemory @455 NONAME + SVidPlayContinue @456 NONAME + SVidPlayContinueSingle @457 NONAME + SVidPlayEnd @458 NONAME + ;SVidSetVolume @459 NONAME + ;Storm460 @460 NONAME + SErrDisplayError @461 NONAME + SErrGetErrorStr @462 NONAME + SErrGetLastError @463 NONAME + ;SErrRegisterMessageSource @464 NONAME + SErrSetLastError @465 NONAME + ;SErrReportNamedResourceLeak @466 NONAME + ;SErrReportResourceLeak @467 NONAME + SErrSuppressErrors @468 NONAME + ;SErrRegisterHandler @469 NONAME + ;SErrUnregisterHandler @470 NONAME + ;Storm471 @471 NONAME + ;SCmdGetBool @472 NONAME + ;SCmdGetNum @473 NONAME + ;SCmdGetString @474 NONAME + ;SCmdProcess @475 NONAME + ;SCmdRegisterArgList @476 NONAME + ;SCmdRegisterArgument @477 NONAME + ;SCmdStringExists @478 NONAME + ;SCmdProcessCommandLine @479 NONAME + ;Ordinal480 @480 NONAME + ;SMemFindNextBlock @481 NONAME + ;SMemFindNextHeap @482 NONAME + ;SMemGetHeapByCaller @483 NONAME + ;SMemGetHeapByPtr @484 NONAME + ;SMemHeapAlloc @485 NONAME + ;SMemHeapCreate @486 NONAME + ;SMemHeapDestroy @487 NONAME + ;SMemHeapFree @488 NONAME + ;SMemHeapRealloc @489 NONAME + ;SMemHeapSize @490 NONAME + SMemCopy @491 NONAME + SMemFill @492 NONAME + ;SMemMove @493 NONAME + SMemZero @494 NONAME + SMemCmp @495 NONAME + ;SMem496 @496 NONAME + ;SMemDumpState @497 NONAME + ;Ordinal498 @498 NONAME + + SStrCopy @501 NONAME + SStrHash @502 NONAME + SStrNCat @503 NONAME + ;SStrTokenize @504 NONAME + ;SStrPack @505 NONAME + SStrLen @506 NONAME + ;SStrDup @507 NONAME + SStrCmp @508 NONAME + SStrCmpI @509 NONAME + SStrUpper @510 NONAME + ;SMsgBreakHandlerChain @511 NONAME + ;SMsgUnregisterCommand @512 NONAME + ;SMsgUnregisterKeyDown @513 NONAME + ;SMsgUnregisterKeyUp @514 NONAME + ;SMsgUnregisterMessage @515 NONAME + ;SMsgGetDispatcher @516 NONAME + ;SMsgSetDefaultWindow @517 NONAME + ;SMsgGetDefaultWindow @518 NONAME + ;SMsg519 @519 NONAME + + ;SRgn521 @521 NONAME + + SRgn523 @523 NONAME + SRgnCreateRegion @524 NONAME + SRgnDeleteRegion @525 NONAME + + ;SRgn527 @527 NONAME + ;SRgn528i @528 NONAME + SRgn529i @529 NONAME + ;SRgn530i @530 NONAME + ;SRgn531i @531 NONAME + ;SRgn532i @532 NONAME + ;SRgn533i @533 NONAME + ;SRgn534 @534 NONAME + ;SRgn535f @535 NONAME + ;SRgn536f @536 NONAME + ;SRgn537f @537 NONAME + ;SRgn538f @538 NONAME + ;SRgn539f @539 NONAME + ;SRgn540f @540 NONAME + ;SLogClose @541 NONAME + ;SLogCreate @542 NONAME + ;SLog543 @543 NONAME + ;SLogDump @544 NONAME + ;SLogFlush @545 NONAME + ;SLogFlushAll @546 NONAME + ;SLogPend @547 NONAME + ;SLogWrite @548 NONAME + ;SLog549 @549 NONAME + ;SLogCriticalLog @550 NONAME + ;SCompCompress @551 NONAME + ;SCompDecompress @552 NONAME + ;SLogVWrite @553 NONAME + ;Ordinal554 @554 NONAME + ;Ordinal555 @555 NONAME + ;Ordinal556 @556 NONAME + ;Ordinal557 @557 NONAME + ;Ordinal558 @558 NONAME + ;Ordinal559 @559 NONAME + ;Ordinal560 @560 NONAME + ;SErrCheckDebugSymbolLibrary @561 NONAME + SErrDisplayErrorFmt @562 NONAME + ;SErrIsDisplayingError @563 NONAME + ;SErrPrepareAppFatal @564 NONAME + ;SErrSetLogTitleString @565 NONAME + ;SErrDisplayAppFatal @566 NONAME + SErrCatchUnhandledExceptions @567 NONAME + ;Storm568 @568 NONAME + ;SStrChr @569 NONAME + ;SStrChrR @570 NONAME + SStrChr @571 NONAME + SStrChrR @572 NONAME + ;SStrToDouble @573 NONAME + ;SStrToFloat @574 NONAME + ;SStrToInt @575 NONAME + ;SStrToUnsigned @576 NONAME + ;SStrToInt64 @577 NONAME + SStrVPrintf @578 NONAME + ;SStrLower @579 NONAME + ;SStrHash64 @580 NONAME + ;SStrPrintf @581 NONAME + ;SDrawSetClientRect @582 NONAME + ;SDrawGetClientRect @583 NONAME + ;SStrStrI @584 NONAME + ;SStrStrI @585 NONAME + ;SStrStr @586 NONAME + ;SStrStr @587 NONAME + ;SNet588 @588 NONAME + + ;SBigAdd @601 NONAME + ;SBigAnd @602 NONAME + ;SBigCompare @603 NONAME + ;SBigCopy @604 NONAME + ;SBigDec @605 NONAME + SBigDel @606 NONAME + ;SBigDiv @607 NONAME + ;SBigFindPrime @608 NONAME + SBigFromBinary @609 NONAME + ;SBigFromStr @610 NONAME + ;SBigFromStream @611 NONAME + ;SBigFromUnsigned @612 NONAME + ;SBigGcd @613 NONAME + ;SBigInc @614 NONAME + ;SBigInvMod @615 NONAME + ;SBigIsEven @616 NONAME + ;SBigIsOdd @617 NONAME + ;SBigIsOne @618 NONAME + ;SBigIsPrime @619 NONAME + ;SBigIsZero @620 NONAME + ;SBigMod @621 NONAME + ;SBigMul @622 NONAME + ;SBigMulMod @623 NONAME + SBigNew @624 NONAME + ;SBigNot @625 NONAME + ;SBigOr @626 NONAME + ;SBigPow @627 NONAME + SBigPowMod @628 NONAME + ;SBigRand @629 NONAME + ;SBigSet2Exp @630 NONAME + ;SBigSetOne @631 NONAME + ;SBigSetZero @632 NONAME + ;SBigShl @633 NONAME + ;SBigShr @634 NONAME + ;SBigSquare @635 NONAME + ;SBigSub @636 NONAME + ;SBigToBinaryArray @637 NONAME + SBigToBinaryBuffer @638 NONAME + ;SBigToBinaryPtr @639 NONAME + ;SBigToStrArray @640 NONAME + ;SBigToStrBuffer @641 NONAME + ;SBigToStrPtr @642 NONAME + ;SBigToStreamArray @643 NONAME + ;SBigToStreamBuffer @644 NONAME + ;SBigToStreamPtr @645 NONAME + ;SBigToUnsigned @646 NONAME + ;SBigXor @647 NONAME + + ;SUniConvertUTF16to8Len @901 NONAME + ;SUniConvertUTF16to8 @902 NONAME + ;SUniConvertUTF8to16Len @903 NONAME + ;SUniConvertUTF8to16 @904 NONAME + ;SUniS905 @905 NONAME + ;SUniS906 @906 NONAME + ;SUniFindAfterUTF8Chr @907 NONAME + ;SUniFindUTF8ChrStart @908 NONAME + ;SUniConvertUTF16To909 @909 NONAME + ;SUniConvertUTF16To910 @910 NONAME + ;SUniConvertUTF16To911 @911 NONAME + ;SUniConvert912 @912 NONAME + ;SUniConvert913 @913 NONAME + ;SUniConvert914 @914 NONAME + ;SUniConvertUTF8ToWin @915 NONAME +; END diff --git a/3rdParty/Storm/Source/storm.dsp b/3rdParty/Storm/Source/storm.dsp new file mode 100644 index 0000000..4400ed6 --- /dev/null +++ b/3rdParty/Storm/Source/storm.dsp @@ -0,0 +1,126 @@ +# Microsoft Developer Studio Project File - Name="storm" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=storm - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "storm.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "storm.mak" CFG="storm - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "storm - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "storm - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "storm - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "WinRel" +# PROP BASE Intermediate_Dir "WinRel" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "WinRel" +# PROP Intermediate_Dir "WinRel" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "STORM_EXPORTS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "STORM_EXPORTS" /FD /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /def:"Storm.def" +# SUBTRACT LINK32 /pdb:none + +!ELSEIF "$(CFG)" == "storm - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "WinDebug" +# PROP BASE Intermediate_Dir "WinDebug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "WinDebug" +# PROP Intermediate_Dir "WinDebug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "STORM_EXPORTS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "STORM_EXPORTS" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /def:"Storm.def" /pdbtype:sept +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "storm - Win32 Release" +# Name "storm - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# Begin Source File + +SOURCE=.\storm.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# Begin Source File + +SOURCE=.\storm.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project diff --git a/3rdParty/Storm/Source/storm.h b/3rdParty/Storm/Source/storm.h new file mode 100644 index 0000000..cdc48d9 --- /dev/null +++ b/3rdParty/Storm/Source/storm.h @@ -0,0 +1,1299 @@ +#pragma once + +#ifndef __BLIZZARD_STORM_HEADER +#define __BLIZZARD_STORM_HEADER + +#include +#include +#include +#include + +// Note to self: Linker error => forgot a return value in cpp + +// Storm API definition +#ifndef STORMAPI +#define STORMAPI __stdcall +#endif + +#ifndef __STORM_SMAX +#define __STORM_SMAX(x,y) (x < y ? y : x) +#endif + +#ifndef __STORM_SSIZEMAX +#define __STORM_SSIZEMAX(x,y) (__STORM_SMAX(sizeof(x),sizeof(y))) +#endif + +#ifndef __STORM_SMIN +#define __STORM_SMIN(x,y) (x < y ? x : y) +#endif + +#ifndef __STORM_SSIZEMIN +#define __STORM_SSIZEMIN(x,y) (__STORM_SMIN(sizeof(x),sizeof(y))) +#endif + +typedef struct _WRECT +{ + WORD left; + WORD top; + WORD right; + WORD bottom; +} WRECT, *PWRECT; + +typedef struct _WPOINT +{ + WORD x; + WORD y; +} WPOINT, *PWPOINT; + +typedef struct _WSIZE +{ + WORD cx; + WORD cy; +} WSIZE, *PWSIZE; + + + +// Game states +#define GAMESTATE_PRIVATE 0x01 +#define GAMESTATE_FULL 0x02 +#define GAMESTATE_ACTIVE 0x04 +#define GAMESTATE_STARTED 0x08 +#define GAMESTATE_REPLAY 0x80 + + +BOOL STORMAPI SNetCreateGame(const char *pszGameName, const char *pszGamePassword, const char *pszGameStatString, DWORD dwGameType, char *GameTemplateData, int GameTemplateSize, int playerCount, char *creatorName, char *a11, int *playerID); +BOOL STORMAPI SNetDestroy(); +BOOL STORMAPI SNetEnumProviders(int (STORMAPI *callback)(DWORD, DWORD, DWORD, DWORD), int mincaps); + +BOOL STORMAPI SNetEnumGames(int (STORMAPI *callback)(DWORD, DWORD, DWORD), int *hintnextcall); + +/* SNetDropPlayer @ 106 + * + * Drops a player from the current game. + * + * playerid: The player ID for the player to be dropped. + * flags: + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetDropPlayer( + int playerid, + DWORD flags); + +/* SNetGetGameInfo @ 107 + * + * Retrieves specific game information from Storm, such as name, password, + * stats, mode, game template, and players. + * + * type: The type of data to retrieve. See GAMEINFO_ flags. + * dst: The destination buffer for the data. + * length: The maximum size of the destination buffer. + * byteswritten: The number of bytes written to the destination buffer. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetGetGameInfo( + int type, + void *dst, + size_t length, + size_t *byteswritten = NULL); + + +#define SNGetGameInfo(typ,dst) SNetGetGameInfo(typ, &dst, sizeof(dst)) + + + +// Game info fields +#define GAMEINFO_NAME 1 +#define GAMEINFO_PASSWORD 2 +#define GAMEINFO_STATS 3 +#define GAMEINFO_MODEFLAG 4 +#define GAMEINFO_GAMETEMPLATE 5 +#define GAMEINFO_PLAYERS 6 + + +BOOL STORMAPI SNetGetNumPlayers(int *firstplayerid, int *lastplayerid, int *activeplayers); + + +typedef struct _CAPS +{ + DWORD dwSize; // Size of this structure // sizeof(CAPS) + DWORD dwUnk_0x04; // Some flags? + DWORD maxmessagesize; // Size of the packet buffer, must be beteen 128 and 512 + DWORD dwUnk_0x0C; // Unknown + DWORD dwDisplayedPlayerCount; // Displayed player count in the mode selection list + DWORD dwUnk_0x14; // some kind of timeout or timer related + DWORD dwPlayerLatency; // ... latency? + DWORD dwPlayerCount; // the number of players that can participate, must be between 1 and 20 + DWORD dwCallDelay; // the number of calls before data is sent over the network // between 2 and 8; single player is set to 1 +} CAPS, *PCAPS; + + +BOOL STORMAPI SNetGetPlayerCaps(char playerid, PCAPS playerCaps); + +/* SNetGetPlayerName @ 113 + * + * Retrieves the name of a player given their player ID. + * + * playerid: The player's ID. + * buffer: The buffer that will receive the name. + * buffersize: The maximum size of buffer. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetGetPlayerName( + int playerid, + char *buffer, + size_t buffersize); + +/* SNetGetProviderCaps @ 114 + * + * Retrieves network provider capacity information. + * + * providerCaps: A pointer to a CAPS structure that will receive the information. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetGetProviderCaps( + PCAPS providerCaps); + +/* SNetGetTurnsInTransit @ 115 + * + * Retrieves the number of turns (buffers) that have been queued + * before sending them over the network. + * + * turns: A pointer to an integer that will receive the value. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetGetTurnsInTransit( + int *turns); + + +BOOL STORMAPI SNetInitializeDevice(int a1, int a2, int a3, int a4, int *a5); + +// Network provider structures +typedef struct _client_info +{ + DWORD dwSize; // 60 + char *pszName; + char *pszVersion; + DWORD dwProduct; + DWORD dwVerbyte; + DWORD dwUnk5; + DWORD dwMaxPlayers; + DWORD dwUnk7; + DWORD dwUnk8; + DWORD dwUnk9; + DWORD dwUnk10; // 0xFF + char *pszCdKey; + char *pszCdOwner; + DWORD dwIsShareware; + DWORD dwLangId; +} client_info; + +typedef struct _user_info +{ + DWORD dwSize; // 16 + char *pszPlayerName; + char *pszUnknown; + DWORD dwUnknown; +} user_info; + +typedef struct _battle_info +{ + DWORD dwSize; // 92 + DWORD dwUnkType; + HWND hFrameWnd; + void *pfnBattleGetResource; + void *pfnBattleGetErrorString; + void *pfnBattleMakeCreateGameDialog; + void *pfnBattleUpdateIcons; + DWORD dwUnk_07; + void *pfnBattleErrorDialog; + void *pfnBattlePlaySound; + DWORD dwUnk_10; + void *pfnBattleGetCursorLink; + DWORD dwUnk_12; + void *pfnUnk_13; + DWORD dwUnk_14; + void *pfnBattleMakeProfileDialog; + char *pszProfileStrings; + void *pfnBattleDrawProfileInfo; + void *pfnUnk_18; + DWORD dwUnk_19; + void *pfnUnk_20; + void *pfnUnk_21; + void *pfnBattleSetLeagueName; +} battle_info; + +typedef struct _module_info +{ + DWORD dwSize; // 20 + char *pszVersionString; + char *pszModuleName; + char *pszMainArchive; + char *pszPatchArchive; +} module_info; + +typedef struct _game +{ + DWORD dwIndex; + DWORD dwGameState; + DWORD dwUnk_08; + SOCKADDR saHost; + DWORD dwUnk_1C; + DWORD dwTimer; + DWORD dwUnk_24; + char szGameName[128]; + char szGameStatString[128]; + _game *pNext; + void *pExtra; + DWORD dwExtraBytes; + DWORD dwProduct; + DWORD dwVersion; +} game; + +typedef struct _storm_head +{ + WORD wChecksum; + WORD wLength; + WORD wSent; + WORD wReceived; + BYTE bCommandClass; + BYTE bCommandType; + BYTE bPlayerId; + BYTE bFlags; +} storm_head; + + +// Traffic flags +#define STRAFFIC_NORMAL 0 +#define STRAFFIC_VERIFY 1 +#define STRAFFIC_RESEND 2 +#define STRAFFIC_REPLY 4 + + +/* SNetInitializeProvider @ 117 + * + * Initializes a provider by storing the provider callbacks, and calling + * spiInitialize() using the parameters passed to this function. + * Note: The use of the parameters is determined by the network + * module. + * + * providerName: The provider's identifier. Example: 'TENB' (BNET). + * gameClientInfo: A pointer to a clientInfo structure containing + * information about the game client. + * userData: A pointer to a userInfo structure containing information + * about the player. + * bnCallbacks: A pointer to a battleInfo structure containing callbacks + * and other information that is specific to Battle.net. + * moduleData: A pointer to a moduleInfo structure containing the + * executable information and paths to MPQ archives. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetInitializeProvider( + DWORD providerName, + client_info *gameClientInfo, + user_info *userData, + battle_info *bnCallbacks, + module_info *moduleData); + + +BOOL STORMAPI SNetJoinGame(int id, char *gameName, char *gamePassword, char *playerName, char *userStats, int *playerid); + +/* SNetLeaveGame @ 119 + * + * Notifies Storm that the player has left the game. Storm will + * notify all connected peers through the network provider. + * + * type: The leave type. It doesn't appear to be important, no documentation available. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetLeaveGame( + int type); + +BOOL STORMAPI SNetPerformUpgrade(DWORD *upgradestatus); +BOOL STORMAPI SNetReceiveMessage(int *senderplayerid, char **data, int *databytes); +BOOL STORMAPI SNetReceiveTurns(int a1, int arraysize, char **arraydata, unsigned int *arraydatabytes, DWORD *arrayplayerstatus); + +// Values for arrayplayerstatus +#define SNET_PS_OK 0 +#define SNET_PS_WAITING 2 +#define SNET_PS_NOTRESPONDING 3 +#define SNET_PS_UNKNOWN default + + +// Event structure +typedef struct _s_evt +{ + DWORD dwFlags; + int dwPlayerId; + void *pData; + DWORD dwSize; +} S_EVT, *PS_EVT; + + +// @TODO: "type" is unknown. +HANDLE STORMAPI SNetRegisterEventHandler(int type, void (STORMAPI *sEvent)(PS_EVT)); + +int STORMAPI SNetSelectGame(int a1, int a2, int a3, int a4, int a5, int *playerid); + +/* SNetSendMessage @ 127 + * + * Sends a message to a player given their player ID. Network message + * is sent using class 01 and is retrieved by the other client using + * SNetReceiveMessage(). + * + * playerID: The player index of the player to receive the data. + * Conversely, this field can be one of the following constants: + * SNPLAYER_ALL | Sends the message to all players, including oneself. + * SNPLAYER_OTHERS | Sends the message to all players, except for oneself. + * data: A pointer to the data. + * databytes: The amount of bytes that the data pointer contains. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetSendMessage( + int playerID, + void *data, + size_t databytes); + + +// Macro values to target specific players +#define SNPLAYER_ALL -1 +#define SNPLAYER_OTHERS -2 + + +/* SNetSendTurn @ 128 + * + * Sends a turn (data packet) to all players in the game. Network data + * is sent using class 02 and is retrieved by the other client using + * SNetReceiveTurns(). + * + * data: A pointer to the data. + * databytes: The amount of bytes that the data pointer contains. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetSendTurn( + char *data, + size_t databytes); + +/* SNetSetGameMode @ 130 + * + * Set's the game's mode flags, notifying the network + * provider that the state of the game has changed. + * For example: notifies Battle.net when the game is + * full. + * + * You should first call SNetGetGameInfo to retrieve + * the existing mode flags. + * + * modeFlags: The new flags for the game mode. + * GAMESTATE_PRIVATE | The game is passworded. + * GAMESTATE_FULL | The game is full. + * GAMESTATE_ACTIVE | The game is available. + * GAMESTATE_STARTED | The game is in progress. + * GAMESTATE_REPLAY | The game is a replay. + * makePublic: Used to make the game a public game, removing the GAMESTATE_PRIVATE flag. + * + * Returns TRUE if the function was called successfully and FALSE otherwise. + */ +BOOL +STORMAPI +SNetSetGameMode( + DWORD modeFlags, + bool makePublic = false); + +#define SNMakeGamePublic() SNetSetGameMode( (DWORD mode, SNetGetGameInfo(GAMEINFO_MODEFLAGS, &mode, 4), mode), true) + +BOOL STORMAPI SNetEnumGamesEx(int a1, int a2, int (__fastcall *callback)(DWORD, DWORD, DWORD), int *hintnextcall); +BOOL STORMAPI SNetSendServerChatCommand(const char *command); + +BOOL STORMAPI SNetDisconnectAll(DWORD flags); +BOOL STORMAPI SNetCreateLadderGame(const char *pszGameName, const char *pszGamePassword, const char *pszGameStatString, DWORD dwGameType, DWORD dwGameLadderType, DWORD dwGameModeFlags, char *GameTemplateData, int GameTemplateSize, int playerCount, char *creatorName, char *a11, int *playerID); + +#define SNET_GAME_RESULT_WIN 1 +#define SNET_GAME_RESULT_LOSS 2 +#define SNET_GAME_RESULT_DRAW 3 +#define SNET_GAME_RESULT_DISCONNECT 4 + +BOOL STORMAPI SNetReportGameResult(unsigned a1, int size, int *results, const char* headerInfo, const char* detailInfo); + +int STORMAPI SNetSendLeagueCommand(char *cmd, char *callback); +int STORMAPI SNetSendReplayPath(int a1, int a2, char *replayPath); +int STORMAPI SNetGetLeagueName(int leagueID); +BOOL STORMAPI SNetGetPlayerNames(char **names); +int STORMAPI SNetLeagueLogout(char *bnetName); +int STORMAPI SNetGetLeaguePlayerName(char *curPlayerLeageName, size_t nameSize); + +HGDIOBJ STORMAPI SDlgDefDialogProc(HWND hDlg, signed int DlgType, HDC textLabel, HWND hWnd); + +HANDLE STORMAPI SDlgDialogBoxIndirectParam(HMODULE hModule, LPCSTR lpName, HWND hWndParent, LPVOID lpParam, LPARAM lParam); + +BOOL STORMAPI SDlgEndDialog(HWND hDlg, HANDLE nResult); + +BOOL STORMAPI SDlgSetControlBitmaps(HWND parentwindow, int *id, int a3, char *buffer2, char *buffer, int flags, int mask); + +/* +// lpCursorName can only be IDC_ARROW +BOOL STORMAPI SDlgSetSystemCursor(void *lpSrcBuffer, void *p_a2, LPSIZE lpSize, LPCSTR lpCursorName); +*/ + +BOOL STORMAPI SDlgBltToWindowE(HWND hWnd, HRGN a2, char *a3, int a4, void *buffer, RECT *rct, SIZE *size, int a8, int a9, DWORD rop); +BOOL STORMAPI SDlgSetBitmapE(HWND hWnd, int a2, char *src, int mask1, int flags, int a6, int a7, int width, int a9, int mask2); + +int STORMAPI Ordinal224(int a1); + +BOOL STORMAPI SFileCloseArchive(HANDLE hArchive); +BOOL STORMAPI SFileCloseFile(HANDLE hFile); + +BOOL STORMAPI SFileDdaBeginEx(HANDLE directsound, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, signed __int32 volume, signed int a6, int a7); +BOOL STORMAPI SFileDdaDestroy(); +BOOL STORMAPI SFileDdaEnd(HANDLE directsound); +BOOL STORMAPI SFileDdaGetPos(HANDLE directsound, int a2, int a3); + +BOOL STORMAPI SFileDdaInitialize(HANDLE directsound); +BOOL STORMAPI SFileDdaSetVolume(HANDLE directsound, signed int bigvolume, signed int volume); +BOOL STORMAPI SFileDestroy(); + +BOOL STORMAPI SFileGetFileArchive(HANDLE hFile, HANDLE archive); +LONG STORMAPI SFileGetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh); +BOOL STORMAPI SFileOpenArchive(const char *szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE *phMpq); + +// values for dwFlags +enum MPQFlags +{ + MPQ_NO_LISTFILE = 0x0010, + MPQ_NO_ATTRIBUTES = 0x0020, + MPQ_FORCE_V1 = 0x0040, + MPQ_CHECK_SECTOR_CRC = 0x0080 +}; + + +BOOL STORMAPI SFileOpenFile(const char *filename, HANDLE *phFile); +BOOL STORMAPI SFileOpenFileEx(HANDLE hMpq, const char *szFileName, DWORD dwSearchScope, HANDLE *phFile); + +// values for dwSearchScope +enum SFileFlags +{ + SFILE_FROM_MPQ = 0x00000000, + SFILE_FROM_ABSOLUTE = 0x00000001, + SFILE_FROM_RELATIVE = 0x00000002, + SFILE_FROM_DISK = 0x00000004 +}; + +BOOL STORMAPI SFileReadFile(HANDLE hFile, void *buffer, DWORD nNumberOfBytesToRead, DWORD *read, LONG lpDistanceToMoveHigh); + +void STORMAPI SFileSetLocale(LCID lcLocale); + +// mode: 0 - Silent (callback is NULL) +// 1 - Application Defined +// 2 - Handled by storm (callback is NULL) +// BOOL STORMAPI callback(const char *pszFilename, DWORD dwErrCode, DWORD dwErrCount) +BOOL STORMAPI SFileSetIoErrorMode(DWORD mode, BOOL (STORMAPI *callback)(const char*,DWORD,DWORD) ); + +BOOL STORMAPI SFileGetArchiveName(HANDLE hArchive, char *name, int length); +BOOL STORMAPI SFileGetFileName(HANDLE hFile, char *buffer, int length); + +BOOL STORMAPI SFileLoadFile(char *filename, void *buffer, int buffersize, int a4, int a5); +BOOL STORMAPI SFileUnloadFile(HANDLE hFile); +BOOL STORMAPI SFileLoadFileEx(void *hArchive, char *filename, int a3, int a4, int a5, DWORD searchScope, struct _OVERLAPPED *lpOverlapped); + +// Options are DWORD except for #6 +// 1: [TRUE|FALSE] - If true, reports resource leaks (SErrReportResourceLeak/SErrReportNamedResourceLeak) to the attached debugger instead of a message box. +// 2: This option is unused. +// 3: [TRUE|FALSE] - If true, reports general memory leaks to the attached debugger instead of a message box. +// 4: This option is unused. +// 5: [TRUE|FALSE] - If true, reports log messages and log dumps to the attached debugger. +// 6: { DWORD blocks_allocated; DWORD blocks_freed; } Used to determine the amount of memory/heap blocks that have been allocated and freed by storm. +// Can also be used for custom allocations outside of storm. +// +//BOOL STORMAPI StormGetOption(int type, void *pValue, size_t *pSize); +//BOOL STORMAPI StormSetOption(int type, void *pValue, size_t size); + +BOOL STORMAPI SBltROP3(void *lpDstBuffer, void *lpSrcBuffer, int srcDrawWidth, int srcDrawHeight, int dstWidth, int srcWidth, int a7, DWORD rop); +BOOL STORMAPI SBltROP3Clipped(void *lpDstBuffer, RECT *lpDstRect, POINT *lpDstPt, int a4, void *lpSrcBuffer, RECT *lpSrcRect, POINT *lpSrcPt, int a8, int a9, DWORD rop); + +#define SBMP_DEFAULT 0 +#define SBMP_BMP 1 +#define SBMP_PCX 2 +#define SBMP_TGA 3 + + +/* SBmpDecodeImage @ 321 + * + * Decodes an image that has already been loaded into a buffer. + * + * dwImgType: Optional, the image type. See SBMP_ macros. + * pSrcBuffer: A pointer to the source buffer. + * dwSrcBuffersize: The size of the data in the source buffer. + * pPalette: An optional buffer that receives the image palette. + * pDstBuffer: A buffer that receives the image data. + * dwDstBuffersize: The size of the specified image buffer. If the size of the + * destination buffer is 0, then the destination buffer is not used. + * pdwWidth: An optional variable that receives the image width. + * pdwHeight: An optional variable that receives the image height. + * pdwBpp: An optional variable that receives the image bits per pixel. + * + * Returns TRUE if the image was supported and decoded correctly, FALSE otherwise. + */ +BOOL +STORMAPI +SBmpDecodeImage( + DWORD dwImgType, + void *pSrcBuffer, + DWORD dwSrcBuffersize, + PALETTEENTRY *pPalette = NULL, + void *pDstBuffer = NULL, + DWORD dwDstBuffersize = 0, + DWORD *pdwWidth = NULL, + DWORD *pdwHeight = NULL, + DWORD *pdwBpp = NULL); + + +/* SBmpLoadImage @ 323 + * + * Load an image from an available archive into a buffer. + * + * pszFileName: The name of the graphic in an active archive. + * pPalette: An optional buffer that receives the image palette. + * pBuffer: A buffer that receives the image data. + * dwBuffersize: The size of the specified image buffer. + * pdwWidth: An optional variable that receives the image width. + * pdwHeight: An optional variable that receives the image height. + * pdwBpp: An optional variable that receives the image bits per pixel. + * + * Returns TRUE if the image was supported and loaded correctly, FALSE otherwise. + */ +BOOL +STORMAPI +SBmpLoadImage( + const char *pszFileName, + PALETTEENTRY *pPalette = NULL, + void *pBuffer = NULL, + DWORD dwBuffersize = 0, + DWORD *pdwWidth = NULL, + DWORD *pdwHeight = NULL, + DWORD *pdwBpp = NULL); + +/* SBmpSaveImage @ 324 + * + * Save an image from a buffer to a file. The image format is determined + * from the filename and is either .gif, .pcx, .tga, or .bmp being the default. + * + * pszFileName: The name of the file to create. + * pPalette: A pointer to a palette array containing 256 entries. + * pBuffer: A buffer containing the image data. + * pdwWidth: The width of the image. + * pdwHeight: The height of the image. + * pdwBpp: The bits per pixel. + * + * Returns TRUE if the image was saved correctly, FALSE otherwise. + */ +BOOL +STORMAPI +SBmpSaveImage( + const char *pszFileName, + PALETTEENTRY *pPalette, + void *pBuffer, + DWORD dwWidth, + DWORD dwHeight, + DWORD dwBpp = 8); + + +HANDLE STORMAPI SBmpAllocLoadImage(const char *fileName, PALETTEENTRY *palette, void **buffer, int *width, int *height, int unused6, int unused7, void *(STORMAPI *allocFunction)(DWORD)); + +BOOL STORMAPI SCodeCompile(char *directives1, char *directives2, char *loopstring, unsigned int maxiterations, unsigned int flags, HANDLE handle); +BOOL STORMAPI SCodeDelete(HANDLE handle); + +int STORMAPI SCodeExecute(HANDLE handle, int a2); + +BOOL STORMAPI SDrawAutoInitialize(HINSTANCE hInst, LPCSTR lpClassName, LPCSTR lpWindowName, WNDPROC pfnWndProc, int nMode, int nWidth, int nHeight, int nBits); + + +/* SDrawCaptureScreen @ 342 + * + * Saves a screenshot from the primary surface being handled by Storm. + * + * pszOutput: The name of the output file. The save format is automatically set by the extension. + * The extensions supported are .gif, .pcx, .tga, and .bmp. It will write a bitmap by default. + * + * Returns TRUE if successful and FALSE otherwise. + */ +BOOL +STORMAPI +SDrawCaptureScreen( + const char *pszOutput); + + +/* SDrawGetFrameWindow @ 346 + * + * Retrieves the window handle that was specified in + * SDrawManualInitialize or created in SDrawAutoInitialize. + * + * sdraw_framewindow: Optional variable that receives the returned handle. + * + * Returns the handle of the window. + */ +HWND +STORMAPI +SDrawGetFrameWindow( + HWND *sdraw_framewindow = NULL); + + +/* SDrawGetObjects @ 347 + * + * Retrieves the object information that was initialized using + * SDrawManualInitialize or SDrawAutoInitialize. + * + * ddInterface: The DirectDraw interface. + * primarySurface: The primary DirectDraw surface. + * surface2: A second unknown surface. + * surface3: A third unknown surface. + * backSurface: The back DirectDraw surface. + * ddPalette: The DirectDraw palette. + * hPalette: The palette handle. + * + * Returns FALSE if the direct draw interface has not been initialized. + */ +BOOL +STORMAPI +SDrawGetObjects( + LPDIRECTDRAW *ddInterface = NULL, + LPDIRECTDRAWSURFACE *primarySurface = NULL, + LPDIRECTDRAWSURFACE *surface2 = NULL, + LPDIRECTDRAWSURFACE *surface3 = NULL, + LPDIRECTDRAWSURFACE *backSurface = NULL, + LPDIRECTDRAWPALETTE *ddPalette = NULL, + HPALETTE *hPalette = NULL); + + +/* SDrawGetScreenSize @ 348 + * + * Obtains information for the current screen resolution. + * + * pdwWidth: Optional variable that receives the screen width. + * pdwHeight: Optional variable that receives the screen height. + * pdwBpp: Optional variable that receives the bits per pixel. + * + * Returns FALSE if no variables were specified. + */ +BOOL +STORMAPI +SDrawGetScreenSize( + DWORD *pdwWidth, + DWORD *pdwHeight, + DWORD *pdwBpp); + + +// undefined +BOOL STORMAPI SDrawLockSurface(int surfacenumber, RECT *lpDestRect, void **lplpSurface, int *lpPitch, int arg_unused); + + +/* SDrawManualInitialize @ 351 + * + * Sets the DirectDraw variables to be referenced in Storm. + * + * hWnd: The handle of the DirectDraw window. + * ddInterface: The DirectDraw interface. + * primarySurface: The first and primary surface. + * surface2: A second surface. Behaviour not completely known. + * surface3: A third surface. Behaviour not completely known. + * backSurface: The fourth and final surface. The back surface. + * ddPalette: The DirectDraw palette if the application requires it. + * hPalette: The palette handle that belongs to the window. + * If this is NULL and ddPalette is specified, then it + * will be created automatically. A palette can be created + * using the CreatePalette WinAPI function. + * + * Returns FALSE if no variables were specified. + */ +BOOL +STORMAPI +SDrawManualInitialize( + HWND hWnd = NULL, + LPDIRECTDRAW ddInterface = NULL, + LPDIRECTDRAWSURFACE primarySurface = NULL, + LPDIRECTDRAWSURFACE surface2 = NULL, + LPDIRECTDRAWSURFACE surface3 = NULL, + LPDIRECTDRAWSURFACE backSurface = NULL, + LPDIRECTDRAWPALETTE ddPalette = NULL, + HPALETTE hPalette = NULL); + + +/* SDrawPostClose @ 353 + * + * Posts a WM_QUIT message to the active drawing window specified + * in SDrawManualInitialize or created in SDrawAutoInitialize. + * + * Returns TRUE if successful and FALSE otherwise. + */ +BOOL +STORMAPI +SDrawPostClose(); + + +// undefined +//BOOL STORMAPI SDrawRealizePalette(); + +BOOL STORMAPI SDrawUnlockSurface(int surfacenumber, void *lpSurface, int a3, RECT *lpRect); +BOOL STORMAPI SDrawUpdatePalette(unsigned int firstentry, unsigned int numentries, PALETTEENTRY *pPalEntries, int a4); + +BOOL STORMAPI SEvtDispatch(DWORD dwMessageID, DWORD dwFlags, int type, PS_EVT pEvent); + +BOOL STORMAPI SGdiDeleteObject(HANDLE handle); + +BOOL STORMAPI SGdiExtTextOut(int a1, int a2, int a3, int a4, unsigned int a8, signed int a6, signed int a7, const char *pszString, unsigned int arg20); +BOOL STORMAPI SGdiImportFont(HGDIOBJ handle, int windowsfont); + +BOOL STORMAPI SGdiSelectObject(int handle); +BOOL STORMAPI SGdiSetPitch(int pitch); + +BOOL STORMAPI Ordinal393(char *pszString, int, int); + + +/* SMemAlloc @ 401 + * + * Allocates a block of memory. This block is different + * from the standard malloc by including a header containing + * information about the block. + * + * amount: The amount of memory to allocate, in bytes. + * logfilename: The name of the file or object that this call belongs to. + * logline: The line in the file or one of the SLOG_ macros. + * defaultValue: The default value of a byte in the allocated memory. + * + * Returns a pointer to the allocated memory. This pointer does NOT include + * the additional storm header. + */ +void* +STORMAPI +SMemAlloc( + size_t amount, + char *logfilename, + int logline, + char defaultValue = 0); + +#define SMAlloc(amount) SMemAlloc((amount), __FILE__, __LINE__) + + +/* SMemFree @ 403 + * + * Frees a block of memory that was created using SMemAlloc, + * includes the log file and line for debugging purposes. + * + * location: The memory location to be freed. + * logfilename: The name of the file or object that this call belongs to. + * logline: The line in the file or one of the SLOG_ macros. + * defaultValue: + * + * Returns TRUE if the call was successful and FALSE otherwise. + */ +BOOL +STORMAPI +SMemFree( + void *location, + char *logfilename, + int logline, + char defaultValue = 0); + +#define SMFree(loc) SMemFree((loc), __FILE__, __LINE__) + + +/* SMemReAlloc @ 405 + * + * Reallocates a block of memory that was created using SMemAlloc, + * includes the log file and line for debugging purposes. + * + * location: The memory location to be re-allocated. If this parameter + * is NULL, then SMemAlloc is called with the remaining parameters. + * amount: The amount of memory to re-allocate. + * logfilename: The name of the file or object that this call belongs to. + * logline: The line in the file or one of the SLOG_ macros. + * defaultValue: + * + * Returns a pointer to the re-allocated memory. This pointer does NOT include + * the additional storm header. + */ +void* +STORMAPI +SMemReAlloc( + void *location, + size_t amount, + char *logfilename, + int logline, + char defaultValue = 0); + +#define SMReAlloc(loc,s) SMemReAlloc((loc),(s), __FILE__, __LINE__) + +// Can be provided instead of logline/__LINE__ parameter to indicate different errors. +#define SLOG_EXPRESSION 0 +#define SLOG_FUNCTION -1 +#define SLOG_OBJECT -2 +#define SLOG_HANDLE -3 +#define SLOG_FILE -4 +#define SLOG_EXCEPTION -5 + + +BOOL STORMAPI SRegLoadData(const char *keyname, const char *valuename, int size, LPBYTE lpData, BYTE flags, LPDWORD lpcbData); +BOOL STORMAPI SRegLoadString(const char *keyname, const char *valuename, BYTE flags, char *buffer, size_t buffersize); +BOOL STORMAPI SRegLoadValue(const char *keyname, const char *valuename, BYTE flags, int *value); +BOOL STORMAPI SRegSaveData(const char *keyname, const char *valuename, int size, BYTE *lpData, DWORD cbData); +BOOL STORMAPI SRegSaveString(const char *keyname, const char *valuename, BYTE flags, char *string); +BOOL STORMAPI SRegSaveValue(const char *keyname, const char *valuename, BYTE flags, DWORD result); + +BOOL STORMAPI SRegDeleteValue(const char *keyname, const char *valuename, BYTE flags); + +// Flags for SReg functions + +// Default behaviour checks both HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER +// relative to the "Software\\Blizzard Entertainment\\" key in both hives. +#define SREG_NONE 0x00000000 +#define SREG_EXCLUDE_LOCAL_MACHINE 0x00000001 // excludes checking the HKEY_LOCAL_MACHINE hive +#define SREG_BATTLE_NET 0x00000002 // sets the relative key to "Software\\Battle.net\\" instead +#define SREG_EXCLUDE_CURRENT_USER 0x00000004 // excludes checking the HKEY_CURRENT_USER hive +#define SREG_ABSOLUTE 0x00000010 // specifies that the key is not a relative key + +BOOL STORMAPI STransBlt(void *lpSurface, int x, int y, int width, HANDLE hTrans); +BOOL STORMAPI STransBltUsingMask(void *lpDest, void *lpSource, int pitch, int width, HANDLE hTrans); + +BOOL STORMAPI STransDelete(HANDLE hTrans); + +BOOL STORMAPI STransDuplicate(HANDLE hTransSource, HANDLE hTransDest); +BOOL STORMAPI STransIntersectDirtyArray(HANDLE hTrans, char * dirtyarraymask, unsigned flags, HANDLE * phTransResult); +BOOL STORMAPI STransInvertMask(HANDLE hTrans, HANDLE * phTransResult); + +BOOL STORMAPI STransSetDirtyArrayInfo(int width, int height, int depth, int bits); + +BOOL STORMAPI STransPointInMask(HANDLE hTrans, int x, int y); // Name is a pure guess +BOOL STORMAPI STransCombineMasks(HANDLE hTransA, HANDLE hTransB, int left, int top, int flags, HANDLE * phTransResult); + +BOOL STORMAPI STransCreateE(void *pBuffer, int width, int height, int bpp, int a5, int bufferSize, HANDLE *phTransOut); + +BOOL STORMAPI SVidDestroy(); +BOOL STORMAPI SVidGetSize(HANDLE video, int width, int height, int zero); +BOOL STORMAPI SVidInitialize(HANDLE video); +BOOL STORMAPI SVidPlayBegin(char *filename, int arg4, int a3, int a4, int a5, int a6, HANDLE* video); + +BOOL STORMAPI SVidPlayContinueSingle(HANDLE video, int a2, int a3); +BOOL STORMAPI SVidPlayEnd(HANDLE video); + +/* SErrDisplayError @ 461 + * + * Displays a formatted error message. The message is detailed and flexible for many applications. + * The message will be different if there is a debugger attached. Will typically terminate the application + * unless the option to continue is given. + * + * dwErrMessage: The error code. See SErrGetLastError and GetLastError. + * logfilename: The name of the file or object that this call belongs to. + * logline: The line in the file or one of the SLOG_ macros. + * message: A message or expression with additional information. + * allowOption: If TRUE, allows the user the option to continue execution, otherwise the program will terminate. + * exitCode: The exit code used for program termination. + * + * Returns TRUE if the user chose to continue execution, FALSE otherwise. + */ +BOOL +STORMAPI +SErrDisplayError( + DWORD dwErrMsg, + const char *logfilename, + int logline, + const char *message = NULL, + BOOL allowOption = FALSE, + int exitCode = 1); + +#define SAssert(x) { if ( !(x) ) SErrDisplayError(STORM_ERROR_ASSERTION, __FILE__, __LINE__, #x) } + +#define SEDisplayError(err) SErrDisplayError(e, __FILE__, __LINE__) + +/* SErrGetErrorStr @ 462 + * + * Retrieves a string that describes the specified error code for + * the system, Storm, DirectDraw, or DirectSound. + * + * dwErrCode: The error code to look up. + * buffer: The destination buffer to receive the string. + * bufferchars: The size of the destination buffer. + * + * Returns TRUE if the call was successful and FALSE otherwise. + */ +BOOL +STORMAPI +SErrGetErrorStr( + DWORD dwErrCode, + char *buffer, + size_t bufferchars); + +#define SEGetErrorStr(e,b) SErrGetErrorStr(e,b,sizeof(b)) + + +/* SErrGetLastError @ 463 + * + * Retrieves the last error that was specifically + * set for the Storm library. + * + * Returns the last error set within the Storm library. + */ +DWORD +STORMAPI +SErrGetLastError(); + + +// Registers a module as a message source for SErrGetErrorStr, always returns TRUE +// groupID is a group in a MessageTable entry for example in STORM_ERROR_BAD_ARGUMENT 0x85100065, 0x510 is the group. +// BOOL STORMAPI SErrRegisterMessageSource(WORD groupID, HMODULE hSourceModule, int a3) + + +/* SErrSetLastError @ 465 + * + * Sets the last error for the Storm library and the Kernel32 library. + * + * dwErrCode: The error code that will be set. + */ +void +STORMAPI +SErrSetLastError( + DWORD dwErrCode = NO_ERROR); + +// +// void STORMAPI SErrReportNamedResourceLeak(const char *pszMsg, const char *pszSubMsg = nullptr) +// void STORMAPI SErrReportResourceLeak(const char *pszMsg) + +void STORMAPI SErrSuppressErrors(BOOL suppressErrors); + +// Values for dwErrCode +#define STORM_ERROR_ASSERTION 0x85100000 +#define STORM_ERROR_BAD_ARGUMENT 0x85100065 +#define STORM_ERROR_GAME_ALREADY_STARTED 0x85100066 +#define STORM_ERROR_GAME_FULL 0x85100067 +#define STORM_ERROR_GAME_NOT_FOUND 0x85100068 +#define STORM_ERROR_GAME_TERMINATED 0x85100069 +#define STORM_ERROR_INVALID_PLAYER 0x8510006a +#define STORM_ERROR_NO_MESSAGES_WAITING 0x8510006b +#define STORM_ERROR_NOT_ARCHIVE 0x8510006c +#define STORM_ERROR_NOT_ENOUGH_ARGUMENTS 0x8510006d +#define STORM_ERROR_NOT_IMPLEMENTED 0x8510006e +#define STORM_ERROR_NOT_IN_ARCHIVE 0x8510006f +#define STORM_ERROR_NOT_IN_GAME 0x85100070 +#define STORM_ERROR_NOT_INITIALIZED 0x85100071 +#define STORM_ERROR_NOT_PLAYING 0x85100072 +#define STORM_ERROR_NOT_REGISTERED 0x85100073 +#define STORM_ERROR_REQUIRES_CODEC1 0x85100074 +#define STORM_ERROR_REQUIRES_CODEC2 0x85100075 +#define STORM_ERROR_REQUIRES_CODEC3 0x85100076 +#define STORM_ERROR_REQUIRES_UPGRADE 0x85100077 +#define STORM_ERROR_STILL_ACTIVE 0x85100078 +#define STORM_ERROR_VERSION_MISMATCH 0x85100079 +#define STORM_ERROR_MEM_NOT_ALLOCATED 0x8510007a +#define STORM_ERROR_MEM_CORRUPTED 0x8510007b +#define STORM_ERROR_MEM_INVALID 0x8510007c +#define STORM_ERROR_MEM_MANAGER_NOT_INITIALIZED 0x8510007d +#define STORM_ERROR_MEM_NOT_FREED 0x8510007e +#define STORM_ERROR_RESOURCES_NOT_RELEASED 0x8510007f +#define STORM_ERROR_OUT_OF_BOUNDS 0x85100080 +#define STORM_ERROR_NULL_POINTER 0x85100081 +#define STORM_ERROR_CDKEY_MISMATCH 0x85100082 +#define STORM_ERROR_FILE_CORRUPTED 0x85100083 +#define STORM_ERROR_FATAL 0x85100084 +#define STORM_ERROR_GAMETYPE_UNAVAILABLE 0x85100085 + + +/* SMemCopy @ 491 + * + * Copies a block of memory from source to destination. + * This function immediately calls memcpy. See online documentation + * of memcpy for more details. + * + * dest: The destination buffer. + * source: The source buffer. + * size: The number of bytes to copy. + */ +void +STORMAPI +SMemCopy( + void *dest, + const void *source, + size_t size); + +#define SMCopy(d,s) ( SMemCopy(d, s, __STORM_SSIZEMIN(s,d)) ) + +/* SMemFill @ 492 + * + * Fills a block of memory with the specified character. + * This function immediately calls memset. See online documentation + * of memset for more details. + * + * dest: The destination buffer. + * source: The size of the destination buffer. + * size: The format to use. + */ +void +STORMAPI +SMemFill( + void *location, + size_t length, + char fillWith = 0); + +#define SMFill(l,f) (SMemFill(l, sizeof(l), f)) + +/* SMemZero @ 494 + * + * Fills a block of memory with the integer 0x00 (Zero). + * + * location: The location to write at. + * length: The amount of bytes to write. + */ +void +STORMAPI +SMemZero( + void *location, + size_t length); + +#define SMZero(l) (SMemZero(l, sizeof(l))) + + +int STORMAPI SMemCmp(void *location1, void *location2, DWORD size); + +#define SMCmp(l,x) ( SMemCmp(l, x, __STORM_SSIZEMIN(x,l)) ) + +/* SStrCopy @ 501 + * + * Copies a string from src to dest (including NULL terminator) + * until the max_length is reached. + * + * dest: The destination array. + * src: The source array. + * max_length: The maximum length of dest. + * + * Returns the number of characters copied. + */ +int +STORMAPI +SStrCopy( + char *dest, + const char *src, + int max_length = 0x7FFFFFFF); + +#define SSCopy(d,s) (SStrCopy(d, s, sizeof(d))) + +#define STORM_HASH_ABSOLUTE 1 + +/* SStrHash @ 502 + * + * Creates a simple hash for the string. This function + * should NOT be used for sensitive information. + * + * string: The input string. + * flags: If STORM_HASH_ABSOLUTE is set then this + function uses the absolute string, otherwise + it will convert backslashes to forward + slashes and some other processing. + * seed: The hash seed. If this value is 0 then the + * default value 0x7FED7FED will be used. + * + * Returns the 32-bit hash of the string. + */ +DWORD +STORMAPI +SStrHash( + const char *string, + DWORD flags = 0, + DWORD Seed = 0); + +int STORMAPI SStrNCat(char *dest, const char *src, DWORD max_length); + +/* SStrLen @ 506 + * + * Retrieves the length of a string. + * + * string: The input string of which to obtain a + * length for. + * + * Returns the length of the string. + */ +int +STORMAPI +SStrLen( + const char *string); + +/* SStrCmp @ 508 + * + * Compares two strings case sensitive. + * + * string1: The first string. + * string2: The second string. + * size: The maximum amount of characters to compare. + * + * Returns 0 if strings are equal. See strcmp documentation for more details. + */ +int +STORMAPI +SStrCmp( + const char *string1, + const char *string2, + size_t size); + +#define SSCmp(s,x) ( SStrCmp(s,x,__STORM_SSIZEMIN(s,x)) ) + +/* SStrCmpI @ 509 + * + * Compares two strings case insensitive. + * + * string1: The first string. + * string2: The second string. + * size: The maximum amount of characters to compare. + * + * Returns 0 if strings are equal. See strcmpi documentation for more details. + */ +int +STORMAPI +SStrCmpI( + const char *string1, + const char *string2, + size_t size); + +#define SSCmpI(s,x) ( SStrCmpI(s,x,__STORM_SSIZEMIN(s,x)) ) + +/* SStrUpper @ 510 + * + * Converts all lower-case alpha characters of a string to upper-case. + * + * string: The string to convert. + * + * Returns the same pointer given in the input. + */ +char* +STORMAPI +SStrUpper( + char* string); + +void STORMAPI SRgn523(HANDLE hRgn, RECT *pRect, int a3, int a4); +void STORMAPI SRgnCreateRegion(HANDLE *hRgn, int a2); +void STORMAPI SRgnDeleteRegion(HANDLE hRgn); + +void STORMAPI SRgn529i(int handle, int a2, int a3); + + +/* SErrDisplayErrorFmt @ 562 + * + * Displays a formatted error message. The message is detailed and flexible for many applications. + * The message will be different if there is a debugger attached. Will typically terminate the application + * unless the option to continue is given. + * + * dwErrMessage: The error code. See SErrGetLastError and GetLastError. + * logfilename: The name of the file or object that this call belongs to. + * logline: The line in the file or one of the SLOG_ macros. + * allowOption: If TRUE, allows the user the option to continue execution, otherwise the program will terminate. + * exitCode: The exit code used for program termination. + * format: Additional message formatting. See printf. + * + * Returns TRUE if the user chose to continue execution, FALSE otherwise. + */ +BOOL +SErrDisplayErrorFmt( + DWORD dwErrMsg, + const char *logfilename, + int logline, + BOOL allowOption, + int exitCode, + const char *format, + ...); + +//#define SEDisplayErrorFmt(err,...) SErrDisplayErrorFmt(err, __FILE__, __LINE__, FALSE, 1, __VA_ARGS__) + +/* SErrCatchUnhandledExceptions @ 567 + * + * Registers a top-level exception filter managed entirely by Storm. + * The registered filter will display formatted exception information by calling SErrDisplayError. + */ +void +STORMAPI +SErrCatchUnhandledExceptions(); + + +/* SStrChr @ 571 + * + * Searches a string for the given character. See + * strchr documentation for more details. + * + * string: The string to search. + * c: The character to search for. + * + * Returns a pointer to the first occurance of the character. + */ +char* +STORMAPI +SStrChr( + const char *string, + char c); + + +char *STORMAPI SStrChrR(const char *string, char c); + + +/* SStrVPrintf @ 578 + * + * Prints a formatted string to a destination buffer. + * This function calls vsnprintf with some extra error handling. + * See online documentation of vsnprintf for more details. + * + * dest: The destination buffer. + * size: The size of the destination buffer. + * format: The format to use. + * + * Returns the number of characters written. + */ +size_t +SStrVPrintf( + char *dest, + size_t size, + const char *format, ...); + + +int STORMAPI SBigDel(void *buffer); + +int STORMAPI SBigFromBinary(void *buffer, const void *str, size_t size); + +int STORMAPI SBigNew(void **buffer); + +int STORMAPI SBigPowMod(void *buffer1, void *buffer2, int a3, int a4); + +int STORMAPI SBigToBinaryBuffer(void *buffer, int length, int a3, int a4); + +void __stdcall SDrawMessageBox(char *,char *,int); +void __cdecl SDrawDestroy(void); +bool __cdecl StormDestroy(void); +bool __stdcall SFileSetBasePath(char *); +void __cdecl SDrawRealizePalette(void); +bool __cdecl SVidPlayContinue(void); +bool __stdcall SNetGetOwnerTurnsWaiting(int *); +void * __stdcall SNetUnregisterEventHandler(int,void (__stdcall*)(struct _SNETEVENT *)); +void * __stdcall SNetRegisterEventHandler(int,void (__stdcall*)(struct _SNETEVENT *)); +bool __stdcall SNetSetBasePlayer(int); +int __stdcall SNetInitializeProvider(unsigned long,struct _SNETPROGRAMDATA *,struct _SNETPLAYERDATA *,struct _SNETUIDATA *,struct _SNETVERSIONDATA *); +int __stdcall SNetGetProviderCaps(struct _SNETCAPS *); +int __stdcall SFileSetFilePointer(HANDLE,int,HANDLE,int); +#endif