Commit 848207b6 authored by nanahira's avatar nanahira

more improves

parent 6ddb626b
...@@ -463,10 +463,9 @@ ban_user = global.ban_user = (name, callback) -> ...@@ -463,10 +463,9 @@ ban_user = global.ban_user = (name, callback) ->
done() done()
return return
_async.each(["players", "watchers"], (player_type, _done)-> _async.each(["players", "watchers"], (player_type, _done)->
_async.each(room[player_type].filter((player)-> _async.each(room[player_type], (player, __done)->
return player and (player.name == name or bad_ip.indexOf(player.ip) != -1) if player and (player.name == name or bad_ip.indexOf(player.ip) != -1)
), (player, __done)-> bad_ip.push(player.ip)
bad_ip = player.ip
ROOM_bad_ip[bad_ip]=99 ROOM_bad_ip[bad_ip]=99
settings.ban.banned_ip.push(player.ip) settings.ban.banned_ip.push(player.ip)
ygopro.stoc_send_chat_to_room(room, "#{player.name} ${kicked_by_system}", ygopro.constants.COLORS.RED) ygopro.stoc_send_chat_to_room(room, "#{player.name} ${kicked_by_system}", ygopro.constants.COLORS.RED)
...@@ -3517,17 +3516,25 @@ if settings.modules.mycard.enabled ...@@ -3517,17 +3516,25 @@ 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.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN and (room.hostinfo.time_limit == 0 or room.duel_stage != ygopro.constants.DUEL_STAGE.DUELING) and !room.windbot _async.each ROOM_all, (room, done)->
for player in room.get_playing_player() when player and (room.duel_stage != ygopro.constants.DUEL_STAGE.SIDING or player.selected_preduel) if room and room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN and (room.hostinfo.time_limit == 0 or room.duel_stage != ygopro.constants.DUEL_STAGE.DUELING) and !room.windbot
_async.each(room.get_playing_player(), (player, _done)->
if player and (room.duel_stage != ygopro.constants.DUEL_STAGE.SIDING or player.selected_preduel)
CLIENT_heartbeat_register(player, true) CLIENT_heartbeat_register(player, true)
_done()
, done)
else
done()
return return
, settings.modules.heartbeat_detection.interval , settings.modules.heartbeat_detection.interval
setInterval ()-> setInterval ()->
current_time = moment() current_time = moment()
for room in ROOM_all when room and room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN and room.hostinfo.auto_death and !room.auto_death_triggered and current_time - moment(room.start_time) > 60000 * room.hostinfo.auto_death _async.each ROOM_all, (room, done)->
if room and room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN and room.hostinfo.auto_death and !room.auto_death_triggered and current_time - moment(room.start_time) > 60000 * room.hostinfo.auto_death
room.auto_death_triggered = true room.auto_death_triggered = true
room.start_death() room.start_death()
done()
, 1000 , 1000
......
...@@ -545,15 +545,15 @@ ...@@ -545,15 +545,15 @@
return; return;
} }
return _async.each(["players", "watchers"], function(player_type, _done) { return _async.each(["players", "watchers"], function(player_type, _done) {
return _async.each(room[player_type].filter(function(player) { return _async.each(room[player_type], function(player, __done) {
return player && (player.name === name || bad_ip.indexOf(player.ip) !== -1); if (player && (player.name === name || bad_ip.indexOf(player.ip) !== -1)) {
}), function(player, __done) { bad_ip.push(player.ip);
bad_ip = player.ip;
ROOM_bad_ip[bad_ip] = 99; ROOM_bad_ip[bad_ip] = 99;
settings.ban.banned_ip.push(player.ip); settings.ban.banned_ip.push(player.ip);
ygopro.stoc_send_chat_to_room(room, player.name + " ${kicked_by_system}", ygopro.constants.COLORS.RED); ygopro.stoc_send_chat_to_room(room, player.name + " ${kicked_by_system}", ygopro.constants.COLORS.RED);
CLIENT_send_replays(player, room); CLIENT_send_replays(player, room);
CLIENT_kick(player); CLIENT_kick(player);
}
return __done(); return __done();
}, _done); }, _done);
}, done); }, done);
...@@ -4496,35 +4496,31 @@ ...@@ -4496,35 +4496,31 @@
if (settings.modules.heartbeat_detection.enabled) { if (settings.modules.heartbeat_detection.enabled) {
setInterval(function() { setInterval(function() {
var len2, len3, m, n, player, ref2, room; _async.each(ROOM_all, function(room, done) {
for (m = 0, len2 = ROOM_all.length; m < len2; m++) {
room = ROOM_all[m];
if (room && room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && (room.hostinfo.time_limit === 0 || room.duel_stage !== ygopro.constants.DUEL_STAGE.DUELING) && !room.windbot) { if (room && room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && (room.hostinfo.time_limit === 0 || room.duel_stage !== ygopro.constants.DUEL_STAGE.DUELING) && !room.windbot) {
ref2 = room.get_playing_player(); return _async.each(room.get_playing_player(), function(player, _done) {
for (n = 0, len3 = ref2.length; n < len3; n++) {
player = ref2[n];
if (player && (room.duel_stage !== ygopro.constants.DUEL_STAGE.SIDING || player.selected_preduel)) { if (player && (room.duel_stage !== ygopro.constants.DUEL_STAGE.SIDING || player.selected_preduel)) {
CLIENT_heartbeat_register(player, true); CLIENT_heartbeat_register(player, true);
} }
return _done();
}, done);
} else {
return done();
} }
} });
}
}, settings.modules.heartbeat_detection.interval); }, settings.modules.heartbeat_detection.interval);
} }
setInterval(function() { setInterval(function() {
var current_time, len2, m, results, room; var current_time;
current_time = moment(); current_time = moment();
results = []; return _async.each(ROOM_all, function(room, done) {
for (m = 0, len2 = ROOM_all.length; m < len2; m++) { if (room && room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && room.hostinfo.auto_death && !room.auto_death_triggered && current_time - moment(room.start_time) > 60000 * room.hostinfo.auto_death) {
room = ROOM_all[m];
if (!(room && room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && room.hostinfo.auto_death && !room.auto_death_triggered && current_time - moment(room.start_time) > 60000 * room.hostinfo.auto_death)) {
continue;
}
room.auto_death_triggered = true; room.auto_death_triggered = true;
results.push(room.start_death()); room.start_death();
} }
return results; return done();
});
}, 1000); }, 1000);
windbot_looplimit = 0; windbot_looplimit = 0;
......
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