summaryrefslogtreecommitdiff
path: root/modules/core
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-10-27 22:29:34 -0400
committerAdam <Adam@anope.org>2010-10-27 22:29:34 -0400
commita26f119bc8666642a54564763626e52e5c72b030 (patch)
treedbc5a6e06105c4111338d61a8739c4ea9c951e1b /modules/core
parenta79da4bba11ef6fec0ef010a7900c742c2e358ad (diff)
Do not store memo number in memo structs, fixes some bugs with deleting memos
Diffstat (limited to 'modules/core')
-rw-r--r--modules/core/db_plain.cpp8
-rw-r--r--modules/core/ms_cancel.cpp4
-rw-r--r--modules/core/ms_del.cpp26
-rw-r--r--modules/core/ms_list.cpp2
-rw-r--r--modules/core/ms_read.cpp4
5 files changed, 19 insertions, 25 deletions
diff --git a/modules/core/db_plain.cpp b/modules/core/db_plain.cpp
index af342786f..080d4c2ae 100644
--- a/modules/core/db_plain.cpp
+++ b/modules/core/db_plain.cpp
@@ -595,7 +595,7 @@ class DBPlain : public Module
else if (key.equals_ci("MI"))
{
Memo *m = new Memo;
- m->number = params[0].is_pos_number_only() ? convertTo<uint32>(params[0]) : 0;
+ // params[0] is the old number of the memo, no longer used
m->time = params[1].is_pos_number_only() ? convertTo<time_t>(params[1]) : 0;
m->sender = params[2];
for (unsigned j = 3; params[j].equals_ci("UNREAD") || params[j].equals_ci("RECEIPT") || params[j].equals_ci("NOTIFYS"); ++j)
@@ -753,7 +753,7 @@ class DBPlain : public Module
else if (key.equals_ci("MI"))
{
Memo *m = new Memo;
- m->number = params[0].is_pos_number_only() ? convertTo<uint32>(params[0]) : 0;
+ // params[0] is the old number of the memo, no longer used
m->time = params[1].is_pos_number_only() ? convertTo<time_t>(params[1]) : 0;
m->sender = params[2];
for (unsigned j = 3; params[j].equals_ci("UNREAD") || params[j].equals_ci("RECEIPT") || params[j].equals_ci("NOTIFYS"); ++j)
@@ -891,7 +891,7 @@ class DBPlain : public Module
MemoInfo *mi = &nc->memos;
for (unsigned k = 0, end = mi->memos.size(); k < end; ++k)
{
- db << "MD MI " << mi->memos[k]->number << " " << mi->memos[k]->time << " " << mi->memos[k]->sender;
+ db << "MD MI 0 " << mi->memos[k]->time << " " << mi->memos[k]->sender;
if (mi->memos[k]->HasFlag(MF_UNREAD))
db << " UNREAD";
if (mi->memos[k]->HasFlag(MF_RECEIPT))
@@ -1038,7 +1038,7 @@ class DBPlain : public Module
for (unsigned k = 0, end = memos->memos.size(); k < end; ++k)
{
- db << "MD MI " << memos->memos[k]->number << " " << memos->memos[k]->time << " " << memos->memos[k]->sender;
+ db << "MD MI 0 " << memos->memos[k]->time << " " << memos->memos[k]->sender;
if (memos->memos[k]->HasFlag(MF_UNREAD))
db << " UNREAD";
if (memos->memos[k]->HasFlag(MF_RECEIPT))
diff --git a/modules/core/ms_cancel.cpp b/modules/core/ms_cancel.cpp
index a7d824d38..46799a148 100644
--- a/modules/core/ms_cancel.cpp
+++ b/modules/core/ms_cancel.cpp
@@ -42,8 +42,8 @@ class CommandMSCancel : public Command
for (i = mi->memos.size() - 1; i >= 0; --i)
if (mi->memos[i]->HasFlag(MF_UNREAD) && u->Account()->display.equals_ci(mi->memos[i]->sender) && !mi->memos[i]->HasFlag(MF_NOTIFYS))
{
- FOREACH_MOD(I_OnMemoDel, OnMemoDel(findnick(nname)->nc, mi, mi->memos[i]->number));
- delmemo(mi, mi->memos[i]->number);
+ FOREACH_MOD(I_OnMemoDel, OnMemoDel(findnick(nname)->nc, mi, mi->memos[i]));
+ mi->Del(mi->memos[i]);
u->SendMessage(MemoServ, MEMO_CANCELLED, nname.c_str());
return MOD_CONT;
}
diff --git a/modules/core/ms_del.cpp b/modules/core/ms_del.cpp
index 4d9a8ec13..2d69fba5e 100644
--- a/modules/core/ms_del.cpp
+++ b/modules/core/ms_del.cpp
@@ -29,11 +29,12 @@ class MemoDelCallback : public NumberList
return;
if (ci)
- FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, Number - 1));
+ FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->memos[Number - 1]));
else
- FOREACH_MOD(I_OnMemoDel, OnMemoDel(u->Account(), mi, Number - 1));
+ FOREACH_MOD(I_OnMemoDel, OnMemoDel(u->Account(), mi, mi->memos[Number - 1]));
- delmemo(mi, Number - 1);
+ mi->Del(Number - 1);
+ u->SendMessage(MemoServ, MEMO_DELETED_ONE, Number);
}
};
@@ -50,7 +51,6 @@ class CommandMSDel : public Command
ChannelInfo *ci = NULL;
Anope::string numstr = !params.empty() ? params[0] : "", chan;
unsigned i, end;
- int last;
if (!numstr.empty() && numstr[0] == '#')
{
@@ -95,21 +95,19 @@ class CommandMSDel : public Command
else if (numstr.equals_ci("LAST"))
{
/* Delete last memo. */
- for (i = 0, end = mi->memos.size(); i < end; ++i)
- last = mi->memos[i]->number;
if (ci)
- FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, last));
+ FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->memos[mi->memos.size() - 1]));
else
- FOREACH_MOD(I_OnMemoDel, OnMemoDel(u->Account(), mi, last));
- delmemo(mi, last);
- u->SendMessage(MemoServ, MEMO_DELETED_ONE, last);
+ FOREACH_MOD(I_OnMemoDel, OnMemoDel(u->Account(), mi, mi->memos[mi->memos.size() - 1]));
+ mi->Del(mi->memos[mi->memos.size() - 1]);
+ u->SendMessage(MemoServ, MEMO_DELETED_ONE, mi->memos.size() + 1);
}
else
{
if (ci)
- FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, 0));
+ FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, NULL));
else
- FOREACH_MOD(I_OnMemoDel, OnMemoDel(u->Account(), mi, 0));
+ FOREACH_MOD(I_OnMemoDel, OnMemoDel(u->Account(), mi, NULL));
/* Delete all memos. */
for (i = 0, end = mi->memos.size(); i < end; ++i)
delete mi->memos[i];
@@ -119,10 +117,6 @@ class CommandMSDel : public Command
else
u->SendMessage(MemoServ, MEMO_DELETED_ALL);
}
-
- /* Reset the order */
- for (i = 0, end = mi->memos.size(); i < end; ++i)
- mi->memos[i]->number = i + 1;
}
return MOD_CONT;
}
diff --git a/modules/core/ms_list.cpp b/modules/core/ms_list.cpp
index b1df87fa9..f71df75fb 100644
--- a/modules/core/ms_list.cpp
+++ b/modules/core/ms_list.cpp
@@ -46,7 +46,7 @@ class MemoListCallback : public NumberList
static void DoList(User *u, ChannelInfo *ci, const MemoInfo *mi, unsigned index)
{
Memo *m = mi->memos[index];
- u->SendMessage(MemoServ, MEMO_LIST_FORMAT, (m->HasFlag(MF_UNREAD)) ? '*' : ' ', m->number, m->sender.c_str(), do_strftime(m->time).c_str());
+ u->SendMessage(MemoServ, MEMO_LIST_FORMAT, (m->HasFlag(MF_UNREAD)) ? '*' : ' ', index + 1, m->sender.c_str(), do_strftime(m->time).c_str());
}
};
diff --git a/modules/core/ms_read.cpp b/modules/core/ms_read.cpp
index 857fd661c..2f743cb30 100644
--- a/modules/core/ms_read.cpp
+++ b/modules/core/ms_read.cpp
@@ -34,9 +34,9 @@ class MemoListCallback : public NumberList
{
Memo *m = mi->memos[index];
if (ci)
- u->SendMessage(MemoServ, MEMO_CHAN_HEADER, m->number, m->sender.c_str(), do_strftime(m->time).c_str(), Config->s_MemoServ.c_str(), ci->name.c_str(), m->number);
+ u->SendMessage(MemoServ, MEMO_CHAN_HEADER, index + 1, m->sender.c_str(), do_strftime(m->time).c_str(), Config->s_MemoServ.c_str(), ci->name.c_str(), index + 1);
else
- u->SendMessage(MemoServ, MEMO_HEADER, m->number, m->sender.c_str(), do_strftime(m->time).c_str(), Config->s_MemoServ.c_str(), m->number);
+ u->SendMessage(MemoServ, MEMO_HEADER, index + 1, m->sender.c_str(), do_strftime(m->time).c_str(), Config->s_MemoServ.c_str(), index + 1);
u->SendMessage(MemoServ, MEMO_TEXT, m->text.c_str());
m->UnsetFlag(MF_UNREAD);