Commit f7408480 authored by nanahira's avatar nanahira

use latest coffeescript

parent 09cdcc3f
// Generated by CoffeeScript 1.12.7 // Generated by CoffeeScript 2.5.1
(function() { (function() {
var WebSocketServer, _delete, broadcast, create, init, room_data, server, settings, start, update, url; var WebSocketServer, _delete, broadcast, create, init, room_data, server, settings, start, update, url;
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
} }
return results; return results;
})(), })(),
options: room.get_old_hostinfo(), options: room.get_old_hostinfo(), // Should be updated when MyCard client updates
arena: settings.modules.arena_mode.enabled && room.arena && settings.modules.arena_mode.mode arena: settings.modules.arena_mode.enabled && room.arena && settings.modules.arena_mode.mode
}; };
}; };
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
results = []; results = [];
for (i = 0, len = ROOM_all.length; i < len; i++) { for (i = 0, len = ROOM_all.length; i < len; i++) {
room = ROOM_all[i]; room = ROOM_all[i];
if (room && room.established && (connection.filter === 'started' || !room["private"]) && ((room.duel_stage !== 0) === (connection.filter === 'started'))) { if (room && room.established && (connection.filter === 'started' || !room.private) && ((room.duel_stage !== 0) === (connection.filter === 'started'))) {
results.push(room_data(room)); results.push(room_data(room));
} }
} }
...@@ -61,19 +61,19 @@ ...@@ -61,19 +61,19 @@
}; };
create = function(room) { create = function(room) {
if (!room["private"]) { if (!room.private) {
return broadcast('create', room_data(room), 'waiting'); return broadcast('create', room_data(room), 'waiting');
} }
}; };
update = function(room) { update = function(room) {
if (!room["private"]) { if (!room.private) {
return broadcast('update', room_data(room), 'waiting'); return broadcast('update', room_data(room), 'waiting');
} }
}; };
start = function(room) { start = function(room) {
if (!room["private"]) { if (!room.private) {
broadcast('delete', room.name, 'waiting'); broadcast('delete', room.name, 'waiting');
} }
return broadcast('create', room_data(room), 'started'); return broadcast('create', room_data(room), 'started');
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
if (room.duel_stage !== 0) { if (room.duel_stage !== 0) {
return broadcast('delete', room.name, 'started'); return broadcast('delete', room.name, 'started');
} else { } else {
if (!room["private"]) { if (!room.private) {
return broadcast('delete', room.name, 'waiting'); return broadcast('delete', room.name, 'waiting');
} }
} }
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
create: create, create: create,
update: update, update: update,
start: start, start: start,
"delete": _delete delete: _delete
}; };
}).call(this); }).call(this);
// Generated by CoffeeScript 1.12.7 // Generated by CoffeeScript 2.5.1
/*
Main script of new dashboard account system.
The account list file is stored at `./config/admin_user.json`. The users are stored at `users`.
The key is the username. The `permissions` field could be a string, using a permission set from the example, or an object, to define a specific set of permissions.
eg. An account for a judge could be as follows, to use the default permission of judges,
"username": {
"password": "123456",
"enabled": true,
"permissions": "judge"
},
or as follows, to use a specific set of permissions.
"username": {
"password": "123456",
"enabled": true,
"permissions": {
"get_rooms": true,
"duel_log": true,
"download_replay": true,
"deck_dashboard_read": true,
"deck_dashboard_write": true,
"shout": true,
"kick_user": true,
"start_death": true
}
},
*/
(function() { (function() {
/*
Main script of new dashboard account system.
The account list file is stored at `./config/admin_user.json`. The users are stored at `users`.
The key is the username. The `permissions` field could be a string, using a permission set from the example, or an object, to define a specific set of permissions.
eg. An account for a judge could be as follows, to use the default permission of judges,
"username": {
"password": "123456",
"enabled": true,
"permissions": "judge"
},
or as follows, to use a specific set of permissions.
"username": {
"password": "123456",
"enabled": true,
"permissions": {
"get_rooms": true,
"duel_log": true,
"download_replay": true,
"deck_dashboard_read": true,
"deck_dashboard_write": true,
"shout": true,
"kick_user": true,
"start_death": true
}
},
*/
var add_log, bunyan, check_permission, default_data, fs, loadJSON, log, moment, reload, save, setting_save, users; var add_log, bunyan, check_permission, default_data, fs, loadJSON, log, moment, reload, save, setting_save, users;
fs = require('fs'); fs = require('fs');
...@@ -122,11 +120,8 @@ or as follows, to use a specific set of permissions. ...@@ -122,11 +120,8 @@ or as follows, to use a specific set of permissions.
return permission[permission_required]; return permission[permission_required];
}; };
this.auth = function(name, pass, permission_required, action, no_log) { this.auth = function(name, pass, permission_required, action = 'unknown', no_log) {
var user; var user;
if (action == null) {
action = 'unknown';
}
reload(); reload();
user = users.users[name]; user = users.users[name];
if (!user) { if (!user) {
......
This diff is collapsed.
// Generated by CoffeeScript 1.12.7 // Generated by CoffeeScript 2.5.1
(function() { (function() {
var Struct, _, declaration, field, i, len, loadJSON, name, result, structs_declaration, type, typedefs; var Struct, _, declaration, field, i, len, loadJSON, name, result, structs_declaration, type, typedefs;
...@@ -14,14 +14,17 @@ ...@@ -14,14 +14,17 @@
this.i18ns = loadJSON('./data/i18n.json'); this.i18ns = loadJSON('./data/i18n.json');
structs_declaration = loadJSON('./data/structs.json'); //常量/类型声明
structs_declaration = loadJSON('./data/structs.json'); //结构体声明
typedefs = loadJSON('./data/typedefs.json'); typedefs = loadJSON('./data/typedefs.json'); //类型声明
this.proto_structs = loadJSON('./data/proto_structs.json'); this.proto_structs = loadJSON('./data/proto_structs.json'); //消息与结构体的对应,未完成,对着duelclient.cpp加
this.constants = loadJSON('./data/constants.json'); this.constants = loadJSON('./data/constants.json'); //network.h里定义的常量
//结构体定义
this.structs = {}; this.structs = {};
for (name in structs_declaration) { for (name in structs_declaration) {
...@@ -35,7 +38,7 @@ ...@@ -35,7 +38,7 @@
result.chars(field.name, field.length * 2, field.encoding); result.chars(field.name, field.length * 2, field.encoding);
break; break;
default: default:
throw "unsupported encoding: " + field.encoding; throw `unsupported encoding: ${field.encoding}`;
} }
} else { } else {
type = field.type; type = field.type;
...@@ -43,7 +46,7 @@ ...@@ -43,7 +46,7 @@
type = typedefs[type]; type = typedefs[type];
} }
if (field.length) { if (field.length) {
result.array(field.name, field.length, type); result.array(field.name, field.length, type); //不支持结构体
} else { } else {
if (this.structs[type]) { if (this.structs[type]) {
result.struct(field.name, this.structs[type]); result.struct(field.name, this.structs[type]);
...@@ -56,6 +59,7 @@ ...@@ -56,6 +59,7 @@
this.structs[name] = result; this.structs[name] = result;
} }
//消息跟踪函数 需要重构, 另暂时只支持异步, 同步没做.
this.stoc_follows = {}; this.stoc_follows = {};
this.stoc_follows_before = {}; this.stoc_follows_before = {};
...@@ -154,11 +158,13 @@ ...@@ -154,11 +158,13 @@
}); });
}; };
//消息发送函数,至少要把俩合起来....
this.stoc_send = function(socket, proto, info) { this.stoc_send = function(socket, proto, info) {
var buffer, header, key, ref, struct, value; var buffer, header, key, ref, struct, value;
if (socket.closed) { if (socket.closed) {
return; return;
} }
//console.log proto, proto_structs.STOC[proto], structs[proto_structs.STOC[proto]]
if (typeof info === 'undefined') { if (typeof info === 'undefined') {
buffer = ""; buffer = "";
} else if (Buffer.isBuffer(info)) { } else if (Buffer.isBuffer(info)) {
...@@ -169,7 +175,7 @@ ...@@ -169,7 +175,7 @@
struct.set(info); struct.set(info);
buffer = struct.buffer(); buffer = struct.buffer();
} }
if (typeof proto === 'string') { if (typeof proto === 'string') { //需要重构
ref = this.constants.STOC; ref = this.constants.STOC;
for (key in ref) { for (key in ref) {
value = ref[key]; value = ref[key];
...@@ -196,6 +202,7 @@ ...@@ -196,6 +202,7 @@
if (socket.closed) { if (socket.closed) {
return; return;
} }
//console.log proto, proto_structs.CTOS[proto], structs[proto_structs.CTOS[proto]]
if (typeof info === 'undefined') { if (typeof info === 'undefined') {
buffer = ""; buffer = "";
} else if (Buffer.isBuffer(info)) { } else if (Buffer.isBuffer(info)) {
...@@ -206,7 +213,7 @@ ...@@ -206,7 +213,7 @@
struct.set(info); struct.set(info);
buffer = struct.buffer(); buffer = struct.buffer();
} }
if (typeof proto === 'string') { if (typeof proto === 'string') { //需要重构
ref = this.constants.CTOS; ref = this.constants.CTOS;
for (key in ref) { for (key in ref) {
value = ref[key]; value = ref[key];
...@@ -228,11 +235,9 @@ ...@@ -228,11 +235,9 @@
} }
}; };
this.stoc_send_chat = function(client, msg, player) { //util
this.stoc_send_chat = function(client, msg, player = 8) {
var j, len1, line, o, r, re, ref, ref1; var j, len1, line, o, r, re, ref, ref1;
if (player == null) {
player = 8;
}
if (!client) { if (!client) {
console.log("err stoc_send_chat"); console.log("err stoc_send_chat");
return; return;
...@@ -256,11 +261,8 @@ ...@@ -256,11 +261,8 @@
} }
}; };
this.stoc_send_chat_to_room = function(room, msg, player) { this.stoc_send_chat_to_room = function(room, msg, player = 8) {
var client, j, k, len1, len2, ref, ref1; var client, j, k, len1, len2, ref, ref1;
if (player == null) {
player = 8;
}
if (!room) { if (!room) {
console.log("err stoc_send_chat_to_room"); console.log("err stoc_send_chat_to_room");
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment