mirror of
https://github.com/1dot13/source.git
synced 2026-09-02 14:36:06 +02:00
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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+250
-249
File diff suppressed because it is too large
Load Diff
@@ -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 );
|
||||
|
||||
@@ -73,6 +73,8 @@
|
||||
|
||||
//legion by Jazz
|
||||
#include "Interface Utils.h"
|
||||
#include <language.hpp>
|
||||
|
||||
//forward declarations of common classes to eliminate includes
|
||||
class OBJECTTYPE;
|
||||
class SOLDIERTYPE;
|
||||
@@ -2747,27 +2749,27 @@ void RenderSMPanel( BOOLEAN *pfDirty )
|
||||
|
||||
mprintf( SM_ARMOR_LABEL_X - StringPixLength( pInvPanelTitleStrings[0], BLOCKFONT2 ) / 2, SM_ARMOR_LABEL_Y, pInvPanelTitleStrings[ 0 ] );
|
||||
|
||||
#ifdef CHINESE
|
||||
if( g_lang == i18n::Lang::zh ) {
|
||||
mprintf( SM_ARMOR_PERCENT_X, SM_ARMOR_PERCENT_Y, ChineseSpecString1 );
|
||||
#else
|
||||
} else {
|
||||
mprintf( SM_ARMOR_PERCENT_X, SM_ARMOR_PERCENT_Y, L"%%" );
|
||||
#endif
|
||||
}
|
||||
|
||||
mprintf( SM_WEIGHT_LABEL_X - StringPixLength( pInvPanelTitleStrings[1], BLOCKFONT2 ), SM_WEIGHT_LABEL_Y, pInvPanelTitleStrings[ 1 ] );
|
||||
|
||||
#ifdef CHINESE
|
||||
if( g_lang == i18n::Lang::zh ) {
|
||||
mprintf( SM_WEIGHT_PERCENT_X, SM_WEIGHT_PERCENT_Y, ChineseSpecString1 );
|
||||
#else
|
||||
} else {
|
||||
mprintf( SM_WEIGHT_PERCENT_X, SM_WEIGHT_PERCENT_Y, L"%%" );
|
||||
#endif
|
||||
}
|
||||
|
||||
mprintf( SM_CAMMO_LABEL_X - StringPixLength( pInvPanelTitleStrings[2], BLOCKFONT2 ), SM_CAMMO_LABEL_Y, pInvPanelTitleStrings[ 2 ] );
|
||||
|
||||
#ifdef CHINESE
|
||||
if( g_lang == i18n::Lang::zh ) {
|
||||
mprintf( SM_CAMMO_PERCENT_X, SM_CAMMO_PERCENT_Y, ChineseSpecString1 );
|
||||
#else
|
||||
} else {
|
||||
mprintf( SM_CAMMO_PERCENT_X, SM_CAMMO_PERCENT_Y, L"%%" );
|
||||
#endif
|
||||
}
|
||||
|
||||
UpdateStatColor( gpSMCurrentMerc->timeChanges.uiChangeAgilityTime, (BOOLEAN)(gpSMCurrentMerc->usValueGoneUp & AGIL_INCREASE ? TRUE : FALSE), (BOOLEAN)((gGameOptions.fNewTraitSystem && (gpSMCurrentMerc->ubCriticalStatDamage[DAMAGED_STAT_AGILITY] > 0)) ? TRUE : FALSE), gpSMCurrentMerc->bExtraAgility != 0 ); // SANDRO
|
||||
|
||||
|
||||
Reference in New Issue
Block a user