Merge branch 'master' of github.com:crafatar/crafatar

This commit is contained in:
Jake 2015-02-16 17:27:14 -06:00
commit 10af521f39
8 changed files with 20 additions and 11 deletions

View File

@ -17,6 +17,7 @@
0. If you add new functions, **add documentation** (comment above) 0. If you add new functions, **add documentation** (comment above)
* Wrap function arguments in `+` signs (e.g. `the +type+ is used for…`) * Wrap function arguments in `+` signs (e.g. `the +type+ is used for…`)
0. If you add new functions, **add tests** (test/test.js) 0. If you add new functions, **add tests** (test/test.js)
0. If you fixed an issue, **add a test** that would catch this issue
0. Run **tests** (`npm test`) 0. Run **tests** (`npm test`)
0. Make sure as much of your code as possible is **covered by tests** 0. Make sure as much of your code as possible is **covered by tests**
0. Double check that your pull request is **awesome** :) 0. Double check that your pull request is **awesome** :)

View File

@ -10,8 +10,8 @@ if (cluster.isMaster) {
cluster.fork(); cluster.fork();
} }
cluster.on("exit", function (worker, code, signal) { cluster.on("exit", function (worker) {
logging.error("Worker died. Rebooting a new one."); logging.error("Worker #" + worker.id + " died. Rebooting a new one.");
setTimeout(cluster.fork, 100); setTimeout(cluster.fork, 100);
}); });

View File

@ -146,7 +146,15 @@ function store_images(rid, userId, details, type, callback) {
currently_running.push(new_hash); currently_running.push(new_hash);
networking.get_profile(rid, (is_uuid ? userId : null), function(err, profile) { networking.get_profile(rid, (is_uuid ? userId : null), function(err, profile) {
if (err || (is_uuid && !profile)) { if (err || (is_uuid && !profile)) {
if (!err && !profile) {
cache.save_hash(rid, userId, null, null, function(cache_err) {
// we have no profile, so we have neither skin nor cape
callback_for(userId, "skin", cache_err, null);
callback_for(userId, "cape", cache_err, null);
});
} else {
callback_for(userId, type, err, null); callback_for(userId, type, err, null);
}
} else { } else {
store_skin(rid, userId, profile, details, function(err, skin_hash) { store_skin(rid, userId, profile, details, function(err, skin_hash) {
cache.save_hash(rid, userId, skin_hash, null, function(cache_err) { cache.save_hash(rid, userId, skin_hash, null, function(cache_err) {

View File

@ -2,7 +2,6 @@
// https://github.com/confuser/serverless-mc-skin-viewer // https://github.com/confuser/serverless-mc-skin-viewer
// Permission to use & distribute https://github.com/confuser/serverless-mc-skin-viewer/blob/master/LICENSE // Permission to use & distribute https://github.com/confuser/serverless-mc-skin-viewer/blob/master/LICENSE
var helpers = require("./helpers");
var logging = require("./logging"); var logging = require("./logging");
var fs = require("fs"); var fs = require("fs");
var Canvas = require("canvas"); var Canvas = require("canvas");
@ -43,7 +42,7 @@ exp.draw_head = function(skin_canvas, model_ctx, scale) {
// using the skin from the +model_ctx+ at the +scale+ // using the skin from the +model_ctx+ at the +scale+
// parts are labeled as if drawn from the skin's POV // parts are labeled as if drawn from the skin's POV
exp.draw_body = function(rid, skin_canvas, model_ctx, scale) { exp.draw_body = function(rid, skin_canvas, model_ctx, scale) {
if (skin_canvas.height == 32 * scale) { if (skin_canvas.height === 32 * scale) {
logging.debug(rid + "uses old skin format"); logging.debug(rid + "uses old skin format");
//Left Leg //Left Leg
//Left Leg - Front //Left Leg - Front
@ -189,8 +188,8 @@ function scale_image(imageData, context, d_x, d_y, scale) {
var width = imageData.width; var width = imageData.width;
var height = imageData.height; var height = imageData.height;
context.clearRect(0,0,width,height); //Clear the spot where it originated from context.clearRect(0,0,width,height); //Clear the spot where it originated from
for(y=0; y<height; y++) { //height original for(var y = 0; y < height; y++) { // height original
for(x=0; x<width; x++) { //width original for(var x = 0; x < width; x++) { // width original
//Gets original colour, then makes a scaled square of the same colour //Gets original colour, then makes a scaled square of the same colour
var index = (x + y * width) * 4; var index = (x + y * width) * 4;
context.fillStyle = "rgba(" + imageData.data[index+0] + "," + imageData.data[index+1] + "," + imageData.data[index+2] + "," + imageData.data[index+3] + ")"; context.fillStyle = "rgba(" + imageData.data[index+0] + "," + imageData.data[index+1] + "," + imageData.data[index+2] + "," + imageData.data[index+3] + ")";

View File

@ -26,7 +26,7 @@
"test": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage" "test": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
}, },
"engines": { "engines": {
"node": "0.12.x" "iojs": "1.2.x"
}, },
"dependencies": { "dependencies": {
"canvas": "crafatar/node-canvas", "canvas": "crafatar/node-canvas",

View File

@ -1,6 +1,7 @@
var logging = require("../modules/logging"); var logging = require("../modules/logging");
var helpers = require("../modules/helpers"); var helpers = require("../modules/helpers");
var config = require("../modules/config"); var config = require("../modules/config");
var cache = require("../modules/cache");
var human_status = { var human_status = {
0: "none", 0: "none",
@ -35,7 +36,7 @@ module.exports = function(req, res) {
logging.log(rid + "storage type: " + human_status[status]); logging.log(rid + "storage type: " + human_status[status]);
if (err) { if (err) {
logging.error(rid + err); logging.error(rid + err);
if (err.code == "ENOENT") { if (err.code === "ENOENT") {
// no such file // no such file
cache.remove_hash(rid, userId); cache.remove_hash(rid, userId);
} }

View File

@ -1,6 +1,7 @@
var logging = require("../modules/logging"); var logging = require("../modules/logging");
var helpers = require("../modules/helpers"); var helpers = require("../modules/helpers");
var config = require("../modules/config"); var config = require("../modules/config");
var cache = require("../modules/cache");
var skins = require("../modules/skins"); var skins = require("../modules/skins");
var renders = require("../modules/renders"); var renders = require("../modules/renders");
var fs = require("fs"); var fs = require("fs");
@ -65,7 +66,7 @@ module.exports = function(req, res) {
logging.log(rid + "storage type: " + human_status[status]); logging.log(rid + "storage type: " + human_status[status]);
if (err) { if (err) {
logging.error(rid + err); logging.error(rid + err);
if (err.code == "ENOENT") { if (err.code === "ENOENT") {
// no such file // no such file
cache.remove_hash(rid, userId); cache.remove_hash(rid, userId);
} }

View File

@ -2,7 +2,6 @@
var logging = require("./modules/logging"); var logging = require("./modules/logging");
var querystring = require("querystring"); var querystring = require("querystring");
var config = require("./modules/config"); var config = require("./modules/config");
var clean = require("./modules/cleaner");
var http = require("http"); var http = require("http");
var mime = require("mime"); var mime = require("mime");
var url = require("url"); var url = require("url");