Browse Source

Remove AppendStrView

pull/6464/head
Gleb Mazovetskiy 3 years ago
parent
commit
e9b5ec77f9
  1. 10
      Source/DiabloUI/multi/selgame.cpp
  2. 10
      Source/debug.cpp
  3. 12
      Source/monster.cpp
  4. 16
      Source/stores.cpp
  5. 2
      Source/utils/format_int.cpp
  6. 2
      Source/utils/language.cpp
  7. 5
      Source/utils/stdcompat/string_view.hpp
  8. 4
      Source/utils/str_cat.hpp

10
Source/DiabloUI/multi/selgame.cpp

@ -244,16 +244,16 @@ void selgame_GameSelection_Focus(int value)
infoString += '\n';
switch (gameInfo.gameData.nTickRate) {
case 20:
AppendStrView(infoString, _("Speed: Normal"));
infoString.append(_("Speed: Normal"));
break;
case 30:
AppendStrView(infoString, _("Speed: Fast"));
infoString.append(_("Speed: Fast"));
break;
case 40:
AppendStrView(infoString, _("Speed: Faster"));
infoString.append(_("Speed: Faster"));
break;
case 50:
AppendStrView(infoString, _("Speed: Fastest"));
infoString.append(_("Speed: Fastest"));
break;
default:
// This should not occure, so no translations is needed
@ -261,7 +261,7 @@ void selgame_GameSelection_Focus(int value)
break;
}
infoString += '\n';
AppendStrView(infoString, _("Players: "));
infoString.append(_("Players: "));
for (auto &playerName : gameInfo.players) {
infoString.append(playerName);
infoString += ' ';

10
Source/debug.cpp

@ -706,7 +706,7 @@ std::string DebugCmdSpawnUniqueMonster(const string_view parameter)
count = num;
break;
}
AppendStrView(name, arg);
name.append(arg);
name += ' ';
}
if (name.empty())
@ -796,7 +796,7 @@ std::string DebugCmdSpawnMonster(const string_view parameter)
count = num;
break;
}
AppendStrView(name, arg);
name.append(arg);
name += ' ';
}
if (name.empty())
@ -1044,7 +1044,7 @@ std::string DebugCmdSearchMonster(const string_view parameter)
}
std::string name;
AppendStrView(name, parameter);
name.append(parameter);
AsciiStrToLower(name);
SearchMonsters.push_back(name);
@ -1059,7 +1059,7 @@ std::string DebugCmdSearchItem(const string_view parameter)
}
std::string name;
AppendStrView(name, parameter);
name.append(parameter);
AsciiStrToLower(name);
SearchItems.push_back(name);
@ -1074,7 +1074,7 @@ std::string DebugCmdSearchObject(const string_view parameter)
}
std::string name;
AppendStrView(name, parameter);
name.append(parameter);
AsciiStrToLower(name);
SearchObjects.push_back(name);

12
Source/monster.cpp

@ -4283,21 +4283,21 @@ void PrintMonstHistory(int mt)
if ((res & (RESIST_MAGIC | RESIST_FIRE | RESIST_LIGHTNING)) != 0) {
std::string resists = std::string(_("Resists:"));
if ((res & RESIST_MAGIC) != 0)
AppendStrView(resists, _(" Magic"));
resists.append(_(" Magic"));
if ((res & RESIST_FIRE) != 0)
AppendStrView(resists, _(" Fire"));
resists.append(_(" Fire"));
if ((res & RESIST_LIGHTNING) != 0)
AppendStrView(resists, _(" Lightning"));
resists.append(_(" Lightning"));
AddPanelString(resists);
}
if ((res & (IMMUNE_MAGIC | IMMUNE_FIRE | IMMUNE_LIGHTNING)) != 0) {
std::string immune = std::string(_("Immune:"));
if ((res & IMMUNE_MAGIC) != 0)
AppendStrView(immune, _(" Magic"));
immune.append(_(" Magic"));
if ((res & IMMUNE_FIRE) != 0)
AppendStrView(immune, _(" Fire"));
immune.append(_(" Fire"));
if ((res & IMMUNE_LIGHTNING) != 0)
AppendStrView(immune, _(" Lightning"));
immune.append(_(" Lightning"));
AddPanelString(immune);
}
}

16
Source/stores.cpp

@ -250,7 +250,7 @@ void AddSText(uint8_t x, size_t y, string_view text, UiFlags flags, bool sel, in
stext[y]._sx = x;
stext[y]._syoff = 0;
stext[y].text.clear();
AppendStrView(stext[y].text, text);
stext[y].text.append(text);
stext[y].flags = flags;
stext[y].type = sel ? STextStruct::Selectable : STextStruct::Label;
stext[y].cursId = cursId;
@ -284,18 +284,18 @@ void PrintStoreItem(const Item &item, int l, UiFlags flags, bool cursIndent = fa
if (item._iIdentified) {
if (item._iMagical != ITEM_QUALITY_UNIQUE) {
if (item._iPrePower != -1) {
AppendStrView(productLine, PrintItemPower(item._iPrePower, item));
productLine.append(PrintItemPower(item._iPrePower, item));
}
}
if (item._iSufPower != -1) {
if (!productLine.empty())
AppendStrView(productLine, _(", "));
AppendStrView(productLine, PrintItemPower(item._iSufPower, item));
productLine.append(_(", "));
productLine.append(PrintItemPower(item._iSufPower, item));
}
}
if (item._iMiscId == IMISC_STAFF && item._iMaxCharges != 0) {
if (!productLine.empty())
AppendStrView(productLine, _(", "));
productLine.append(_(", "));
productLine.append(fmt::format(fmt::runtime(_("Charges: {:d}/{:d}")), item._iCharges, item._iMaxCharges));
}
if (!productLine.empty()) {
@ -312,7 +312,7 @@ void PrintStoreItem(const Item &item, int l, UiFlags flags, bool cursIndent = fa
if (item._iMaxDur != DUR_INDESTRUCTIBLE && item._iMaxDur != 0)
productLine += fmt::format(fmt::runtime(_("Dur: {:d}/{:d}, ")), item._iDurability, item._iMaxDur);
else
AppendStrView(productLine, _("Indestructible, "));
productLine.append(_("Indestructible, "));
}
int8_t str = item._iMinStr;
@ -320,9 +320,9 @@ void PrintStoreItem(const Item &item, int l, UiFlags flags, bool cursIndent = fa
int8_t dex = item._iMinDex;
if (str == 0 && mag == 0 && dex == 0) {
AppendStrView(productLine, _("No required attributes"));
productLine.append(_("No required attributes"));
} else {
AppendStrView(productLine, _("Required:"));
productLine.append(_("Required:"));
if (str != 0)
productLine.append(fmt::format(fmt::runtime(_(" {:d} Str")), str));
if (mag != 0)

2
Source/utils/format_int.cpp

@ -36,7 +36,7 @@ std::string FormatInteger(int n)
out.append(begin, mlen);
begin += mlen;
for (; begin != end; begin += GroupSize) {
AppendStrView(out, separator);
out.append(separator);
out.append(begin, GroupSize);
}

2
Source/utils/language.cpp

@ -297,7 +297,7 @@ string_view LanguageParticularTranslate(string_view context, string_view message
std::string key = std::string(context);
key.reserve(key.size() + 1 + message.size());
key += Glue;
AppendStrView(key, message);
key.append(message);
auto it = translation[0].find(key.c_str());
if (it == translation[0].end()) {

5
Source/utils/stdcompat/string_view.hpp

@ -4,9 +4,4 @@
#include <string_view> // IWYU pragma: export
namespace devilution {
using ::std::string_view;
inline void AppendStrView(std::string &out, string_view str)
{
out.append(str);
}
} // namespace devilution

4
Source/utils/str_cat.hpp

@ -33,7 +33,7 @@ inline char *BufCopy(char *out, string_view value)
*/
inline void StrAppend(std::string &out, string_view value)
{
AppendStrView(out, value);
out.append(value);
}
/**
@ -51,7 +51,7 @@ inline char *BufCopy(char *out, const char *str)
*/
inline void StrAppend(std::string &out, const char *str)
{
AppendStrView(out, string_view(str != nullptr ? str : "(nullptr)"));
out.append(string_view(str != nullptr ? str : "(nullptr)"));
}
template <typename... Args>

Loading…
Cancel
Save