mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Return string by copy to fix cases when string is constructed on stack
This commit is contained in:
parent
33a9aa8ee5
commit
7c0d5666a0
@ -136,10 +136,10 @@ void CLobbyScreen::startScenario(bool allowOnlyAI)
|
||||
logGlobal->error("Exception during startScenario: %s", e.what());
|
||||
|
||||
if(std::string(e.what()) == "ExceptionNoHuman")
|
||||
CInfoWindow::showInfoDialog(std::ref(CGI->generaltexth->allTexts[530]), CInfoWindow::TCompsInfo(), PlayerColor(1));
|
||||
CInfoWindow::showInfoDialog(CGI->generaltexth->allTexts[530], CInfoWindow::TCompsInfo(), PlayerColor(1));
|
||||
|
||||
if(std::string(e.what()) == "ExceptionNoTemplate")
|
||||
CInfoWindow::showInfoDialog(std::ref(CGI->generaltexth->allTexts[751]), CInfoWindow::TCompsInfo(), PlayerColor(1));
|
||||
CInfoWindow::showInfoDialog(CGI->generaltexth->allTexts[751], CInfoWindow::TCompsInfo(), PlayerColor(1));
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
@ -205,7 +205,7 @@ static std::function<void()> genCommand(CMenuScreen * menu, std::vector<std::str
|
||||
break;
|
||||
case 4: //exit
|
||||
{
|
||||
return std::bind(CInfoWindow::showYesNoDialog, std::ref(CGI->generaltexth->allTexts[69]), std::vector<std::shared_ptr<CComponent>>(), do_quit, 0, PlayerColor(1));
|
||||
return std::bind(CInfoWindow::showYesNoDialog, CGI->generaltexth->allTexts[69], std::vector<std::shared_ptr<CComponent>>(), do_quit, 0, PlayerColor(1));
|
||||
}
|
||||
break;
|
||||
case 5: //highscores
|
||||
|
@ -132,7 +132,7 @@ CQuestLog::CQuestLog (const std::vector<QuestInfo> & Quests)
|
||||
ok = std::make_shared<CButton>(Point(539, 398), "IOKAY.DEF", CGI->generaltexth->zelp[445], std::bind(&CQuestLog::close, this), SDLK_RETURN);
|
||||
// Both button and lable are shifted to -2px by x and y to not make them actually look like they're on same line with quests list and ok button
|
||||
hideCompleteButton = std::make_shared<CToggleButton>(Point(10, 396), "sysopchk.def", CButton::tooltipLocalized("vcmi.questLog.hideComplete"), std::bind(&CQuestLog::toggleComplete, this, _1));
|
||||
hideCompleteLabel = std::make_shared<CLabel>(46, 398, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->translate("vcmi.questLog.hideComplete.label"));
|
||||
hideCompleteLabel = std::make_shared<CLabel>(46, 398, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->translate("vcmi.questLog.hideComplete.hover"));
|
||||
slider = std::make_shared<CSlider>(Point(166, 195), 191, std::bind(&CQuestLog::sliderMoved, this, _1), QUEST_COUNT, 0, false, CSlider::BROWN);
|
||||
|
||||
recreateLabelList();
|
||||
|
@ -454,7 +454,7 @@ CSystemOptionsWindow::CSystemOptionsWindow()
|
||||
leftGroup->add(122, 64, CGI->generaltexth->allTexts[569]);
|
||||
leftGroup->add(122, 130, CGI->generaltexth->allTexts[570]);
|
||||
leftGroup->add(122, 196, CGI->generaltexth->allTexts[571]);
|
||||
leftGroup->add(122, 262, CGI->generaltexth->translate("vcmi.systemOptions.resolutionButton.label"));
|
||||
leftGroup->add(122, 262, CGI->generaltexth->translate("vcmi.systemOptions.resolutionButton.hover"));
|
||||
leftGroup->add(122, 347, CGI->generaltexth->allTexts[394]);
|
||||
leftGroup->add(122, 412, CGI->generaltexth->allTexts[395]);
|
||||
|
||||
@ -464,8 +464,8 @@ CSystemOptionsWindow::CSystemOptionsWindow()
|
||||
rightGroup->add(282, 89, CGI->generaltexth->allTexts[573]);
|
||||
rightGroup->add(282, 121, CGI->generaltexth->allTexts[574]);
|
||||
rightGroup->add(282, 153, CGI->generaltexth->allTexts[577]);
|
||||
//rightGroup->add(282, 185, CGI->generaltexth->translate("vcmi.systemOptions.creatureWindowButton.label"));
|
||||
rightGroup->add(282, 217, CGI->generaltexth->translate("vcmi.systemOptions.fullscreenButton.label"));
|
||||
//rightGroup->add(282, 185, CGI->generaltexth->translate("vcmi.systemOptions.creatureWindowButton.hover"));
|
||||
rightGroup->add(282, 217, CGI->generaltexth->translate("vcmi.systemOptions.fullscreenButton.hover"));
|
||||
|
||||
//setting up buttons
|
||||
load = std::make_shared<CButton>(Point(246, 298), "SOLOAD.DEF", CGI->generaltexth->zelp[321], [&](){ bloadf(); }, SDLK_l);
|
||||
@ -583,7 +583,7 @@ void CSystemOptionsWindow::selectGameRes()
|
||||
}
|
||||
|
||||
GH.pushIntT<CObjectListWindow>(items, nullptr,
|
||||
CGI->generaltexth->translate("vcmi.systemOptions.resolutionMenu.label"),
|
||||
CGI->generaltexth->translate("vcmi.systemOptions.resolutionMenu.hover"),
|
||||
CGI->generaltexth->translate("vcmi.systemOptions.resolutionMenu.help"),
|
||||
std::bind(&CSystemOptionsWindow::setGameRes, this, _1),
|
||||
currentResolutionIndex);
|
||||
|
@ -139,7 +139,7 @@ void MetaString::getLocalString(const std::pair<ui8,ui32> &txt, std::string &dst
|
||||
switch(type)
|
||||
{
|
||||
case GENERAL_TXT:
|
||||
dst = VLC->generaltexth->translate("core.allTexts", ser);
|
||||
dst = VLC->generaltexth->translate("core.genrltxt", ser);
|
||||
break;
|
||||
case XTRAINFO_TXT:
|
||||
dst = VLC->generaltexth->translate("core.xtrainfo", ser);
|
||||
|
@ -603,7 +603,7 @@ LegacyTextContainer::LegacyTextContainer(CGeneralTextHandler & owner, std::strin
|
||||
basePath(basePath)
|
||||
{}
|
||||
|
||||
const std::string & LegacyTextContainer::operator[](size_t index) const
|
||||
std::string LegacyTextContainer::operator[](size_t index) const
|
||||
{
|
||||
return owner.translate(basePath, index);
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class DLL_LINKAGE LegacyTextContainer
|
||||
|
||||
public:
|
||||
LegacyTextContainer(CGeneralTextHandler & owner, std::string const & basePath);
|
||||
const std::string & operator[](size_t index) const;
|
||||
std::string operator [](size_t index) const;
|
||||
};
|
||||
|
||||
/// Small wrapper that provides help text access API compatible with old code
|
||||
@ -166,7 +166,7 @@ public:
|
||||
|
||||
/// returns translated version of a string that can be displayed to user
|
||||
template<typename ... Args>
|
||||
const std::string & translate(std::string arg1, Args ... args) const
|
||||
std::string translate(std::string arg1, Args ... args) const
|
||||
{
|
||||
TextIdentifier id(arg1, args ...);
|
||||
return deserialize(id);
|
||||
|
@ -24,7 +24,7 @@
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
///helpers
|
||||
static const std::string & visitedTxt(const bool visited)
|
||||
static std::string visitedTxt(const bool visited)
|
||||
{
|
||||
int id = visited ? 352 : 353;
|
||||
return VLC->generaltexth->allTexts[id];
|
||||
|
@ -56,7 +56,7 @@ static void showInfoDialog(const CGHeroInstance* h, const ui32 txtID, const ui16
|
||||
showInfoDialog(playerID,txtID,soundID);
|
||||
}
|
||||
|
||||
static const std::string & visitedTxt(const bool visited)
|
||||
static std::string visitedTxt(const bool visited)
|
||||
{
|
||||
int id = visited ? 352 : 353;
|
||||
return VLC->generaltexth->allTexts[id];
|
||||
|
@ -402,7 +402,7 @@ Component CRewardInfo::getDisplayedComponent(const CGHeroInstance * h) const
|
||||
}
|
||||
|
||||
// FIXME: copy-pasted from CObjectHandler
|
||||
static const std::string & visitedTxt(const bool visited)
|
||||
static std::string visitedTxt(const bool visited)
|
||||
{
|
||||
int id = visited ? 352 : 353;
|
||||
return VLC->generaltexth->allTexts[id];
|
||||
|
@ -58,7 +58,7 @@ static void showInfoDialog(const CGHeroInstance* h, const ui32 txtID, const ui16
|
||||
showInfoDialog(playerID,txtID,soundID);
|
||||
}
|
||||
|
||||
static const std::string & visitedTxt(const bool visited)
|
||||
static std::string visitedTxt(const bool visited)
|
||||
{
|
||||
int id = visited ? 352 : 353;
|
||||
return VLC->generaltexth->allTexts[id];
|
||||
|
Loading…
Reference in New Issue
Block a user