From 81f83be16034f7660bffc3570821836495023cce Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Tue, 13 Aug 2013 20:27:42 -0400 Subject: [PATCH] safeguard against NaN & null-value tasks --- script/algos.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/script/algos.coffee b/script/algos.coffee index 81aec29859..9b2e53fe61 100644 --- a/script/algos.coffee +++ b/script/algos.coffee @@ -191,6 +191,12 @@ obj.score = (user, task, direction, options={}) -> [paths, times, cron] = [options.paths || {}, options.times || 1, options.cron || false] priority = task.priority or '!' + # Handle corrupt tasks + return 0 unless task.id + if !_.isNumber(value) or _.isNaN(value) + task.value = value = 0; + paths["task.#{task.id}.value"] = true + # If they're trying to purhcase a too-expensive reward, don't allow them to do that. if task.value > user.stats.gp and task.type is 'reward' return