Commit 35901924 authored by mercury233's avatar mercury233

fix side hang timeout

parent 21a2d777
...@@ -756,7 +756,7 @@ wait_room_start = (room, time)-> ...@@ -756,7 +756,7 @@ wait_room_start = (room, time)->
time -= 1 time -= 1
if time if time
unless time % 5 unless time % 5
ygopro.stoc_send_chat_to_room(room, "#{if time <= 9 then ' ' else ''}#{time}秒后房主若不开始游戏将被请出房间", if time <= 9 then ygopro.constants.COLORS.RED else ygopro.constants.COLORS.BLUE) ygopro.stoc_send_chat_to_room(room, "#{if time <= 9 then ' ' else ''}#{time}秒后房主若不开始游戏将被请出房间", if time <= 9 then ygopro.constants.COLORS.RED else ygopro.constants.COLORS.BABYBLUE)
setTimeout (()-> wait_room_start(room, time);return), 1000 setTimeout (()-> wait_room_start(room, time);return), 1000
else else
for player in room.players for player in room.players
...@@ -857,6 +857,10 @@ ygopro.ctos_follow 'UPDATE_DECK', false, (buffer, info, client, server)-> ...@@ -857,6 +857,10 @@ ygopro.ctos_follow 'UPDATE_DECK', false, (buffer, info, client, server)->
side = (info.deckbuf[i] for i in [info.mainc...info.mainc + info.sidec]) side = (info.deckbuf[i] for i in [info.mainc...info.mainc + info.sidec])
client.main = main client.main = main
client.side = side client.side = side
return unless client.room and client.room.random_type
if client.is_host
client.room.waiting_for_player = client.room.waiting_for_player2
client.room.last_active_time = moment()
return return
ygopro.ctos_follow 'RESPONSE', false, (buffer, info, client, server)-> ygopro.ctos_follow 'RESPONSE', false, (buffer, info, client, server)->
...@@ -891,6 +895,15 @@ ygopro.stoc_follow 'SELECT_TP', false, (buffer, info, client, server)-> ...@@ -891,6 +895,15 @@ ygopro.stoc_follow 'SELECT_TP', false, (buffer, info, client, server)->
client.room.last_active_time = moment() client.room.last_active_time = moment()
return return
ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server)->
return unless client.room and client.room.random_type
if client.is_host
client.room.waiting_for_player = client
else
client.room.waiting_for_player2 = client
client.room.last_active_time = moment()
return
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 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) time_passed = Math.floor((moment() - room.last_active_time) / 1000)
......
...@@ -864,7 +864,7 @@ ...@@ -864,7 +864,7 @@
time -= 1; time -= 1;
if (time) { if (time) {
if (!(time % 5)) { if (!(time % 5)) {
ygopro.stoc_send_chat_to_room(room, "" + (time <= 9 ? ' ' : '') + time + "秒后房主若不开始游戏将被请出房间", time <= 9 ? ygopro.constants.COLORS.RED : ygopro.constants.COLORS.BLUE); ygopro.stoc_send_chat_to_room(room, "" + (time <= 9 ? ' ' : '') + time + "秒后房主若不开始游戏将被请出房间", time <= 9 ? ygopro.constants.COLORS.RED : ygopro.constants.COLORS.BABYBLUE);
} }
setTimeout((function() { setTimeout((function() {
wait_room_start(room, time); wait_room_start(room, time);
...@@ -1041,6 +1041,13 @@ ...@@ -1041,6 +1041,13 @@
})(); })();
client.main = main; client.main = main;
client.side = side; client.side = side;
if (!(client.room && client.room.random_type)) {
return;
}
if (client.is_host) {
client.room.waiting_for_player = client.room.waiting_for_player2;
}
client.room.last_active_time = moment();
}); });
ygopro.ctos_follow('RESPONSE', false, function(buffer, info, client, server) { ygopro.ctos_follow('RESPONSE', false, function(buffer, info, client, server) {
...@@ -1087,6 +1094,18 @@ ...@@ -1087,6 +1094,18 @@
client.room.last_active_time = moment(); client.room.last_active_time = moment();
}); });
ygopro.stoc_follow('CHANGE_SIDE', false, function(buffer, info, client, server) {
if (!(client.room && client.room.random_type)) {
return;
}
if (client.is_host) {
client.room.waiting_for_player = client;
} else {
client.room.waiting_for_player2 = client;
}
client.room.last_active_time = moment();
});
setInterval(function() { setInterval(function() {
var k, len, ref, room, time_passed; var k, len, ref, room, time_passed;
ref = Room.all; ref = Room.all;
......
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