From 93ef93dacd778fdeac1c2d9a0a822841d383dbaa Mon Sep 17 00:00:00 2001 From: "Morgan 'ARR\\!' Allen" Date: Tue, 11 Apr 2017 20:57:37 -0700 Subject: [PATCH] fixed encoding, rotation, other stuff --- index.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index b0e9ce3..0466544 100644 --- a/index.js +++ b/index.js @@ -11,11 +11,11 @@ module.exports = function(input, output, feedFile, opts) { var section = -1; var sections = [[], [], [], []]; - fs.createReadStream(feedFile) + fs.createReadStream(feedFile, { encoding: "latin1" }) .on("data", function(data) { buf += data.toString(); - var lines = buf.split("\n"); + var lines = buf.split("\r\n"); buf = lines.pop(); for(var i = 0; i < lines.length; i++) { @@ -72,7 +72,9 @@ module.exports = function(input, output, feedFile, opts) { var p = match[1]; var x = match[3]; var y = match[4]; - var r = match[5]; + var r = Math.round(match[5] - 90); + + if(r < 0) r += 360; if(!feeds[p]) { if(!opts.quite) @@ -83,7 +85,7 @@ module.exports = function(input, output, feedFile, opts) { var feed = feeds[p]; - this.push([ 0, seq++, feed.slot, x, y, r, 0.50, 0, 100, null, null, null ].join(",") + "\n"); + this.push([ ++seq, 1, feed.slot, Math.abs(x), Math.abs(y), r, 0.50, 0, 100, null, null, null ].join(",") + "\r\n"); }; done(); @@ -91,13 +93,13 @@ module.exports = function(input, output, feedFile, opts) { next(null, tr, sections); }], function(err, tr, sections) { - var rs = fs.createReadStream(input); - var ws = fs.createWriteStream(output); + var rs = fs.createReadStream(input, { encoding: "latin1" }); + var ws = fs.createWriteStream(output, { encoding: "latin1" }); var i = 0; async.forEachSeries(sections, function(section, next) { - ws.write(section.join("\n") + (++i < 4 ? "\n\n" : "\n"), next); + ws.write(section.join("\r\n") + (++i < 4 ? "\r\n\r\n" : "\r\n"), next); }, function() { rs.pipe(tr); tr.pipe(ws).on("close", function() {