+ std::string message;
+ VAFORMAT(message, text, text);
+ ClientProtocol::Messages::Privmsg msg(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, ServerInstance->Config->ServerName, message, MSG_NOTICE);
+ ClientProtocol::Event msgevent(ServerInstance->GetRFCEvents().privmsg, msg);
+
+ for (LocalList::const_iterator i = local_users.begin(); i != local_users.end(); ++i)
+ {
+ LocalUser* user = *i;
+ user->Send(msgevent);
+ }
+}
+
+/**
+ * This function is called once a second from the mainloop.
+ * It is intended to do background checking on all the users, e.g. do
+ * ping checks, registration timeouts, etc.
+ */
+void UserManager::DoBackgroundUserStuff()
+{
+ for (LocalList::iterator i = local_users.begin(); i != local_users.end(); )
+ {
+ // It's possible that we quit the user below due to ping timeout etc. and QuitUser() removes it from the list
+ LocalUser* curr = *i;
+ ++i;
+
+ if (curr->CommandFloodPenalty || curr->eh.getSendQSize())
+ {
+ unsigned int rate = curr->MyClass->GetCommandRate();
+ if (curr->CommandFloodPenalty > rate)
+ curr->CommandFloodPenalty -= rate;
+ else
+ curr->CommandFloodPenalty = 0;
+ curr->eh.OnDataReady();
+ }
+
+ switch (curr->registered)
+ {
+ case REG_ALL:
+ CheckPingTimeout(curr);
+ break;
+
+ case REG_NICKUSER:
+ CheckModulesReady(curr);
+ break;
+
+ default:
+ CheckRegistrationTimeout(curr);
+ break;
+ }
+ }
+}
+
+already_sent_t UserManager::NextAlreadySentId()
+{
+ if (++already_sent_id == 0)
+ {
+ // Wrapped around, reset the already_sent ids of all users
+ already_sent_id = 1;
+ for (LocalList::iterator i = local_users.begin(); i != local_users.end(); ++i)
+ {
+ LocalUser* user = *i;
+ user->already_sent = 0;
+ }
+ }
+ return already_sent_id;