Commit 7e5b710c authored by nanahira's avatar nanahira

no reconnect in random duel after opponent quitted

parent 1c7b1d0d
...@@ -480,7 +480,7 @@ CLIENT_reconnect_register = (client, room_id, error) -> ...@@ -480,7 +480,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)
...@@ -994,13 +994,12 @@ class Room ...@@ -994,13 +994,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)->
...@@ -2824,7 +2823,7 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)-> ...@@ -2824,7 +2823,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
...@@ -2842,7 +2841,7 @@ if settings.modules.random_duel.enabled ...@@ -2842,7 +2841,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
......
...@@ -622,7 +622,7 @@ ...@@ -622,7 +622,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 = {
...@@ -1288,20 +1288,18 @@ ...@@ -1288,20 +1288,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, ref2; var found, len2, m, player, ref2;
if (!settings.modules.reconnect.enabled) { if (!settings.modules.reconnect.enabled) {
return false; return 0;
} }
found = false; found = 0;
ref2 = this.get_playing_player(); ref2 = this.get_playing_player();
for (m = 0, len2 = ref2.length; m < len2; m++) { for (m = 0, len2 = ref2.length; m < len2; m++) {
player = ref2[m]; player = ref2[m];
if (!player.closed) { if (player.closed) {
continue; found++;
} }
found = true;
break;
} }
return found; return found;
}; };
...@@ -3593,7 +3591,7 @@ ...@@ -3593,7 +3591,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);
...@@ -3616,7 +3614,7 @@ ...@@ -3616,7 +3614,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