mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 11:19:10 +00:00
Convert custom HeadSpin integer types to standard types from stdint.h
This commit is contained in:
@ -939,13 +939,13 @@ std::vector<std::wstring> pfLocalizationDataMgr::IGetAllLanguageNames()
|
||||
void pfLocalizationDataMgr::IConvertElement(LocElementInfo *elementInfo, const std::wstring & curPath)
|
||||
{
|
||||
pfLocalizationDataMgr::localizedElement newElement;
|
||||
Int16 numArgs = -1;
|
||||
int16_t numArgs = -1;
|
||||
|
||||
LocalizationXMLFile::element::iterator curTranslation;
|
||||
for (curTranslation = elementInfo->fElement.begin(); curTranslation != elementInfo->fElement.end(); curTranslation++)
|
||||
{
|
||||
newElement[curTranslation->first].FromXML(curTranslation->second);
|
||||
UInt16 argCount = newElement[curTranslation->first].GetArgumentCount();
|
||||
uint16_t argCount = newElement[curTranslation->first].GetArgumentCount();
|
||||
if (numArgs == -1) // just started
|
||||
numArgs = argCount;
|
||||
else if (argCount != numArgs)
|
||||
@ -990,24 +990,24 @@ void pfLocalizationDataMgr::IConvertAge(LocAgeInfo *ageInfo, const std::wstring
|
||||
|
||||
//// IConvertToByteStream ////////////////////////////////////////////
|
||||
|
||||
char *pfLocalizationDataMgr::IConvertToByteStream(const std::wstring & data, UInt32 &len)
|
||||
char *pfLocalizationDataMgr::IConvertToByteStream(const std::wstring & data, uint32_t &len)
|
||||
{
|
||||
len = data.length() * 2 + 2; // each wchar_t is two chars and add two bytes for the header
|
||||
char *retVal = TRACKED_NEW char[len]; // we don't add an extra byte for the 0 because the parser doesn't need it
|
||||
char lowbyte = 0, highbyte = 0;
|
||||
char lowByte = 0, highByte = 0;
|
||||
retVal[0] = (char)0xFF; // insert FFFE for little-endian UTF-16 (big-endian would be FEFF)
|
||||
retVal[1] = (char)0xFE;
|
||||
int curByteStreamPos = 2;
|
||||
for (int curLoc = 0; curLoc < data.length(); curLoc++)
|
||||
{
|
||||
wchar_t curChar = data[curLoc];
|
||||
lowbyte = (char)(curChar & 0x00FF);
|
||||
highbyte = (char)((curChar & 0xFF00) >> 8);
|
||||
lowByte = (char)(curChar & 0x00FF);
|
||||
highByte = (char)((curChar & 0xFF00) >> 8);
|
||||
|
||||
// since the data is AABBCCDD, we need to put in in our byte stream as BBAADDCC
|
||||
// since the data is AABBCCDD, we need to put in in our uint8_t stream as BBAADDCC
|
||||
// (so it kinda looks backward because we're storing this as little-endian)
|
||||
retVal[curByteStreamPos + 1] = highbyte;
|
||||
retVal[curByteStreamPos] = lowbyte;
|
||||
retVal[curByteStreamPos + 1] = highByte;
|
||||
retVal[curByteStreamPos] = lowByte;
|
||||
curByteStreamPos += 2;
|
||||
}
|
||||
return retVal;
|
||||
@ -1063,7 +1063,7 @@ void pfLocalizationDataMgr::IWriteText(const std::string & filename, const std::
|
||||
if (weWroteData)
|
||||
{
|
||||
// now spit the results out to the file
|
||||
UInt32 numBytes;
|
||||
uint32_t numBytes;
|
||||
char *byteStream = IConvertToByteStream(fileData, numBytes);
|
||||
hsStream *xmlStream = plEncryptedStream::OpenEncryptedFileWrite(filename.c_str());
|
||||
xmlStream->Write(numBytes, byteStream);
|
||||
|
@ -113,7 +113,7 @@ protected:
|
||||
void IConvertSet(LocSetInfo *setInfo, const std::wstring & curPath);
|
||||
void IConvertAge(LocAgeInfo *ageInfo, const std::wstring & curPath);
|
||||
|
||||
char *IConvertToByteStream(const std::wstring & data, UInt32 &len); // converts the wstring data to a string of bytes for file writing
|
||||
char *IConvertToByteStream(const std::wstring & data, uint32_t &len); // converts the wstring data to a string of bytes for file writing
|
||||
void IWriteText(const std::string & filename, const std::wstring & ageName, const std::wstring & languageName); // Write localization text to the specified file
|
||||
|
||||
pfLocalizationDataMgr(const std::string & path);
|
||||
|
@ -131,7 +131,7 @@ void pfLocalizedString::IConvertFromPlainText(const std::wstring & plainText)
|
||||
curTextBlock.fText = L"";
|
||||
|
||||
std::wstring number = plainText.substr(curIndex + 1, (endArgPos - (curIndex + 1)));
|
||||
curTextBlock.fParamIndex = (UInt8)wcstol(number.c_str(), NULL, 10) - 1; // args are 1-based, vectors are 0-based
|
||||
curTextBlock.fParamIndex = (uint8_t)wcstol(number.c_str(), NULL, 10) - 1; // args are 1-based, vectors are 0-based
|
||||
fText.push_back(curTextBlock);
|
||||
|
||||
curTextBlock.fIsParam = false;
|
||||
@ -240,7 +240,7 @@ void pfLocalizedString::IConvertFromXML(const std::wstring & xml)
|
||||
curTextBlock.fText = L"";
|
||||
|
||||
std::wstring number = xml.substr(curIndex + 1, (endArgPos - (curIndex + 1)));
|
||||
curTextBlock.fParamIndex = (UInt8)wcstol(number.c_str(), nil, 10) - 1; // args are 1-based, vectors are 0-based
|
||||
curTextBlock.fParamIndex = (uint8_t)wcstol(number.c_str(), nil, 10) - 1; // args are 1-based, vectors are 0-based
|
||||
fText.push_back(curTextBlock);
|
||||
|
||||
curTextBlock.fIsParam = false;
|
||||
|
@ -67,7 +67,7 @@ protected:
|
||||
{
|
||||
bool fIsParam; // if true, then this is a parameter, not a string
|
||||
std::wstring fText;
|
||||
UInt8 fParamIndex;
|
||||
uint8_t fParamIndex;
|
||||
|
||||
textBlock() : fIsParam(false), fParamIndex(0) {}
|
||||
};
|
||||
@ -75,7 +75,7 @@ protected:
|
||||
std::vector<textBlock> fText; // the individual text elements that make up this string
|
||||
std::wstring fXMLRep; // the XML representation of this string
|
||||
std::wstring fPlainTextRep; // the plain text representation of this string
|
||||
UInt16 fNumArguments; // number of arguments this string has
|
||||
uint16_t fNumArguments; // number of arguments this string has
|
||||
|
||||
void IConvertFromPlainText(const std::wstring & plainText);
|
||||
void IUpdatePlainText(); // from the internal representation
|
||||
@ -91,7 +91,7 @@ public:
|
||||
void FromXML(const std::wstring & xml);
|
||||
std::wstring ToXML() {return fXMLRep;}
|
||||
|
||||
UInt16 GetArgumentCount() {return fNumArguments;}
|
||||
uint16_t GetArgumentCount() {return fNumArguments;}
|
||||
|
||||
// Various operators, they all work pretty much the same as the standard string or wstring operators
|
||||
// but note that the all work on the plain text representation (not the XML representation)
|
||||
|
Reference in New Issue
Block a user