Commit 6bdff452 authored by Chen Bill's avatar Chen Bill

DataManager: fix FormatAttribute, FormatRace

parent 6a2deaac
......@@ -304,39 +304,31 @@ const wchar_t* DataManager::FormatLocation(int location, int sequence) const {
else
return unknown_string;
}
const wchar_t* DataManager::FormatAttribute(int attribute) {
wchar_t* p = attBuffer;
unsigned filter = 1;
int i = 1010;
for(; filter != 0x80; filter <<= 1, ++i) {
if(attribute & filter) {
BufferIO::CopyWStrRef(GetSysString(i), p, 16);
*p = L'|';
*++p = 0;
std::wstring DataManager::FormatAttribute(unsigned int attribute) const {
std::wstring buffer;
for (int i = 0; i < ATTRIBUTES_COUNT; ++i) {
if (attribute & (0x1U << i)) {
buffer.append(GetSysString(1010 + i));
buffer.push_back(L'|');
}
}
if(p != attBuffer)
*(p - 1) = 0;
else
return unknown_string;
return attBuffer;
if (buffer.empty())
return std::wstring(unknown_string);
buffer.pop_back();
return buffer;
}
const wchar_t* DataManager::FormatRace(int race) {
wchar_t* p = racBuffer;
unsigned filter = 1;
int i = 1020;
for(; filter < (1 << RACES_COUNT); filter <<= 1, ++i) {
if(race & filter) {
BufferIO::CopyWStrRef(GetSysString(i), p, 16);
*p = L'|';
*++p = 0;
std::wstring DataManager::FormatRace(unsigned int race) const {
std::wstring buffer;
for(int i = 0; i < RACES_COUNT; ++i) {
if(race & (0x1U << i)) {
buffer.append(GetSysString(1020 + i));
buffer.push_back(L'|');
}
}
if(p != racBuffer)
*(p - 1) = 0;
else
return unknown_string;
return racBuffer;
if (buffer.empty())
return std::wstring(unknown_string);
buffer.pop_back();
return buffer;
}
const wchar_t* DataManager::FormatType(int type) {
wchar_t* p = tpBuffer;
......
......@@ -33,8 +33,8 @@ public:
std::vector<unsigned int> GetSetCodes(std::wstring setname) const;
const wchar_t* GetNumString(int num, bool bracket = false);
const wchar_t* FormatLocation(int location, int sequence) const;
const wchar_t* FormatAttribute(int attribute);
const wchar_t* FormatRace(int race);
std::wstring FormatAttribute(unsigned int attribute) const;
std::wstring FormatRace(unsigned int race) const;
const wchar_t* FormatType(int type);
const wchar_t* FormatSetName(const uint16_t setcode[]);
const wchar_t* FormatLinkMarker(int link_marker);
......@@ -50,8 +50,6 @@ public:
wchar_t numStrings[301][4]{};
wchar_t numBuffer[6]{};
wchar_t attBuffer[128]{};
wchar_t racBuffer[128]{};
wchar_t tpBuffer[128]{};
wchar_t scBuffer[128]{};
wchar_t lmBuffer[32]{};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment