Commit dc57bdcf authored by mercury233's avatar mercury233 Committed by GitHub

save replay on ygopro error (#48)

parent 272aa580
......@@ -3570,7 +3570,7 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server, datas)->
if !room.replays[room.duel_count - 1]
# console.log("Replay saved: ", room.duel_count - 1, client.pos)
room.replays[room.duel_count - 1] = buffer
if settings.modules.mysql.enabled
if settings.modules.mysql.enabled or room.has_ygopro_error
if client.pos == 0
replay_filename=moment_now.format("YYYY-MM-DD HH-mm-ss")
if room.hostinfo.mode != 2
......@@ -3580,6 +3580,10 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server, datas)->
for player,i in room.dueling_players
replay_filename=replay_filename + (if i > 0 then (if i == 2 then " VS " else " & ") else " ") + player.name
replay_filename=replay_filename.replace(/[\/\\\?\*]/g, '_')+".yrp"
fs.writeFile(settings.modules.tournament_mode.replay_path + replay_filename, buffer, (err)->
if err then log.warn "SAVE REPLAY ERROR", replay_filename, err
)
if settings.modules.mysql.enabled
playerInfos = room.dueling_players.map((player) ->
return {
name: player.name
......@@ -3598,11 +3602,8 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server, datas)->
cardCount: if player.card_count? then player.card_count else room.hostinfo.start_hand
}
)
fs.writeFile(settings.modules.tournament_mode.replay_path + replay_filename, buffer, (err)->
if err then log.warn "SAVE REPLAY ERROR", replay_filename, err
)
dataManager.saveDuelLog(room.name, room.process_pid, room.cloud_replay_id, replay_filename, room.hostinfo.mode, room.duel_count, playerInfos) # no synchronize here because too slow
if settings.modules.cloud_replay.enabled and settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe
if settings.modules.mysql.enabled && settings.modules.cloud_replay.enabled and settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe
ygopro.stoc_send_chat(client, "${cloud_replay_delay_part1}R##{room.cloud_replay_id}${cloud_replay_delay_part2}", ygopro.constants.COLORS.BABYBLUE)
await return settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.block_replay_to_player or settings.modules.replay_delay and room.hostinfo.mode == 1
else
......
......@@ -4770,7 +4770,7 @@
// console.log("Replay saved: ", room.duel_count - 1, client.pos)
room.replays[room.duel_count - 1] = buffer;
}
if (settings.modules.mysql.enabled) {
if (settings.modules.mysql.enabled || room.has_ygopro_error) {
if (client.pos === 0) {
replay_filename = moment_now.format("YYYY-MM-DD HH-mm-ss");
if (room.hostinfo.mode !== 2) {
......@@ -4787,6 +4787,12 @@
}
}
replay_filename = replay_filename.replace(/[\/\\\?\*]/g, '_') + ".yrp";
fs.writeFile(settings.modules.tournament_mode.replay_path + replay_filename, buffer, function(err) {
if (err) {
return log.warn("SAVE REPLAY ERROR", replay_filename, err);
}
});
if (settings.modules.mysql.enabled) {
playerInfos = room.dueling_players.map(function(player) {
return {
name: player.name,
......@@ -4805,14 +4811,10 @@
cardCount: player.card_count != null ? player.card_count : room.hostinfo.start_hand
};
});
fs.writeFile(settings.modules.tournament_mode.replay_path + replay_filename, buffer, function(err) {
if (err) {
return log.warn("SAVE REPLAY ERROR", replay_filename, err);
}
});
dataManager.saveDuelLog(room.name, room.process_pid, room.cloud_replay_id, replay_filename, room.hostinfo.mode, room.duel_count, playerInfos); // no synchronize here because too slow
}
if (settings.modules.cloud_replay.enabled && settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe) {
}
if (settings.modules.mysql.enabled && settings.modules.cloud_replay.enabled && settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe) {
ygopro.stoc_send_chat(client, `\${cloud_replay_delay_part1}R#${room.cloud_replay_id}\${cloud_replay_delay_part2}`, ygopro.constants.COLORS.BABYBLUE);
}
return settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.block_replay_to_player || settings.modules.replay_delay && room.hostinfo.mode === 1;
......
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