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
+7 -6
View File
@@ -82,6 +82,7 @@
#include "Sound Control.h"
#include "Multi Language Graphic Utils.h"
#include <language.hpp>
#ifdef JA2UB
#include "Ja25_Tactical.h"
@@ -7409,11 +7410,11 @@ void RenderItemDescriptionBox( )
FindFontRightCoordinates( gODBItemDescRegions[0][0].sLeft, gODBItemDescRegions[0][0].sTop, gODBItemDescRegions[0][0].sRight - gODBItemDescRegions[0][0].sLeft, gODBItemDescRegions[0][0].sBottom - gODBItemDescRegions[0][0].sTop ,pStr, BLOCKFONT2, &usX, &usY);
}
#ifdef CHINESE
if( g_lang == i18n::Lang::zh ) {
wcscat( pStr, ChineseSpecString1 );
#else
} else {
wcscat( pStr, L"%%" );
#endif
}
mprintf( usX, usY, pStr );
}
@@ -11178,11 +11179,11 @@ void SetupPickupPage( INT8 bPage )
}
else
{
#ifdef CHINESE
if( g_lang == i18n::Lang::zh ) {
swprintf( pStr, ChineseSpecString3, sValue );
#else
} else {
swprintf( pStr, L"%d%%", sValue );
#endif
}
}
SetRegionFastHelpText( &(gItemPickupMenu.Regions[ cnt - iStart ]), pStr );