# HG changeset patch # User Dominic Cleal # Date 1228582176 0 # Node ID bef72aa85f2b8440856eb27d6ada8ef2ad91234f # Parent e238f28f774a5f52742fe13c7b32051eb734faf9 Ignoring bad data with 2^32 second finish times diff -r e238f28f774a -r bef72aa85f2b skillbot.pl --- a/skillbot.pl Sat Dec 06 16:46:52 2008 +0000 +++ b/skillbot.pl Sat Dec 06 16:49:36 2008 +0000 @@ -410,7 +410,7 @@ # If the char was training before and now has stopped then cancel # the announcement del_one_shot_timer($f->{timer}) if defined $f->{timer}; - next; + return; } # Check for changes in the skill, skip or cancel announcement @@ -419,9 +419,20 @@ del_one_shot_timer($f->{timer}); } + my $finish = $skill->finish_time - time(); + my $prefinish = $finish - 60; + irc_debug("Character %s is training %s %lu (%s == %lu sec)", $f->{char}->name, $skill->name, $skill->level, - $skill->time_remaining, ($skill->finish_time - time())); + $skill->time_remaining, $finish); + + # Cap time at 3 months to ignore bad data + if ($finish > 60 * 60 * 24 * 90) + { + irc_debug("Unreasonable finish time given of %s seconds, ignoring", + $finish); + return; + } $f->{skill} = $skill; @@ -432,9 +443,6 @@ $text =~ s/[\n\r]/ /g; } - my $finish = $skill->finish_time - time(); - my $prefinish = $finish - 60; - # Add a timer shortly before the end to ensure the user's still training if ($prefinish > 0) {