mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
first version of recorder
This commit is contained in:
parent
81f5990e0c
commit
5d70170ed9
4 changed files with 1725 additions and 17 deletions
|
|
@ -52,7 +52,7 @@ function(Parent, Nc, Parser, Settings) {
|
|||
y: Math.abs(update.p.y - this.player.doll.body.GetPosition().y)
|
||||
}
|
||||
|
||||
if(difference.x < Settings.PUNKBUSTER_DIFFERENCE_METERS
|
||||
if(true || difference.x < Settings.PUNKBUSTER_DIFFERENCE_METERS
|
||||
&& difference.y < Settings.PUNKBUSTER_DIFFERENCE_METERS) {
|
||||
this.player.doll.updatePositionState(update);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,33 +1,63 @@
|
|||
define([
|
||||
"Lib/Utilities/NotificationCenter",
|
||||
"Game/Channel/Channel"
|
||||
"Game/Channel/Channel",
|
||||
"Game/Config/Settings",
|
||||
'fs'
|
||||
],
|
||||
|
||||
function (Nc, Channel) {
|
||||
function (Nc, Channel, Settings, fs) {
|
||||
|
||||
"use strict";
|
||||
|
||||
function PipeToServer (process) {
|
||||
|
||||
var self = this;
|
||||
|
||||
this.channel = null;
|
||||
this.process = process;
|
||||
this.recordingFileName = null;
|
||||
|
||||
Nc.on(Nc.ns.channel.to.server.controlCommand.send, this.send, this);
|
||||
|
||||
process.on('message', function (message, handle) {
|
||||
process.on('message', this.onProcessMessage.bind(this));
|
||||
}
|
||||
|
||||
if(message.data.hasOwnProperty('CREATE')) {
|
||||
self.channel = new Channel(self, message.data.options);
|
||||
} else if (message.data.hasOwnProperty('KILL')) {
|
||||
self.channel.destroy();
|
||||
} else {
|
||||
self.onMessage(message);
|
||||
PipeToServer.prototype.onProcessMessage = function (message, handle) {
|
||||
|
||||
if(message.data.hasOwnProperty('CREATE')) {
|
||||
this.channel = new Channel(this, message.data.options);
|
||||
|
||||
message.data.options.playingFileName = "Quickstart-1425229312283.log";
|
||||
|
||||
if(message.data.options.playingFileName) {
|
||||
var self = this;
|
||||
setTimeout(function() {
|
||||
console.log(message.data.options.playingFileName)
|
||||
self.play(message.data.options.playingFileName);
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
if(Settings.CHANNEL_RECORD_SESSION) {
|
||||
this.recordingFileName = Settings.CHANNEL_RECORDING_PATH + "/" + this.channel.name + "-" + Date.now() + ".log";
|
||||
if(!fs.existsSync(Settings.CHANNEL_RECORDING_PATH)) {
|
||||
fs.mkdirSync(Settings.CHANNEL_RECORDING_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (message.data.hasOwnProperty('KILL')) {
|
||||
this.channel.destroy();
|
||||
} else {
|
||||
this.onMessage(message);
|
||||
|
||||
if(Settings.CHANNEL_RECORD_SESSION && this.channel && this.channel.name) {
|
||||
var m = JSON.stringify(message);
|
||||
var timestamp = Date.now();
|
||||
var line = timestamp + m + "\n";
|
||||
|
||||
fs.appendFile(this.recordingFileName, line, function (err) {
|
||||
if (err) throw err;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
PipeToServer.prototype.send = function (recipient, data) {
|
||||
var message = {
|
||||
|
|
@ -50,6 +80,34 @@ function (Nc, Channel) {
|
|||
|
||||
}
|
||||
|
||||
PipeToServer.prototype.play = function(playingFileName) {
|
||||
var self = this;
|
||||
var data = fs.readFileSync(Settings.CHANNEL_RECORDING_PATH + "/" + playingFileName);
|
||||
var lines = data.toString().split("\n");
|
||||
var now = Date.now();
|
||||
var start = 0;
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
// bind message variable
|
||||
(function() {
|
||||
var line = lines[i];
|
||||
if(line.length > 0) {
|
||||
var time = parseInt(line.substring(0, Date.now().toString().length), 10);
|
||||
if(i == 0) {
|
||||
start = time;
|
||||
}
|
||||
time -= start;
|
||||
|
||||
var jsonString = line.substring(Date.now().toString().length);
|
||||
var message = JSON.parse(jsonString);
|
||||
|
||||
setTimeout(function() {
|
||||
self.onProcessMessage(message, null);
|
||||
}, time);
|
||||
}
|
||||
})();
|
||||
};
|
||||
};
|
||||
|
||||
PipeToServer.prototype.destroy = function() {
|
||||
this.send('coordinator', {destroy:this.channel.name});
|
||||
this.process.exit(0);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ define(function() {
|
|||
GRAPHICS_SUBPATH_TILES: 'Tiles/',
|
||||
MAPS_PATH: 'static/maps/tiled/',
|
||||
AUDIO_PATH: 'static/sounds/',
|
||||
CHANNEL_RECORDING_PATH: 'recordings/',
|
||||
|
||||
RATIO: 21, //35
|
||||
// original tile size is 25 but we want it to resize to 20
|
||||
|
|
@ -45,7 +46,7 @@ define(function() {
|
|||
RESPAWN_TIME: 5,
|
||||
HEALTH_DISPLAY_TIME: 2,
|
||||
CRITICAL_HEALTH_THRESHOLD: 0.3,
|
||||
RAGDOLL_DESTRUCTION_TIME: 20,
|
||||
RAGDOLL_DESTRUCTION_TIME: 20000,
|
||||
VIEWPORT_SPEED_FACTOR: 640,
|
||||
VIEWPORT_LOOK_AHEAD: 0.1,
|
||||
|
||||
|
|
@ -76,11 +77,12 @@ define(function() {
|
|||
NETWORK_LOG_FILTER: ['ping', 'pong', 'worldUpdate', 'lookAt'],
|
||||
|
||||
// CHANNEL
|
||||
CHANNEL_DESTRUCTION_TIME: 5 * 60,
|
||||
CHANNEL_DESTRUCTION_TIME: 0.5 * 60,
|
||||
CHANNEL_END_ROUND_TIME: 4, //10,
|
||||
CHANNEL_DEFAULT_MAX_USERS: 40,
|
||||
CHANNEL_DEFAULT_SCORE_LIMIT: 10,
|
||||
CHANNEL_DEFAULT_LEVELS: ['debug'],
|
||||
CHANNEL_RECORD_SESSION: false,
|
||||
|
||||
// ME STATE
|
||||
ME_STATE_MAX_DIFFERENCE_METERS: 1,
|
||||
|
|
|
|||
1648
recordings/Quickstart-1425229312283.rec
Normal file
1648
recordings/Quickstart-1425229312283.rec
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue