summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2012-06-17 17:48:18 +0200
committerattilamolnar <attilamolnar@hush.com>2012-06-17 17:51:08 +0200
commit45e265b0f5af1ace1ca7f214cb35f64864b1b1be (patch)
treed86e2f4b5b506d4bf177e8e5df1d7d3fa64f1ec3 /src/modules
parent5eb361b215d99f25a586f7fd71158e22ea410355 (diff)
m_chanhistory Keep history when changing parameters
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_chanhistory.cpp16
1 files changed, 15 insertions, 1 deletions
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