Commit 54b96fe5 authored by mercury233's avatar mercury233

update & fix

parent c6b37a09
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
"tips": "http://mycard.moe/ygopro/tips.json", "tips": "http://mycard.moe/ygopro/tips.json",
"dialogues": "http://mycard.moe/ygopro/dialogues.json", "dialogues": "http://mycard.moe/ygopro/dialogues.json",
"redis_port": 6379, "redis_port": 6379,
"enable_websocket_roomlist": true,
"enable_random_duel": false, "enable_random_duel": false,
"mycard_auth": "https://ygobbs.com", "mycard_auth": "https://ygobbs.com",
"post_start_watching": true, "post_start_watching": true,
...@@ -17,6 +18,7 @@ ...@@ -17,6 +18,7 @@
"port": 7922, "port": 7922,
"password": "123456", "password": "123456",
"ssl": { "ssl": {
"enabled": true,
"port": 7923, "port": 7923,
"cert": "ssl/ygopro-server.crt", "cert": "ssl/ygopro-server.crt",
"key": "ssl/ygopro-server.key" "key": "ssl/ygopro-server.key"
......
...@@ -4,7 +4,7 @@ _.mixin(_.str.exports()); ...@@ -4,7 +4,7 @@ _.mixin(_.str.exports());
spawn = require('child_process').spawn spawn = require('child_process').spawn
spawnSync = require('child_process').spawnSync spawnSync = require('child_process').spawnSync
ygopro = require './ygopro.js' ygopro = require './ygopro.js'
roomlist = require './roomlist' roomlist = require './roomlist' if settings.modules.enable_websocket_roomlist
bunyan = require 'bunyan' bunyan = require 'bunyan'
moment = require 'moment' moment = require 'moment'
#redis = require 'redis' #redis = require 'redis'
...@@ -309,7 +309,7 @@ class Room ...@@ -309,7 +309,7 @@ class Room
@process.stdout.setEncoding('utf8') @process.stdout.setEncoding('utf8')
@process.stdout.once 'data', (data)=> @process.stdout.once 'data', (data)=>
@established = true @established = true
roomlist.create(this) if !@private roomlist.create(this) if !@private and settings.modules.enable_websocket_roomlist
@port = parseInt data @port = parseInt data
_.each @players, (player)=> _.each @players, (player)=>
player.server.connect @port, '127.0.0.1',=> player.server.connect @port, '127.0.0.1',=>
...@@ -352,7 +352,7 @@ class Room ...@@ -352,7 +352,7 @@ class Room
index = _.indexOf(Room.all, this) index = _.indexOf(Room.all, this)
#Room.all[index] = null unless index == -1 #Room.all[index] = null unless index == -1
Room.all.splice(index, 1) unless index == -1 Room.all.splice(index, 1) unless index == -1
roomlist.delete @name if !@private and !@started and @established roomlist.delete @name if !@private and !@started and @established and settings.modules.enable_websocket_roomlist
return return
get_playing_player: -> get_playing_player: ->
...@@ -383,7 +383,7 @@ class Room ...@@ -383,7 +383,7 @@ class Room
Room.players_oppentlist[client.remoteAddress] = null Room.players_oppentlist[client.remoteAddress] = null
if @established if @established
roomlist.update(this) if !@private and !@started roomlist.update(this) if !@private and !@started and settings.modules.enable_websocket_roomlist
client.server.connect @port, '127.0.0.1', -> client.server.connect @port, '127.0.0.1', ->
client.server.write buffer for buffer in client.pre_establish_buffers client.server.write buffer for buffer in client.pre_establish_buffers
client.established = true client.established = true
...@@ -405,7 +405,7 @@ class Room ...@@ -405,7 +405,7 @@ class Room
Room.ban_player(client.name, client.ip, "强退") Room.ban_player(client.name, client.ip, "强退")
if @players.length if @players.length
ygopro.stoc_send_chat_to_room this, "#{client.name} #{'离开了游戏'}#{if error then ": #{error}" else ''}" ygopro.stoc_send_chat_to_room this, "#{client.name} #{'离开了游戏'}#{if error then ": #{error}" else ''}"
roomlist.update(this) if !@private and !@started roomlist.update(this) if !@private and !@started and settings.modules.enable_websocket_roomlist
#client.room = null #client.room = null
else else
@process.kill() @process.kill()
......
// Generated by CoffeeScript 1.9.3 // Generated by CoffeeScript 1.10.0
(function() { (function() {
var Room, _, bunyan, get_memory_usage, log, moment, roomlist, settings, spawn, spawnSync, ygopro; var Room, _, bunyan, get_memory_usage, log, moment, roomlist, settings, spawn, spawnSync, ygopro;
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
ygopro = require('./ygopro.js'); ygopro = require('./ygopro.js');
roomlist = require('./roomlist'); if (settings.modules.enable_websocket_roomlist) {
roomlist = require('./roomlist');
}
bunyan = require('bunyan'); bunyan = require('bunyan');
...@@ -187,7 +189,7 @@ ...@@ -187,7 +189,7 @@
}; };
function Room(name, hostinfo) { function Room(name, hostinfo) {
var draw_count, lflist, param, rule, start_hand, start_lp, time_limit; var draw_count, error1, lflist, param, rule, start_hand, start_lp, time_limit;
this.hostinfo = hostinfo; this.hostinfo = hostinfo;
this.name = name; this.name = name;
this.alive = true; this.alive = true;
...@@ -394,7 +396,7 @@ ...@@ -394,7 +396,7 @@
this.process.stdout.once('data', (function(_this) { this.process.stdout.once('data', (function(_this) {
return function(data) { return function(data) {
_this.established = true; _this.established = true;
if (!_this["private"]) { if (!_this["private"] && settings.modules.enable_websocket_roomlist) {
roomlist.create(_this); roomlist.create(_this);
} }
_this.port = parseInt(data); _this.port = parseInt(data);
...@@ -412,7 +414,7 @@ ...@@ -412,7 +414,7 @@
}); });
}; };
})(this)); })(this));
} catch (_error) { } catch (error1) {
this.error = "建立房间失败,请重试"; this.error = "建立房间失败,请重试";
} }
} }
...@@ -453,7 +455,7 @@ ...@@ -453,7 +455,7 @@
if (index !== -1) { if (index !== -1) {
Room.all.splice(index, 1); Room.all.splice(index, 1);
} }
if (!this["private"] && !this.started && this.established) { if (!this["private"] && !this.started && this.established && settings.modules.enable_websocket_roomlist) {
roomlist["delete"](this.name); roomlist["delete"](this.name);
} }
}; };
...@@ -498,7 +500,7 @@ ...@@ -498,7 +500,7 @@
} }
} }
if (this.established) { if (this.established) {
if (!this["private"] && !this.started) { if (!this["private"] && !this.started && settings.modules.enable_websocket_roomlist) {
roomlist.update(this); roomlist.update(this);
} }
client.server.connect(this.port, '127.0.0.1', function() { client.server.connect(this.port, '127.0.0.1', function() {
...@@ -532,7 +534,7 @@ ...@@ -532,7 +534,7 @@
} }
if (this.players.length) { if (this.players.length) {
ygopro.stoc_send_chat_to_room(this, client.name + " " + '离开了游戏' + (error ? ": " + error : '')); ygopro.stoc_send_chat_to_room(this, client.name + " " + '离开了游戏' + (error ? ": " + error : ''));
if (!this["private"] && !this.started) { if (!this["private"] && !this.started && settings.modules.enable_websocket_roomlist) {
roomlist.update(this); roomlist.update(this);
} }
} else { } else {
......
// Generated by CoffeeScript 1.9.3 // Generated by CoffeeScript 1.10.0
(function() { (function() {
var WebSocketServer, _delete, broadcast, create, init, room_data, server, update; var WebSocketServer, _delete, broadcast, create, init, room_data, server, update;
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
connection = ref[i]; connection = ref[i];
try { try {
results.push(connection.send(message)); results.push(connection.send(message));
} catch (_error) {} } catch (undefined) {}
} }
return results; return results;
}; };
......
...@@ -10,7 +10,7 @@ var sqlite3 = require('sqlite3').verbose(); ...@@ -10,7 +10,7 @@ var sqlite3 = require('sqlite3').verbose();
var fs = require('fs'); var fs = require('fs');
var constants = require('./constants.json'); var constants = require('./constants.json');
var DECKPATH="S:\\deck\\replays" var DECKPATH="C:\\deck\\deck"
var DBFILE="F:\\Works\\deck\\cards.cdb" var DBFILE="F:\\Works\\deck\\cards.cdb"
var ALL_MAIN_CARDS={}; var ALL_MAIN_CARDS={};
...@@ -47,12 +47,12 @@ function add_to_all_list(LIST,id,use) { ...@@ -47,12 +47,12 @@ function add_to_all_list(LIST,id,use) {
function read_deck_file(filename) { function read_deck_file(filename) {
console.log("reading "+filename); console.log("reading "+filename);
var deck_text=fs.readFileSync(DECKPATH+"\\"+filename,{encoding:"ASCII"}) var deck_text=fs.readFileSync(DECKPATH+"\\"+filename,{encoding:"ASCII"})
var deck_array=deck_text.split("\r\n"); var deck_array=deck_text.split("\n");
var deck_main={}; var deck_main={};
var deck_side={}; var deck_side={};
var current_deck=deck_main; var current_deck=deck_main;
for (var i in deck_array) { for (var i in deck_array) {
if (deck_array[i]=="!side") if (deck_array[i].indexOf("!side")>=0)
current_deck=deck_side; current_deck=deck_side;
var card=parseInt(deck_array[i]); var card=parseInt(deck_array[i]);
if (!isNaN(card)) { if (!isNaN(card)) {
...@@ -150,7 +150,9 @@ function read_decks() { ...@@ -150,7 +150,9 @@ function read_decks() {
} }
} }
output_csv(ALL_MAIN_CARDS,"main.csv"); output_csv(ALL_MAIN_CARDS,"main.csv");
//output_csv(ALL_SIDE_CARDS,"side.csv"); if (ALL_SIDE_CARDS.length) {
output_csv(ALL_SIDE_CARDS,"side.csv");
}
} }
function output_csv(list,filename) { function output_csv(list,filename) {
......
...@@ -225,6 +225,18 @@ var pushDatas = function() { ...@@ -225,6 +225,18 @@ var pushDatas = function() {
} catch (error) { } catch (error) {
sendResponse("git error: "+error.stdout); sendResponse("git error: "+error.stdout);
} }
var proc2 = spawn("git", ["push", "gitcafe", "master:gitcafe-pages"], { cwd: config.git_html_path, env: process.env });
proc2.stdout.setEncoding('utf8');
proc2.stdout.on('data', function(data) {
sendResponse("git push: "+data);
});
proc2.stderr.setEncoding('utf8');
proc2.stderr.on('data', function(data) {
sendResponse("git push error: "+data);
});
proc2.on('close', function (code) {
sendResponse("gitcafe上传完成。");
});
var proc = spawn("git", ["push"], { cwd: config.git_html_path, env: process.env }); var proc = spawn("git", ["push"], { cwd: config.git_html_path, env: process.env });
proc.stdout.setEncoding('utf8'); proc.stdout.setEncoding('utf8');
proc.stdout.on('data', function(data) { proc.stdout.on('data', function(data) {
...@@ -235,7 +247,7 @@ var pushDatas = function() { ...@@ -235,7 +247,7 @@ var pushDatas = function() {
sendResponse("git push: "+data); sendResponse("git push: "+data);
}); });
proc.on('close', function (code) { proc.on('close', function (code) {
sendResponse("命令执行完成。"); sendResponse("github上传完成。");
}); });
} }
......
...@@ -34,7 +34,7 @@ settings.version = parseInt(fs.readFileSync('ygopro/gframe/game.cpp', 'utf8').ma ...@@ -34,7 +34,7 @@ settings.version = parseInt(fs.readFileSync('ygopro/gframe/game.cpp', 'utf8').ma
#组件 #组件
ygopro = require './ygopro.js' ygopro = require './ygopro.js'
Room = require './room.js' Room = require './room.js'
roomlist = require './roomlist.js' roomlist = require './roomlist.js' if settings.modules.enable_websocket_roomlist
users_cache = {} users_cache = {}
...@@ -643,6 +643,7 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)-> ...@@ -643,6 +643,7 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
if dialogues[card] if dialogues[card]
for line in _.lines dialogues[card][Math.floor(Math.random() * dialogues[card].length)] for line in _.lines dialogues[card][Math.floor(Math.random() * dialogues[card].length)]
ygopro.stoc_send_chat client, line, 15 ygopro.stoc_send_chat client, line, 15
return
#房间管理 #房间管理
ygopro.ctos_follow 'HS_KICK', true, (buffer, info, client, server)-> ygopro.ctos_follow 'HS_KICK', true, (buffer, info, client, server)->
...@@ -730,7 +731,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)-> ...@@ -730,7 +731,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)->
return unless client.room return unless client.room
unless client.room.started #first start unless client.room.started #first start
client.room.started = true client.room.started = true
roomlist.delete client.room.name unless client.room.private roomlist.delete client.room.name if settings.modules.enable_websocket_roomlist and not client.room.private
#client.room.duels = [] #client.room.duels = []
client.room.dueling_players = [] client.room.dueling_players = []
for player in client.room.players when player.pos != 7 for player in client.room.players when player.pos != 7
...@@ -897,7 +898,7 @@ if settings.modules.http ...@@ -897,7 +898,7 @@ if settings.modules.http
http_server = http.createServer(requestListener) http_server = http.createServer(requestListener)
http_server.listen settings.modules.http.port http_server.listen settings.modules.http.port
if settings.modules.http.ssl if settings.modules.http.ssl.enabled
https = require 'https' https = require 'https'
options = options =
cert: fs.readFileSync(settings.modules.http.ssl.cert) cert: fs.readFileSync(settings.modules.http.ssl.cert)
......
// Generated by CoffeeScript 1.9.3 // Generated by CoffeeScript 1.10.0
(function() { (function() {
var Graveyard, Room, _, bunyan, crypto, debug, dialogues, execFile, fs, http, http_server, https, https_server, log, moment, net, options, os, path, pg, request, requestListener, roomlist, settings, tips, tribute, url, users_cache, wait_room_start, ygopro; var Graveyard, Room, _, bunyan, crypto, debug, dialogues, execFile, fs, http, http_server, https, https_server, log, moment, net, options, os, path, pg, request, requestListener, roomlist, settings, tips, tribute, url, users_cache, wait_room_start, ygopro;
...@@ -44,7 +44,9 @@ ...@@ -44,7 +44,9 @@
Room = require('./room.js'); Room = require('./room.js');
roomlist = require('./roomlist.js'); if (settings.modules.enable_websocket_roomlist) {
roomlist = require('./roomlist.js');
}
users_cache = {}; users_cache = {};
...@@ -629,7 +631,7 @@ ...@@ -629,7 +631,7 @@
} }
ygopro.stoc_follow('GAME_MSG', false, function(buffer, info, client, server) { ygopro.stoc_follow('GAME_MSG', false, function(buffer, info, client, server) {
var card, k, len, line, msg, playertype, pos, ref, ref1, ref2, results, val; var card, k, len, line, msg, playertype, pos, ref, ref1, ref2, val;
msg = buffer.readInt8(0); msg = buffer.readInt8(0);
if (msg >= 10 && msg < 30) { if (msg >= 10 && msg < 30) {
client.room.waiting_for_player = client; client.room.waiting_for_player = client;
...@@ -692,12 +694,10 @@ ...@@ -692,12 +694,10 @@
card = buffer.readUInt32LE(1); card = buffer.readUInt32LE(1);
if (dialogues[card]) { if (dialogues[card]) {
ref2 = _.lines(dialogues[card][Math.floor(Math.random() * dialogues[card].length)]); ref2 = _.lines(dialogues[card][Math.floor(Math.random() * dialogues[card].length)]);
results = [];
for (k = 0, len = ref2.length; k < len; k++) { for (k = 0, len = ref2.length; k < len; k++) {
line = ref2[k]; line = ref2[k];
results.push(ygopro.stoc_send_chat(client, line, 15)); ygopro.stoc_send_chat(client, line, 15);
} }
return results;
} }
} }
} }
...@@ -838,7 +838,7 @@ ...@@ -838,7 +838,7 @@
} }
if (!client.room.started) { if (!client.room.started) {
client.room.started = true; client.room.started = true;
if (!client.room["private"]) { if (settings.modules.enable_websocket_roomlist && !client.room["private"]) {
roomlist["delete"](client.room.name); roomlist["delete"](client.room.name);
} }
client.room.dueling_players = []; client.room.dueling_players = [];
...@@ -1082,7 +1082,7 @@ ...@@ -1082,7 +1082,7 @@
}; };
http_server = http.createServer(requestListener); http_server = http.createServer(requestListener);
http_server.listen(settings.modules.http.port); http_server.listen(settings.modules.http.port);
if (settings.modules.http.ssl) { if (settings.modules.http.ssl.enabled) {
https = require('https'); https = require('https');
options = { options = {
cert: fs.readFileSync(settings.modules.http.ssl.cert), cert: fs.readFileSync(settings.modules.http.ssl.cert),
......
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