Commit 7b36b356 authored by nanahira's avatar nanahira

merge

parents 02fc8cdc 7e5b710c
...@@ -99,6 +99,7 @@ ...@@ -99,6 +99,7 @@
"reconnect": { "reconnect": {
"enabled": true, "enabled": true,
"auto_surrender_after_disconnect": false, "auto_surrender_after_disconnect": false,
"allow_kick_reconnect": true,
"wait_time": 60000 "wait_time": 60000
}, },
"heartbeat_detection": { "heartbeat_detection": {
......
...@@ -146,6 +146,7 @@ ...@@ -146,6 +146,7 @@
"deck_incorrect_reconnect": "Please pick your previous deck.", "deck_incorrect_reconnect": "Please pick your previous deck.",
"reconnect_failed": "Reconnect failed.", "reconnect_failed": "Reconnect failed.",
"reconnecting_to_room": "Reconnecting to server...", "reconnecting_to_room": "Reconnecting to server...",
"reconnect_kicked": "You are kicked out because you're logined in on other devices.",
"challonge_user_not_found": "You are not a participant of the tournament.", "challonge_user_not_found": "You are not a participant of the tournament.",
"challonge_match_load_failed": "Failed loading tournament info.", "challonge_match_load_failed": "Failed loading tournament info.",
"challonge_match_not_found": "Your current match was not found.", "challonge_match_not_found": "Your current match was not found.",
...@@ -460,6 +461,7 @@ ...@@ -460,6 +461,7 @@
"deck_incorrect_reconnect": "请选择你在本局决斗中使用的卡组。", "deck_incorrect_reconnect": "请选择你在本局决斗中使用的卡组。",
"reconnect_failed": "重新连接失败。", "reconnect_failed": "重新连接失败。",
"reconnecting_to_room": "正在重新连接到服务器……", "reconnecting_to_room": "正在重新连接到服务器……",
"reconnect_kicked": "你的账号已经在其他设备登录,你被迫下线。",
"challonge_user_not_found": "未找到你的参赛信息。", "challonge_user_not_found": "未找到你的参赛信息。",
"challonge_match_load_failed": "读取比赛信息失败。", "challonge_match_load_failed": "读取比赛信息失败。",
"challonge_match_not_found": "你没有当前轮次的比赛。", "challonge_match_not_found": "你没有当前轮次的比赛。",
......
...@@ -49,6 +49,7 @@ import_datas = [ ...@@ -49,6 +49,7 @@ import_datas = [
"is_post_watcher", "is_post_watcher",
"retry_count", "retry_count",
"name", "name",
"pass",
"is_first", "is_first",
"lp", "lp",
"card_count", "card_count",
...@@ -586,7 +587,7 @@ CLIENT_reconnect_register = (client, room_id, error) -> ...@@ -586,7 +587,7 @@ CLIENT_reconnect_register = (client, room_id, error) ->
room = ROOM_all[room_id] room = ROOM_all[room_id]
if client.had_new_reconnection if client.had_new_reconnection
return false return false
if !settings.modules.reconnect.enabled or !room or client.system_kicked or client.flee_free or disconnect_list[CLIENT_get_authorize_key(client)] or client.is_post_watcher or !CLIENT_is_player(client, room) or !room.started or room.windbot or (settings.modules.reconnect.auto_surrender_after_disconnect and room.hostinfo.mode != 1) if !settings.modules.reconnect.enabled or !room or client.system_kicked or client.flee_free or disconnect_list[CLIENT_get_authorize_key(client)] or client.is_post_watcher or !CLIENT_is_player(client, room) or !room.started or room.windbot or (settings.modules.reconnect.auto_surrender_after_disconnect and room.hostinfo.mode != 1) or (room.random_type and room.max_player and room.get_disconnected_count() >= room.max_player - 1)
return false return false
# for player in room.players # for player in room.players
# if player != client and CLIENT_get_authorize_key(player) == CLIENT_get_authorize_key(client) # if player != client and CLIENT_get_authorize_key(player) == CLIENT_get_authorize_key(client)
...@@ -656,7 +657,7 @@ CLIENT_is_player = (client, room) -> ...@@ -656,7 +657,7 @@ CLIENT_is_player = (client, room) ->
break break
return is_player and client.pos <= 3 return is_player and client.pos <= 3
CLIENT_is_able_to_reconnect = (client) -> CLIENT_is_able_to_reconnect = (client, deckbuf) ->
unless settings.modules.reconnect.enabled unless settings.modules.reconnect.enabled
return false return false
if client.system_kicked if client.system_kicked
...@@ -668,13 +669,21 @@ CLIENT_is_able_to_reconnect = (client) -> ...@@ -668,13 +669,21 @@ CLIENT_is_able_to_reconnect = (client) ->
if !room if !room
CLIENT_reconnect_unregister(client) CLIENT_reconnect_unregister(client)
return false return false
# if disconnect_info.old_server.closed if deckbuf and !_.isEqual(deckbuf, disconnect_info.deckbuf)
# return false return false
# current_room = disconnect_info.room return true
# unless current_room and current_room.started
# return false CLIENT_get_kick_reconnect_target = (client, deckbuf) ->
# if client.is_post_watcher or !CLIENT_is_player(client, current_room) or (room.windbot and client.is_local) for room in ROOM_all when room.started and !room.windbot
# return false for player in room.get_playing_player() when !player.closed and player.name == client.name and player.pass == client.pass and (settings.modules.mycard.enabled or player.ip == client.ip) and (!deckbuf or _.isEqual(player.start_deckbuf, deckbuf))
return player
return null
CLIENT_is_able_to_kick_reconnect = (client, deckbuf) ->
unless settings.modules.reconnect.enabled and settings.modules.reconnect.allow_kick_reconnect
return false
if !CLIENT_get_kick_reconnect_target(client, deckbuf)
return false
return true return true
CLIENT_send_pre_reconnect_info = (client, room, old_client) -> CLIENT_send_pre_reconnect_info = (client, room, old_client) ->
...@@ -718,14 +727,18 @@ CLIENT_send_reconnect_info = (client, server, room) -> ...@@ -718,14 +727,18 @@ CLIENT_send_reconnect_info = (client, server, room) ->
return return
CLIENT_pre_reconnect = (client) -> CLIENT_pre_reconnect = (client) ->
if !CLIENT_is_able_to_reconnect(client) if CLIENT_is_able_to_reconnect(client)
return dinfo = disconnect_list[CLIENT_get_authorize_key(client)]
dinfo = disconnect_list[CLIENT_get_authorize_key(client)] client.pre_reconnecting = true
client.pre_deckbuf = dinfo.deckbuf client.pos = dinfo.old_client.pos
client.pre_reconnecting = true client.setTimeout(300000)
client.pos = dinfo.old_client.pos CLIENT_send_pre_reconnect_info(client, ROOM_all[dinfo.room_id], dinfo.old_client)
client.setTimeout(300000) else if CLIENT_is_able_to_kick_reconnect(client)
CLIENT_send_pre_reconnect_info(client, ROOM_all[dinfo.room_id], dinfo.old_client) player = CLIENT_get_kick_reconnect_target(client)
client.pre_reconnecting = true
client.pos = player.pos
client.setTimeout(300000)
CLIENT_send_pre_reconnect_info(client, ROOM_all[player.rid], player)
return return
CLIENT_reconnect = (client) -> CLIENT_reconnect = (client) ->
...@@ -754,6 +767,35 @@ CLIENT_reconnect = (client) -> ...@@ -754,6 +767,35 @@ CLIENT_reconnect = (client) ->
CLIENT_reconnect_unregister(client, true) CLIENT_reconnect_unregister(client, true)
return return
CLIENT_kick_reconnect = (client, deckbuf) ->
if !CLIENT_is_able_to_kick_reconnect(client)
ygopro.stoc_send_chat(client, "${reconnect_failed}", ygopro.constants.COLORS.RED)
CLIENT_kick(client)
return
client.pre_reconnecting = false
player = CLIENT_get_kick_reconnect_target(client, deckbuf)
room = ROOM_all[player.rid]
current_old_server = client.server
client.server = player.server
client.server.client = client
ygopro.stoc_send_chat(player, "${reconnect_kicked}", ygopro.constants.COLORS.RED)
player.server = null
player.had_new_reconnection = true
CLIENT_kick(player)
current_old_server.client = null
current_old_server.had_new_reconnection = true
current_old_server.destroy()
client.established = true
client.pre_establish_buffers = []
if room.random_type or room.arena
room.last_active_time = moment()
CLIENT_import_data(client, player, room)
CLIENT_send_reconnect_info(client, client.server, room)
#console.log("#{client.name} ${reconnect_to_game}")
ygopro.stoc_send_chat_to_room(room, "#{client.name} ${reconnect_to_game}")
CLIENT_reconnect_unregister(client, true)
return
if settings.modules.reconnect.enabled if settings.modules.reconnect.enabled
disconnect_list = {} # {old_client, old_server, room_id, timeout, deckbuf} disconnect_list = {} # {old_client, old_server, room_id, timeout, deckbuf}
...@@ -1061,13 +1103,12 @@ class Room ...@@ -1061,13 +1103,12 @@ class Room
return return
return host_player return host_player
is_has_disconnected_player: -> get_disconnected_count: ->
if !settings.modules.reconnect.enabled if !settings.modules.reconnect.enabled
return false return 0
found = false found = 0
for player in @get_playing_player() when player.closed for player in @get_playing_player() when player.closed
found = true found++
break
return found return found
add_windbot: (botdata)-> add_windbot: (botdata)->
...@@ -1445,7 +1486,8 @@ ygopro.ctos_follow 'PLAYER_INFO', true, (buffer, info, client, server)-> ...@@ -1445,7 +1486,8 @@ ygopro.ctos_follow 'PLAYER_INFO', true, (buffer, info, client, server)->
ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)-> ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
#log.info info #log.info info
info.pass=info.pass.trim() info.pass=info.pass.trim()
if CLIENT_is_able_to_reconnect(client) client.pass = info.pass
if CLIENT_is_able_to_reconnect(client) or CLIENT_is_able_to_kick_reconnect(client)
CLIENT_pre_reconnect(client) CLIENT_pre_reconnect(client)
return return
else if settings.modules.stop else if settings.modules.stop
...@@ -2756,8 +2798,13 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)-> ...@@ -2756,8 +2798,13 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server)-> ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server)->
if settings.modules.reconnect.enabled and client.pre_reconnecting if settings.modules.reconnect.enabled and client.pre_reconnecting
if _.isEqual(buffer, client.pre_deckbuf) if !CLIENT_is_able_to_reconnect(client) and !CLIENT_is_able_to_kick_reconnect(client)
ygopro.stoc_send_chat(client, "${reconnect_failed}", ygopro.constants.COLORS.RED)
CLIENT_kick(client)
else if CLIENT_is_able_to_reconnect(client, buffer)
CLIENT_reconnect(client) CLIENT_reconnect(client)
else if CLIENT_is_able_to_kick_reconnect(client, buffer)
CLIENT_kick_reconnect(client, buffer)
else else
ygopro.stoc_send_chat(client, "${deck_incorrect_reconnect}", ygopro.constants.COLORS.RED) ygopro.stoc_send_chat(client, "${deck_incorrect_reconnect}", ygopro.constants.COLORS.RED)
ygopro.stoc_send(client, 'ERROR_MSG', { ygopro.stoc_send(client, 'ERROR_MSG', {
...@@ -3053,7 +3100,7 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)-> ...@@ -3053,7 +3100,7 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
if settings.modules.random_duel.enabled if settings.modules.random_duel.enabled
setInterval ()-> setInterval ()->
for room in ROOM_all when room and room.started and room.random_type and room.last_active_time and room.waiting_for_player and !room.is_has_disconnected_player() for room in ROOM_all when room and room.started and room.random_type and room.last_active_time and room.waiting_for_player and room.get_disconnected_count() == 0
time_passed = Math.floor((moment() - room.last_active_time) / 1000) time_passed = Math.floor((moment() - room.last_active_time) / 1000)
#log.info time_passed #log.info time_passed
if time_passed >= settings.modules.random_duel.hang_timeout if time_passed >= settings.modules.random_duel.hang_timeout
...@@ -3071,7 +3118,7 @@ if settings.modules.random_duel.enabled ...@@ -3071,7 +3118,7 @@ if settings.modules.random_duel.enabled
if settings.modules.mycard.enabled if settings.modules.mycard.enabled
setInterval ()-> setInterval ()->
for room in ROOM_all when room and room.started and room.arena and room.last_active_time and room.waiting_for_player and !room.is_has_disconnected_player() for room in ROOM_all when room and room.started and room.arena and room.last_active_time and room.waiting_for_player and room.get_disconnected_count() == 0
time_passed = Math.floor((moment() - room.last_active_time) / 1000) time_passed = Math.floor((moment() - room.last_active_time) / 1000)
#log.info time_passed #log.info time_passed
if time_passed >= settings.modules.random_duel.hang_timeout if time_passed >= settings.modules.random_duel.hang_timeout
......
// Generated by CoffeeScript 1.12.7 // Generated by CoffeeScript 1.12.7
(function() { (function() {
var CLIENT_check_vip, CLIENT_get_authorize_key, CLIENT_heartbeat_register, CLIENT_heartbeat_unregister, CLIENT_import_data, CLIENT_is_able_to_reconnect, CLIENT_is_player, CLIENT_kick, CLIENT_pre_reconnect, CLIENT_reconnect, CLIENT_reconnect_register, CLIENT_reconnect_unregister, CLIENT_send_pre_reconnect_info, CLIENT_send_reconnect_info, CLIENT_send_vip_status, CLIENT_use_cdkey, Cloud_replay_ids, ROOM_all, ROOM_bad_ip, ROOM_ban_player, ROOM_clear_disconnect, ROOM_connected_ip, ROOM_find_by_name, ROOM_find_by_port, ROOM_find_by_title, ROOM_find_or_create_ai, ROOM_find_or_create_by_name, ROOM_find_or_create_random, ROOM_players_banned, ROOM_players_oppentlist, ROOM_unwelcome, ROOM_validate, Room, SERVER_clear_disconnect, VIP_generate_cdkeys, _, addCallback, badwords, ban_user, bunyan, challonge, chat_color, concat_name, config, cppversion, crypto, date, default_config, default_data, dialogues, disconnect_list, duel_log, e, exec, execFile, fs, geoip, get_memory_usage, http, http_server, https, https_server, import_datas, j, k, l, len, len1, lflists, list, loadJSON, load_dialogues, load_dialogues_custom, load_tips, load_words, log, long_resolve_cards, memory_usage, merge, moment, net, oldbadwords, oldconfig, olddialogues, oldduellog, oldtips, oldwords, options, os, path, pgClient, pg_client, pg_query, redis, redisdb, ref, ref1, ref2, release_disconnect, report_to_big_brother, request, requestListener, roomlist, setting_change, setting_save, settings, spawn, spawnSync, tips, url, users_cache, v, vip_info, wait_room_start, wait_room_start_arena, windbot_bin, windbot_parameters, windbot_process, windbots, words, ygopro, zlib; var CLIENT_check_vip, CLIENT_get_authorize_key, CLIENT_get_kick_reconnect_target, CLIENT_heartbeat_register, CLIENT_heartbeat_unregister, CLIENT_import_data, CLIENT_is_able_to_kick_reconnect, CLIENT_is_able_to_reconnect, CLIENT_is_player, CLIENT_kick, CLIENT_kick_reconnect, CLIENT_pre_reconnect, CLIENT_reconnect, CLIENT_reconnect_register, CLIENT_reconnect_unregister, CLIENT_send_pre_reconnect_info, CLIENT_send_reconnect_info, CLIENT_send_vip_status, CLIENT_use_cdkey, Cloud_replay_ids, ROOM_all, ROOM_bad_ip, ROOM_ban_player, ROOM_clear_disconnect, ROOM_connected_ip, ROOM_find_by_name, ROOM_find_by_port, ROOM_find_by_title, ROOM_find_or_create_ai, ROOM_find_or_create_by_name, ROOM_find_or_create_random, ROOM_players_banned, ROOM_players_oppentlist, ROOM_unwelcome, ROOM_validate, Room, SERVER_clear_disconnect, VIP_generate_cdkeys, _, addCallback, badwords, ban_user, bunyan, challonge, chat_color, concat_name, config, cppversion, crypto, date, default_config, default_data, dialogues, disconnect_list, duel_log, e, exec, execFile, fs, geoip, get_memory_usage, http, http_server, https, https_server, import_datas, j, k, l, len, len1, lflists, list, loadJSON, load_dialogues, load_dialogues_custom, load_tips, load_words, log, long_resolve_cards, memory_usage, merge, moment, net, oldbadwords, oldconfig, olddialogues, oldduellog, oldtips, oldwords, options, os, path, pgClient, pg_client, pg_query, redis, redisdb, ref, ref1, ref2, release_disconnect, report_to_big_brother, request, requestListener, roomlist, setting_change, setting_save, settings, spawn, spawnSync, tips, url, users_cache, v, vip_info, wait_room_start, wait_room_start_arena, windbot_bin, windbot_parameters, windbot_process, windbots, words, ygopro, zlib;
net = require('net'); net = require('net');
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
} }
}); });
import_datas = ["abuse_count", "vip", "vpass", "rag", "rid", "is_post_watcher", "retry_count", "name", "is_first", "lp", "card_count", "is_host", "pos", "surrend_confirm", "kick_count", "deck_saved", "main", "side", "side_interval", "side_tcount", "selected_preduel", "last_game_msg", "last_game_msg_title", "last_hint_msg", "start_deckbuf", "challonge_info", "ready_trap"]; import_datas = ["abuse_count", "vip", "vpass", "rag", "rid", "is_post_watcher", "retry_count", "name", "pass", "is_first", "lp", "card_count", "is_host", "pos", "surrend_confirm", "kick_count", "deck_saved", "main", "side", "side_interval", "side_tcount", "selected_preduel", "last_game_msg", "last_game_msg_title", "last_hint_msg", "start_deckbuf", "challonge_info", "ready_trap"];
merge = require('deepmerge'); merge = require('deepmerge');
...@@ -778,7 +778,7 @@ ...@@ -778,7 +778,7 @@
if (client.had_new_reconnection) { if (client.had_new_reconnection) {
return false; return false;
} }
if (!settings.modules.reconnect.enabled || !room || client.system_kicked || client.flee_free || disconnect_list[CLIENT_get_authorize_key(client)] || client.is_post_watcher || !CLIENT_is_player(client, room) || !room.started || room.windbot || (settings.modules.reconnect.auto_surrender_after_disconnect && room.hostinfo.mode !== 1)) { if (!settings.modules.reconnect.enabled || !room || client.system_kicked || client.flee_free || disconnect_list[CLIENT_get_authorize_key(client)] || client.is_post_watcher || !CLIENT_is_player(client, room) || !room.started || room.windbot || (settings.modules.reconnect.auto_surrender_after_disconnect && room.hostinfo.mode !== 1) || (room.random_type && room.max_player && room.get_disconnected_count() >= room.max_player - 1)) {
return false; return false;
} }
dinfo = { dinfo = {
...@@ -875,7 +875,7 @@ ...@@ -875,7 +875,7 @@
return is_player && client.pos <= 3; return is_player && client.pos <= 3;
}; };
CLIENT_is_able_to_reconnect = function(client) { CLIENT_is_able_to_reconnect = function(client, deckbuf) {
var disconnect_info, room; var disconnect_info, room;
if (!settings.modules.reconnect.enabled) { if (!settings.modules.reconnect.enabled) {
return false; return false;
...@@ -892,6 +892,36 @@ ...@@ -892,6 +892,36 @@
CLIENT_reconnect_unregister(client); CLIENT_reconnect_unregister(client);
return false; return false;
} }
if (deckbuf && !_.isEqual(deckbuf, disconnect_info.deckbuf)) {
return false;
}
return true;
};
CLIENT_get_kick_reconnect_target = function(client, deckbuf) {
var len2, len3, m, n, player, ref3, room;
for (m = 0, len2 = ROOM_all.length; m < len2; m++) {
room = ROOM_all[m];
if (room.started && !room.windbot) {
ref3 = room.get_playing_player();
for (n = 0, len3 = ref3.length; n < len3; n++) {
player = ref3[n];
if (!player.closed && player.name === client.name && player.pass === client.pass && (settings.modules.mycard.enabled || player.ip === client.ip) && (!deckbuf || _.isEqual(player.start_deckbuf, deckbuf))) {
return player;
}
}
}
}
return null;
};
CLIENT_is_able_to_kick_reconnect = function(client, deckbuf) {
if (!(settings.modules.reconnect.enabled && settings.modules.reconnect.allow_kick_reconnect)) {
return false;
}
if (!CLIENT_get_kick_reconnect_target(client, deckbuf)) {
return false;
}
return true; return true;
}; };
...@@ -945,16 +975,20 @@ ...@@ -945,16 +975,20 @@
}; };
CLIENT_pre_reconnect = function(client) { CLIENT_pre_reconnect = function(client) {
var dinfo; var dinfo, player;
if (!CLIENT_is_able_to_reconnect(client)) { if (CLIENT_is_able_to_reconnect(client)) {
return; dinfo = disconnect_list[CLIENT_get_authorize_key(client)];
client.pre_reconnecting = true;
client.pos = dinfo.old_client.pos;
client.setTimeout(300000);
CLIENT_send_pre_reconnect_info(client, ROOM_all[dinfo.room_id], dinfo.old_client);
} else if (CLIENT_is_able_to_kick_reconnect(client)) {
player = CLIENT_get_kick_reconnect_target(client);
client.pre_reconnecting = true;
client.pos = player.pos;
client.setTimeout(300000);
CLIENT_send_pre_reconnect_info(client, ROOM_all[player.rid], player);
} }
dinfo = disconnect_list[CLIENT_get_authorize_key(client)];
client.pre_deckbuf = dinfo.deckbuf;
client.pre_reconnecting = true;
client.pos = dinfo.old_client.pos;
client.setTimeout(300000);
CLIENT_send_pre_reconnect_info(client, ROOM_all[dinfo.room_id], dinfo.old_client);
}; };
CLIENT_reconnect = function(client) { CLIENT_reconnect = function(client) {
...@@ -985,6 +1019,37 @@ ...@@ -985,6 +1019,37 @@
CLIENT_reconnect_unregister(client, true); CLIENT_reconnect_unregister(client, true);
}; };
CLIENT_kick_reconnect = function(client, deckbuf) {
var current_old_server, player, room;
if (!CLIENT_is_able_to_kick_reconnect(client)) {
ygopro.stoc_send_chat(client, "${reconnect_failed}", ygopro.constants.COLORS.RED);
CLIENT_kick(client);
return;
}
client.pre_reconnecting = false;
player = CLIENT_get_kick_reconnect_target(client, deckbuf);
room = ROOM_all[player.rid];
current_old_server = client.server;
client.server = player.server;
client.server.client = client;
ygopro.stoc_send_chat(player, "${reconnect_kicked}", ygopro.constants.COLORS.RED);
player.server = null;
player.had_new_reconnection = true;
CLIENT_kick(player);
current_old_server.client = null;
current_old_server.had_new_reconnection = true;
current_old_server.destroy();
client.established = true;
client.pre_establish_buffers = [];
if (room.random_type || room.arena) {
room.last_active_time = moment();
}
CLIENT_import_data(client, player, room);
CLIENT_send_reconnect_info(client, client.server, room);
ygopro.stoc_send_chat_to_room(room, client.name + " ${reconnect_to_game}");
CLIENT_reconnect_unregister(client, true);
};
if (settings.modules.reconnect.enabled) { if (settings.modules.reconnect.enabled) {
disconnect_list = {}; disconnect_list = {};
} }
...@@ -1379,20 +1444,18 @@ ...@@ -1379,20 +1444,18 @@
return host_player; return host_player;
}; };
Room.prototype.is_has_disconnected_player = function() { Room.prototype.get_disconnected_count = function() {
var found, len2, m, player, ref3; var found, len2, m, player, ref3;
if (!settings.modules.reconnect.enabled) { if (!settings.modules.reconnect.enabled) {
return false; return 0;
} }
found = false; found = 0;
ref3 = this.get_playing_player(); ref3 = this.get_playing_player();
for (m = 0, len2 = ref3.length; m < len2; m++) { for (m = 0, len2 = ref3.length; m < len2; m++) {
player = ref3[m]; player = ref3[m];
if (!player.closed) { if (player.closed) {
continue; found++;
} }
found = true;
break;
} }
return found; return found;
}; };
...@@ -1831,7 +1894,8 @@ ...@@ -1831,7 +1894,8 @@
ygopro.ctos_follow('JOIN_GAME', false, function(buffer, info, client, server) { ygopro.ctos_follow('JOIN_GAME', false, function(buffer, info, client, server) {
var check, decrypted_buffer, finish, i, id, len2, len3, len4, m, n, name, o, pre_room, ref3, ref4, ref5, replay_id, room, secret; var check, decrypted_buffer, finish, i, id, len2, len3, len4, m, n, name, o, pre_room, ref3, ref4, ref5, replay_id, room, secret;
info.pass = info.pass.trim(); info.pass = info.pass.trim();
if (CLIENT_is_able_to_reconnect(client)) { client.pass = info.pass;
if (CLIENT_is_able_to_reconnect(client) || CLIENT_is_able_to_kick_reconnect(client)) {
CLIENT_pre_reconnect(client); CLIENT_pre_reconnect(client);
return; return;
} else if (settings.modules.stop) { } else if (settings.modules.stop) {
...@@ -3471,8 +3535,13 @@ ...@@ -3471,8 +3535,13 @@
ygopro.ctos_follow('UPDATE_DECK', true, function(buffer, info, client, server) { ygopro.ctos_follow('UPDATE_DECK', true, function(buffer, info, client, server) {
var buff_main, buff_side, card, current_deck, deck, deck_array, deck_main, deck_side, deck_text, deckbuf, decks, found_deck, i, len2, len3, line, m, n, oppo_pos, room, struct, win_pos; var buff_main, buff_side, card, current_deck, deck, deck_array, deck_main, deck_side, deck_text, deckbuf, decks, found_deck, i, len2, len3, line, m, n, oppo_pos, room, struct, win_pos;
if (settings.modules.reconnect.enabled && client.pre_reconnecting) { if (settings.modules.reconnect.enabled && client.pre_reconnecting) {
if (_.isEqual(buffer, client.pre_deckbuf)) { if (!CLIENT_is_able_to_reconnect(client) && !CLIENT_is_able_to_kick_reconnect(client)) {
ygopro.stoc_send_chat(client, "${reconnect_failed}", ygopro.constants.COLORS.RED);
CLIENT_kick(client);
} else if (CLIENT_is_able_to_reconnect(client, buffer)) {
CLIENT_reconnect(client); CLIENT_reconnect(client);
} else if (CLIENT_is_able_to_kick_reconnect(client, buffer)) {
CLIENT_kick_reconnect(client, buffer);
} else { } else {
ygopro.stoc_send_chat(client, "${deck_incorrect_reconnect}", ygopro.constants.COLORS.RED); ygopro.stoc_send_chat(client, "${deck_incorrect_reconnect}", ygopro.constants.COLORS.RED);
ygopro.stoc_send(client, 'ERROR_MSG', { ygopro.stoc_send(client, 'ERROR_MSG', {
...@@ -3905,7 +3974,7 @@ ...@@ -3905,7 +3974,7 @@
var len2, m, room, time_passed; var len2, m, room, time_passed;
for (m = 0, len2 = ROOM_all.length; m < len2; m++) { for (m = 0, len2 = ROOM_all.length; m < len2; m++) {
room = ROOM_all[m]; room = ROOM_all[m];
if (!(room && room.started && room.random_type && room.last_active_time && room.waiting_for_player && !room.is_has_disconnected_player())) { if (!(room && room.started && room.random_type && room.last_active_time && room.waiting_for_player && room.get_disconnected_count() === 0)) {
continue; continue;
} }
time_passed = Math.floor((moment() - room.last_active_time) / 1000); time_passed = Math.floor((moment() - room.last_active_time) / 1000);
...@@ -3928,7 +3997,7 @@ ...@@ -3928,7 +3997,7 @@
var len2, m, room, time_passed; var len2, m, room, time_passed;
for (m = 0, len2 = ROOM_all.length; m < len2; m++) { for (m = 0, len2 = ROOM_all.length; m < len2; m++) {
room = ROOM_all[m]; room = ROOM_all[m];
if (!(room && room.started && room.arena && room.last_active_time && room.waiting_for_player && !room.is_has_disconnected_player())) { if (!(room && room.started && room.arena && room.last_active_time && room.waiting_for_player && room.get_disconnected_count() === 0)) {
continue; continue;
} }
time_passed = Math.floor((moment() - room.last_active_time) / 1000); time_passed = Math.floor((moment() - room.last_active_time) / 1000);
......
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