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
00b1e400
Commit
00b1e400
authored
Aug 20, 2021
by
mercury233
Committed by
GitHub
Aug 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
limit rooms count (#49)
parent
ed7f6950
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
11 deletions
+41
-11
data/default_config.json
data/default_config.json
+2
-0
ygopro-server.coffee
ygopro-server.coffee
+16
-5
ygopro-server.js
ygopro-server.js
+23
-6
No files found.
data/default_config.json
View file @
00b1e400
...
...
@@ -23,6 +23,8 @@
"update"
:
"请更新你的客户端版本"
,
"wait_update"
:
"你的客户端版本高于服务器版本,请等待服务器更新"
,
"stop"
:
false
,
"full"
:
"服务器已爆满"
,
"max_rooms_count"
:
0
,
"side_timeout"
:
false
,
"replay_delay"
:
true
,
"hide_name"
:
false
,
...
...
ygopro-server.coffee
View file @
00b1e400
...
...
@@ -718,6 +718,17 @@ ROOM_player_get_score = global.ROOM_player_get_score = (player)->
return
""
return
await
dataManager
.
getRandomDuelScoreDisplay
(
player
.
name_vpass
)
if
settings
.
modules
.
max_rooms_count
rooms_count
=
0
get_rooms_count
=
()
->
_rooms_count
=
0
for
room
in
ROOM_all
when
room
and
room
.
established
_rooms_count
++
rooms_count
=
_rooms_count
setTimeout
get_rooms_count
,
1000
return
setTimeout
get_rooms_count
,
1000
ROOM_find_or_create_by_name
=
global
.
ROOM_find_or_create_by_name
=
(
name
,
player_ip
)
->
uname
=
name
.
toUpperCase
()
if
settings
.
modules
.
windbot
.
enabled
and
(
uname
[
0
...
2
]
==
'AI'
or
(
!
settings
.
modules
.
random_duel
.
enabled
and
uname
==
''
))
...
...
@@ -726,7 +737,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
>=
90
else
if
memory_usage
>=
90
or
(
settings
.
modules
.
max_rooms_count
and
rooms_count
>=
settings
.
modules
.
max_rooms_count
)
return
null
else
room
=
new
Room
(
name
)
...
...
@@ -768,7 +779,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
<
90
else
if
memory_usage
<
90
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
)
...
...
@@ -2206,7 +2217,7 @@ ygopro.ctos_follow 'JOIN_GAME', true, (buffer, info, client, server, datas)->
return
if
!
room
ygopro
.
stoc_die
(
client
,
"${server_full}"
)
ygopro
.
stoc_die
(
client
,
settings
.
modules
.
full
)
else
if
room
.
error
ygopro
.
stoc_die
(
client
,
room
.
error
)
else
...
...
@@ -2367,7 +2378,7 @@ ygopro.ctos_follow 'JOIN_GAME', true, (buffer, info, client, server, datas)->
# room.max_player = 2
room
.
welcome
=
"${challonge_match_created}"
if
!
room
ygopro
.
stoc_die
(
client
,
"${server_full}"
)
ygopro
.
stoc_die
(
client
,
settings
.
modules
.
full
)
else
if
room
.
error
ygopro
.
stoc_die
(
client
,
room
.
error
)
else
...
...
@@ -2408,7 +2419,7 @@ ygopro.ctos_follow 'JOIN_GAME', true, (buffer, info, client, server, datas)->
#log.info 'join_game',info.pass, client.name
room
=
await
ROOM_find_or_create_by_name
(
info
.
pass
,
client
.
ip
)
if
!
room
ygopro
.
stoc_die
(
client
,
"${server_full}"
)
ygopro
.
stoc_die
(
client
,
settings
.
modules
.
full
)
else
if
room
.
error
ygopro
.
stoc_die
(
client
,
room
.
error
)
else
...
...
ygopro-server.js
View file @
00b1e400
// Generated by CoffeeScript 2.5.1
(
function
()
{
// 标准库
var
CLIENT_get_authorize_key
,
CLIENT_get_kick_reconnect_target
,
CLIENT_heartbeat_register
,
CLIENT_heartbeat_unregister
,
CLIENT_import_data
,
CLIENT_is_able_to_kick_reconnect
,
CLIENT_is_able_to_reconnect
,
CLIENT_is_banned_by_mc
,
CLIENT_is_player
,
CLIENT_kick
,
CLIENT_kick_reconnect
,
CLIENT_pre_reconnect
,
CLIENT_reconnect
,
CLIENT_reconnect_register
,
CLIENT_reconnect_unregister
,
CLIENT_send_pre_reconnect_info
,
CLIENT_send_reconnect_info
,
CLIENT_send_replays
,
Q
,
ROOM_all
,
ROOM_bad_ip
,
ROOM_ban_player
,
ROOM_clear_disconnect
,
ROOM_connected_ip
,
ROOM_find_by_name
,
ROOM_find_by_pid
,
ROOM_find_by_port
,
ROOM_find_by_title
,
ROOM_find_or_create_ai
,
ROOM_find_or_create_by_name
,
ROOM_find_or_create_random
,
ROOM_kick
,
ROOM_player_flee
,
ROOM_player_get_score
,
ROOM_player_lose
,
ROOM_player_win
,
ROOM_players_oppentlist
,
ROOM_unwelcome
,
ROOM_validate
,
ReplayParser
,
ResolveData
,
Room
,
SERVER_clear_disconnect
,
SERVER_kick
,
SOCKET_flush_data
,
_
,
_async
,
addCallback
,
athleticChecker
,
auth
,
axios
,
badwordR
,
badwords
,
ban_user
,
bunyan
,
challonge
,
challonge_cache
,
challonge_queue_callbacks
,
checkFileExists
,
createDirectoryIfNotExists
,
crypto
,
dataManager
,
deck_name_match
,
dialogues
,
disconnect_list
,
exec
,
execFile
,
fs
,
geoip
,
getDuelLogQueryFromQs
,
getSeedTimet
,
get_callback
,
get_memory_usage
,
http
,
httpRequestListener
,
importOldConfig
,
import_datas
,
init
,
is_challonge_requesting
,
lflists
,
loadJSON
,
loadJSONAsync
,
loadLFList
,
loadRemoteData
,
load_dialogues
,
load_tips
,
log
,
long_resolve_cards
,
memory_usage
,
merge
,
moment
,
moment_long_ago_string
,
moment_now
,
moment_now_string
,
net
,
netRequestHandler
,
os
,
osu
,
path
,
qs
,
real_windbot_server_ip
,
refresh_challonge_cache
,
release_disconnect
,
replaced_index
,
report_to_big_brother
,
request
,
roomlis
t
,
setting_change
,
setting_save
,
settings
,
spawn
,
spawnSync
,
spawn_windbot
,
tips
,
url
,
users_cache
,
util
,
wait_room_start
,
wait_room_start_arena
,
windbot_looplimit
,
windbot_process
,
windbots
,
ygopro
,
zlib
;
var
CLIENT_get_authorize_key
,
CLIENT_get_kick_reconnect_target
,
CLIENT_heartbeat_register
,
CLIENT_heartbeat_unregister
,
CLIENT_import_data
,
CLIENT_is_able_to_kick_reconnect
,
CLIENT_is_able_to_reconnect
,
CLIENT_is_banned_by_mc
,
CLIENT_is_player
,
CLIENT_kick
,
CLIENT_kick_reconnect
,
CLIENT_pre_reconnect
,
CLIENT_reconnect
,
CLIENT_reconnect_register
,
CLIENT_reconnect_unregister
,
CLIENT_send_pre_reconnect_info
,
CLIENT_send_reconnect_info
,
CLIENT_send_replays
,
Q
,
ROOM_all
,
ROOM_bad_ip
,
ROOM_ban_player
,
ROOM_clear_disconnect
,
ROOM_connected_ip
,
ROOM_find_by_name
,
ROOM_find_by_pid
,
ROOM_find_by_port
,
ROOM_find_by_title
,
ROOM_find_or_create_ai
,
ROOM_find_or_create_by_name
,
ROOM_find_or_create_random
,
ROOM_kick
,
ROOM_player_flee
,
ROOM_player_get_score
,
ROOM_player_lose
,
ROOM_player_win
,
ROOM_players_oppentlist
,
ROOM_unwelcome
,
ROOM_validate
,
ReplayParser
,
ResolveData
,
Room
,
SERVER_clear_disconnect
,
SERVER_kick
,
SOCKET_flush_data
,
_
,
_async
,
addCallback
,
athleticChecker
,
auth
,
axios
,
badwordR
,
badwords
,
ban_user
,
bunyan
,
challonge
,
challonge_cache
,
challonge_queue_callbacks
,
checkFileExists
,
createDirectoryIfNotExists
,
crypto
,
dataManager
,
deck_name_match
,
dialogues
,
disconnect_list
,
exec
,
execFile
,
fs
,
geoip
,
getDuelLogQueryFromQs
,
getSeedTimet
,
get_callback
,
get_memory_usage
,
get_rooms_count
,
http
,
httpRequestListener
,
importOldConfig
,
import_datas
,
init
,
is_challonge_requesting
,
lflists
,
loadJSON
,
loadJSONAsync
,
loadLFList
,
loadRemoteData
,
load_dialogues
,
load_tips
,
log
,
long_resolve_cards
,
memory_usage
,
merge
,
moment
,
moment_long_ago_string
,
moment_now
,
moment_now_string
,
net
,
netRequestHandler
,
os
,
osu
,
path
,
qs
,
real_windbot_server_ip
,
refresh_challonge_cache
,
release_disconnect
,
replaced_index
,
report_to_big_brother
,
request
,
roomlist
,
rooms_coun
t
,
setting_change
,
setting_save
,
settings
,
spawn
,
spawnSync
,
spawn_windbot
,
tips
,
url
,
users_cache
,
util
,
wait_room_start
,
wait_room_start_arena
,
windbot_looplimit
,
windbot_process
,
windbots
,
ygopro
,
zlib
;
net
=
require
(
'
net
'
);
...
...
@@ -919,6 +919,23 @@
return
(
await
dataManager
.
getRandomDuelScoreDisplay
(
player
.
name_vpass
));
};
if
(
settings
.
modules
.
max_rooms_count
)
{
rooms_count
=
0
;
get_rooms_count
=
function
()
{
var
_rooms_count
,
j
,
len
,
room
;
_rooms_count
=
0
;
for
(
j
=
0
,
len
=
ROOM_all
.
length
;
j
<
len
;
j
++
)
{
room
=
ROOM_all
[
j
];
if
(
room
&&
room
.
established
)
{
_rooms_count
++
;
}
}
rooms_count
=
_rooms_count
;
setTimeout
(
get_rooms_count
,
1000
);
};
setTimeout
(
get_rooms_count
,
1000
);
}
ROOM_find_or_create_by_name
=
global
.
ROOM_find_or_create_by_name
=
async
function
(
name
,
player_ip
)
{
var
room
,
success
,
uname
;
uname
=
name
.
toUpperCase
();
...
...
@@ -930,7 +947,7 @@
}
if
(
room
=
ROOM_find_by_name
(
name
))
{
return
room
;
}
else
if
(
memory_usage
>=
90
)
{
}
else
if
(
memory_usage
>=
90
||
(
settings
.
modules
.
max_rooms_count
&&
rooms_count
>=
settings
.
modules
.
max_rooms_count
)
)
{
return
null
;
}
else
{
room
=
new
Room
(
name
);
...
...
@@ -982,7 +999,7 @@
if
(
result
)
{
result
.
welcome
=
'
${random_duel_enter_room_waiting}
'
;
//log.info 'found room', player_name
}
else
if
(
memory_usage
<
90
)
{
}
else
if
(
memory_usage
<
90
&&
!
(
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
);
...
...
@@ -2912,7 +2929,7 @@
return
;
}
if
(
!
room
)
{
ygopro
.
stoc_die
(
client
,
"
${server_full}
"
);
ygopro
.
stoc_die
(
client
,
settings
.
modules
.
full
);
}
else
if
(
room
.
error
)
{
ygopro
.
stoc_die
(
client
,
room
.
error
);
}
else
{
...
...
@@ -3102,7 +3119,7 @@
room
.
welcome
=
"
${challonge_match_created}
"
;
}
if
(
!
room
)
{
ygopro
.
stoc_die
(
client
,
"
${server_full}
"
);
ygopro
.
stoc_die
(
client
,
settings
.
modules
.
full
);
}
else
if
(
room
.
error
)
{
ygopro
.
stoc_die
(
client
,
room
.
error
);
}
else
{
...
...
@@ -3137,7 +3154,7 @@
//log.info 'join_game',info.pass, client.name
room
=
(
await
ROOM_find_or_create_by_name
(
info
.
pass
,
client
.
ip
));
if
(
!
room
)
{
ygopro
.
stoc_die
(
client
,
"
${server_full}
"
);
ygopro
.
stoc_die
(
client
,
settings
.
modules
.
full
);
}
else
if
(
room
.
error
)
{
ygopro
.
stoc_die
(
client
,
room
.
error
);
}
else
{
...
...
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