Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var i;
var nt;
missingTypes = [];
for ( i = 0; i < activeConfig.length; i++) {
var type = activeConfig[i].type;
// TODO: remove workspace in next release+1
if (type != "workspace" && type != "tab") {
nt = typeRegistry.get(type);
if (!nt && missingTypes.indexOf(type) == -1) {
missingTypes.push(type);
}
}
}
if (missingTypes.length > 0) {
util.log("[varai] Waiting for missing types to be registered:");
for ( i = 0; i < missingTypes.length; i++) {
util.log("[varai] - " + missingTypes[i]);
}
return;
}
util.log("[varai] Starting flows");
events.emit("nodes-starting");
for ( i = 0; i < activeConfig.length; i++) {
var nn = null;
// TODO: remove workspace in next release+1
if (activeConfig[i].type != "workspace" && activeConfig[i].type != "tab") {
nt = typeRegistry.get(activeConfig[i].type);
if (nt) {
try {
nn = new nt(activeConfig[i]);
global.ItemTemplate = require('./src/server/entity/itemTemplate');
global.Item = require('./src/server/entity/item');
// Load DataHandler global for now (holds memory DB of item and unit templates)
global.dataHandler = require('./src/server/game/dataHandler');
// load AI as a module
var AI = require('./src/server/game/ai');
// temp pass them on to global for access below
global.StateMachine = AI.StateMachine;
global.State = AI.State;
_.extend(global, AI.States);
// READ REST OF OLD GLOBAL APP HERE
for (var f = 0; f < includes.length; f++) {
log("Loading: " + includes[f]);
eval(fs.readFileSync(includes[f]) + '');
}
// temp hack
global.worldHandler = worldHandler;
global.actorScripts = {};
LoadActorScripts()
.then(function(scripts) {
_.extend(global.actorScripts, scripts);
// Load Chat module - after worldHandler, there is a dep
global.chatHandler = require('./src/server/game/chat')(io, global.dataHandler.units, global.worldHandler);
// All set! Tell WorldHandler to load
function onClientDisconnect() {
util.log("Player has disconnected: " + this.id);
delete players[this.id];
this.broadcast.emit("remove player", {id: this.id});
};
process.on('uncaughtException',function(err) {
util.log('[varai] Uncaught Exception:');
util.log(err.stack);
process.exit(1);
});
function onMeteorCast(data){
//util.log("A Meteor has been cast " + JSON.stringify(data.meteor_x));
util.log(data.meteor_x);
this.emit('meteor cast', {meteor_x: data.meteor_x });
this.broadcast.emit('meteor cast', {meteor_x: data.meteor_x });
};
models.Project.create(projects, function(err) {
if (err) {
util.log(err);
util.log('addLang error');
return done(err);
}
var projects = Array.prototype.slice.call(arguments, 1);
_.each(_.map(exerciseProject, function(p) { return parseInt(p, 10); }), function(project, i) {
exercises[i].project = projects[project]._id;
exercises[i].projectName = projects[project].name;
});
models.Exercise.create(exercises, function(err) {
if (err) {
util.log(err);
util.log('addLang error');
return done(err);
}
_.each(Array.prototype.slice.call(arguments, 1), function(exercise) {
.catch((err) => {
log(err);
vscode.window.showWarningMessage(
"dune error: "+err,
);
return "";
});
function getAllMessagesFromGateway () {
if (verboseMode) {
sys.log("fetch all messages from gateway...");
}
fetchMessages(function(newMessages){
saveAllMessagesToFile(newMessages, notifyListeners);
writeMessagesToLog(newMessages);
removeAllMessagesFromGateway();
});
if (watchMode) {
setTimeout(getAllMessagesFromGateway, config.timeout || 30000);
}
}
request.get(url, function (err, res, data) {
if (err || res.statusCode != 200) return;
log("====== fetchLatest ======");
var json = JSON.parse(data);
if (latest.news && (json.news.length + 1) == latest.news.length) return;
uploader.updateUptoken();
json.news.forEach(function (item) {
fetchStory(item.id, json.date, true);
uploader.uploadLink(item.image, 'image/' + getKey(item.image));
uploader.uploadLink(item.thumbnail, 'thumbnail/' + getKey(item.thumbnail));
item.date = json.date;
delete item.ga_prefix;
item.url = '/story/' + item.id;
item.image = '/image/' + getKey(item.image);
item.thumbnail = '/thumbnail/' + getKey(item.thumbnail);
});
var before = moment(json.date, 'YYYYMMDD').subtract(1, 'days').format('YYYYMMDD');
db.get('daily-' + before).then(function (data) {
json.news.push({
response.end("MapServer Error: " + err.code + " ("+err.codeStr+"): " + err.message + ' in ' + err.routine);
} else {
cache.set(key, {mimetype: map.mimetype, buffer: buffer});
response.writeHead(200, {
'Content-Type': map.mimetype
});
response.end(buffer);
}
});
}
} else {
response.writeHead(404, {});
response.end('File not found.');
}
}).listen(port);
util.log("mapserv.js running on port " + port );