Commit 890da55b authored by nanahira's avatar nanahira

test srvpro in ygosharp

parent 5c4550cb
......@@ -18,6 +18,7 @@ config.user.bak
/node_modules
/ssl
/ygosrv233
/ygosharp
test*
*.heapsnapshot
......
......@@ -131,6 +131,16 @@
"no_connect_count_limit": false,
"no_ban_player": false
},
"ygosharp": {
"enabled": false,
"path": "./ygosharp/",
"param": {
"root": ".",
"database": "cards.cdb",
"lflist": "lflist.conf",
"script": "script"
}
},
"pre_util": {
"enabled": false,
"port": 7944,
......
......@@ -158,6 +158,7 @@ catch
setting_save(chat_color)
try
throw 1 if settings.modules.ygosharp.enabled
cppversion = parseInt(fs.readFileSync('ygopro/gframe/game.cpp', 'utf8').match(/PRO_VERSION = ([x\dABCDEF]+)/)[1], '16')
setting_change(settings, "version", cppversion)
log.info "ygopro version 0x"+settings.version.toString(16), "(from source code)"
......@@ -166,6 +167,14 @@ catch
log.info "ygopro version 0x"+settings.version.toString(16), "(from config)"
# load the lflist of current date
lflists = []
#ygosharp
if settings.modules.ygosharp.enabled
try
for list in fs.readFileSync(settings.modules.ygosharp.path + '/' + settings.modules.ygosharp.param.lflist, 'utf8').match(/!.*/g)
date=list.match(/!([\d\.]+)/)
continue unless date
lflists.push({date: moment(list.match(/!([\d\.]+)/)[1], 'YYYY.MM.DD').utcOffset("-08:00"), tcg: list.indexOf('TCG') != -1})
catch
# expansions/lflist
try
for list in fs.readFileSync('ygopro/expansions/lflist.conf', 'utf8').match(/!.*/g)
......@@ -181,7 +190,7 @@ try
lflists.push({date: moment(list.match(/!([\d\.]+)/)[1], 'YYYY.MM.DD').utcOffset("-08:00"), tcg: list.indexOf('TCG') != -1})
catch
if settings.modules.cloud_replay.enabled
if settings.modules.cloud_replay.enabled and !settings.modules.ygosharp.enabled
redis = require 'redis'
zlib = require 'zlib'
redisdb = redis.createClient host: "127.0.0.1", port: settings.modules.cloud_replay.redis_port
......@@ -516,12 +525,40 @@ class Room
if (rule.match /(^|,|,)(IGPRIORITY|PR)(,|,|$)/)
@hostinfo.enable_priority = true
proc_bin_name = './ygopro'
proc_bin_path = 'ygopro'
if settings.modules.ygosharp.enabled
proc_bin_path = settings.modules.ygosharp.path
if /^win/.test(process.platform)
proc_bin_name = './YGOSharp.exe'
param = []
else
proc_bin_name = 'mono'
param = ['./YGOSharp.exe']
param.push('ClientVersion='+settings.version)
param.push('BanlistFile='+settings.modules.ygosharp.param.lflist)
param.push('RootPath='+settings.modules.ygosharp.param.root)
param.push('ScriptDirectory='+settings.modules.ygosharp.param.script)
param.push('DatabaseFile='+settings.modules.ygosharp.param.database)
param.push('Mode='+@hostinfo.mode)
param.push('Region='+@hostinfo.rule)
param.push('BanList='+@hostinfo.lflist)
param.push('StartLp='+@hostinfo.start_lp)
param.push('StartHand='+@hostinfo.start_hand)
param.push('DrawCount='+@hostinfo.draw_count)
param.push('GameTimer='+@hostinfo.time_limit)
param.push('NoCheckDeck='+(if @hostinfo.no_check_deck then 'true' else 'false'))
param.push('NoShuffleDeck='+(if @hostinfo.no_shuffle_deck then 'true' else 'false'))
param.push('MasterRule='+(if @hostinfo.enable_priority then '3' else '4'))
param.push('SRVProMode=true')
param.push('SRVProReplayMode='+@hostinfo.replay_mode)
else
param = [0, @hostinfo.lflist, @hostinfo.rule, @hostinfo.mode, (if @hostinfo.enable_priority then 'T' else 'F'),
(if @hostinfo.no_check_deck then 'T' else 'F'), (if @hostinfo.no_shuffle_deck then 'T' else 'F'),
@hostinfo.start_lp, @hostinfo.start_hand, @hostinfo.draw_count, @hostinfo.time_limit, @hostinfo.replay_mode]
try
@process = spawn './ygopro', param, {cwd: 'ygopro'}
@process = spawn proc_bin_name, param, {cwd: proc_bin_path}
@process.on 'error', (err)=>
_.each @players, (player)->
ygopro.stoc_die(player, "${create_room_failed}")
......@@ -590,7 +627,7 @@ class Room
#else
# log.info 'SCORE POST OK', response.statusCode, response.statusMessage, @name, body
return
if @player_datas.length and settings.modules.cloud_replay.enabled
if @player_datas.length and settings.modules.cloud_replay.enabled and !settings.modules.ygosharp.enabled
replay_id = @cloud_replay_id
if @has_ygopro_error
log_rep_id = true
......@@ -792,7 +829,7 @@ net.createServer (client) ->
client.destroy()
return
if settings.modules.cloud_replay.enabled
if settings.modules.cloud_replay.enabled and !settings.modules.ygosharp.enabled
client.open_cloud_replay= (err, replay)->
if err or !replay
ygopro.stoc_die(client, "${cloud_replay_no}")
......@@ -994,7 +1031,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
if settings.modules.stop
ygopro.stoc_die(client, settings.modules.stop)
else if info.pass.toUpperCase()=="R" and settings.modules.cloud_replay.enabled
else if info.pass.toUpperCase()=="R" and settings.modules.cloud_replay.enabled and !settings.modules.ygosharp.enabled
ygopro.stoc_send_chat(client,"${cloud_replay_hint}", ygopro.constants.COLORS.BABYBLUE)
redisdb.lrange client.ip+":replays", 0, 2, (err, result)->
_.each result, (replay_id,id)->
......@@ -1015,7 +1052,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
client.destroy()
return), 500
else if info.pass[0...2].toUpperCase()=="R#" and settings.modules.cloud_replay.enabled
else if info.pass[0...2].toUpperCase()=="R#" and settings.modules.cloud_replay.enabled and !settings.modules.ygosharp.enabled
replay_id=info.pass.split("#")[1]
if (replay_id>0 and replay_id<=9)
redisdb.lindex client.ip+":replays", replay_id-1, (err, replay_id)->
......@@ -1030,7 +1067,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
else
ygopro.stoc_die(client, "${cloud_replay_no}")
else if info.pass.toUpperCase()=="W" and settings.modules.cloud_replay.enabled
else if info.pass.toUpperCase()=="W" and settings.modules.cloud_replay.enabled and !settings.modules.ygosharp.enabled
replay_id=Cloud_replay_ids[Math.floor(Math.random()*Cloud_replay_ids.length)]
redisdb.hgetall "replay:"+replay_id, client.open_cloud_replay
......@@ -1138,6 +1175,11 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
if settings.modules.cloud_replay.enable_halfway_watch
client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room)
if settings.modules.ygosharp.enabled
ygopro.stoc_send_chat_to_room(room, "#{client.name} ${watch_join}")
ygopro.stoc_send_chat(client, "${watch_watching}", ygopro.constants.COLORS.BABYBLUE)
room.connect(client)
return
client.is_post_watcher = true
ygopro.stoc_send_chat_to_room(room, "#{client.name} ${watch_join}")
room.watchers.push client
......@@ -1248,6 +1290,11 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
if settings.modules.cloud_replay.enable_halfway_watch
client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room)
if settings.modules.ygosharp.enabled
ygopro.stoc_send_chat_to_room(room, "#{client.name} ${watch_join}")
ygopro.stoc_send_chat(client, "${watch_watching}", ygopro.constants.COLORS.BABYBLUE)
room.connect(client)
return
client.is_post_watcher = true
ygopro.stoc_send_chat_to_room(room, "#{client.name} ${watch_join}")
room.watchers.push client
......@@ -1286,7 +1333,7 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
#client.score_shown = true
return
if !room.recorder
if !room.recorder and !settings.modules.ygosharp.enabled
room.recorder = recorder = net.connect room.port, ->
ygopro.ctos_send recorder, 'PLAYER_INFO', {
name: "Marshtomp"
......@@ -1300,14 +1347,14 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
recorder.on 'data', (data)->
room=ROOM_all[client.rid]
return unless room and settings.modules.cloud_replay.enabled
return unless room and settings.modules.cloud_replay.enabled and !settings.modules.ygosharp.enabled
room.recorder_buffers.push data
return
recorder.on 'error', (error)->
return
if settings.modules.cloud_replay.enable_halfway_watch and !room.watcher
if settings.modules.cloud_replay.enable_halfway_watch and !settings.modules.ygosharp.enabled and !room.watcher
room.watcher = watcher = if settings.modules.test_mode.watch_public_hand then room.recorder else net.connect room.port, ->
ygopro.ctos_send watcher, 'PLAYER_INFO', {
name: "the Big Brother"
......@@ -2080,7 +2127,7 @@ ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server)->
ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
room=ROOM_all[client.rid]
return settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe unless room
if settings.modules.cloud_replay.enabled and room.random_type
if settings.modules.cloud_replay.enabled and !settings.modules.ygosharp.enabled and !settings.modules.ygosharp.enabled and room.random_type
Cloud_replay_ids.push room.cloud_replay_id
if settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.replay_safe
if client.pos == 0
......@@ -2110,7 +2157,7 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
fs.writeFile(settings.modules.tournament_mode.replay_path + replay_filename, buffer, (err)->
if err then log.warn "SAVE REPLAY ERROR", replay_filename, err
)
if settings.modules.cloud_replay.enabled
if settings.modules.cloud_replay.enabled and !settings.modules.ygosharp.enabled
ygopro.stoc_send_chat(client, "${cloud_replay_delay_part1}R##{room.cloud_replay_id}${cloud_replay_delay_part2}", ygopro.constants.COLORS.BABYBLUE)
return settings.modules.tournament_mode.block_replay_to_player
else
......
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