+void XLineManager::expire_lines()
+{
+ time_t current = ServerInstance->Time();
+
+ /* Because we now store all our XLines in sorted order using ((*i)->duration + (*i)->set_time) as a key, this
+ * means that to expire the XLines we just need to do a while, picking off the top few until there are
+ * none left at the head of the queue that are after the current time.
+ */
+
+ while ((glines.size()) && (current > (*glines.begin())->expiry))
+ {
+ std::vector<GLine*>::iterator i = glines.begin();
+ ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed G-Line %s@%s (set by %s %d seconds ago)",(*i)->identmask,(*i)->hostmask,(*i)->source,(*i)->duration);
+ glines.erase(i);
+ }
+
+ while ((elines.size()) && (current > (*elines.begin())->expiry))
+ {
+ std::vector<ELine*>::iterator i = elines.begin();
+ ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed E-Line %s@%s (set by %s %d seconds ago)",(*i)->identmask,(*i)->hostmask,(*i)->source,(*i)->duration);
+ elines.erase(i);
+ }
+
+ while ((zlines.size()) && (current > (*zlines.begin())->expiry))
+ {
+ std::vector<ZLine*>::iterator i = zlines.begin();
+ ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed Z-Line %s (set by %s %d seconds ago)",(*i)->ipaddr,(*i)->source,(*i)->duration);
+ zlines.erase(i);
+ }
+
+ while ((klines.size()) && (current > (*klines.begin())->expiry))
+ {
+ std::vector<KLine*>::iterator i = klines.begin();
+ ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed K-Line %s@%s (set by %s %d seconds ago)",(*i)->identmask,(*i)->hostmask,(*i)->source,(*i)->duration);
+ klines.erase(i);
+ }
+
+ while ((qlines.size()) && (current > (*qlines.begin())->expiry))
+ {
+ std::vector<QLine*>::iterator i = qlines.begin();
+ ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed Q-Line %s (set by %s %d seconds ago)",(*i)->nick,(*i)->source,(*i)->duration);
+ qlines.erase(i);
+ }
+
+}
+
+// applies lines, removing clients and changing nicks etc as applicable
+
+void XLineManager::apply_lines(const int What)