- /* Add bonus, if you've been connected for more than 10 minutes you
- * get a free target every TARGET_DELAY seconds.
- * this is pretty fuzzy, but it will help in some cases.
- */
- if ((CurrentTime - cptr->firsttime) > 600)
- free_targets += (CurrentTime - cptr->firsttime - 600) / TARGET_DELAY;
+ memcpy(entry->target->targets, cli_targets(cptr), MAXTARGETS);
+ /*
+ * This calculation can be pretty unfair towards large multi-user hosts, but
+ * there is "nothing" we can do without also allowing spam bots to send more
+ * messages or by drastically increasing the amount of memory used in the IPregistry.
+ *
+ * The problem is that when a client disconnects, leaving no free targets, then
+ * the next client from that IP number has to pay for it (getting no free targets).
+ * But ALSO the next client, and the next client, and the next client etc - until
+ * another client disconnects that DOES leave free targets. The reason for this
+ * is that if there are 10 SPAM bots, and they all disconnect at once, then they
+ * ALL should get no free targets when reconnecting. We'd need to store an entry
+ * per client (instead of per IP number) to avoid this.
+ */
+ if (cli_nexttarget(cptr) < CurrentTime) {
+ /*
+ * Number of free targets
+ */
+ free_targets = (CurrentTime - cli_nexttarget(cptr)) / TARGET_DELAY + 1;
+ }
+ else
+ free_targets = 0;
+ /*
+ * Add bonus, this is pretty fuzzy, but it will help in some cases.
+ */
+ if ((CurrentTime - cli_firsttime(cptr)) > 600)
+ /*
+ * Was longer then 10 minutes online?
+ */
+ free_targets += (CurrentTime - cli_firsttime(cptr) - 600) / TARGET_DELAY;
+ /*
+ * Finally, store smallest value for Judgment Day
+ */
+ if (free_targets < entry->target->count)
+ entry->target->count = free_targets;
+ }
+}