破基岩榜改为深灰色;避免int型数据溢出污染记分板。脚本:不再缓存服务器白名单

This commit is contained in:
Harvey_Husky
2023-07-24 19:46:24 +08:00
parent 2a96a9ee3a
commit cfbd6da92a
14 changed files with 77 additions and 59 deletions
+18 -27
View File
@@ -43,7 +43,6 @@ global_current_scoreboard_list = [
'fzsd.module.scoreboard.display.aviating_distance',
'fzsd.module.scoreboard.display.placement_count'
];
global_server_whitelist_cache = null;
__config() -> {
'scope' -> 'global',
@@ -184,10 +183,7 @@ __on_player_disconnects(player, reason) -> (
// 获取服务器白名单
get_server_whitelist() -> (
if(global_server_whitelist_cache == null,
global_server_whitelist_cache = keys(system_info('server_whitelist'));
);
return(global_server_whitelist_cache);
return(keys(system_info('server_whitelist')));
);
// 重载配置文件
@@ -387,20 +383,14 @@ merge_score(from, to, fzsd_version) -> (
// 获取承载总榜数据的玩家名
// 因为新计分板允许玩家自定义显示的总榜名称故做复杂判断才能使脚本确定用来承载总榜数据的玩家名
get_total_score_name_new(scoreboard) -> (
INT_MIN = -2147483648;
// 获取系统总榜id
system_total_name = replace(scoreboard, 'display', 'total');
// 系统总榜id
sys_total_name = replace(scoreboard, 'display', 'total');
// 当前总分
current_score = scoreboard('fzsd.module.scoreboard.assign.general', sys_total_name);
// 将系统总榜分数加上最小int值使其成为最低分
scoreboard(
'fzsd.module.scoreboard.assign.general',
system_total_name,
scoreboard(
'fzsd.module.scoreboard.assign.general',
system_total_name
) + INT_MIN
);
// 将系统总榜分数设为INT_MIN使其成为最低分
scoreboard('fzsd.module.scoreboard.assign.general', sys_total_name, -2147483648);
// 将总分赋值到显示计分板上
display_total_score(scoreboard);
@@ -419,14 +409,7 @@ get_total_score_name_new(scoreboard) -> (
);
// 恢复总榜分数
scoreboard(
'fzsd.module.scoreboard.assign.general',
system_total_name,
scoreboard(
'fzsd.module.scoreboard.assign.general',
system_total_name
) - INT_MIN
);
scoreboard('fzsd.module.scoreboard.assign.general', sys_total_name, current_score);
display_total_score(scoreboard);
// 返回榜内最低分的玩家名承载总榜数据的玩家名
@@ -444,7 +427,15 @@ command_recalculate_total_score(scoreboard) -> (
total_score = 0;
for(scoreboard(scoreboard),
if(_ != total_score_name_new,
total_score += scoreboard(scoreboard, _);
current_player_score = scoreboard(scoreboard, _);
if(current_player_score < 0, // 避免溢出
current_player_score = 2147483647;
scoreboard(scoreboard, _, 2147483647);
);
total_score += current_player_score;
);
if(total_score < 0, // 避免溢出
total_score = 2147483647;
);
);
// 赋值总分到系统总分计分板
@@ -521,7 +512,7 @@ restore_score(player_name, scoreboard) -> (
require_not_null(player_name);
if(scoreboard == null,
for(global_current_scoreboard_list, restore_score(player_name, _));
return();
return(true);
);
player = player(player_name);
player_is_offline = false;