Commit 6c605bb7 authored by nanahira's avatar nanahira

Merge branch 'compat_pre'

parents 710b646e 6438a63f
......@@ -72,6 +72,11 @@
"enabled": false,
"generate_count": 500
},
"pre_release_compat": {
"enabled": false,
"official_database": "./ygopro/cards.cdb",
"pre_release_database": "./../ygopro-pre-data/expansions/pre-release.cdb"
},
"random_duel": {
"enabled": true,
"no_rematch_check": false,
......
......@@ -72,6 +72,11 @@
"enabled": false,
"generate_count": 500
},
"pre_release_compat": {
"enabled": false,
"official_database": "./ygopro/cards.cdb",
"pre_release_database": "./../ygopro-pre-data/expansions/pre-release.cdb"
},
"random_duel": {
"enabled": false,
"no_rematch_check": false,
......
......@@ -77,6 +77,11 @@
"enabled": false,
"generate_count": 500
},
"pre_release_compat": {
"enabled": false,
"official_database": "./ygopro/cards.cdb",
"pre_release_database": "./../ygopro-pre-data/expansions/pre-release.cdb"
},
"random_duel": {
"enabled": false,
"no_rematch_check": false,
......
......@@ -186,6 +186,7 @@
"vip_set_victory": "Your victory word have been set.",
"vip_password_changed": "Password changed.",
"vip_player_name_too_long": "Your username or password is too long to log in. Please change your username and try again.",
"pre_release_compat_hint": "It seems like you're a duelist with pre-release cards. The pre-release compat mode is turned on.",
"replay_hint_part1": "Sending the replay of the duel number ",
"replay_hint_part2": ".",
"athletic_arena_tip": "During an athletic match, a game quit behavior is regarded as a surrender."
......@@ -521,6 +522,7 @@
"vip_set_victory": "已设置胜利台词。",
"vip_password_changed": "密码修改成功。",
"vip_player_name_too_long": "你的用户名或设置的密码太长,使用此用户名可能会无法登陆。请更换用户名重试。",
"pre_release_compat_hint": "看起来你是使用先行卡数据的用户,已开启先行卡兼容模式。",
"replay_hint_part1": "正在发送第",
"replay_hint_part2": "局决斗的录像。",
"athletic_arena_tip": "在竞技匹配中,比赛开始前退出游戏也会视为投降。"
......
......@@ -44,6 +44,7 @@ import_datas = [
"abuse_count",
"ban_mc",
"vip",
"is_using_pre_release",
"vpass",
"rag",
"rid",
......@@ -341,6 +342,9 @@ if settings.modules.windbot.enabled
if settings.modules.heartbeat_detection.enabled
long_resolve_cards = loadJSON('./data/long_resolve_cards.json')
if settings.modules.pre_release_compat.enabled
sqlite3 = require('sqlite3').verbose()
# 组件
ygopro = require './ygopro.js'
roomlist = require './roomlist.js' if settings.modules.http.websocket_roomlist
......@@ -1015,6 +1019,22 @@ SOCKET_flush_data = (sk, datas) ->
datas.splice(0, datas.length)
return true
replace_buffer = (buffer, list, start_pos) ->
found = 0
len = buffer.length
if len < 4 + start_pos
return 0
for i in [start_pos...len - 3]
code = buffer.readInt32LE(i)
if list[code]
code = list[code]
buffer.writeInt32LE(code, i)
found++
i += 3
if i >= len - 4
break
return found
class Room
constructor: (name, @hostinfo) ->
@name = name
......@@ -1039,6 +1059,40 @@ class Room
@replays = []
ROOM_all.push this
if settings.modules.pre_release_compat.enabled
list_official_to_pre = {}
list_pre_to_official = {}
@list_official_to_pre = list_official_to_pre
@list_pre_to_official = list_pre_to_official
temp_list = {}
try
official_database = new sqlite3.Database(settings.modules.pre_release_compat.official_database)
pre_release_database = new sqlite3.Database(settings.modules.pre_release_compat.pre_release_database)
pre_release_database.each("select id,name from texts", (err, result) ->
if err
log.warn("Error loading pre-release database.", err)
else
temp_list[result.name] = result.id
return
, () ->
official_database.each("select id,name from texts", (err, result) ->
if err
log.warn("Error loading official database.", err)
else if temp_list[result.name] and temp_list[result.name] != result.id
official_code = result.id
pre_release_code = temp_list[result.name]
list_official_to_pre[official_code] = pre_release_code
list_pre_to_official[pre_release_code] = official_code
return
#, () ->
# console.log("Load success.")
# return
)
return
)
catch error
log.warn("Error loading databases", error)
@hostinfo ||= JSON.parse(JSON.stringify(settings.hostinfo))
delete @hostinfo.comment
if lflists.length
......@@ -1733,6 +1787,8 @@ ygopro.ctos_follow 'PLAYER_INFO', true, (buffer, info, client, server, datas)->
client.name = name
client.vpass = vpass
client.name_vpass = if vpass then name + "$" + vpass else name
if settings.modules.pre_release_compat.enabled
client.is_using_pre_release = client.name_vpass == "COMPAT"
#console.log client.name, client.vpass
if settings.modules.vip.enabled and CLIENT_check_vip(client)
client.vip = true
......@@ -2360,6 +2416,8 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
room=ROOM_all[client.rid]
return unless room and !client.reconnecting
msg = buffer.readInt8(0)
if settings.modules.pre_release_compat.enabled and client.is_using_pre_release
replace_buffer(buffer, room.list_official_to_pre, 1)
if settings.modules.retry_handle.enabled
if ygopro.constants.MSG[msg] == 'RETRY'
if !client.retry_count?
......@@ -3271,14 +3329,51 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server, datas)->
else
#log.info("bad deck: " + client.name + " / " + buff_main + " / " + buff_side)
ygopro.stoc_send_chat(client, "${deck_incorrect_part1} #{found_deck} ${deck_incorrect_part2}", ygopro.constants.COLORS.RED)
return false
else
#log.info("player deck not found: " + client.name)
ygopro.stoc_send_chat(client, "#{client.name}${deck_not_found}", ygopro.constants.COLORS.RED)
return false
if settings.modules.pre_release_compat.enabled
found = false
buff_main_new = []
buff_side_new = []
for code in buff_main
code_ = code
if room.list_pre_to_official[code]
code_ = room.list_pre_to_official[code]
found = true
buff_main_new.push(code_)
for code in buff_side
code_ = code
if room.list_pre_to_official[code]
code_ = room.list_pre_to_official[code]
found = true
buff_side_new.push(code_)
if found
compat_struct = ygopro.structs["deck"]
compat_struct._setBuff(buffer)
compat_deckbuf = buff_main_new.concat(buff_side_new)
compat_struct.set("mainc", buff_main_new.length)
compat_struct.set("sidec", buff_side_new.length)
compat_struct.set("deckbuf", compat_deckbuf)
buffer = compat_struct.buffer
client.main = buff_main_new
client.side = buff_side_new
if !room.started
client.is_using_pre_release = found or client.vpass == "COMPAT"
if client.is_using_pre_release
ygopro.stoc_send_chat(client, "${pre_release_compat_hint}", ygopro.constants.COLORS.BABYBLUE)
return false
ygopro.ctos_follow 'RESPONSE', false, (buffer, info, client, server, datas)->
room=ROOM_all[client.rid]
return unless room and (room.random_type or room.arena)
return unless room
if settings.modules.pre_release_compat.enabled and client.is_using_pre_release
replace_buffer(buffer, room.list_pre_to_official, 0)
return unless room.random_type or room.arena
room.last_active_time = moment()
return
......
This diff is collapsed.
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