Commit 4e44d2c7 authored by nanahira's avatar nanahira

replay_mode flag

parent 829ee179
...@@ -1304,12 +1304,14 @@ class Room ...@@ -1304,12 +1304,14 @@ class Room
@recover_buffers = [[], [], [], []] @recover_buffers = [[], [], [], []]
@welcome = "${recover_hint}" @welcome = "${recover_hint}"
@hostinfo.replay_mode = 0 # 0x1: Save the replays in file. 0x2: Block the replays to observers. @hostinfo.replay_mode = 0
if settings.modules.tournament_mode.enabled if settings.modules.tournament_mode.enabled # 0x1: Save the replays in file
@hostinfo.replay_mode |= 0x1 @hostinfo.replay_mode |= 0x1
if (settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.block_replay_to_player) or (@hostinfo.mode == 1 and settings.modules.replay_delay) if (settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.block_replay_to_player) or (@hostinfo.mode == 1 and settings.modules.replay_delay) # 0x2: Block the replays to observers
@hostinfo.replay_mode |= 0x2 @hostinfo.replay_mode |= 0x2
if settings.modules.tournament_mode.enabled or room.arena # 0x4: Save chat in cloud replay
@hostinfo.replay_mode |= 0x4
if !@recovered if !@recovered
@spawn() @spawn()
...@@ -1756,6 +1758,11 @@ class Room ...@@ -1756,6 +1758,11 @@ class Room
else else
@last_active_time = moment_now_string @last_active_time = moment_now_string
addRecorderBuffer: (buffer) ->
if settings.modules.cloud_replay.enabled
@recorder_buffers.push buffer
return
# 网络连接 # 网络连接
netRequestHandler = (client) -> netRequestHandler = (client) ->
client.ip = client.remoteAddress client.ip = client.remoteAddress
...@@ -2392,8 +2399,8 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ...@@ -2392,8 +2399,8 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
recorder.on 'data', (data)-> recorder.on 'data', (data)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return unless room and settings.modules.cloud_replay.enabled return unless room
room.recorder_buffers.push data room.addRecorderBuffer(data)
return return
recorder.on 'error', (error)-> recorder.on 'error', (error)->
......
...@@ -1703,13 +1703,16 @@ ...@@ -1703,13 +1703,16 @@
this.welcome = "${recover_hint}"; this.welcome = "${recover_hint}";
} }
} }
this.hostinfo.replay_mode = 0; // 0x1: Save the replays in file. 0x2: Block the replays to observers. this.hostinfo.replay_mode = 0;
if (settings.modules.tournament_mode.enabled) { if (settings.modules.tournament_mode.enabled) { // 0x1: Save the replays in file
this.hostinfo.replay_mode |= 0x1; this.hostinfo.replay_mode |= 0x1;
} }
if ((settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.block_replay_to_player) || (this.hostinfo.mode === 1 && settings.modules.replay_delay)) { if ((settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.block_replay_to_player) || (this.hostinfo.mode === 1 && settings.modules.replay_delay)) { // 0x2: Block the replays to observers
this.hostinfo.replay_mode |= 0x2; this.hostinfo.replay_mode |= 0x2;
} }
if (settings.modules.tournament_mode.enabled || room.arena) { // 0x4: Save chat in cloud replay
this.hostinfo.replay_mode |= 0x4;
}
if (!this.recovered) { if (!this.recovered) {
this.spawn(); this.spawn();
} }
...@@ -2379,6 +2382,12 @@ ...@@ -2379,6 +2382,12 @@
} }
} }
addRecorderBuffer(buffer) {
if (settings.modules.cloud_replay.enabled) {
this.recorder_buffers.push(buffer);
}
}
}; };
// 网络连接 // 网络连接
...@@ -3148,10 +3157,10 @@ ...@@ -3148,10 +3157,10 @@
}); });
recorder.on('data', function(data) { recorder.on('data', function(data) {
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!(room && settings.modules.cloud_replay.enabled)) { if (!room) {
return; return;
} }
room.recorder_buffers.push(data); room.addRecorderBuffer(data);
}); });
recorder.on('error', function(error) {}); recorder.on('error', function(error) {});
} }
......
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