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
@@ -33,6 +33,7 @@
#include "GameSettings.h"
#include "fresh_header.h"
#include "connect.h"
#include <language.hpp>
#ifdef JA2UB
#include "Explosion Control.h"
@@ -1492,7 +1493,7 @@ void SetDoorString( INT32 sGridNo )
// ATE: If here, we try to say, opened or closed...
if ( gfUIIntTileLocation2 == FALSE )
{
#ifdef GERMAN
if( g_lang == i18n::Lang::de ) {
wcscpy( gzIntTileLocation2, TacticalStr[ DOOR_DOOR_MOUSE_DESCRIPTION ] );
gfUIIntTileLocation2 = TRUE;
@@ -1535,7 +1536,7 @@ void SetDoorString( INT32 sGridNo )
gfUIIntTileLocation = TRUE;
}
}
#else
} else {
// Try to get doors status here...
pDoorStatus = GetDoorStatus( sGridNo );
@@ -1576,7 +1577,7 @@ void SetDoorString( INT32 sGridNo )
}
}
#endif
}
}
}