mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Replace instances of std::map<std::string, std::string> with StringMap
Also, clean up surrounding code style Replace by-value parameter passing with const refs when possible Fix post-increment of iterators
This commit is contained in:
parent
603297cc35
commit
da34a2b33e
25 changed files with 180 additions and 193 deletions
26
src/game.cpp
26
src/game.cpp
|
@ -87,11 +87,11 @@ struct TextDestNodeMetadata : public TextDest {
|
|||
std::string ntext = wide_to_narrow(text);
|
||||
infostream << "Submitting 'text' field of node at (" << m_p.X << ","
|
||||
<< m_p.Y << "," << m_p.Z << "): " << ntext << std::endl;
|
||||
std::map<std::string, std::string> fields;
|
||||
StringMap fields;
|
||||
fields["text"] = ntext;
|
||||
m_client->sendNodemetaFields(m_p, "", fields);
|
||||
}
|
||||
void gotText(std::map<std::string, std::string> fields)
|
||||
void gotText(const StringMap &fields)
|
||||
{
|
||||
m_client->sendNodemetaFields(m_p, "", fields);
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ struct TextDestPlayerInventory : public TextDest {
|
|||
m_client = client;
|
||||
m_formname = formname;
|
||||
}
|
||||
void gotText(std::map<std::string, std::string> fields)
|
||||
void gotText(const StringMap &fields)
|
||||
{
|
||||
m_client->sendInventoryFields(m_formname, fields);
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ struct LocalFormspecHandler : public TextDest {
|
|||
errorstream << "LocalFormspecHandler::gotText old style message received" << std::endl;
|
||||
}
|
||||
|
||||
void gotText(std::map<std::string, std::string> fields)
|
||||
void gotText(const StringMap &fields)
|
||||
{
|
||||
if (m_formname == "MT_PAUSE_MENU") {
|
||||
if (fields.find("btn_sound") != fields.end()) {
|
||||
|
@ -180,9 +180,9 @@ struct LocalFormspecHandler : public TextDest {
|
|||
|
||||
if ((fields.find("btn_send") != fields.end()) ||
|
||||
(fields.find("quit") != fields.end())) {
|
||||
if (fields.find("f_text") != fields.end()) {
|
||||
m_client->typeChatMessage(narrow_to_wide(fields["f_text"]));
|
||||
}
|
||||
StringMap::const_iterator it = fields.find("f_text");
|
||||
if (it != fields.end())
|
||||
m_client->typeChatMessage(narrow_to_wide(it->second));
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -210,12 +210,14 @@ struct LocalFormspecHandler : public TextDest {
|
|||
return;
|
||||
}
|
||||
|
||||
errorstream << "LocalFormspecHandler::gotText unhandled >" << m_formname << "< event" << std::endl;
|
||||
int i = 0;
|
||||
errorstream << "LocalFormspecHandler::gotText unhandled >"
|
||||
<< m_formname << "< event" << std::endl;
|
||||
|
||||
for (std::map<std::string, std::string>::iterator iter = fields.begin();
|
||||
iter != fields.end(); iter++) {
|
||||
errorstream << "\t" << i << ": " << iter->first << "=" << iter->second << std::endl;
|
||||
int i = 0;
|
||||
StringMap::const_iterator it;
|
||||
for (it = fields.begin(); it != fields.end(); ++it) {
|
||||
errorstream << "\t" << i << ": " << it->first
|
||||
<< "=" << it->second << std::endl;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue