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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
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
nanahira
srvpro
Commits
1fcaaa19
Commit
1fcaaa19
authored
Mar 13, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.mycard.moe:nanahira/srvpro
parents
33727617
36683943
Pipeline
#33669
failed with stages
in 16 minutes and 40 seconds
Changes
5
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
14 deletions
+72
-14
data-manager/DeckEncoder.js
data-manager/DeckEncoder.js
+2
-0
data-manager/DeckEncoder.ts
data-manager/DeckEncoder.ts
+3
-1
data/default_config.json
data/default_config.json
+3
-1
ygopro-server.coffee
ygopro-server.coffee
+29
-6
ygopro-server.js
ygopro-server.js
+35
-6
No files found.
data-manager/DeckEncoder.js
View file @
1fcaaa19
...
...
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports
.
decodeDeck
=
exports
.
encodeDeck
=
void
0
;
const
assert_1
=
__importDefault
(
require
(
"
assert
"
));
function
encodeDeck
(
deck
)
{
deck
.
main
??
=
[];
deck
.
side
??
=
[];
let
pointer
=
0
;
const
bufferSize
=
(
2
+
deck
.
main
.
length
+
deck
.
side
.
length
)
*
4
;
const
buffer
=
Buffer
.
allocUnsafe
(
bufferSize
);
...
...
data-manager/DeckEncoder.ts
View file @
1fcaaa19
...
...
@@ -6,6 +6,8 @@ export interface Deck {
}
export
function
encodeDeck
(
deck
:
Deck
)
{
deck
.
main
??
=
[];
deck
.
side
??
=
[];
let
pointer
=
0
;
const
bufferSize
=
(
2
+
deck
.
main
.
length
+
deck
.
side
.
length
)
*
4
;
const
buffer
=
Buffer
.
allocUnsafe
(
bufferSize
);
...
...
@@ -40,4 +42,4 @@ export function decodeDeck(buffer: Buffer): Deck {
pointer
+=
4
;
}
return
{
main
,
side
};
}
\ No newline at end of file
}
data/default_config.json
View file @
1fcaaa19
...
...
@@ -16,7 +16,9 @@
"draw_count"
:
1
,
"time_limit"
:
180
,
"no_watch"
:
false
,
"auto_death"
:
false
"auto_death"
:
false
,
"bo5"
:
false
,
"sideins"
:
false
},
"modules"
:
{
"welcome"
:
"MyCard YGOPro Server"
,
...
...
ygopro-server.coffee
View file @
1fcaaa19
...
...
@@ -278,7 +278,7 @@ loadLFList = (path) ->
lflists
.
push
({
date
:
moment
(
list
.
match
(
/!([\d\.]+)/
)[
1
],
'YYYY.MM.DD'
).
utcOffset
(
"-08:00"
),
tcg
:
list
.
indexOf
(
'TCG'
)
!=
-
1
})
catch
init
=
()
->
init
=
()
->
log
.
info
(
'Reading config.'
)
await
createDirectoryIfNotExists
(
"./config"
)
await
importOldConfig
()
...
...
@@ -624,6 +624,13 @@ init = () ->
return
,
60000
)
# clean zombie rooms
setInterval
()
->
for
room
in
ROOM_all
when
room
and
!
room
.
players
.
length
room
.
terminate
()
return
,
300000
if
settings
.
modules
.
random_duel
.
enabled
setInterval
()
->
for
room
in
ROOM_all
when
room
and
room
.
duel_stage
!=
ygopro
.
constants
.
DUEL_STAGE
.
BEGIN
and
room
.
random_type
and
room
.
last_active_time
and
room
.
waiting_for_player
and
room
.
get_disconnected_count
()
==
0
and
(
!
settings
.
modules
.
side_timeout
or
room
.
duel_stage
!=
ygopro
.
constants
.
DUEL_STAGE
.
SIDING
)
and
!
room
.
recovered
...
...
@@ -642,6 +649,7 @@ init = () ->
return
,
1000
if
settings
.
modules
.
mycard
.
enabled
setInterval
()
->
for
room
in
ROOM_all
when
room
and
room
.
duel_stage
!=
ygopro
.
constants
.
DUEL_STAGE
.
BEGIN
and
room
.
arena
and
room
.
last_active_time
and
room
.
waiting_for_player
and
room
.
get_disconnected_count
()
==
0
and
(
!
settings
.
modules
.
side_timeout
or
room
.
duel_stage
!=
ygopro
.
constants
.
DUEL_STAGE
.
SIDING
)
and
!
room
.
recovered
...
...
@@ -826,7 +834,7 @@ ROOM_find_or_create_by_name = global.ROOM_find_or_create_by_name = (name, player
return
await
ROOM_find_or_create_random
(
uname
,
player_ip
)
if
room
=
ROOM_find_by_name
(
name
)
return
room
else
if
memory_usage
>=
9
0
or
(
settings
.
modules
.
max_rooms_count
and
rooms_count
>=
settings
.
modules
.
max_rooms_count
)
else
if
memory_usage
>=
9
5
or
(
settings
.
modules
.
max_rooms_count
and
rooms_count
>=
settings
.
modules
.
max_rooms_count
)
return
null
else
room
=
new
Room
(
name
)
...
...
@@ -868,7 +876,7 @@ ROOM_find_or_create_random = global.ROOM_find_or_create_random = (type, player_i
if
result
result
.
welcome
=
'${random_duel_enter_room_waiting}'
#log.info 'found room', player_name
else
if
memory_usage
<
9
0
and
not
(
settings
.
modules
.
max_rooms_count
and
rooms_count
>=
settings
.
modules
.
max_rooms_count
)
else
if
memory_usage
<
9
5
and
not
(
settings
.
modules
.
max_rooms_count
and
rooms_count
>=
settings
.
modules
.
max_rooms_count
)
type
=
if
type
then
type
else
settings
.
modules
.
random_duel
.
default_type
name
=
type
+
',RANDOM#'
+
Math
.
floor
(
Math
.
random
()
*
100000
)
result
=
new
Room
(
name
)
...
...
@@ -1489,6 +1497,13 @@ class Room
else
@
hostinfo
.
auto_death
=
40
if
(
rule
.
match
/(^|,|,)(30EX|SIDEINS)(,|,|$)/
)
@
hostinfo
.
sideins
=
true
if
(
rule
.
match
/(^|,|,)(BO5|BESTOF5)(,|,|$)/
)
@
hostinfo
.
mode
=
1
@
hostinfo
.
bo5
=
true
if
settings
.
modules
.
tournament_mode
.
enable_recover
and
(
param
=
rule
.
match
/(^|,|,)(RC|RECOVER)(\d*)T(\d*)(,|,|$)/
)
@
recovered
=
true
@
recovering
=
true
...
...
@@ -1510,7 +1525,12 @@ class Room
@
spawn
()
spawn
:
(
firstSeed
)
->
param
=
[
0
,
@
hostinfo
.
lflist
,
@
hostinfo
.
rule
,
@
hostinfo
.
mode
,
@
hostinfo
.
duel_rule
,
duel_rule_flags
=
(
@
hostinfo
.
duel_rule
&
0xf
)
if
@
hostinfo
.
sideins
duel_rule_flags
|=
0x10
if
@
hostinfo
.
bo5
duel_rule_flags
|=
0x20
param
=
[
0
,
@
hostinfo
.
lflist
,
@
hostinfo
.
rule
,
@
hostinfo
.
mode
,
duel_rule_flags
,
(
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
]
...
...
@@ -1747,8 +1767,11 @@ class Room
add_windbot
:
(
botdata
)
->
@
windbot
=
botdata
bot_url
=
"http://
#{
settings
.
modules
.
windbot
.
server_ip
}
:
#{
settings
.
modules
.
windbot
.
port
}
/?name=
#{
encodeURIComponent
(
botdata
.
name
)
}
&deck=
#{
encodeURIComponent
(
botdata
.
deck
)
}
&host=
#{
settings
.
modules
.
windbot
.
my_ip
}
&port=
#{
settings
.
port
}
&dialog=
#{
encodeURIComponent
(
botdata
.
dialog
)
}
&version=
#{
settings
.
version
}
&password=
#{
encodeURIComponent
(
@
name
)
}
"
if
botdata
.
deckcode
bot_url
+=
"&deckcode=
#{
encodeURIComponent
(
botdata
.
deckcode
.
toString
(
'base64'
))
}
"
request
url
:
"http://
#{
settings
.
modules
.
windbot
.
server_ip
}
:
#{
settings
.
modules
.
windbot
.
port
}
/?name=
#{
encodeURIComponent
(
botdata
.
name
)
}
&deck=
#{
encodeURIComponent
(
botdata
.
deck
)
}
&host=
#{
settings
.
modules
.
windbot
.
my_ip
}
&port=
#{
settings
.
port
}
&dialog=
#{
encodeURIComponent
(
botdata
.
dialog
)
}
&version=
#{
settings
.
version
}
&password=
#{
encodeURIComponent
(
@
name
)
}
"
url
:
bot_url
,
(
error
,
response
,
body
)
=>
if
error
log
.
warn
'windbot add error'
,
error
,
this
.
name
...
...
@@ -2789,7 +2812,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
ygopro
.
stoc_send_chat_to_room
(
room
,
"${death_remain_final}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
ygopro
.
stoc_send_chat_to_room
(
room
,
"${death_remain_part1}"
+
(
room
.
death
-
room
.
turn
)
+
"${death_remain_part2}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
if
client
.
surrend_confirm
if
client
.
surrend_confirm
and
(
r_player
&
0x2
)
==
0
client
.
surrend_confirm
=
false
ygopro
.
stoc_send_chat
(
client
,
"${surrender_canceled}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
...
...
ygopro-server.js
View file @
1fcaaa19
...
...
@@ -791,6 +791,16 @@
}
},
60000
);
}
// clean zombie rooms
setInterval
(
function
()
{
var
l
,
len1
,
room
;
for
(
l
=
0
,
len1
=
ROOM_all
.
length
;
l
<
len1
;
l
++
)
{
room
=
ROOM_all
[
l
];
if
(
room
&&
!
room
.
players
.
length
)
{
room
.
terminate
();
}
}
},
300000
);
if
(
settings
.
modules
.
random_duel
.
enabled
)
{
setInterval
(
async
function
()
{
var
l
,
len1
,
room
,
time_passed
;
...
...
@@ -1062,7 +1072,7 @@
}
if
(
room
=
ROOM_find_by_name
(
name
))
{
return
room
;
}
else
if
(
memory_usage
>=
9
0
||
(
settings
.
modules
.
max_rooms_count
&&
rooms_count
>=
settings
.
modules
.
max_rooms_count
))
{
}
else
if
(
memory_usage
>=
9
5
||
(
settings
.
modules
.
max_rooms_count
&&
rooms_count
>=
settings
.
modules
.
max_rooms_count
))
{
return
null
;
}
else
{
room
=
new
Room
(
name
);
...
...
@@ -1115,7 +1125,7 @@
if
(
result
)
{
result
.
welcome
=
'
${random_duel_enter_room_waiting}
'
;
//log.info 'found room', player_name
}
else
if
(
memory_usage
<
9
0
&&
!
(
settings
.
modules
.
max_rooms_count
&&
rooms_count
>=
settings
.
modules
.
max_rooms_count
))
{
}
else
if
(
memory_usage
<
9
5
&&
!
(
settings
.
modules
.
max_rooms_count
&&
rooms_count
>=
settings
.
modules
.
max_rooms_count
))
{
type
=
type
?
type
:
settings
.
modules
.
random_duel
.
default_type
;
name
=
type
+
'
,RANDOM#
'
+
Math
.
floor
(
Math
.
random
()
*
100000
);
result
=
new
Room
(
name
);
...
...
@@ -1931,6 +1941,13 @@
this
.
hostinfo
.
auto_death
=
40
;
}
}
if
(
rule
.
match
(
/
(
^|,|,
)(
30EX|SIDEINS
)(
,|,|$
)
/
))
{
this
.
hostinfo
.
sideins
=
true
;
}
if
(
rule
.
match
(
/
(
^|,|,
)(
BO5|BESTOF5
)(
,|,|$
)
/
))
{
this
.
hostinfo
.
mode
=
1
;
this
.
hostinfo
.
bo5
=
true
;
}
if
(
settings
.
modules
.
tournament_mode
.
enable_recover
&&
(
param
=
rule
.
match
(
/
(
^|,|,
)(
RC|RECOVER
)(\d
*
)
T
(\d
*
)(
,|,|$
)
/
)))
{
this
.
recovered
=
true
;
this
.
recovering
=
true
;
...
...
@@ -1956,8 +1973,15 @@
}
spawn
(
firstSeed
)
{
var
e
,
i
,
j
,
l
,
param
,
seeds
;
param
=
[
0
,
this
.
hostinfo
.
lflist
,
this
.
hostinfo
.
rule
,
this
.
hostinfo
.
mode
,
this
.
hostinfo
.
duel_rule
,
(
this
.
hostinfo
.
no_check_deck
?
'
T
'
:
'
F
'
),
(
this
.
hostinfo
.
no_shuffle_deck
?
'
T
'
:
'
F
'
),
this
.
hostinfo
.
start_lp
,
this
.
hostinfo
.
start_hand
,
this
.
hostinfo
.
draw_count
,
this
.
hostinfo
.
time_limit
,
this
.
hostinfo
.
replay_mode
];
var
duel_rule_flags
,
e
,
i
,
j
,
l
,
param
,
seeds
;
duel_rule_flags
=
this
.
hostinfo
.
duel_rule
&
0xf
;
if
(
this
.
hostinfo
.
sideins
)
{
duel_rule_flags
|=
0x10
;
}
if
(
this
.
hostinfo
.
bo5
)
{
duel_rule_flags
|=
0x20
;
}
param
=
[
0
,
this
.
hostinfo
.
lflist
,
this
.
hostinfo
.
rule
,
this
.
hostinfo
.
mode
,
duel_rule_flags
,
(
this
.
hostinfo
.
no_check_deck
?
'
T
'
:
'
F
'
),
(
this
.
hostinfo
.
no_shuffle_deck
?
'
T
'
:
'
F
'
),
this
.
hostinfo
.
start_lp
,
this
.
hostinfo
.
start_hand
,
this
.
hostinfo
.
draw_count
,
this
.
hostinfo
.
time_limit
,
this
.
hostinfo
.
replay_mode
];
if
(
firstSeed
)
{
param
.
push
(
firstSeed
);
seeds
=
getSeedTimet
(
2
);
...
...
@@ -2307,9 +2331,14 @@
}
add_windbot
(
botdata
)
{
var
bot_url
;
this
.
windbot
=
botdata
;
bot_url
=
`http://
${
settings
.
modules
.
windbot
.
server_ip
}
:
${
settings
.
modules
.
windbot
.
port
}
/?name=
${
encodeURIComponent
(
botdata
.
name
)}
&deck=
${
encodeURIComponent
(
botdata
.
deck
)}
&host=
${
settings
.
modules
.
windbot
.
my_ip
}
&port=
${
settings
.
port
}
&dialog=
${
encodeURIComponent
(
botdata
.
dialog
)}
&version=
${
settings
.
version
}
&password=
${
encodeURIComponent
(
this
.
name
)}
`
;
if
(
botdata
.
deckcode
)
{
bot_url
+=
`&deckcode=
${
encodeURIComponent
(
botdata
.
deckcode
.
toString
(
'
base64
'
))}
`
;
}
request
({
url
:
`http://
${
settings
.
modules
.
windbot
.
server_ip
}
:
${
settings
.
modules
.
windbot
.
port
}
/?name=
${
encodeURIComponent
(
botdata
.
name
)}
&deck=
${
encodeURIComponent
(
botdata
.
deck
)}
&host=
${
settings
.
modules
.
windbot
.
my_ip
}
&port=
${
settings
.
port
}
&dialog=
${
encodeURIComponent
(
botdata
.
dialog
)}
&version=
${
settings
.
version
}
&password=
${
encodeURIComponent
(
this
.
name
)}
`
url
:
bot_url
},
(
error
,
response
,
body
)
=>
{
if
(
error
)
{
log
.
warn
(
'
windbot add error
'
,
error
,
this
.
name
);
...
...
@@ -3656,7 +3685,7 @@
}
}
}
if
(
client
.
surrend_confirm
)
{
if
(
client
.
surrend_confirm
&&
(
r_player
&
0x2
)
===
0
)
{
client
.
surrend_confirm
=
false
;
ygopro
.
stoc_send_chat
(
client
,
"
${surrender_canceled}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
...
...
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