mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 19:29:09 +00:00
MinGW fixes for pfLocalizationMgr.
This commit is contained in:
@ -50,6 +50,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
#include <bxwchar.h>
|
#include <bxwchar.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// MinGW sucks
|
||||||
|
#if defined(_WIN32) && !defined(_MSC_VER)
|
||||||
|
# define swprintf _snwprintf
|
||||||
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// LocalizationXMLFile - a basic class for storing all the
|
// LocalizationXMLFile - a basic class for storing all the
|
||||||
@ -422,7 +427,7 @@ bool LocalizationXMLFile::Parse(const std::string & fileName)
|
|||||||
if (XML_Parse(fParser, Buff, (int)len, done) == XML_STATUS_ERROR)
|
if (XML_Parse(fParser, Buff, (int)len, done) == XML_STATUS_ERROR)
|
||||||
{
|
{
|
||||||
wchar_t lineNumber[256];
|
wchar_t lineNumber[256];
|
||||||
_itow(XML_GetCurrentLineNumber(fParser), lineNumber, 10);
|
swprintf(lineNumber, 256, L"%d", XML_GetCurrentLineNumber(fParser));
|
||||||
fLastError += L"ERROR: Parse error at line ";
|
fLastError += L"ERROR: Parse error at line ";
|
||||||
fLastError += lineNumber;
|
fLastError += lineNumber;
|
||||||
fLastError += L": ";
|
fLastError += L": ";
|
||||||
@ -466,7 +471,7 @@ bool LocalizationXMLFile::Parse(const std::string & fileName)
|
|||||||
void LocalizationXMLFile::AddError(const std::wstring & errorText)
|
void LocalizationXMLFile::AddError(const std::wstring & errorText)
|
||||||
{
|
{
|
||||||
wchar_t lineNumber[256];
|
wchar_t lineNumber[256];
|
||||||
_itow(XML_GetCurrentLineNumber(fParser), lineNumber, 10);
|
swprintf(lineNumber, 256, L"%d", XML_GetCurrentLineNumber(fParser));
|
||||||
fLastError += L"ERROR (line ";
|
fLastError += L"ERROR (line ";
|
||||||
fLastError += lineNumber;
|
fLastError += lineNumber;
|
||||||
fLastError += L"): " + errorText + L"\n";
|
fLastError += L"): " + errorText + L"\n";
|
||||||
@ -603,7 +608,7 @@ void LocalizationDatabase::IVerifyElement(const std::wstring &ageName, const std
|
|||||||
int numLocales = plLocalization::GetNumLocales();
|
int numLocales = plLocalization::GetNumLocales();
|
||||||
for (int curLocale = 0; curLocale <= numLocales; curLocale++)
|
for (int curLocale = 0; curLocale <= numLocales; curLocale++)
|
||||||
{
|
{
|
||||||
char *name = plLocalization::GetLanguageName((plLocalization::Language)curLocale);
|
const char *name = plLocalization::GetLanguageName((plLocalization::Language)curLocale);
|
||||||
wchar_t *wName = hsStringToWString(name);
|
wchar_t *wName = hsStringToWString(name);
|
||||||
languageNames.push_back(wName);
|
languageNames.push_back(wName);
|
||||||
delete [] wName;
|
delete [] wName;
|
||||||
@ -629,12 +634,7 @@ void LocalizationDatabase::IVerifyElement(const std::wstring &ageName, const std
|
|||||||
{
|
{
|
||||||
fErrorString += L"ERROR: The language " + curTranslation->first + L" used by " + ageName + L"." + setName + L".";
|
fErrorString += L"ERROR: The language " + curTranslation->first + L" used by " + ageName + L"." + setName + L".";
|
||||||
fErrorString += elementName + L" is not supported, discarding translation\n";
|
fErrorString += elementName + L" is not supported, discarding translation\n";
|
||||||
#if !HS_BUILD_FOR_MAC
|
|
||||||
curTranslation = theElement.erase(curTranslation);
|
|
||||||
#else
|
|
||||||
// jfim: I thought std::map::erase returned void?
|
|
||||||
theElement.erase(curTranslation);
|
theElement.erase(curTranslation);
|
||||||
#endif
|
|
||||||
curTranslation--; // because this will be incremented on the next run through the loop
|
curTranslation--; // because this will be incremented on the next run through the loop
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -645,12 +645,7 @@ void LocalizationDatabase::IVerifyElement(const std::wstring &ageName, const std
|
|||||||
{
|
{
|
||||||
fErrorString += L"ERROR: Default language " + defaultLanguage + L" is missing from the translations in element ";
|
fErrorString += L"ERROR: Default language " + defaultLanguage + L" is missing from the translations in element ";
|
||||||
fErrorString += ageName + L"." + setName + L"." + elementName + L", deleting element\n";
|
fErrorString += ageName + L"." + setName + L"." + elementName + L", deleting element\n";
|
||||||
#if !HS_BUILD_FOR_MAC
|
|
||||||
curElement = theSet.erase(curElement);
|
|
||||||
#else
|
|
||||||
// jfim: I thought std::map::erase returned void?
|
|
||||||
theSet.erase(curElement);
|
theSet.erase(curElement);
|
||||||
#endif
|
|
||||||
curElement--;
|
curElement--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -918,7 +913,7 @@ pfLocalizationDataMgr::localizedElement pfLocalizationDataMgr::ICreateLocalizedE
|
|||||||
|
|
||||||
for (int curLocale = 0; curLocale <= numLocales; curLocale++)
|
for (int curLocale = 0; curLocale <= numLocales; curLocale++)
|
||||||
{
|
{
|
||||||
char *name = plLocalization::GetLanguageName((plLocalization::Language)curLocale);
|
const char *name = plLocalization::GetLanguageName((plLocalization::Language)curLocale);
|
||||||
wchar_t *wName = hsStringToWString(name);
|
wchar_t *wName = hsStringToWString(name);
|
||||||
retVal[wName] = L"";
|
retVal[wName] = L"";
|
||||||
delete [] wName;
|
delete [] wName;
|
||||||
@ -932,7 +927,7 @@ pfLocalizationDataMgr::localizedElement pfLocalizationDataMgr::ICreateLocalizedE
|
|||||||
std::wstring pfLocalizationDataMgr::IGetCurrentLanguageName()
|
std::wstring pfLocalizationDataMgr::IGetCurrentLanguageName()
|
||||||
{
|
{
|
||||||
std::wstring retVal;
|
std::wstring retVal;
|
||||||
char *name = plLocalization::GetLanguageName(plLocalization::GetLanguage());
|
const char *name = plLocalization::GetLanguageName(plLocalization::GetLanguage());
|
||||||
wchar_t *wName = hsStringToWString(name);
|
wchar_t *wName = hsStringToWString(name);
|
||||||
retVal = wName;
|
retVal = wName;
|
||||||
delete [] wName;
|
delete [] wName;
|
||||||
@ -948,7 +943,7 @@ std::vector<std::wstring> pfLocalizationDataMgr::IGetAllLanguageNames()
|
|||||||
|
|
||||||
for (int curLocale = 0; curLocale <= numLocales; curLocale++)
|
for (int curLocale = 0; curLocale <= numLocales; curLocale++)
|
||||||
{
|
{
|
||||||
char *name = plLocalization::GetLanguageName((plLocalization::Language)curLocale);
|
const char *name = plLocalization::GetLanguageName((plLocalization::Language)curLocale);
|
||||||
wchar_t *wName = hsStringToWString(name);
|
wchar_t *wName = hsStringToWString(name);
|
||||||
retVal.push_back(wName);
|
retVal.push_back(wName);
|
||||||
delete [] wName;
|
delete [] wName;
|
||||||
@ -1257,7 +1252,7 @@ std::wstring pfLocalizationDataMgr::GetElementPlainTextData(const std::wstring &
|
|||||||
if (fLocalizedElements.exists(name))
|
if (fLocalizedElements.exists(name))
|
||||||
{
|
{
|
||||||
if (fLocalizedElements[name].find(languageName) != fLocalizedElements[name].end())
|
if (fLocalizedElements[name].find(languageName) != fLocalizedElements[name].end())
|
||||||
retVal = (std::wstring)fLocalizedElements[name][languageName];
|
retVal = fLocalizedElements[name][languageName];
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
#include <bxwchar.h>
|
#include <bxwchar.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// MinGW sucks
|
||||||
|
#if defined(_WIN32) && !defined(_MSC_VER)
|
||||||
|
# define swprintf _snwprintf
|
||||||
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//// pfLocalizedString functions /////////////////////////////////////
|
//// pfLocalizedString functions /////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@ -114,7 +119,7 @@ void pfLocalizedString::IConvertFromPlainText(const std::wstring & plainText)
|
|||||||
curTextBlock.fText = L"";
|
curTextBlock.fText = L"";
|
||||||
|
|
||||||
std::wstring number = plainText.substr(curIndex + 1, (endArgPos - (curIndex + 1)));
|
std::wstring number = plainText.substr(curIndex + 1, (endArgPos - (curIndex + 1)));
|
||||||
curTextBlock.fParamIndex = _wtoi(number.c_str()) - 1; // args are 1-based, vectors are 0-based
|
curTextBlock.fParamIndex = (UInt8)wcstol(number.c_str(), NULL, 10) - 1; // args are 1-based, vectors are 0-based
|
||||||
fText.push_back(curTextBlock);
|
fText.push_back(curTextBlock);
|
||||||
|
|
||||||
curTextBlock.fIsParam = false;
|
curTextBlock.fIsParam = false;
|
||||||
@ -150,7 +155,7 @@ void pfLocalizedString::IUpdatePlainText()
|
|||||||
{
|
{
|
||||||
std::wstring paramStr = L"%";
|
std::wstring paramStr = L"%";
|
||||||
wchar_t buff[256];
|
wchar_t buff[256];
|
||||||
_itow(curTextBlock.fParamIndex + 1, buff, 10);
|
swprintf(buff, 256, L"%d", curTextBlock.fParamIndex + 1);
|
||||||
paramStr += buff;
|
paramStr += buff;
|
||||||
paramStr += L"s";
|
paramStr += L"s";
|
||||||
fPlainTextRep += paramStr;
|
fPlainTextRep += paramStr;
|
||||||
@ -223,7 +228,7 @@ void pfLocalizedString::IConvertFromXML(const std::wstring & xml)
|
|||||||
curTextBlock.fText = L"";
|
curTextBlock.fText = L"";
|
||||||
|
|
||||||
std::wstring number = xml.substr(curIndex + 1, (endArgPos - (curIndex + 1)));
|
std::wstring number = xml.substr(curIndex + 1, (endArgPos - (curIndex + 1)));
|
||||||
curTextBlock.fParamIndex = _wtoi(number.c_str()) - 1; // args are 1-based, vectors are 0-based
|
curTextBlock.fParamIndex = (UInt8)wcstol(number.c_str(), nil, 10) - 1; // args are 1-based, vectors are 0-based
|
||||||
fText.push_back(curTextBlock);
|
fText.push_back(curTextBlock);
|
||||||
|
|
||||||
curTextBlock.fIsParam = false;
|
curTextBlock.fIsParam = false;
|
||||||
@ -260,7 +265,7 @@ void pfLocalizedString::IUpdateXML()
|
|||||||
{
|
{
|
||||||
std::wstring paramStr = L"%";
|
std::wstring paramStr = L"%";
|
||||||
wchar_t buff[256];
|
wchar_t buff[256];
|
||||||
_itow(curTextBlock.fParamIndex + 1, buff, 10);
|
swprintf(buff, 256, L"%d", curTextBlock.fParamIndex + 1);
|
||||||
paramStr += buff;
|
paramStr += buff;
|
||||||
paramStr += L"s";
|
paramStr += L"s";
|
||||||
fXMLRep += paramStr;
|
fXMLRep += paramStr;
|
||||||
|
@ -86,7 +86,7 @@ public:
|
|||||||
bool operator>=(pfLocalizedString &obj);
|
bool operator>=(pfLocalizedString &obj);
|
||||||
bool operator!=(pfLocalizedString &obj);
|
bool operator!=(pfLocalizedString &obj);
|
||||||
|
|
||||||
operator const wchar_t *() {return fPlainTextRep.c_str();}
|
//operator const wchar_t *() {return fPlainTextRep.c_str();}
|
||||||
operator std::wstring() {return fPlainTextRep;}
|
operator std::wstring() {return fPlainTextRep;}
|
||||||
|
|
||||||
pfLocalizedString operator+(pfLocalizedString &obj);
|
pfLocalizedString operator+(pfLocalizedString &obj);
|
||||||
|
Reference in New Issue
Block a user