Skip to content

Commit a178456

Browse files
committed
feat:增加迟延模式
可以在标识前添加[lag]进一步放宽时间校验,以减少重开
1 parent 02f93e3 commit a178456

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/mineSweeperGUI.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,17 @@ def timeCount(self):
299299
self.showTime(self.time_10ms // 100)
300300
since_time_unix_2 = QtCore.QDateTime.currentDateTime().\
301301
toMSecsSinceEpoch() - self.start_time_unix_2
302-
if abs(t * 1000 - since_time_unix_2) > 100 and\
302+
# 防CE作弊。
303+
# 假如标识不以"[lag]"开头,则误差大于100ms时重开。
304+
# 假如标识以"[lag]"开头,则误差大于1000ms、或误差大于50ms且大于10%时重开。
305+
gap_ms = abs(t * 1000 - since_time_unix_2)
306+
if gap_ms > 100 and\
303307
(self.game_state == "playing" or self.game_state == "joking"):
304-
# 防CE作弊
305-
self.gameRestart()
308+
if self.player_identifier[:5] != "[lag]":
309+
self.gameRestart()
310+
elif gap_ms > 1000 or gap_ms > 50 and\
311+
gap_ms / min(t * 1000, since_time_unix_2) > 0.1:
312+
self.gameRestart()
306313

307314
if self.time_10ms % 1 == 0:
308315
# 计数器用100Hz的刷新率
@@ -768,8 +775,8 @@ def dump_evf_file_data(self):
768775
self.label.ms_board.player_identifier = self.player_identifier
769776
self.label.ms_board.race_identifier = self.race_identifier
770777
self.label.ms_board.uniqueness_identifier = self.unique_identifier
771-
self.label.ms_board.country = "XX" if not self.country else country_name[self.country].upper(
772-
)
778+
self.label.ms_board.country = "XX" if not self.country else\
779+
country_name[self.country].upper()
773780
self.label.ms_board.device_uuid = hashlib.md5(
774781
bytes(str(uuid.getnode()).encode())).hexdigest().encode("UTF-8")
775782

0 commit comments

Comments
 (0)