Improve viscolor parsing

This commit is contained in:
Jordan Eldredge 2014-11-19 08:47:37 +01:00
parent ecea48dae3
commit d6e52f9f59

10
skin.js
View file

@ -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)');
}
}
},