Commit fbe54a4c authored by nanahira's avatar nanahira

no AFK kick when disconnected

parent 6b716e4d
......@@ -628,6 +628,8 @@ CLIENT_reconnect = (client) ->
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, dinfo.old_client, room)
CLIENT_send_reconnect_info(client, client.server, room)
ygopro.stoc_send_chat_to_room(room, "#{client.name} ${reconnect_to_game}")
......@@ -2575,12 +2577,12 @@ if settings.modules.random_duel.enabled
for room in ROOM_all when room and room.started and room.random_type and room.last_active_time and room.waiting_for_player
time_passed = Math.floor((moment() - room.last_active_time) / 1000)
#log.info time_passed
if time_passed >= settings.modules.random_duel.hang_timeout
if time_passed >= settings.modules.random_duel.hang_timeout and !room.waiting_for_player.closed
room.last_active_time = moment()
ROOM_ban_player(room.waiting_for_player.name, room.waiting_for_player.ip, "${random_ban_reason_AFK}")
ygopro.stoc_send_chat_to_room(room, "#{room.waiting_for_player.name} ${kicked_by_system}", ygopro.constants.COLORS.RED)
room.waiting_for_player.server.destroy()
else if time_passed >= (settings.modules.random_duel.hang_timeout - 20) and not (time_passed % 10)
else if time_passed >= (settings.modules.random_duel.hang_timeout - 20) and not (time_passed % 10) and !room.waiting_for_player.closed
ygopro.stoc_send_chat_to_room(room, "#{room.waiting_for_player.name} ${afk_warn_part1}#{settings.modules.random_duel.hang_timeout - time_passed}${afk_warn_part2}", ygopro.constants.COLORS.RED)
ROOM_unwelcome(room, room.waiting_for_player, "${random_ban_reason_AFK}")
return
......@@ -2591,13 +2593,13 @@ if settings.modules.mycard.enabled
for room in ROOM_all when room and room.started and room.arena and room.last_active_time and room.waiting_for_player
time_passed = Math.floor((moment() - room.last_active_time) / 1000)
#log.info time_passed
if time_passed >= settings.modules.random_duel.hang_timeout
if time_passed >= settings.modules.random_duel.hang_timeout and !room.waiting_for_player.closed
room.last_active_time = moment()
ygopro.stoc_send_chat_to_room(room, "#{room.waiting_for_player.name} ${kicked_by_system}", ygopro.constants.COLORS.RED)
room.scores[room.waiting_for_player.name] = -9
#log.info room.waiting_for_player.name, room.scores[room.waiting_for_player.name]
room.waiting_for_player.server.destroy()
else if time_passed >= (settings.modules.random_duel.hang_timeout - 20) and not (time_passed % 10)
else if time_passed >= (settings.modules.random_duel.hang_timeout - 20) and not (time_passed % 10) and !room.waiting_for_player.closed
ygopro.stoc_send_chat_to_room(room, "#{room.waiting_for_player.name} ${afk_warn_part1}#{settings.modules.random_duel.hang_timeout - time_passed}${afk_warn_part2}", ygopro.constants.COLORS.RED)
return
, 1000
......
......@@ -810,6 +810,9 @@
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, dinfo.old_client, room);
CLIENT_send_reconnect_info(client, client.server, room);
ygopro.stoc_send_chat_to_room(room, client.name + " ${reconnect_to_game}");
......@@ -3260,12 +3263,12 @@
continue;
}
time_passed = Math.floor((moment() - room.last_active_time) / 1000);
if (time_passed >= settings.modules.random_duel.hang_timeout) {
if (time_passed >= settings.modules.random_duel.hang_timeout && !room.waiting_for_player.closed) {
room.last_active_time = moment();
ROOM_ban_player(room.waiting_for_player.name, room.waiting_for_player.ip, "${random_ban_reason_AFK}");
ygopro.stoc_send_chat_to_room(room, room.waiting_for_player.name + " ${kicked_by_system}", ygopro.constants.COLORS.RED);
room.waiting_for_player.server.destroy();
} else if (time_passed >= (settings.modules.random_duel.hang_timeout - 20) && !(time_passed % 10)) {
} else if (time_passed >= (settings.modules.random_duel.hang_timeout - 20) && !(time_passed % 10) && !room.waiting_for_player.closed) {
ygopro.stoc_send_chat_to_room(room, room.waiting_for_player.name + " ${afk_warn_part1}" + (settings.modules.random_duel.hang_timeout - time_passed) + "${afk_warn_part2}", ygopro.constants.COLORS.RED);
ROOM_unwelcome(room, room.waiting_for_player, "${random_ban_reason_AFK}");
}
......@@ -3282,12 +3285,12 @@
continue;
}
time_passed = Math.floor((moment() - room.last_active_time) / 1000);
if (time_passed >= settings.modules.random_duel.hang_timeout) {
if (time_passed >= settings.modules.random_duel.hang_timeout && !room.waiting_for_player.closed) {
room.last_active_time = moment();
ygopro.stoc_send_chat_to_room(room, room.waiting_for_player.name + " ${kicked_by_system}", ygopro.constants.COLORS.RED);
room.scores[room.waiting_for_player.name] = -9;
room.waiting_for_player.server.destroy();
} else if (time_passed >= (settings.modules.random_duel.hang_timeout - 20) && !(time_passed % 10)) {
} else if (time_passed >= (settings.modules.random_duel.hang_timeout - 20) && !(time_passed % 10) && !room.waiting_for_player.closed) {
ygopro.stoc_send_chat_to_room(room, room.waiting_for_player.name + " ${afk_warn_part1}" + (settings.modules.random_duel.hang_timeout - time_passed) + "${afk_warn_part2}", ygopro.constants.COLORS.RED);
}
}
......
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