Skip to content

Commit

Permalink
- merge whitespaces before comparing Dehacked texts
Browse files Browse the repository at this point in the history
With introduction of localization support, several strings are no longer identical to the original messages
Double spaces were removed, and letter case was changed
The latter is already handled, extra whitespaces are now deleted to deal with the former

https://forum.zdoom.org/viewtopic.php?t=69236
  • Loading branch information
alexey-lysiuk committed Jul 12, 2020
1 parent 6e79209 commit fcb6e1b
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions src/gamedata/d_dehacked.cpp
Expand Up @@ -2191,22 +2191,18 @@ static int PatchText (int oldSize)
}
newSize = atoi (temp);

oldStr = new char[oldSize + 1];
newStr = new char[newSize + 1];

if (!oldStr || !newStr)
{
Printf ("Out of memory.\n");
goto donewithtext;
}

FString oldStrData, newStrData;
oldStr = oldStrData.LockNewBuffer(oldSize + 1);
newStr = newStrData.LockNewBuffer(newSize + 1);

good = ReadChars (&oldStr, oldSize);
good += ReadChars (&newStr, newSize);

oldStrData.UnlockBuffer();
newStrData.UnlockBuffer();

if (!good)
{
delete[] newStr;
delete[] oldStr;
Printf ("Unexpected end-of-file.\n");
return 0;
}
Expand Down Expand Up @@ -2271,11 +2267,11 @@ static int PatchText (int oldSize)
const char *str;
do
{
oldStrData.MergeChars(' ');
str = EnglishStrings.MatchString(oldStr);
if (str != NULL)
{
FString newname = newStr;
TableElement te = { LumpFileNum, { newname, newname, newname, newname } };
TableElement te = { LumpFileNum, { newStrData, newStrData, newStrData, newStrData } };
DehStrings.Insert(str, te);
EnglishStrings.Remove(str); // remove entry so that it won't get found again by the next iteration or by another replacement later
good = true;
Expand All @@ -2289,11 +2285,6 @@ static int PatchText (int oldSize)
}

donewithtext:
if (newStr)
delete[] newStr;
if (oldStr)
delete[] oldStr;

// Fetch next identifier for main loop
while ((result = GetLine ()) == 1)
;
Expand Down

0 comments on commit fcb6e1b

Please sign in to comment.