diff --git a/src/clj/game/core/servers.cljc b/src/clj/game/core/servers.cljc index bc92280ca5..64bfb80fc4 100644 --- a/src/clj/game/core/servers.cljc +++ b/src/clj/game/core/servers.cljc @@ -62,7 +62,7 @@ :archives -3 :rd -2 :hq -1 - (string->num + (parse-long (last (safe-split (str zone) #":remote"))))) (defn zones->sorted-names diff --git a/src/clj/game/utils.cljc b/src/clj/game/utils.cljc index 38a38fc27c..1680fd72d1 100644 --- a/src/clj/game/utils.cljc +++ b/src/clj/game/utils.cljc @@ -45,10 +45,11 @@ (cons x (step more (conj seen k))))))))] (step coll #{}))) -(defn string->num [s] - (cond - (number? s) s - (string? s) (parse-long s))) +#?(:clj (defn string->num [s] + (try + (let [num (bigdec s)] + (if (and (> num Integer/MIN_VALUE) (< num Integer/MAX_VALUE)) (int num) num)) + (catch Exception _ nil)))) (def safe-split (fnil str/split ""))