diff options
| author | oy <Tom_Adams@web.de> | 2011-02-10 12:07:00 +0100 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-02-10 12:07:00 +0100 |
| commit | 0c119ba99bdf78c3c0a0a9562abe7e139e97e530 (patch) | |
| tree | 6f3da29157aeba9f2426df932027e58ea4c7a60f /src | |
| parent | 3f05289328dfaeb67a344de0b553e31cbb11ea36 (diff) | |
| download | zcatch-0c119ba99bdf78c3c0a0a9562abe7e139e97e530.tar.gz zcatch-0c119ba99bdf78c3c0a0a9562abe7e139e97e530.zip | |
fixed possible problem with localisations if the linereader flushes its memory between reading the origin and the replacement string
Diffstat (limited to 'src')
| -rw-r--r-- | src/game/client/components/menus_settings.cpp | 8 | ||||
| -rw-r--r-- | src/game/localization.cpp | 6 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index a1779796..9accd6af 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -690,6 +690,7 @@ void LoadLanguageIndexfile(IStorage *pStorage, IConsole *pConsole, sorted_array< return; } + char aOrigin[128]; CLineReader LineReader; LineReader.Init(File); char *pLine; @@ -697,7 +698,8 @@ void LoadLanguageIndexfile(IStorage *pStorage, IConsole *pConsole, sorted_array< { if(!str_length(pLine) || pLine[0] == '#') // skip empty lines and comments continue; - + + str_copy(aOrigin, pLine, sizeof(aOrigin)); char *pReplacement = LineReader.Get(); if(!pReplacement) { @@ -708,13 +710,13 @@ void LoadLanguageIndexfile(IStorage *pStorage, IConsole *pConsole, sorted_array< if(pReplacement[0] != '=' || pReplacement[1] != '=' || pReplacement[2] != ' ') { char aBuf[128]; - str_format(aBuf, sizeof(aBuf), "malform replacement for index '%s'", pLine); + str_format(aBuf, sizeof(aBuf), "malform replacement for index '%s'", aOrigin); pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", aBuf); continue; } char aFileName[128]; - str_format(aFileName, sizeof(aFileName), "languages/%s.txt", pLine); + str_format(aFileName, sizeof(aFileName), "languages/%s.txt", aOrigin); pLanguages->add(CLanguage(pReplacement+3, aFileName)); } io_close(File); diff --git a/src/game/localization.cpp b/src/game/localization.cpp index ad025100..69896300 100644 --- a/src/game/localization.cpp +++ b/src/game/localization.cpp @@ -63,6 +63,7 @@ bool CLocalizationDatabase::Load(const char *pFilename, IStorage *pStorage, ICon pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", aBuf); m_Strings.clear(); + char aOrigin[512]; CLineReader LineReader; LineReader.Init(IoHandle); char *pLine; @@ -74,6 +75,7 @@ bool CLocalizationDatabase::Load(const char *pFilename, IStorage *pStorage, ICon if(pLine[0] == '#') // skip comments continue; + str_copy(aOrigin, pLine, sizeof(aOrigin)); char *pReplacement = LineReader.Get(); if(!pReplacement) { @@ -83,13 +85,13 @@ bool CLocalizationDatabase::Load(const char *pFilename, IStorage *pStorage, ICon if(pReplacement[0] != '=' || pReplacement[1] != '=' || pReplacement[2] != ' ') { - str_format(aBuf, sizeof(aBuf), "malform replacement line for '%s'", pLine); + str_format(aBuf, sizeof(aBuf), "malform replacement line for '%s'", aOrigin); pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", aBuf); continue; } pReplacement += 3; - AddString(pLine, pReplacement); + AddString(aOrigin, pReplacement); } io_close(IoHandle); |