diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index c14af1fc..70f21941 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -707,9 +707,6 @@ SkipLoadingGameSettings=0 ;The formula for the duration in ticks is: 10 * (value - 3 * EN) KnockoutTime=35 -;Set to 1 to display sfall built-in credits at the bottom of credits.txt contents instead of at the top -CreditsAtBottom=0 - ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ; Critical modding options - the following options should be changed with caution ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX diff --git a/artifacts/scripting/sfall function notes.md b/artifacts/scripting/sfall function notes.md index 3258b7af..e7b981ab 100644 --- a/artifacts/scripting/sfall function notes.md +++ b/artifacts/scripting/sfall function notes.md @@ -943,7 +943,7 @@ sfall_funcX metarule functions `int sfall_func2("get_stat_min", int stat, bool who)`\ `int sfall_func2("get_stat_max", int stat, bool who)` - Returns the maximum or minimum set value of the specified stat (see `set_stat_min` and `set_stat_max` functions) -- `who`: 0 (false) or omitting the argument - returns the value of the player, 1 (true) - returns the value set for other critters +- `who`: 0 (False) or omitting the argument - returns the value of the player, 1 (True) - returns the value set for other critters ---- #### interface_art_draw @@ -1021,7 +1021,7 @@ sfall_funcX metarule functions ---- #### obj_is_openable `bool sfall_func1("obj_is_openable", object obj)` -- Returns True if the object is openable (i.e. has an opening/closing animation) +- Returns True if the object is openable (i.e. has an opening/closing animation), False otherwise **** diff --git a/sfall/Modules/Credits.cpp b/sfall/Modules/Credits.cpp index 830e13c3..e90dd612 100644 --- a/sfall/Modules/Credits.cpp +++ b/sfall/Modules/Credits.cpp @@ -27,7 +27,7 @@ namespace sfall { -static DWORD InCredits = 0; +static bool InCredits = false; static DWORD CreditsLine = 0; static const char* ExtraLines[] = { @@ -84,15 +84,6 @@ static const char* ExtraLines[] = { static DWORD ExtraLineCount = sizeof(ExtraLines) / 4; //static const char* creditsFile = "credits.txt"; -static void __declspec(naked) ShowCreditsHook() { - InCredits = 1; - CreditsLine = 0; - //__asm mov eax, creditsFile; - __asm call fo::funcoffs::credits_; - InCredits = 0; - __asm retn; -} - static DWORD __fastcall CreditsNextLine(char* buf, DWORD* font, DWORD* colour) { if (!InCredits || CreditsLine >= ExtraLineCount) return 0; const char* line = ExtraLines[CreditsLine++]; @@ -159,14 +150,38 @@ morelines: } } -void Credits::init() { - const DWORD showCreditsAddr[] = {0x480C49, 0x43F881}; - HookCalls(ShowCreditsHook, showCreditsAddr); - if (IniReader::GetConfigInt("Misc", "CreditsAtBottom", 0)) { - HookCall(0x42CB49, CreditsNextLineHook_Bottom); +static void __stdcall SetCreditsPosition(DWORD addr) { + void* func; + if (addr == (0x43F881 + 5)) { // called from endgame_movie_ + func = CreditsNextLineHook_Bottom; } else { - HookCall(0x42CB49, CreditsNextLineHook_Top); + func = CreditsNextLineHook_Top; + } + HookCall(0x42CB49, func); +} + +static void __declspec(naked) ShowCreditsHook() { + __asm { + push eax; + push edx; + push ebx; + push [esp + 12]; // return address + call SetCreditsPosition; + pop ebx; + pop edx; + pop eax; + mov InCredits, 1; + mov CreditsLine, 0; + //mov eax, creditsFile; + call fo::funcoffs::credits_; + mov InCredits, 0; + retn; } } +void Credits::init() { + const DWORD showCreditsAddr[] = {0x480C49, 0x43F881}; + HookCalls(ShowCreditsHook, showCreditsAddr); +} + }