From d6e52f9f59e30166967ff22cf8f1e45be6b2125e Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Wed, 19 Nov 2014 08:47:37 +0100 Subject: [PATCH] Improve viscolor parsing --- skin.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/skin.js b/skin.js index 21421d3d..87a5253e 100644 --- a/skin.js +++ b/skin.js @@ -75,11 +75,17 @@ SkinManager = { _parseVisColors: function(zip) { var entries = this._findFileInZip("VISCOLOR.TXT", zip).asText().split("\n"); - var regex = /^(\d+),\s*(\d+),\s*(\d+)/ - for(var i = 0; i <= entries.length; i++) { + var regex = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/ + // changed to a hard number to deal with empty lines at the end... + // plus its only meant to be an exact amount of numbers anywayz + // - @PAEz + for(var i = 0; i < 24; i++) { var matches = regex.exec(entries[i]); if(matches) { this.visColors.push('rgb(' + matches.slice(1,4).join(',') + ')'); + } else { + console.error('Error in VISCOLOR.TXT on line', i); + this.visColors.push('rgb(255,0,0)'); } } },