Replace a ton of trivial #ifdefs with runtime checks

This one is big, but unless I missed something, should be all be
trivial.

scripted-diff with the following, then manually tweaked whatever needed:
```

if [ $# -ne 3 ]; then
    echo "Usage: $0 '<pattern>' '<replacement>' '<filename>'"
    exit 1
fi

pattern="$1"
replacement="$2"
filename="$3"

if [ ! -f "$filename" ]; then
    echo "Error: File $filename does not exist."
    exit 1
fi

sed -i '/'"$pattern"'/ {
    :loop
    $ !{
        N
        /'"$pattern"'.*\n.*#endif/ {
            s/'"$pattern"'/'"$replacement"'/
            s/#else/} else {/
            s/#endif/}/
            P
            D
        }
        /'"$pattern"'/ b loop
    }
}' "$filename"

echo "Replacement complete in $filename"
```

h/t to Grok2 for the sed command
This commit is contained in:
Marco Antonio J. Costa
2024-12-31 16:28:44 -03:00
parent cd69f5f3ae
commit d008d10b31
18 changed files with 413 additions and 396 deletions
+4 -3
View File
@@ -5,6 +5,7 @@
#include "Timer Control.h"
#include "Multi Language Graphic Utils.h"
#include <stdio.h>
#include <language.hpp>
UINT32 guiSplashFrameFade = 10;
UINT32 guiSplashStartTime = 0;
@@ -13,10 +14,10 @@ extern HVSURFACE ghFrameBuffer;
//Simply create videosurface, load image, and draw it to the screen.
void InitJA2SplashScreen()
{
#ifdef ENGLISH
if( g_lang == i18n::Lang::en ) {
ClearMainMenu();
#else
} else {
UINT32 uiLogoID = 0;
HVSURFACE hVSurface; // unused jonathanl // lalien reenabled for international versions
VSURFACE_DESC VSurfaceDesc; //unused jonathanl // lalien reenabled for international versions
@@ -69,7 +70,7 @@ void InitJA2SplashScreen()
GetVideoSurface( &hVSurface, uiLogoID );
BltVideoSurfaceToVideoSurface( ghFrameBuffer, hVSurface, 0, iScreenWidthOffset, iScreenHeightOffset, 0, NULL );
DeleteVideoSurfaceFromIndex( uiLogoID );
#endif // ENGLISH
} // ENGLISH
InvalidateScreen();
RefreshScreen( NULL );