Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
srvpro
Commits
9ebbb587
Commit
9ebbb587
authored
Sep 22, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tempg
parent
9387f727
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
2 deletions
+45
-2
ygopro-server.coffee
ygopro-server.coffee
+45
-2
No files found.
ygopro-server.coffee
View file @
9ebbb587
...
...
@@ -271,6 +271,45 @@ if settings.modules.challonge.enabled
challonge
=
require
(
'challonge'
).
createClient
({
apiKey
:
settings
.
modules
.
challonge
.
api_key
})
challonge_cache
=
[]
challonge_queue_callbacks
=
[[],
[]]
is_requesting
=
[
false
,
false
]
get_callback
=
(
challonge_type
,
_callback
)
->
return
((
err
,
data
)
->
if
!
err
and
data
challonge_cache
[
challonge_type
]
=
data
_callback
(
err
,
data
)
while
challonge_queue_callbacks
[
challonge_type
].
length
cur_callback
=
challonge_queue_callbacks
[
challonge_type
][
0
]
challonge_queue_callbacks
[
challonge_type
].
splice
(
0
,
1
)
cur_callback
(
err
,
data
)
is_requesting
[
challonge_type
]
=
false
return
)
challonge
.
participants
.
_index
=
(
_data
)
->
if
challonge_cache
[
0
]
_data
.
callback
(
null
,
challonge_cache
[
0
])
else
if
is_requesting
[
0
]
challonge_queue_callbacks
[
0
].
push
(
_data
.
callback
)
else
_data
.
callback
=
get_callback
(
0
,
_data
.
callback
)
is_requesting
[
0
]
=
true
challonge
.
participants
.
index
(
_data
)
return
challonge
.
matches
.
_index
=
(
_data
)
->
if
challonge_cache
[
1
]
_data
.
callback
(
null
,
challonge_cache
[
1
])
else
if
is_requesting
[
1
]
challonge_queue_callbacks
[
1
].
push
(
_data
.
callback
)
else
_data
.
callback
=
get_callback
(
1
,
_data
.
callback
)
is_requesting
[
1
]
=
true
challonge
.
matches
.
index
(
_data
)
return
setInterval
(
challonge_cache
[
0
]
=
null
challonge_cache
[
1
]
=
null
,
10000
)
# 获取可用内存
memory_usage
=
0
...
...
@@ -947,6 +986,8 @@ class Room
callback
:
(
err
,
data
)
->
if
err
log
.
warn
(
"Errored pushing scores to Challonge."
,
err
)
else
challonge_cache
[
1
]
=
null
return
})
if
@
player_datas
.
length
and
settings
.
modules
.
cloud_replay
.
enabled
...
...
@@ -1631,7 +1672,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
client
.
write
buffer
else
ygopro
.
stoc_send_chat
(
client
,
'${loading_user_info}'
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
challonge
.
participants
.
index
({
challonge
.
participants
.
_
index
({
id
:
settings
.
modules
.
challonge
.
tournament_id
,
callback
:
(
err
,
data
)
->
if
err
or
!
data
...
...
@@ -1648,7 +1689,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
ygopro
.
stoc_die
(
client
,
'${challonge_user_not_found}'
)
return
client
.
challonge_info
=
found
challonge
.
matches
.
index
({
challonge
.
matches
.
_
index
({
id
:
settings
.
modules
.
challonge
.
tournament_id
,
callback
:
(
err
,
data
)
->
if
client
.
closed
...
...
@@ -2816,6 +2857,8 @@ ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server)->
callback
:
(
err
,
data
)
->
if
err
log
.
warn
(
"Errored pushing scores to Challonge."
,
err
)
else
challonge_cache
[
1
]
=
null
return
})
if
room
.
random_type
or
room
.
arena
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment