Commit 8e1bfb38 authored by nanahira's avatar nanahira

fix mobile infinite loop reconnect

parent bd62cf57
...@@ -659,7 +659,7 @@ CLIENT_heartbeat_unregister = (client) -> ...@@ -659,7 +659,7 @@ CLIENT_heartbeat_unregister = (client) ->
return true return true
CLIENT_heartbeat_register = (client, send) -> CLIENT_heartbeat_register = (client, send) ->
if !settings.modules.heartbeat_detection.enabled or client.closed or client.is_post_watcher or client.pre_reconnecting or client.reconnecting or client.pos > 3 or client.heartbeat_protected if !settings.modules.heartbeat_detection.enabled or client.closed or client.is_post_watcher or client.pre_reconnecting or client.reconnecting or client.waiting_for_last or client.pos > 3 or client.heartbeat_protected
return false return false
if client.heartbeat_timeout if client.heartbeat_timeout
CLIENT_heartbeat_unregister(client) CLIENT_heartbeat_unregister(client)
...@@ -2165,19 +2165,14 @@ ygopro.ctos_follow 'REQUEST_FIELD', true, (buffer, info, client, server)-> ...@@ -2165,19 +2165,14 @@ ygopro.ctos_follow 'REQUEST_FIELD', true, (buffer, info, client, server)->
ygopro.stoc_follow 'FIELD_FINISH', true, (buffer, info, client, server)-> ygopro.stoc_follow 'FIELD_FINISH', true, (buffer, info, client, server)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return unless room return true unless room and settings.modules.reconnect.enabled
client.reconnecting = false client.reconnecting = false
if settings.modules.heartbeat_detection.enabled if client.time_confirm_required # client did not send TIME_CONFIRM
client.heartbeat_protected = true client.waiting_for_last = true
if !client.last_game_msg else if client.last_game_msg and client.last_game_msg_title != 'WAITING' # client sent TIME_CONFIRM
return true if client.last_hint_msg
if client.last_game_msg_title != 'WAITING' ygopro.stoc_send(client, 'GAME_MSG', client.last_hint_msg)
setTimeout( () -> ygopro.stoc_send(client, 'GAME_MSG', client.last_game_msg)
if client.last_hint_msg
ygopro.stoc_send(client, 'GAME_MSG', client.last_hint_msg)
ygopro.stoc_send(client, 'GAME_MSG', client.last_game_msg)
return
, 50)
return true return true
wait_room_start = (room, time)-> wait_room_start = (room, time)->
...@@ -2612,11 +2607,17 @@ ygopro.ctos_follow 'TIME_CONFIRM', false, (buffer, info, client, server)-> ...@@ -2612,11 +2607,17 @@ ygopro.ctos_follow 'TIME_CONFIRM', false, (buffer, info, client, server)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return unless room return unless room
if settings.modules.reconnect.enabled if settings.modules.reconnect.enabled
if client.waiting_for_last
client.waiting_for_last = false
if client.last_game_msg and client.last_game_msg_title != 'WAITING'
if client.last_hint_msg
ygopro.stoc_send(client, 'GAME_MSG', client.last_hint_msg)
ygopro.stoc_send(client, 'GAME_MSG', client.last_game_msg)
client.time_confirm_required = false client.time_confirm_required = false
return unless settings.modules.heartbeat_detection.enabled if settings.modules.heartbeat_detection.enabled
client.heartbeat_protected = false client.heartbeat_protected = false
client.heartbeat_responsed = true client.heartbeat_responsed = true
CLIENT_heartbeat_unregister(client) CLIENT_heartbeat_unregister(client)
return return
ygopro.ctos_follow 'HAND_RESULT', false, (buffer, info, client, server)-> ygopro.ctos_follow 'HAND_RESULT', false, (buffer, info, client, server)->
......
...@@ -845,7 +845,7 @@ ...@@ -845,7 +845,7 @@
}; };
CLIENT_heartbeat_register = function(client, send) { CLIENT_heartbeat_register = function(client, send) {
if (!settings.modules.heartbeat_detection.enabled || client.closed || client.is_post_watcher || client.pre_reconnecting || client.reconnecting || client.pos > 3 || client.heartbeat_protected) { if (!settings.modules.heartbeat_detection.enabled || client.closed || client.is_post_watcher || client.pre_reconnecting || client.reconnecting || client.waiting_for_last || client.pos > 3 || client.heartbeat_protected) {
return false; return false;
} }
if (client.heartbeat_timeout) { if (client.heartbeat_timeout) {
...@@ -2663,23 +2663,17 @@ ...@@ -2663,23 +2663,17 @@
ygopro.stoc_follow('FIELD_FINISH', true, function(buffer, info, client, server) { ygopro.stoc_follow('FIELD_FINISH', true, function(buffer, info, client, server) {
var room; var room;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!room) { if (!(room && settings.modules.reconnect.enabled)) {
return;
}
client.reconnecting = false;
if (settings.modules.heartbeat_detection.enabled) {
client.heartbeat_protected = true;
}
if (!client.last_game_msg) {
return true; return true;
} }
if (client.last_game_msg_title !== 'WAITING') { client.reconnecting = false;
setTimeout(function() { if (client.time_confirm_required) {
if (client.last_hint_msg) { client.waiting_for_last = true;
ygopro.stoc_send(client, 'GAME_MSG', client.last_hint_msg); } else if (client.last_game_msg && client.last_game_msg_title !== 'WAITING') {
} if (client.last_hint_msg) {
ygopro.stoc_send(client, 'GAME_MSG', client.last_game_msg); ygopro.stoc_send(client, 'GAME_MSG', client.last_hint_msg);
}, 50); }
ygopro.stoc_send(client, 'GAME_MSG', client.last_game_msg);
} }
return true; return true;
}); });
...@@ -3280,14 +3274,22 @@ ...@@ -3280,14 +3274,22 @@
return; return;
} }
if (settings.modules.reconnect.enabled) { if (settings.modules.reconnect.enabled) {
if (client.waiting_for_last) {
client.waiting_for_last = false;
if (client.last_game_msg && client.last_game_msg_title !== 'WAITING') {
if (client.last_hint_msg) {
ygopro.stoc_send(client, 'GAME_MSG', client.last_hint_msg);
}
ygopro.stoc_send(client, 'GAME_MSG', client.last_game_msg);
}
}
client.time_confirm_required = false; client.time_confirm_required = false;
} }
if (!settings.modules.heartbeat_detection.enabled) { if (settings.modules.heartbeat_detection.enabled) {
return; client.heartbeat_protected = false;
client.heartbeat_responsed = true;
CLIENT_heartbeat_unregister(client);
} }
client.heartbeat_protected = false;
client.heartbeat_responsed = true;
CLIENT_heartbeat_unregister(client);
}); });
ygopro.ctos_follow('HAND_RESULT', false, function(buffer, info, client, server) { ygopro.ctos_follow('HAND_RESULT', false, function(buffer, info, client, server) {
......
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