diff options
author | Adam <Adam@anope.org> | 2015-11-04 20:03:26 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2015-11-04 20:05:01 -0500 |
commit | 80c332bc410cf08b9bef8995fe00441c6e736baa (patch) | |
tree | 2d7773e89c6b2b9b8e389ae72f98f8f6b13ca131 /modules/commands/os_news.cpp | |
parent | 27a2645ed3a44cad9435a5315078bfd35d1c793f (diff) |
Fix logonnews to prioritize the newest entries if it can't show them all
Diffstat (limited to 'modules/commands/os_news.cpp')
-rw-r--r-- | modules/commands/os_news.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/modules/commands/os_news.cpp b/modules/commands/os_news.cpp index b74ca3b57..a0dc13407 100644 --- a/modules/commands/os_news.cpp +++ b/modules/commands/os_news.cpp @@ -403,23 +403,27 @@ class OSNews : public Module else if (Type == NEWS_RANDOM) msg = _("[\002Random News\002 - %s] %s"); - unsigned displayed = 0; - for (unsigned i = 0, end = newsList.size(); i < end; ++i) + int start = 0; + + if (type != NEWS_RANDOM) + { + start = newsList.size() - news_count; + if (start < 0) + start = 0; + } + + for (unsigned i = start, end = newsList.size(); i < end; ++i) { if (Type == NEWS_RANDOM && i != cur_rand_news) continue; u->SendMessage(bi, msg.c_str(), Anope::strftime(newsList[i]->time, u->Account(), true).c_str(), newsList[i]->text.c_str()); - ++displayed; - if (Type == NEWS_RANDOM) { ++cur_rand_news; break; } - else if (displayed >= news_count) - break; } /* Reset to head of list to get first random news value */ |