Commit 0ad19f16 authored by nanahira's avatar nanahira

add hide_name and disable_chat

parent bd64c628
Pipeline #29616 passed with stages
in 15 minutes
......@@ -79,6 +79,7 @@
"record_match_scores": false,
"post_match_scores": false,
"post_match_accesskey": "123456",
"disable_chat": false,
"blank_pass_modes": {
"S": true,
"M": true,
......
......@@ -178,6 +178,7 @@
"refresh_failed": "Refresh field failed.",
"banned_athletic_deck_part1": "Entertainment Mode does not allow top ",
"banned_athletic_deck_part2": " popular meta decks. Please change your deck.",
"chat_disabled": "Chat is disabled in this room.",
"using_athletic_deck": " is using a competitive deck."
},
"es-es": {
......@@ -505,6 +506,7 @@
"refresh_fail": "刷新场面失败。",
"banned_athletic_deck_part1": "娱乐匹配中禁止使用使用数前",
"banned_athletic_deck_part2": "的竞技卡组。请更换卡组。",
"chat_disabled": "本房间禁止聊天。",
"using_athletic_deck": " 正在使用竞技卡组。"
},
"ko-kr": {
......
......@@ -314,6 +314,9 @@ init = () ->
settings.modules.random_duel.blank_pass_modes = {"S":true,"M":false,"T":false}
delete settings.modules.random_duel.blank_pass_match
imported = true
if settings.modules.hide_name == true
settings.modules.hide_name = "start"
imported = true
#finish
keysFromEnv = Object.keys(process.env).filter((key) => key.startsWith('SRVPRO_'))
if keysFromEnv.length > 0
......@@ -1660,7 +1663,7 @@ class Room
if settings.modules.random_duel.record_match_scores and @random_type == 'M'
ROOM_player_flee(client.name_vpass)
if @players.length and !(@windbot and client.is_host) and !(@arena and @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and client.pos <= 3)
left_name = (if settings.modules.hide_name and @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN then "********" else client.name)
left_name = @getMaskedPlayerName(client)
ygopro.stoc_send_chat_to_room this, "#{left_name} ${left_game}" + if error then ": #{error}" else ''
roomlist.update(this) if !@windbot and @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and settings.modules.http.websocket_roomlist
#client.room = null
......@@ -1816,6 +1819,15 @@ class Room
@watcher_buffers.push chat_buf
return
getMaskedPlayerName(player, sight_player) ->
if not settings.modules.hide_name or (sight_player and player == sight_player) or not (@random_type or @arena)
return player.name
if @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and settings.modules.hide_name == "start"
return "********"
if settings.modules.hide_name == "always"
return "********"
return player.name
# 网络连接
netRequestHandler = (client) ->
if !client.isWs
......@@ -2815,7 +2827,7 @@ ygopro.stoc_follow 'TYPE_CHANGE', true, (buffer, info, client, server, datas)->
ygopro.stoc_follow 'HS_PLAYER_ENTER', true, (buffer, info, client, server, datas)->
room=ROOM_all[client.rid]
return false unless room and settings.modules.hide_name and room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN
if room and settings.modules.hide_name and room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN
pos = info.pos
if pos < 4 and pos != client.pos
struct = ygopro.structs.get("STOC_HS_PlayerEnter")
......@@ -2924,7 +2936,7 @@ wait_room_start_arena = (room)->
if room.waiting_for_player_time > 0
unless room.waiting_for_player_time % 5
for player in room.players when player
display_name = (if settings.modules.hide_name and player != room.waiting_for_player then "********" else room.waiting_for_player.name)
display_name = room.getMaskedPlayerName(player, room.waiting_for_player)
ygopro.stoc_send_chat(player, "#{if room.waiting_for_player_time <= 9 then ' ' else ''}#{room.waiting_for_player_time}${kick_count_down_arena_part1} #{display_name} ${kick_count_down_arena_part2}", if room.waiting_for_player_time <= 9 then ygopro.constants.COLORS.RED else ygopro.constants.COLORS.LIGHTBLUE)
else
ygopro.stoc_send_chat_to_room(room, "#{room.waiting_for_player.name} ${kicked_by_system}", ygopro.constants.COLORS.RED)
......@@ -2990,7 +3002,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server, datas)->
clearInterval client.side_interval
client.side_interval = null
client.side_tcount = null
if settings.modules.hide_name and room.duel_count == 0
if settings.modules.hide_name == "start" and room.duel_count == 0
for player in room.get_playing_player() when player != client
ygopro.stoc_send(client, 'HS_PLAYER_ENTER', {
name: player.name,
......@@ -3186,6 +3198,9 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)->
ygopro.stoc_send_chat_to_room(room, "#{client.name}: #{msg}", 9)
return true
return cancel
if room.random_type and settings.modules.random_duel.disable_chat
ygopro.stoc_send_chat(client, "${chat_disabled}", ygopro.constants.COLORS.BABYBLUE)
return true
if client.abuse_count>=5 or CLIENT_is_banned_by_mc(client)
log.warn "BANNED CHAT", client.name, client.ip, msg
ygopro.stoc_send_chat(client, "${banned_chat_tip}" + (if client.ban_mc and client.ban_mc.message then (": " + client.ban_mc.message) else ""), ygopro.constants.COLORS.RED)
......
......@@ -415,6 +415,10 @@
delete settings.modules.random_duel.blank_pass_match;
imported = true;
}
if (settings.modules.hide_name === true) {
settings.modules.hide_name = "start";
imported = true;
}
//finish
keysFromEnv = Object.keys(process.env).filter((key) => {
return key.startsWith('SRVPRO_');
......@@ -1582,7 +1586,8 @@
});
};
Room = class Room {
Room = (function() {
class Room {
constructor(name, hostinfo) {
var death_time, draw_count, duel_rule, extra_mode_func, lflist, param, rule, start_hand, start_lp, time_limit;
this.hostinfo = hostinfo;
......@@ -2222,7 +2227,7 @@
}
}
if (this.players.length && !(this.windbot && client.is_host) && !(this.arena && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && client.pos <= 3)) {
left_name = (settings.modules.hide_name && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN ? "********" : client.name);
left_name = this.getMaskedPlayerName(client);
ygopro.stoc_send_chat_to_room(this, `${left_name} \${left_game}` + (error ? `: ${error}` : ''));
if (!this.windbot && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.http.websocket_roomlist) {
roomlist.update(this);
......@@ -2459,6 +2464,23 @@
};
getMaskedPlayerName(player, sight_player)(function() {
if (!settings.modules.hide_name || (sight_player && player === sight_player) || !(this.random_type || this.arena)) {
return player.name;
}
if (this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.hide_name === "start") {
return "********";
}
if (settings.modules.hide_name === "always") {
return "********";
}
return player.name;
});
return Room;
}).call(this);
// 网络连接
netRequestHandler = function(client) {
var closeHandler, connect_count, dataHandler, server;
......@@ -3718,9 +3740,7 @@
ygopro.stoc_follow('HS_PLAYER_ENTER', true, async function(buffer, info, client, server, datas) {
var pos, room, struct;
room = ROOM_all[client.rid];
if (!(room && settings.modules.hide_name && room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN)) {
return false;
}
if (room && settings.modules.hide_name && room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN) {
pos = info.pos;
if (pos < 4 && pos !== client.pos) {
struct = ygopro.structs.get("STOC_HS_PlayerEnter");
......@@ -3728,6 +3748,7 @@
struct.set("name", "********");
buffer = struct.buffer;
}
}
return false;
});
......@@ -3894,7 +3915,7 @@
if (!(player)) {
continue;
}
display_name = (settings.modules.hide_name && player !== room.waiting_for_player ? "********" : room.waiting_for_player.name);
display_name = room.getMaskedPlayerName(player, room.waiting_for_player);
ygopro.stoc_send_chat(player, `${room.waiting_for_player_time <= 9 ? ' ' : ''}${room.waiting_for_player_time}\${kick_count_down_arena_part1} ${display_name} \${kick_count_down_arena_part2}`, room.waiting_for_player_time <= 9 ? ygopro.constants.COLORS.RED : ygopro.constants.COLORS.LIGHTBLUE);
}
}
......@@ -3991,7 +4012,7 @@
client.side_tcount = null;
}
}
if (settings.modules.hide_name && room.duel_count === 0) {
if (settings.modules.hide_name === "start" && room.duel_count === 0) {
ref1 = room.get_playing_player();
for (l = 0, len1 = ref1.length; l < len1; l++) {
player = ref1[l];
......@@ -4275,6 +4296,10 @@
}
return cancel;
}
if (room.random_type && settings.modules.random_duel.disable_chat) {
ygopro.stoc_send_chat(client, "${chat_disabled}", ygopro.constants.COLORS.BABYBLUE);
return true;
}
if (client.abuse_count >= 5 || CLIENT_is_banned_by_mc(client)) {
log.warn("BANNED CHAT", client.name, client.ip, msg);
ygopro.stoc_send_chat(client, "${banned_chat_tip}" + (client.ban_mc && client.ban_mc.message ? ": " + client.ban_mc.message : ""), ygopro.constants.COLORS.RED);
......
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