Commit d552e276 authored by Chen Bill's avatar Chen Bill Committed by GitHub

Use const references for formatting (#2923)

parent a5ce265b
...@@ -1307,8 +1307,8 @@ void Game::DrawDeckBd() { ...@@ -1307,8 +1307,8 @@ void Game::DrawDeckBd() {
else else
myswprintf(adBuffer, L"%d/-", ptr->second.attack); myswprintf(adBuffer, L"%d/-", ptr->second.attack);
} }
auto attribute = dataManager.FormatAttribute(ptr->second.attribute); const auto& attribute = dataManager.FormatAttribute(ptr->second.attribute);
auto race = dataManager.FormatRace(ptr->second.race); const auto& race = dataManager.FormatRace(ptr->second.race);
myswprintf(textBuffer, L"%ls/%ls %ls%d", attribute.c_str(), race.c_str(), form, ptr->second.level); myswprintf(textBuffer, L"%ls/%ls %ls%d", attribute.c_str(), race.c_str(), form, ptr->second.level);
DrawShadowText(textFont, textBuffer, Resize(860, 187 + i * 66, 955, 207 + i * 66), Resize(1, 1, 0, 0)); DrawShadowText(textFont, textBuffer, Resize(860, 187 + i * 66, 955, 207 + i * 66), Resize(1, 1, 0, 0));
if(ptr->second.type & TYPE_PENDULUM) { if(ptr->second.type & TYPE_PENDULUM) {
...@@ -1319,7 +1319,7 @@ void Game::DrawDeckBd() { ...@@ -1319,7 +1319,7 @@ void Game::DrawDeckBd() {
} else { } else {
myswprintf(textBuffer, L"%ls", dataManager.GetName(ptr->first)); myswprintf(textBuffer, L"%ls", dataManager.GetName(ptr->first));
DrawShadowText(textFont, textBuffer, Resize(860, 165 + i * 66, 955, 185 + i * 66), Resize(1, 1, 0, 0)); DrawShadowText(textFont, textBuffer, Resize(860, 165 + i * 66, 955, 185 + i * 66), Resize(1, 1, 0, 0));
auto type = dataManager.FormatType(ptr->second.type); const auto& type = dataManager.FormatType(ptr->second.type);
myswprintf(textBuffer, L"%ls", type.c_str()); myswprintf(textBuffer, L"%ls", type.c_str());
DrawShadowText(textFont, textBuffer, Resize(860, 187 + i * 66, 955, 207 + i * 66), Resize(1, 1, 0, 0)); DrawShadowText(textFont, textBuffer, Resize(860, 187 + i * 66, 955, 207 + i * 66), Resize(1, 1, 0, 0));
myswprintf(textBuffer, L"%ls", availBuffer); myswprintf(textBuffer, L"%ls", availBuffer);
......
...@@ -1116,7 +1116,7 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) { ...@@ -1116,7 +1116,7 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
break; break;
} }
case HINT_RACE: { case HINT_RACE: {
auto race = dataManager.FormatRace(data); const auto& race = dataManager.FormatRace(data);
myswprintf(textBuffer, dataManager.GetSysString(1511), race.c_str()); myswprintf(textBuffer, dataManager.GetSysString(1511), race.c_str());
mainGame->AddLog(textBuffer); mainGame->AddLog(textBuffer);
mainGame->gMutex.lock(); mainGame->gMutex.lock();
...@@ -1127,7 +1127,7 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) { ...@@ -1127,7 +1127,7 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
break; break;
} }
case HINT_ATTRIB: { case HINT_ATTRIB: {
auto attribute = dataManager.FormatAttribute(data); const auto& attribute = dataManager.FormatAttribute(data);
myswprintf(textBuffer, dataManager.GetSysString(1511), attribute.c_str()); myswprintf(textBuffer, dataManager.GetSysString(1511), attribute.c_str());
mainGame->AddLog(textBuffer); mainGame->AddLog(textBuffer);
mainGame->gMutex.lock(); mainGame->gMutex.lock();
......
...@@ -1597,8 +1597,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1597,8 +1597,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
myswprintf(formatBuffer, L"\nLINK-%d", mcard->link); myswprintf(formatBuffer, L"\nLINK-%d", mcard->link);
str.append(formatBuffer); str.append(formatBuffer);
} }
auto race = dataManager.FormatRace(mcard->race); const auto& race = dataManager.FormatRace(mcard->race);
auto attribute = dataManager.FormatAttribute(mcard->attribute); const auto& attribute = dataManager.FormatAttribute(mcard->attribute);
myswprintf(formatBuffer, L" %ls/%ls", race.c_str(), attribute.c_str()); myswprintf(formatBuffer, L" %ls/%ls", race.c_str(), attribute.c_str());
str.append(formatBuffer); str.append(formatBuffer);
if(mcard->location == LOCATION_HAND && (mcard->type & TYPE_PENDULUM)) { if(mcard->location == LOCATION_HAND && (mcard->type & TYPE_PENDULUM)) {
...@@ -1625,11 +1625,11 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1625,11 +1625,11 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
else if(mcard->cHint == CHINT_CARD) else if(mcard->cHint == CHINT_CARD)
myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(212), dataManager.GetName(mcard->chValue)); myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(212), dataManager.GetName(mcard->chValue));
else if(mcard->cHint == CHINT_RACE) { else if(mcard->cHint == CHINT_RACE) {
auto race = dataManager.FormatRace(mcard->chValue); const auto& race = dataManager.FormatRace(mcard->chValue);
myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(213), race.c_str()); myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(213), race.c_str());
} }
else if(mcard->cHint == CHINT_ATTRIBUTE) { else if(mcard->cHint == CHINT_ATTRIBUTE) {
auto attribute = dataManager.FormatAttribute(mcard->chValue); const auto& attribute = dataManager.FormatAttribute(mcard->chValue);
myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(214), attribute.c_str()); myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(214), attribute.c_str());
} }
else if(mcard->cHint == CHINT_NUMBER) else if(mcard->cHint == CHINT_NUMBER)
......
...@@ -1564,7 +1564,7 @@ void Game::ShowCardInfo(int code, bool resize) { ...@@ -1564,7 +1564,7 @@ void Game::ShowCardInfo(int code, bool resize) {
} }
if (target->second.setcode[0]) { if (target->second.setcode[0]) {
offset = 23;// *yScale; offset = 23;// *yScale;
auto setname = dataManager.FormatSetName(target->second.setcode); const auto& setname = dataManager.FormatSetName(target->second.setcode);
myswprintf(formatBuffer, L"%ls%ls", dataManager.GetSysString(1329), setname.c_str()); myswprintf(formatBuffer, L"%ls%ls", dataManager.GetSysString(1329), setname.c_str());
stSetName->setText(formatBuffer); stSetName->setText(formatBuffer);
} }
...@@ -1576,9 +1576,9 @@ void Game::ShowCardInfo(int code, bool resize) { ...@@ -1576,9 +1576,9 @@ void Game::ShowCardInfo(int code, bool resize) {
} }
if(is_valid && cit->second.type & TYPE_MONSTER) { if(is_valid && cit->second.type & TYPE_MONSTER) {
auto& cd = cit->second; auto& cd = cit->second;
auto type = dataManager.FormatType(cd.type); const auto& type = dataManager.FormatType(cd.type);
auto race = dataManager.FormatRace(cd.race); const auto& race = dataManager.FormatRace(cd.race);
auto attribute = dataManager.FormatAttribute(cd.attribute); const auto& attribute = dataManager.FormatAttribute(cd.attribute);
myswprintf(formatBuffer, L"[%ls] %ls/%ls", type.c_str(), race.c_str(), attribute.c_str()); myswprintf(formatBuffer, L"[%ls] %ls/%ls", type.c_str(), race.c_str(), attribute.c_str());
stInfo->setText(formatBuffer); stInfo->setText(formatBuffer);
int offset_info = 0; int offset_info = 0;
...@@ -1601,7 +1601,7 @@ void Game::ShowCardInfo(int code, bool resize) { ...@@ -1601,7 +1601,7 @@ void Game::ShowCardInfo(int code, bool resize) {
myswprintf(adBuffer, L"%d/%d", cd.attack, cd.defense); myswprintf(adBuffer, L"%d/%d", cd.attack, cd.defense);
} else { } else {
form = L"LINK-"; form = L"LINK-";
auto link_marker = dataManager.FormatLinkMarker(cd.link_marker); const auto& link_marker = dataManager.FormatLinkMarker(cd.link_marker);
if(cd.attack < 0) if(cd.attack < 0)
myswprintf(adBuffer, L"?/- %ls", link_marker.c_str()); myswprintf(adBuffer, L"?/- %ls", link_marker.c_str());
else else
...@@ -1624,7 +1624,7 @@ void Game::ShowCardInfo(int code, bool resize) { ...@@ -1624,7 +1624,7 @@ void Game::ShowCardInfo(int code, bool resize) {
} }
else { else {
if (is_valid) { if (is_valid) {
auto type = dataManager.FormatType(cit->second.type); const auto& type = dataManager.FormatType(cit->second.type);
myswprintf(formatBuffer, L"[%ls]", type.c_str()); myswprintf(formatBuffer, L"[%ls]", type.c_str());
} }
else else
......
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