Commit 1cbf2bb5 authored by nanahira's avatar nanahira

Merge branch 'master' into tcg_random

parents 10f7a2a3 2052f6f7
......@@ -398,7 +398,10 @@ if settings.modules.challonge.enabled
else
_data.callback = get_callback(0, _data.callback)
is_requesting[0] = moment()
challonge.participants.index(_data)
try
challonge.participants.index(_data)
catch err
_data.callback(err, null)
return
challonge.matches._index = (_data) ->
if settings.modules.challonge.cache_ttl and challonge_cache[1]
......@@ -408,7 +411,16 @@ if settings.modules.challonge.enabled
else
_data.callback = get_callback(1, _data.callback)
is_requesting[1] = moment()
challonge.matches.index(_data)
try
challonge.matches.index(_data)
catch err
_data.callback(err, null)
return
challonge.matches._update = (_data) ->
try
challonge.matches.update(_data)
catch err
log.warn("Errored pushing scores to Challonge.", err)
return
refresh_challonge_cache = () ->
if settings.modules.challonge.cache_ttl
......@@ -941,7 +953,7 @@ CLIENT_heartbeat_unregister = (client) ->
return true
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
if client.heartbeat_timeout
CLIENT_heartbeat_unregister(client)
......@@ -1261,7 +1273,7 @@ class Room
return
if settings.modules.challonge.enabled and @started and @hostinfo.mode != 2 and !@kicked
challonge.matches.update({
challonge.matches._update({
id: settings.modules.challonge.tournament_id,
matchId: @challonge_info.id,
match: @get_challonge_score(),
......@@ -2743,11 +2755,9 @@ ygopro.stoc_follow 'FIELD_FINISH', true, (buffer, info, client, server, datas)->
room=ROOM_all[client.rid]
return true unless room and settings.modules.reconnect.enabled
client.reconnecting = false
#if client.time_confirm_required # client did not send TIME_CONFIRM
# client.waiting_for_last = true
#else
if client.last_game_msg and client.last_game_msg_title != 'WAITING' # client sent TIME_CONFIRM
SOCKET_flush_data(client, datas)
if client.time_confirm_required # client did not send TIME_CONFIRM
client.waiting_for_last = true
else if client.last_game_msg and client.last_game_msg_title != 'WAITING' # client sent TIME_CONFIRM
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)
......@@ -3351,12 +3361,12 @@ ygopro.ctos_follow 'TIME_CONFIRM', false, (buffer, info, client, server, datas)-
room=ROOM_all[client.rid]
return unless room
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)
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
if settings.modules.heartbeat_detection.enabled
client.heartbeat_protected = false
......@@ -3463,7 +3473,7 @@ ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server, datas)->
if settings.modules.challonge.enabled and settings.modules.challonge.post_score_midduel and room.hostinfo.mode != 2 and client.pos == 0
temp_log = JSON.parse(JSON.stringify(room.get_challonge_score()))
delete temp_log.winnerId
challonge.matches.update({
challonge.matches._update({
id: settings.modules.challonge.tournament_id,
matchId: room.challonge_info.id,
match: temp_log,
......
......@@ -486,6 +486,7 @@
});
};
challonge.participants._index = function(_data) {
var err;
if (settings.modules.challonge.cache_ttl && challonge_cache[0]) {
_data.callback(null, challonge_cache[0]);
} else if (is_requesting[0] && moment() - is_requesting[0] <= 5000) {
......@@ -493,10 +494,16 @@
} else {
_data.callback = get_callback(0, _data.callback);
is_requesting[0] = moment();
challonge.participants.index(_data);
try {
challonge.participants.index(_data);
} catch (error1) {
err = error1;
_data.callback(err, null);
}
}
};
challonge.matches._index = function(_data) {
var err;
if (settings.modules.challonge.cache_ttl && challonge_cache[1]) {
_data.callback(null, challonge_cache[1]);
} else if (is_requesting[1] && moment() - is_requesting[1] <= 5000) {
......@@ -504,7 +511,21 @@
} else {
_data.callback = get_callback(1, _data.callback);
is_requesting[1] = moment();
challonge.matches.index(_data);
try {
challonge.matches.index(_data);
} catch (error1) {
err = error1;
_data.callback(err, null);
}
}
};
challonge.matches._update = function(_data) {
var err;
try {
challonge.matches.update(_data);
} catch (error1) {
err = error1;
log.warn("Errored pushing scores to Challonge.", err);
}
};
refresh_challonge_cache = function() {
......@@ -1225,7 +1246,7 @@
};
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;
}
if (client.heartbeat_timeout) {
......@@ -1650,7 +1671,7 @@
})(this));
}
if (settings.modules.challonge.enabled && this.started && this.hostinfo.mode !== 2 && !this.kicked) {
challonge.matches.update({
challonge.matches._update({
id: settings.modules.challonge.tournament_id,
matchId: this.challonge_info.id,
match: this.get_challonge_score(),
......@@ -3462,8 +3483,9 @@
return true;
}
client.reconnecting = false;
if (client.last_game_msg && client.last_game_msg_title !== 'WAITING') {
SOCKET_flush_data(client, datas);
if (client.time_confirm_required) {
client.waiting_for_last = true;
} 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_hint_msg);
}
......@@ -4304,6 +4326,15 @@
return;
}
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;
}
if (settings.modules.heartbeat_detection.enabled) {
......@@ -4451,7 +4482,7 @@
if (settings.modules.challonge.enabled && settings.modules.challonge.post_score_midduel && room.hostinfo.mode !== 2 && client.pos === 0) {
temp_log = JSON.parse(JSON.stringify(room.get_challonge_score()));
delete temp_log.winnerId;
challonge.matches.update({
challonge.matches._update({
id: settings.modules.challonge.tournament_id,
matchId: room.challonge_info.id,
match: temp_log,
......
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