diff --git a/artifacts/scripting/headers/sfall.h b/artifacts/scripting/headers/sfall.h index ab8779ce..8ec266bc 100644 --- a/artifacts/scripting/headers/sfall.h +++ b/artifacts/scripting/headers/sfall.h @@ -58,13 +58,6 @@ #define LIST_SPATIAL (6) #define LIST_ALL (9) -//Valid flags for force_encounter_with_flags -#define ENCOUNTER_FLAG_NO_CAR (0x1) -#define ENCOUNTER_FLAG_LOCK (0x2) // block new forced encounter by the next function call until the current specified encounter occurs -#define ENCOUNTER_FLAG_NO_ICON (0x4) // disable displaying the flashing icon -#define ENCOUNTER_FLAG_ICON_SP (0x8) // use special encounter icon -#define ENCOUNTER_FLAG_FADEOUT (0x10) // fade out the screen on encounter (Note: you yourself should restore the fade screen when entering the encounter) - //Valid window types for get_window_attribute #define WINTYPE_INVENTORY (0) // any inventory window #define WINTYPE_DIALOG (1) @@ -75,6 +68,13 @@ #define WINTYPE_SKILLDEX (6) #define WINTYPE_ESCMENU (7) // escape menu +//Valid flags for force_encounter_with_flags +#define ENCOUNTER_FLAG_NO_CAR (0x1) +#define ENCOUNTER_FLAG_LOCK (0x2) // block new forced encounter by the next function call until the current specified encounter occurs +#define ENCOUNTER_FLAG_NO_ICON (0x4) // disable displaying the flashing icon +#define ENCOUNTER_FLAG_ICON_SP (0x8) // use special encounter icon +#define ENCOUNTER_FLAG_FADEOUT (0x10) // fade out the screen on encounter (Note: you yourself should restore the fade screen when entering the encounter) + //The attack types returned by get_attack_type #define ATKTYPE_LWEP1 (0) #define ATKTYPE_LWEP2 (1) diff --git a/sfall/FalloutEngine.cpp b/sfall/FalloutEngine.cpp index e1dbd621..a103bbda 100644 --- a/sfall/FalloutEngine.cpp +++ b/sfall/FalloutEngine.cpp @@ -57,9 +57,9 @@ BYTE* ptr_DarkGreenColor = reinterpret_cast(_DarkGreenColor) BYTE* ptr_DarkGreenGreyColor = reinterpret_cast(_DarkGreenGreyColor); TGameObj** ptr_dialog_target = reinterpret_cast(_dialog_target); DWORD* ptr_dialog_target_is_party = reinterpret_cast(_dialog_target_is_party); -DWORD* ptr_dialogueBackWindow = reinterpret_cast(_dialogueBackWindow); +const DWORD* ptr_dialogueBackWindow = reinterpret_cast(_dialogueBackWindow); DWORD* ptr_drugInfoList = reinterpret_cast(_drugInfoList); -DWORD* ptr_edit_win = reinterpret_cast(_edit_win); +const DWORD* ptr_edit_win = reinterpret_cast(_edit_win); DWORD* ptr_Educated = reinterpret_cast(_Educated); DWORD* ptr_elevation = reinterpret_cast(_elevation); DWORD* ptr_Experience_ = reinterpret_cast(_Experience_); @@ -91,12 +91,12 @@ DWORD* ptr_hot_line_count = reinterpret_cast(_hot_line_count DWORD* ptr_i_fid = reinterpret_cast(_i_fid); TGameObj** ptr_i_lhand = reinterpret_cast(_i_lhand); TGameObj** ptr_i_rhand = reinterpret_cast(_i_rhand); -DWORD* ptr_i_wid = reinterpret_cast(_i_wid); +const DWORD* ptr_i_wid = reinterpret_cast(_i_wid); TGameObj** ptr_i_worn = reinterpret_cast(_i_worn); DWORD* ptr_idle_func = reinterpret_cast(_idle_func); DWORD* ptr_In_WorldMap = reinterpret_cast(_In_WorldMap); // moving in WorldMap DWORD* ptr_info_line = reinterpret_cast(_info_line); -DWORD* ptr_interfaceWindow = reinterpret_cast(_interfaceWindow); +const DWORD* ptr_interfaceWindow = reinterpret_cast(_interfaceWindow); DWORD* ptr_intfaceEnabled = reinterpret_cast(_intfaceEnabled); DWORD* ptr_intotal = reinterpret_cast(_intotal); TGameObj** ptr_inven_dude = reinterpret_cast(_inven_dude); @@ -149,7 +149,7 @@ DWORD* ptr_optionsButtonDownKey = reinterpret_cast(_optionsButtonD DWORD* ptr_optionsButtonUp = reinterpret_cast(_optionsButtonUp); DWORD* ptr_optionsButtonUp1 = reinterpret_cast(_optionsButtonUp1); DWORD* ptr_optionsButtonUpKey = reinterpret_cast(_optionsButtonUpKey); -DWORD* ptr_optnwin = reinterpret_cast(_optnwin); +const DWORD* ptr_optnwin = reinterpret_cast(_optnwin); DWORD* ptr_outlined_object = reinterpret_cast(_outlined_object); DWORD* ptr_partyMemberAIOptions = reinterpret_cast(_partyMemberAIOptions); DWORD* ptr_partyMemberCount = reinterpret_cast(_partyMemberCount); @@ -166,7 +166,7 @@ DWORD* ptr_pc_proto = reinterpret_cast(_pc_proto); BYTE* ptr_PeanutButter = reinterpret_cast(_PeanutButter); DWORD* ptr_perk_data = reinterpret_cast(_perk_data); int** ptr_perkLevelDataList = reinterpret_cast(_perkLevelDataList); -DWORD* ptr_pip_win = reinterpret_cast(_pip_win); +const DWORD* ptr_pip_win = reinterpret_cast(_pip_win); DWORD* ptr_pipboy_message_file = reinterpret_cast(_pipboy_message_file); DWORD* ptr_pipmesg = reinterpret_cast(_pipmesg); DWORD* ptr_preload_list_index = reinterpret_cast(_preload_list_index); @@ -184,7 +184,7 @@ DWORD* ptr_rotation = reinterpret_cast(_rotation); BoundRect* ptr_scr_size = reinterpret_cast(_scr_size); DWORD* ptr_scriptListInfo = reinterpret_cast(_scriptListInfo); DWORD* ptr_skill_data = reinterpret_cast(_skill_data); -DWORD* ptr_skldxwin = reinterpret_cast(_skldxwin); +const DWORD* ptr_skldxwin = reinterpret_cast(_skldxwin); DWORD* ptr_slot_cursor = reinterpret_cast(_slot_cursor); DWORD* ptr_sneak_working = reinterpret_cast(_sneak_working); // DWORD var char** ptr_sound_music_path1 = reinterpret_cast(_sound_music_path1); @@ -221,7 +221,7 @@ DWORD* ptr_wd_obj = reinterpret_cast(_wd_obj); DWORD* ptr_window = reinterpret_cast(_window); // total 50 WINinfo* BYTE* ptr_WhiteColor = reinterpret_cast(_WhiteColor); DWORD* ptr_wmAreaInfoList = reinterpret_cast(_wmAreaInfoList); -DWORD* ptr_wmBkWin = reinterpret_cast(_wmBkWin); +const DWORD* ptr_wmBkWin = reinterpret_cast(_wmBkWin); BYTE** ptr_wmBkWinBuf = reinterpret_cast(_wmBkWinBuf); DWORD* ptr_wmLastRndTime = reinterpret_cast(_wmLastRndTime); long* ptr_wmWorldOffsetX = reinterpret_cast(_wmWorldOffsetX); @@ -857,7 +857,7 @@ long __stdcall GetInputBtn() { WRAP_WATCOM_CALL0(get_input_) } -void __stdcall GSoundPlaySfxFile(const char* name) { +void __stdcall GsoundPlaySfxFile(const char* name) { WRAP_WATCOM_CALL1(gsound_play_sfx_file_, name) } @@ -1149,7 +1149,7 @@ long __fastcall WordWrap(const char* text, int maxWidth, DWORD* buf, BYTE* count WRAP_WATCOM_FCALL4(_word_wrap_, text, maxWidth, buf, count) } -long __stdcall GSoundBackgroundVolumeGetSet(long setVolume) { +long __stdcall GsoundBackgroundVolumeGetSet(long setVolume) { WRAP_WATCOM_CALL1(gsound_background_volume_get_set_, setVolume) } @@ -1355,7 +1355,7 @@ long __stdcall LoadFrame(const char* filename, FrmFile** frmPtr) { static MSGNode messageBuf; -const char* __stdcall GetMessageStr(const MSGList* fileAddr, long messageId) { +const char* GetMessageStr(const MSGList* fileAddr, long messageId) { const char* result; __asm { mov ebx, messageId; @@ -1367,7 +1367,7 @@ const char* __stdcall GetMessageStr(const MSGList* fileAddr, long messageId) { return result; } -const char* __stdcall MsgSearch(const MSGList* fileAddr, long messageId) { +const char* MsgSearch(const MSGList* fileAddr, long messageId) { messageBuf.number = messageId; long result; __asm { @@ -1464,7 +1464,7 @@ enum WinNameType { }; WINinfo* GetUIWindow(long winType) { - long winID = -1; + long winID = 0; switch (winType) { case WINTYPE_Inventory: winID = *ptr_i_wid; @@ -1493,7 +1493,7 @@ WINinfo* GetUIWindow(long winType) { default: return (WINinfo*)-1; } - return (winID != -1) ? GNWFind(winID) : nullptr; + return (winID > 0) ? GNWFind(winID) : nullptr; } // Returns an array of objects within the specified radius from the source tile @@ -1514,7 +1514,7 @@ void GetObjectsTileRadius(std::vector &objs, long sourceTile, long ra //--------------------------------------------------------- // print text to surface -void PrintText(char* displayText, BYTE colorIndex, DWORD xPos, DWORD yPos, DWORD txtWidth, DWORD toWidth, BYTE* toSurface) { +void __stdcall PrintText(char* displayText, BYTE colorIndex, DWORD xPos, DWORD yPos, DWORD txtWidth, DWORD toWidth, BYTE* toSurface) { DWORD posOffset = yPos * toWidth + xPos; __asm { xor eax, eax; @@ -1531,18 +1531,18 @@ void PrintText(char* displayText, BYTE colorIndex, DWORD xPos, DWORD yPos, DWORD //--------------------------------------------------------- //gets the height of the currently selected font -DWORD GetTextHeight() { - DWORD TxtHeight; +DWORD __stdcall GetTextHeight() { +// DWORD TxtHeight; __asm { call dword ptr ds:[_text_height]; //get text height - mov TxtHeight, eax; +// mov TxtHeight, eax; } - return TxtHeight; +// return TxtHeight; } //--------------------------------------------------------- //gets the length of a string using the currently selected font -DWORD __stdcall GetTextWidth(const char *TextMsg) { +DWORD __stdcall GetTextWidth(const char* TextMsg) { __asm { mov eax, TextMsg; call dword ptr ds:[_text_width]; //get text width @@ -1551,46 +1551,43 @@ DWORD __stdcall GetTextWidth(const char *TextMsg) { //--------------------------------------------------------- //get width of Char for current font -DWORD GetCharWidth(char CharVal) { - DWORD charWidth; +DWORD __stdcall GetCharWidth(char charVal) { __asm { - mov al, CharVal; + mov al, charVal; call dword ptr ds:[_text_char_width]; - mov charWidth, eax; } - return charWidth; } //--------------------------------------------------------- //get maximum string length for current font - if all characters were maximum width -DWORD GetMaxTextWidth(char *TextMsg) { - DWORD msgWidth; +DWORD __stdcall GetMaxTextWidth(const char* TextMsg) { +// DWORD msgWidth; __asm { mov eax, TextMsg; call dword ptr ds:[_text_mono_width]; - mov msgWidth, eax; +// mov msgWidth, eax; } - return msgWidth; +// return msgWidth; } //--------------------------------------------------------- //get number of pixels between characters for current font -DWORD GetCharGapWidth() { - DWORD gapWidth; +DWORD __stdcall GetCharGapWidth() { +// DWORD gapWidth; __asm { call dword ptr ds:[_text_spacing]; - mov gapWidth, eax; +// mov gapWidth, eax; } - return gapWidth; +// return gapWidth; } //--------------------------------------------------------- //get maximum character width for current font -DWORD GetMaxCharWidth() { - DWORD charWidth = 0; +DWORD __stdcall GetMaxCharWidth() { +// DWORD charWidth = 0; __asm { call dword ptr ds:[_text_max]; - mov charWidth, eax; +// mov charWidth, eax; } - return charWidth; +// return charWidth; } diff --git a/sfall/FalloutEngine.h b/sfall/FalloutEngine.h index bc163f8a..bc330922 100644 --- a/sfall/FalloutEngine.h +++ b/sfall/FalloutEngine.h @@ -322,9 +322,9 @@ extern BYTE* ptr_DarkGreenColor; extern BYTE* ptr_DarkGreenGreyColor; extern TGameObj** ptr_dialog_target; extern DWORD* ptr_dialog_target_is_party; -extern DWORD* ptr_dialogueBackWindow; +extern const DWORD* ptr_dialogueBackWindow; extern DWORD* ptr_drugInfoList; -extern DWORD* ptr_edit_win; +extern const DWORD* ptr_edit_win; extern DWORD* ptr_Educated; extern DWORD* ptr_elevation; extern DWORD* ptr_Experience_; @@ -356,12 +356,12 @@ extern DWORD* ptr_hot_line_count; extern DWORD* ptr_i_fid; extern TGameObj** ptr_i_lhand; extern TGameObj** ptr_i_rhand; -extern DWORD* ptr_i_wid; +extern const DWORD* ptr_i_wid; extern TGameObj** ptr_i_worn; extern DWORD* ptr_idle_func; extern DWORD* ptr_In_WorldMap; extern DWORD* ptr_info_line; -extern DWORD* ptr_interfaceWindow; +extern const DWORD* ptr_interfaceWindow; extern DWORD* ptr_intfaceEnabled; extern DWORD* ptr_intotal; extern TGameObj** ptr_inven_dude; @@ -414,7 +414,7 @@ extern DWORD* ptr_optionsButtonDownKey; extern DWORD* ptr_optionsButtonUp; extern DWORD* ptr_optionsButtonUp1; extern DWORD* ptr_optionsButtonUpKey; -extern DWORD* ptr_optnwin; +extern const DWORD* ptr_optnwin; extern DWORD* ptr_outlined_object; extern DWORD* ptr_partyMemberAIOptions; extern DWORD* ptr_partyMemberCount; @@ -431,7 +431,7 @@ extern DWORD* ptr_pc_proto; extern BYTE* ptr_PeanutButter; extern DWORD* ptr_perk_data; extern int** ptr_perkLevelDataList; // limited to PERK_Count -extern DWORD* ptr_pip_win; +extern const DWORD* ptr_pip_win; extern DWORD* ptr_pipboy_message_file; extern DWORD* ptr_pipmesg; extern DWORD* ptr_preload_list_index; @@ -450,7 +450,7 @@ extern DWORD* ptr_sad; extern BoundRect* ptr_scr_size; extern DWORD* ptr_scriptListInfo; extern DWORD* ptr_skill_data; -extern DWORD* ptr_skldxwin; +extern const DWORD* ptr_skldxwin; extern DWORD* ptr_slot_cursor; extern DWORD* ptr_sneak_working; // DWORD var extern char** ptr_sound_music_path1; @@ -487,7 +487,7 @@ extern DWORD* ptr_wd_obj; extern DWORD* ptr_window; // total 50 WINinfo* extern BYTE* ptr_WhiteColor; extern DWORD* ptr_wmAreaInfoList; -extern DWORD* ptr_wmBkWin; +extern const DWORD* ptr_wmBkWin; extern BYTE** ptr_wmBkWinBuf; extern DWORD* ptr_wmLastRndTime; extern long* ptr_wmWorldOffsetX; @@ -1060,7 +1060,7 @@ void __stdcall DisplayConsoleMessage(const char* msg); long __stdcall GetInputBtn(); // plays SFX sound with given name -void __stdcall GSoundPlaySfxFile(const char* name); +void __stdcall GsoundPlaySfxFile(const char* name); // Returns the name of the critter const char* __stdcall CritterName(TGameObj* critter); @@ -1180,7 +1180,7 @@ long __fastcall GetGameConfigString(const char* outValue, const char* section, c long __fastcall WordWrap(const char* text, int maxWidth, DWORD* buf, BYTE* count); -long __stdcall GSoundBackgroundVolumeGetSet(long setVolume); +long __stdcall GsoundBackgroundVolumeGetSet(long setVolume); WINinfo* __stdcall GNWFind(long winRef); @@ -1272,10 +1272,10 @@ long __stdcall LoadFrame(const char* filename, FrmFile** frmPtr); ///////////////////////////////// ENGINE UTILS ///////////////////////////////// // returns message string from given file or "Error" when not found -const char* __stdcall GetMessageStr(const MSGList* fileAddr, long messageId); +const char* GetMessageStr(const MSGList* fileAddr, long messageId); // similar to GetMessageStr, but returns nullptr when no message is found -const char* __stdcall MsgSearch(const MSGList* fileAddr, long messageId); +const char* MsgSearch(const MSGList* fileAddr, long messageId); // returns pointer to prototype by PID, or nullptr on failure char* GetProtoPtr(long pid); @@ -1301,16 +1301,22 @@ WINinfo* GetUIWindow(long winType); void GetObjectsTileRadius(std::vector &objs, long sourceTile, long radius, long elev, long type); // Print text to surface -void PrintText(char* displayText, BYTE colorIndex, DWORD xPos, DWORD yPos, DWORD txtWidth, DWORD toWidth, BYTE* toSurface); +void __stdcall PrintText(char* displayText, BYTE colorIndex, DWORD xPos, DWORD yPos, DWORD txtWidth, DWORD toWidth, BYTE* toSurface); + // gets the height of the currently selected font -DWORD GetTextHeight(); +DWORD __stdcall GetTextHeight(); + // gets the length of a string using the currently selected font -DWORD __stdcall GetTextWidth(const char *TextMsg); +DWORD __stdcall GetTextWidth(const char* textMsg); + // get width of Char for current font -DWORD GetCharWidth(char charVal); +DWORD __stdcall GetCharWidth(char charVal); + // get maximum string length for current font - if all characters were maximum width -DWORD GetMaxTextWidth(char *textMsg); +DWORD __stdcall GetMaxTextWidth(const char* textMsg); + // get number of pixels between characters for current font -DWORD GetCharGapWidth(); +DWORD __stdcall GetCharGapWidth(); + // get maximum character width for current font -DWORD GetMaxCharWidth(); +DWORD __stdcall GetMaxCharWidth(); diff --git a/sfall/HeroAppearance.cpp b/sfall/HeroAppearance.cpp index ad006541..4b35313f 100644 --- a/sfall/HeroAppearance.cpp +++ b/sfall/HeroAppearance.cpp @@ -1114,7 +1114,7 @@ void _stdcall HeroSelectWindow(int raceStyleFlag) { button = GetInputBtn(); if (button == 0x148) { // previous style/race - up arrow button pushed - GSoundPlaySfxFile("ib1p1xx1"); + GsoundPlaySfxFile("ib1p1xx1"); if (isStyle) { if (styleVal == 0) continue; @@ -1135,7 +1135,7 @@ void _stdcall HeroSelectWindow(int raceStyleFlag) { drawFlag = true; } } else if (button == 0x150) { // Next style/race - down arrow button pushed - GSoundPlaySfxFile("ib1p1xx1"); + GsoundPlaySfxFile("ib1p1xx1"); if (isStyle) { styleVal++; @@ -1156,7 +1156,7 @@ void _stdcall HeroSelectWindow(int raceStyleFlag) { } } } else if (button == 0x0D) { // save and exit - Enter button pushed - GSoundPlaySfxFile("ib1p1xx1"); + GsoundPlaySfxFile("ib1p1xx1"); if (!isStyle && currentRaceVal == raceVal) { // return style to previous value if no race change styleVal = currentStyleVal; } @@ -1342,15 +1342,15 @@ static int _stdcall CheckCharButtons() { case 1: *ptr_info_line = 0x501; play: - GSoundPlaySfxFile("ib3p1xx1"); + GsoundPlaySfxFile("ib3p1xx1"); break; case 2: style = true; case 3: - GSoundPlaySfxFile("ISDXXXX1"); + GsoundPlaySfxFile("ISDXXXX1"); break; default: - GSoundPlaySfxFile("IB3LU1X1"); + GsoundPlaySfxFile("IB3LU1X1"); return button; } FixTextHighLight(); diff --git a/sfall/Interface.cpp b/sfall/Interface.cpp index b363daec..5d8d9c30 100644 --- a/sfall/Interface.cpp +++ b/sfall/Interface.cpp @@ -221,7 +221,7 @@ static long gmouse_handle_event_hook() { // if IFACE_BAR_MODE is not enabled, check the display_win window area win = GNWFind(*(DWORD*)_display_win); RECT *rect = &win->wRect; - return MouseClickIn(rect->left, rect->top, rect->right, rect->bottom); // 1 - click in the display_win area + return MouseClickIn(rect->left, rect->top, rect->right, rect->bottom); // 1 - click in the display window area } static void __declspec(naked) gmouse_bk_process_hook() { diff --git a/sfall/LoadGameHook.cpp b/sfall/LoadGameHook.cpp index fdab7980..5c9e25f5 100644 --- a/sfall/LoadGameHook.cpp +++ b/sfall/LoadGameHook.cpp @@ -144,7 +144,7 @@ static void _stdcall SaveGame2() { errorSave: dlog_f("ERROR creating: %s\n", DL_MAIN, buf); DisplayConsoleMessage(SaveSfallDataFailMsg); - GSoundPlaySfxFile("IISXXXX1"); + GsoundPlaySfxFile("IISXXXX1"); } static char SaveFailMsg[128]; diff --git a/sfall/Movies.cpp b/sfall/Movies.cpp index c5b8b445..bdc976f6 100644 --- a/sfall/Movies.cpp +++ b/sfall/Movies.cpp @@ -371,7 +371,7 @@ static DWORD __fastcall PreparePlayMovie(const DWORD id) { SafeWrite8(0x4F5F40, 0xC3); // blocking sfShowFrame_ for disabling the display of mve video frames #ifdef NDEBUG // mute sound because mve file is still being played to get subtitles - backgroundVolume = GSoundBackgroundVolumeGetSet(0); + backgroundVolume = GsoundBackgroundVolumeGetSet(0); #endif } @@ -398,7 +398,7 @@ static void _stdcall PlayMovieRestore() { SafeWrite8(0x4CB850, 0x53); // GNW95_ShowRect_ } else { SafeWrite8(0x4F5F40, 0x53); // push ebx - if (backgroundVolume) backgroundVolume = GSoundBackgroundVolumeGetSet(backgroundVolume); // restore volume + if (backgroundVolume) backgroundVolume = GsoundBackgroundVolumeGetSet(backgroundVolume); // restore volume } Gfx_SetMovieTexture(0);