- fixed: ZDoom aborted on old WADs containing a binary LANGUAGE lump.

SVN r2414 (trunk)
This commit is contained in:
Christoph Oelckers 2010-07-06 20:32:24 +00:00
parent ccd4dc3189
commit ea04d2bbdf
3 changed files with 30 additions and 0 deletions

View File

@ -331,6 +331,24 @@ void FScanner::RestorePos (const FScanner::SavedPos &pos)
Crossed = false;
}
//==========================================================================
//
// FScanner :: isText
//
// Checks if this is a text file.
//
//==========================================================================
bool FScanner::isText()
{
for(unsigned int i=0;i<ScriptBuffer.Len();i++)
{
int c = ScriptBuffer[i];
if (c < ' ' && c != '\n' && c != '\r' && c != '\t') return false;
}
return true;
}
//==========================================================================
//
// FScanner :: SetCMode

View File

@ -61,6 +61,8 @@ public:
void ScriptError(const char *message, ...);
void ScriptMessage(const char *message, ...);
bool isText();
// Members ------------------------------------------------------
char *String;
int StringLen;

View File

@ -139,6 +139,7 @@ void FStringTable::LoadStrings (bool enuOnly)
void FStringTable::LoadLanguage (int lumpnum, DWORD code, bool exactMatch, int passnum)
{
static bool errordone = false;
const DWORD orMask = exactMatch ? 0 : MAKE_ID(0,0,0xff,0);
DWORD inCode = 0;
StringEntry *entry, **pentry;
@ -211,6 +212,15 @@ void FStringTable::LoadLanguage (int lumpnum, DWORD code, bool exactMatch, int p
{ // Process string definitions.
if (inCode == 0)
{
// LANGUAGE lump is bad. We need to check if this is an old binary
// lump and if so just skip it to allow old WADs to run which contain
// such a lump.
if (!sc.isText())
{
if (!errordone) Printf("Skipping binary 'LANGUAGE' lump.\n");
errordone = true;
return;
}
sc.ScriptError ("Found a string without a language specified.");
}