From 45e265b0f5af1ace1ca7f214cb35f64864b1b1be Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Sun, 17 Jun 2012 17:48:18 +0200 Subject: m_chanhistory Keep history when changing parameters --- src/modules/m_chanhistory.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp index ac6d80bad..482d526eb 100644 --- a/src/modules/m_chanhistory.cpp +++ b/src/modules/m_chanhistory.cpp @@ -79,7 +79,21 @@ class HistoryMode : public ModeHandler len = maxlines; if (parameter == channel->GetModeParameter(this)) return MODEACTION_DENY; - ext.set(channel, new HistoryList(len, time)); + + HistoryList* history = ext.get(channel); + if (history) + { + // Shrink the list if the new line number limit is lower than the old one + if (len < history->lines.size()) + history->lines.erase(history->lines.begin(), history->lines.begin() + (history->lines.size() - len)); + + history->maxlen = len; + history->maxtime = time; + } + else + { + ext.set(channel, new HistoryList(len, time)); + } channel->SetModeParam('H', parameter); } else -- cgit v1.2.3