From e60736583e6b2b99a7024fb9e4930fa586dabd9a Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 11 Sep 2023 09:18:43 +0100 Subject: Make the permchannels database easier to read. Adding the extra keys for list modes made the database a lot harder to read because of the extra line length. To work around this put each key on its own line and indent them to the same level. --- src/modules/m_permchannels.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/modules/m_permchannels.cpp') diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp index 9dc1c829f..62c89ecce 100644 --- a/src/modules/m_permchannels.cpp +++ b/src/modules/m_permchannels.cpp @@ -89,6 +89,7 @@ static bool WriteDatabase(PermChannel& permchanmode, bool save_listmodes, unsign << "# Any changes to this file will be automatically overwritten." << std::endl << std::endl; + const static std::string indent(14, ' '); for (const auto& [_, chan] : ServerInstance->Channels.GetChans()) { if (!chan->IsModeSet(permchanmode)) @@ -136,15 +137,15 @@ static bool WriteDatabase(PermChannel& permchanmode, bool save_listmodes, unsign } } - stream << "name) - << "\" ts=\"" << chan->age; + stream << "name) << "\"" << std::endl + << indent << "ts=\"" << chan->age << "\"" << std::endl; if (!chan->topic.empty()) { // Only store the topic if one is set. - stream << "\" topic=\"" << ServerConfig::Escape(chan->topic) - << "\" topicts=\"" << chan->topicset - << "\" topicsetby=\"" << ServerConfig::Escape(chan->setby); + stream << indent << "topic=\"" << ServerConfig::Escape(chan->topic) << "\"" << std::endl + << indent << "topicts=\"" << chan->topicset << "\"" << std::endl + << indent << "topicsetby=\"" << ServerConfig::Escape(chan->setby) << "\"" << std::endl; } if (save_listmodes && writeversion >= 2) @@ -155,18 +156,18 @@ static bool WriteDatabase(PermChannel& permchanmode, bool save_listmodes, unsign if (!list || list->empty()) continue; - stream << "\" " << lm->name << "list=\""; + stream << indent << lm->name << "list=\""; for (auto entry = list->begin(); entry != list->end(); ++entry) { if (entry != list->begin()) stream << ' '; stream << entry->mask << ' ' << entry->setter << ' ' << entry->time; } + stream << "\"" << std::endl; } } - stream << "\" modes=\"" << ServerConfig::Escape(chanmodes) - << "\">" << std::endl; + stream << indent << "modes=\"" << ServerConfig::Escape(chanmodes) << "\">" << std::endl; } if (stream.fail()) -- cgit v1.3.1-10-gc9f91