mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +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:
+8
-7
@@ -22,6 +22,7 @@
|
||||
#include "font.h"
|
||||
#include "Font Control.h"
|
||||
#include "GameSettings.h"
|
||||
#include <language.hpp>
|
||||
|
||||
#include <vfs/Tools/vfs_property_container.h>
|
||||
|
||||
@@ -353,7 +354,7 @@ INT32 CreateWinFont( LOGFONT &logfont )
|
||||
HDC hdc = GetDC(NULL);
|
||||
SelectObject(hdc, hFont);
|
||||
|
||||
#ifdef CHINESE
|
||||
if(g_lang == i18n::Lang::zh) {
|
||||
SIZE RectSize;
|
||||
wchar_t str[2]=L"\1";
|
||||
for (int i = 1; i<0x80; i++)
|
||||
@@ -365,7 +366,7 @@ INT32 CreateWinFont( LOGFONT &logfont )
|
||||
str[0] = L'啊';
|
||||
GetTextExtentPoint32W( hdc, str, 1, &RectSize );
|
||||
WinFonts[iFont].Width[0] = (UINT8)RectSize.cx;
|
||||
#endif
|
||||
}
|
||||
|
||||
TEXTMETRIC tm;
|
||||
GetTextMetrics(hdc, &tm);
|
||||
@@ -467,7 +468,7 @@ INT16 WinFontStringPixLength( STR16 string2, INT32 iFont )
|
||||
|
||||
if (pWinFont == NULL) return(0);
|
||||
|
||||
#ifdef CHINESE
|
||||
if(g_lang == i18n::Lang::zh) {
|
||||
wchar_t *p=string2;
|
||||
UINT32 size = 0;
|
||||
while (*p!=0)
|
||||
@@ -482,7 +483,7 @@ INT16 WinFontStringPixLength( STR16 string2, INT32 iFont )
|
||||
p++;
|
||||
}
|
||||
return size;
|
||||
#else
|
||||
} else {
|
||||
SIZE RectSize;
|
||||
HDC hdc = GetDC(NULL);
|
||||
|
||||
@@ -491,7 +492,7 @@ INT16 WinFontStringPixLength( STR16 string2, INT32 iFont )
|
||||
ReleaseDC(NULL, hdc);
|
||||
|
||||
return( (INT16)RectSize.cx );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -502,11 +503,11 @@ INT16 GetWinFontHeight(INT32 iFont)
|
||||
pWinFont = GetWinFont(iFont);
|
||||
|
||||
if (pWinFont == NULL) return(0);
|
||||
#ifdef CHINESE //zwwooooo: Correct tactical interface font height to fixed Chinese characters smearing bug
|
||||
if(g_lang == i18n::Lang::zh) { //zwwooooo: Correct tactical interface font height to fixed Chinese characters smearing bug
|
||||
if (iFont == WinFontMap[TINYFONT1] || iFont == WinFontMap[SMALLFONT1] || iFont == WinFontMap[FONT14ARIAL])
|
||||
{
|
||||
return pWinFont->Height + 2;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return pWinFont->Height;
|
||||
}
|
||||
|
||||
+3
-2
@@ -58,6 +58,7 @@
|
||||
#endif
|
||||
#include <Music Control.h>
|
||||
|
||||
#include <language.hpp>
|
||||
|
||||
static void MAGIC(std::string const& aarrrrgggh = "")
|
||||
{}
|
||||
@@ -858,13 +859,13 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
|
||||
}
|
||||
#endif
|
||||
|
||||
# ifdef ENGLISH
|
||||
if( g_lang == i18n::Lang::en ) {
|
||||
try
|
||||
{
|
||||
SetIntroType( INTRO_SPLASH );
|
||||
}
|
||||
HANDLE_FATAL_ERROR;
|
||||
# endif
|
||||
}
|
||||
|
||||
gfApplicationActive = TRUE;
|
||||
gfProgramIsRunning = TRUE;
|
||||
|
||||
Reference in New Issue
Block a user