Commit 0f5c4d51 authored by nanahira's avatar nanahira

update

parent 01274c16
......@@ -425,10 +425,12 @@ CLIENT_get_authorize_key = (client) ->
else
return client.ip
CLIENT_reconnect_unregister = (client, reconnected) ->
CLIENT_reconnect_unregister = (client, reconnected, exact) ->
if !settings.modules.reconnect.enabled
return false
if disconnect_list[CLIENT_get_authorize_key(client)]
if exact and disconnect_list[CLIENT_get_authorize_key(client)].old_client != client
return false
release_disconnect(disconnect_list[CLIENT_get_authorize_key(client)], reconnected)
delete disconnect_list[CLIENT_get_authorize_key(client)]
return true
......@@ -438,8 +440,11 @@ CLIENT_reconnect_register = (client, room_id, error) ->
room = ROOM_all[room_id]
if client.had_new_reconnection
return false
if !settings.modules.reconnect.enabled or client.system_kicked 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 and client.is_local) 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 disconnect_list[CLIENT_get_authorize_key(client)] or client.is_post_watcher or !CLIENT_is_player(client, room) or !room.started or (room.windbot and client.is_local) or (settings.modules.reconnect.auto_surrender_after_disconnect and room.hostinfo.mode != 1)
return false
for player in room.players
if player != client and CLIENT_get_authorize_key(player) == CLIENT_get_authorize_key(client)
return false # some issues may occur in this case, so return false
dinfo = {
room_id: room_id,
old_client: client,
......@@ -497,13 +502,22 @@ CLIENT_import_data = (client, old_client, room) ->
return
SERVER_clear_disconnect = (server) ->
return unless settings.modules.reconnect.enabled
return false unless settings.modules.reconnect.enabled
for k,v of disconnect_list
if v and server == v.old_server
release_disconnect(v)
delete disconnect_list[k]
return
return
return true
return false
ROOM_clear_disconnect = (room_id) ->
return false unless settings.modules.reconnect.enabled
for k,v of disconnect_list
if v and room_id == v.room_id
release_disconnect(v)
delete disconnect_list[k]
return true
return false
CLIENT_is_player = (client, room) ->
is_player = false
......@@ -836,11 +850,7 @@ class Room
@deleted = true
index = _.indexOf(ROOM_all, this)
if settings.modules.reconnect.enabled
for k,v of disconnect_list
if v and index == v.room_id
release_disconnect(v)
delete disconnect_list[k]
break
ROOM_clear_disconnect(index)
ROOM_all[index] = null unless index == -1
#ROOM_all.splice(index, 1) unless index == -1
roomlist.delete this if !@windbot and @established and settings.modules.http.websocket_roomlist
......@@ -925,7 +935,7 @@ class Room
@process.kill()
#client.room = null
this.delete()
if !CLIENT_reconnect_unregister(client)
if !CLIENT_reconnect_unregister(client, false, true)
client.server.destroy()
return
......
// Generated by CoffeeScript 1.12.7
(function() {
var CLIENT_get_authorize_key, 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, Cloud_replay_ids, ROOM_all, ROOM_bad_ip, ROOM_ban_player, 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, _, addCallback, badwords, ban_user, bunyan, chat_color, 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, j, l, len, len1, lflists, list, loadJSON, load_dialogues, load_tips, log, memory_usage, merge, moment, net, oldbadwords, oldconfig, olddialogues, oldduellog, oldtips, options, os, path, pgClient, pg_client, pg_query, redis, redisdb, ref, ref1, release_disconnect, report_to_big_brother, request, requestListener, roomlist, setting_change, setting_save, settings, spawn, spawnSync, tips, url, users_cache, wait_room_start, wait_room_start_arena, windbot_bin, windbot_parameters, windbot_process, windbots, ygopro, zlib;
var CLIENT_get_authorize_key, 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, 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, _, addCallback, badwords, ban_user, bunyan, chat_color, 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, j, l, len, len1, lflists, list, loadJSON, load_dialogues, load_tips, log, memory_usage, merge, moment, net, oldbadwords, oldconfig, olddialogues, oldduellog, oldtips, options, os, path, pgClient, pg_client, pg_query, redis, redisdb, ref, ref1, release_disconnect, report_to_big_brother, request, requestListener, roomlist, setting_change, setting_save, settings, spawn, spawnSync, tips, url, users_cache, wait_room_start, wait_room_start_arena, windbot_bin, windbot_parameters, windbot_process, windbots, ygopro, zlib;
net = require('net');
......@@ -585,11 +585,14 @@
}
};
CLIENT_reconnect_unregister = function(client, reconnected) {
CLIENT_reconnect_unregister = function(client, reconnected, exact) {
if (!settings.modules.reconnect.enabled) {
return false;
}
if (disconnect_list[CLIENT_get_authorize_key(client)]) {
if (exact && disconnect_list[CLIENT_get_authorize_key(client)].old_client !== client) {
return false;
}
release_disconnect(disconnect_list[CLIENT_get_authorize_key(client)], reconnected);
delete disconnect_list[CLIENT_get_authorize_key(client)];
return true;
......@@ -598,14 +601,21 @@
};
CLIENT_reconnect_register = function(client, room_id, error) {
var dinfo, room, tmot;
var dinfo, len2, m, player, ref2, room, tmot;
room = ROOM_all[room_id];
if (client.had_new_reconnection) {
return false;
}
if (!settings.modules.reconnect.enabled || client.system_kicked || disconnect_list[CLIENT_get_authorize_key(client)] || client.is_post_watcher || !CLIENT_is_player(client, room) || !room.started || (room.windbot && client.is_local) || (settings.modules.reconnect.auto_surrender_after_disconnect && room.hostinfo.mode !== 1)) {
if (!settings.modules.reconnect.enabled || !room || client.system_kicked || disconnect_list[CLIENT_get_authorize_key(client)] || client.is_post_watcher || !CLIENT_is_player(client, room) || !room.started || (room.windbot && client.is_local) || (settings.modules.reconnect.auto_surrender_after_disconnect && room.hostinfo.mode !== 1)) {
return false;
}
ref2 = room.players;
for (m = 0, len2 = ref2.length; m < len2; m++) {
player = ref2[m];
if (player !== client && CLIENT_get_authorize_key(player) === CLIENT_get_authorize_key(client)) {
return false;
}
}
dinfo = {
room_id: room_id,
old_client: client,
......@@ -672,16 +682,33 @@
SERVER_clear_disconnect = function(server) {
var k, v;
if (!settings.modules.reconnect.enabled) {
return;
return false;
}
for (k in disconnect_list) {
v = disconnect_list[k];
if (v && server === v.old_server) {
release_disconnect(v);
delete disconnect_list[k];
return;
return true;
}
}
return false;
};
ROOM_clear_disconnect = function(room_id) {
var k, v;
if (!settings.modules.reconnect.enabled) {
return false;
}
for (k in disconnect_list) {
v = disconnect_list[k];
if (v && room_id === v.room_id) {
release_disconnect(v);
delete disconnect_list[k];
return true;
}
}
return false;
};
CLIENT_is_player = function(client, room) {
......@@ -1009,7 +1036,7 @@
}
Room.prototype["delete"] = function() {
var end_time, index, k, log_rep_id, name, player_ips, player_names, recorder_buffer, ref2, replay_id, score, score_array, v;
var end_time, index, log_rep_id, name, player_ips, player_names, recorder_buffer, ref2, replay_id, score, score_array;
if (this.deleted) {
return;
}
......@@ -1097,14 +1124,7 @@
this.deleted = true;
index = _.indexOf(ROOM_all, this);
if (settings.modules.reconnect.enabled) {
for (k in disconnect_list) {
v = disconnect_list[k];
if (v && index === v.room_id) {
release_disconnect(v);
delete disconnect_list[k];
break;
}
}
ROOM_clear_disconnect(index);
}
if (index !== -1) {
ROOM_all[index] = null;
......@@ -1223,7 +1243,7 @@
this.process.kill();
this["delete"]();
}
if (!CLIENT_reconnect_unregister(client)) {
if (!CLIENT_reconnect_unregister(client, false, true)) {
client.server.destroy();
}
}
......
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