Commit 7b181569 authored by nanahira's avatar nanahira

send both 0 and 1 in heartbeat

parent 641c668e
...@@ -589,19 +589,16 @@ CLIENT_send_reconnect_info = (client, server, room) -> ...@@ -589,19 +589,16 @@ CLIENT_send_reconnect_info = (client, server, room) ->
if room.turn and room.turn > 0 if room.turn and room.turn > 0
ygopro.ctos_send(server, 'REQUEST_FIELD') ygopro.ctos_send(server, 'REQUEST_FIELD')
else if room.changing_side else if room.changing_side
client.is_reconnect_recovering = true
ygopro.stoc_send(client, 'DUEL_START') ygopro.stoc_send(client, 'DUEL_START')
if !client.selected_preduel if !client.selected_preduel
ygopro.stoc_send(client, 'CHANGE_SIDE') ygopro.stoc_send(client, 'CHANGE_SIDE')
client.reconnecting = false client.reconnecting = false
else if room.selecting_hand else if room.selecting_hand
client.is_reconnect_recovering = true
ygopro.stoc_send(client, 'DUEL_START') ygopro.stoc_send(client, 'DUEL_START')
if (room.hostinfo.mode != 2 or client.pos == 0 or client.pos == 2) and !client.selected_preduel if (room.hostinfo.mode != 2 or client.pos == 0 or client.pos == 2) and !client.selected_preduel
ygopro.stoc_send(client, 'SELECT_HAND') ygopro.stoc_send(client, 'SELECT_HAND')
client.reconnecting = false client.reconnecting = false
else if room.selecting_tp else if room.selecting_tp
client.is_reconnect_recovering = true
ygopro.stoc_send(client, 'DUEL_START') ygopro.stoc_send(client, 'DUEL_START')
if client == room.selecting_tp and !client.selected_preduel if client == room.selecting_tp and !client.selected_preduel
ygopro.stoc_send(client, 'SELECT_TP') ygopro.stoc_send(client, 'SELECT_TP')
...@@ -666,7 +663,11 @@ CLIENT_heartbeat_register = (client, send) -> ...@@ -666,7 +663,11 @@ CLIENT_heartbeat_register = (client, send) ->
client.heartbeat_responsed = false client.heartbeat_responsed = false
if send if send
ygopro.stoc_send(client, "TIME_LIMIT", { ygopro.stoc_send(client, "TIME_LIMIT", {
player: (if client.is_first and !client.is_reconnect_recovering then 0 else 1), player: 0,
left_time: 0
})
ygopro.stoc_send(client, "TIME_LIMIT", {
player: 1,
left_time: 0 left_time: 0
}) })
client.heartbeat_timeout = setTimeout(() -> client.heartbeat_timeout = setTimeout(() ->
...@@ -1816,8 +1817,6 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server)-> ...@@ -1816,8 +1817,6 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server)->
#log.info 'MSG', ygopro.constants.MSG[msg] #log.info 'MSG', ygopro.constants.MSG[msg]
if ygopro.constants.MSG[msg] == 'START' if ygopro.constants.MSG[msg] == 'START'
playertype = buffer.readUInt8(1) playertype = buffer.readUInt8(1)
if settings.modules.reconnect.enabled
client.is_reconnect_recovering = false # dInfo.isFirst is false after reconnecting, so detect this to make client send CTOS_TIME_CONFIRM, assuming the client did not do anything else before reconnecting. I think doing with the client's dInfo.isFirst is still needed.
client.is_first = !(playertype & 0xf) client.is_first = !(playertype & 0xf)
client.lp = room.hostinfo.start_lp client.lp = room.hostinfo.start_lp
client.card_count = 0 if room.hostinfo.mode != 2 client.card_count = 0 if room.hostinfo.mode != 2
...@@ -2756,7 +2755,7 @@ if settings.modules.mycard.enabled ...@@ -2756,7 +2755,7 @@ if settings.modules.mycard.enabled
if settings.modules.heartbeat_detection.enabled if settings.modules.heartbeat_detection.enabled
setInterval ()-> setInterval ()->
for room in ROOM_all when room and room.started and (room.hostinfo.time_limit == 0 or !room.turn or room.turn <= 0) and !room.windbot for room in ROOM_all when room and room.started and (room.hostinfo.time_limit == 0 or !room.turn or room.turn <= 0) and !room.windbot
for player in room.players when ((!room.changing_side or player.selected_preduel) and room.duel_count and room.duel_count > 0) or player.is_reconnect_recovering for player in room.players when !room.changing_side or player.selected_preduel
CLIENT_heartbeat_register(player, true) CLIENT_heartbeat_register(player, true)
return return
, settings.modules.heartbeat_detection.interval , settings.modules.heartbeat_detection.interval
......
...@@ -764,21 +764,18 @@ ...@@ -764,21 +764,18 @@
if (room.turn && room.turn > 0) { if (room.turn && room.turn > 0) {
ygopro.ctos_send(server, 'REQUEST_FIELD'); ygopro.ctos_send(server, 'REQUEST_FIELD');
} else if (room.changing_side) { } else if (room.changing_side) {
client.is_reconnect_recovering = true;
ygopro.stoc_send(client, 'DUEL_START'); ygopro.stoc_send(client, 'DUEL_START');
if (!client.selected_preduel) { if (!client.selected_preduel) {
ygopro.stoc_send(client, 'CHANGE_SIDE'); ygopro.stoc_send(client, 'CHANGE_SIDE');
} }
client.reconnecting = false; client.reconnecting = false;
} else if (room.selecting_hand) { } else if (room.selecting_hand) {
client.is_reconnect_recovering = true;
ygopro.stoc_send(client, 'DUEL_START'); ygopro.stoc_send(client, 'DUEL_START');
if ((room.hostinfo.mode !== 2 || client.pos === 0 || client.pos === 2) && !client.selected_preduel) { if ((room.hostinfo.mode !== 2 || client.pos === 0 || client.pos === 2) && !client.selected_preduel) {
ygopro.stoc_send(client, 'SELECT_HAND'); ygopro.stoc_send(client, 'SELECT_HAND');
} }
client.reconnecting = false; client.reconnecting = false;
} else if (room.selecting_tp) { } else if (room.selecting_tp) {
client.is_reconnect_recovering = true;
ygopro.stoc_send(client, 'DUEL_START'); ygopro.stoc_send(client, 'DUEL_START');
if (client === room.selecting_tp && !client.selected_preduel) { if (client === room.selecting_tp && !client.selected_preduel) {
ygopro.stoc_send(client, 'SELECT_TP'); ygopro.stoc_send(client, 'SELECT_TP');
...@@ -853,7 +850,11 @@ ...@@ -853,7 +850,11 @@
client.heartbeat_responsed = false; client.heartbeat_responsed = false;
if (send) { if (send) {
ygopro.stoc_send(client, "TIME_LIMIT", { ygopro.stoc_send(client, "TIME_LIMIT", {
player: (client.is_first && !client.is_reconnect_recovering ? 0 : 1), player: 0,
left_time: 0
});
ygopro.stoc_send(client, "TIME_LIMIT", {
player: 1,
left_time: 0 left_time: 0
}); });
} }
...@@ -2189,9 +2190,6 @@ ...@@ -2189,9 +2190,6 @@
} }
if (ygopro.constants.MSG[msg] === 'START') { if (ygopro.constants.MSG[msg] === 'START') {
playertype = buffer.readUInt8(1); playertype = buffer.readUInt8(1);
if (settings.modules.reconnect.enabled) {
client.is_reconnect_recovering = false;
}
client.is_first = !(playertype & 0xf); client.is_first = !(playertype & 0xf);
client.lp = room.hostinfo.start_lp; client.lp = room.hostinfo.start_lp;
if (room.hostinfo.mode !== 2) { if (room.hostinfo.mode !== 2) {
...@@ -3497,7 +3495,7 @@ ...@@ -3497,7 +3495,7 @@
ref2 = room.players; ref2 = room.players;
for (n = 0, len3 = ref2.length; n < len3; n++) { for (n = 0, len3 = ref2.length; n < len3; n++) {
player = ref2[n]; player = ref2[n];
if (((!room.changing_side || player.selected_preduel) && room.duel_count && room.duel_count > 0) || player.is_reconnect_recovering) { if (!room.changing_side || player.selected_preduel) {
CLIENT_heartbeat_register(player, true); CLIENT_heartbeat_register(player, true);
} }
} }
......
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