*/
LocalList local_users;
+ /** Last used already sent id, used when sending messages to neighbors to help determine whether the message has
+ * been sent to a particular user or not. See User::ForEachNeighbor() for more info.
+ */
+ already_sent_t already_sent_id;
+
public:
/** Constructor, initializes variables
*/
*/
unsigned int CommandFloodPenalty;
- static already_sent_t already_sent_id;
already_sent_t already_sent;
/** Check if the user matches a G or K line, and disconnect them if they do.
}
UserManager::UserManager()
- : unregistered_count(0)
+ : already_sent_id(0)
+ , unregistered_count(0)
{
}
void UserManager::GarbageCollect()
{
// Reset the already_sent IDs so we don't wrap it around and drop a message
- LocalUser::already_sent_id = 0;
for (LocalList::const_iterator i = local_users.begin(); i != local_users.end(); ++i)
(**i).already_sent = 0;
}
already_sent_t UserManager::NextAlreadySentId()
{
- return ++LocalUser::already_sent_id;
+ 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;
}