Permalink
Browse files

Node 0.8 update

  • Loading branch information...
1 parent 4ad35b5 commit 6b83c513ec7cb4c6285fb979e467f57018ef3058 @bpierre committed Aug 12, 2012
Showing with 12 additions and 13 deletions.
  1. +2 −2 package.json
  2. +10 −11 server/lib/data-manager.js
View
@@ -13,10 +13,10 @@
"url": "git://github.com/bpierre/modul.io.git"
},
"engines": {
- "node": "~0.6.6"
+ "node": "~0.8"
},
"dependencies": {
- "canvas": "~0.10",
+ "canvas": "~0.13",
"ejs": "~0.6",
"express": "~2.5",
"socket.io": "~0.9",
View
@@ -1,7 +1,6 @@
var fs = require('fs'),
path = require('path'),
world = require('./world').getWorld(),
- world = require('./world').getWorld(),
dManager = null;
// DataManager Class
@@ -10,7 +9,7 @@ var DataManager = function() {
DataManager.prototype.loadAllModuls = function(callback) {
var self = this;
-
+
// List moduls
var modulsList = [];
var dirs = fs.readdirSync(__dirname + '/../data');
@@ -32,7 +31,7 @@ DataManager.prototype.loadAllModuls = function(callback) {
}
}
}
-
+
// Load the moduls list
var loadModulCount = modulsList.length;
for (var k in modulsList) {
@@ -55,7 +54,7 @@ DataManager.prototype.createDefaultModul = function(modulId, callback) {
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
-
+
var modul = new Modul(modulId);
var modulAdded = null;
if (!modulAdded) {
@@ -68,32 +67,32 @@ DataManager.prototype.createDefaultModul = function(modulId, callback) {
modul.updateCode(
fs.readFileSync(__dirname + '/../fixtures/default-default.modul', 'utf8')
);
-
+
return callback(modul);
};
DataManager.prototype.loadModul = function(name, callback) {
var Modul = require('./modul').Modul;
-
+
var modulPath = path.normalize(__dirname + '/../data/' + name);
var modulCode = null;
-
+
try {
modulCode = fs.readFileSync(modulPath, 'utf8');
} catch(e) {
if (e.code === 'EISDIR') {
return callback();
}
}
-
+
if (modulCode) {
var curModul = new Modul(name);
curModul.updateCode(modulCode, function(){
-
+
// Temp
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
-
+
var x = 0, y = 0;
(function A(){
x = getRandomInt(1, world.width-1);
@@ -102,7 +101,7 @@ DataManager.prototype.loadModul = function(name, callback) {
A();
}
})();
-
+
return callback();
});
}

0 comments on commit 6b83c51

Please sign in to comment.