diff --git a/doc/tgchange.txt b/doc/tgchange.txt index 0669d67..50e648e 100644 --- a/doc/tgchange.txt +++ b/doc/tgchange.txt @@ -11,8 +11,8 @@ yourself. You will have a set number of 'slots', each different client you message will take up one slot. A client doing a nick change will not use a new slot, -however a client leaving the network and reconnecting will. You will -receive 1 new slot roughly every minute. +however a client disconnecting from the server it is on and reconnecting +will. You will receive 1 new slot roughly every minute. When all slots are filled, messages to new clients will not be accepted. Messages to clients already filling a slot will be accepted. If all slots diff --git a/include/client.h b/include/client.h index a2d2a14..2d17c60 100644 --- a/include/client.h +++ b/include/client.h @@ -290,7 +290,7 @@ struct LocalUser auth_request_t *auth_request; /* target change stuff */ - void *targets[10]; /* targets were aware of */ + uint32_t targets[10]; /* targets were aware of (fnv32(use_id(target_p))) */ unsigned int targinfo[2]; /* cyclic array, no in use */ time_t target_last; /* last time we cleared a slot */ diff --git a/modules/core/m_message.c b/modules/core/m_message.c index 21c93af..8f6e7eb 100644 --- a/modules/core/m_message.c +++ b/modules/core/m_message.c @@ -566,6 +566,7 @@ static int add_target(struct Client *source_p, struct Client *target_p) { int i, j; + uint32_t hashv; /* can msg themselves or services without using any target slots */ if(source_p == target_p || IsService(target_p)) @@ -579,13 +580,15 @@ add_target(struct Client *source_p, struct Client *target_p) if(source_p->localClient->target_last > CurrentTime && IsOper(target_p)) return 1; + hashv = fnv_hash_upper(use_id(target_p), 32); + if(USED_TARGETS(source_p)) { /* hunt for an existing target */ for(i = PREV_FREE_TARGET(source_p), j = USED_TARGETS(source_p); j; --j, PREV_TARGET(i)) { - if(source_p->localClient->targets[i] == target_p) + if(source_p->localClient->targets[i] == hashv) return 1; } @@ -624,7 +627,7 @@ add_target(struct Client *source_p, struct Client *target_p) SetTGChange(source_p); } - source_p->localClient->targets[FREE_TARGET(source_p)] = target_p; + source_p->localClient->targets[FREE_TARGET(source_p)] = hashv; NEXT_TARGET(FREE_TARGET(source_p)); ++USED_TARGETS(source_p); return 1;