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
a180954a
Commit
a180954a
authored
Nov 14, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish rep chat feature
parent
c9102370
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
86 deletions
+110
-86
ygopro-server.coffee
ygopro-server.coffee
+38
-27
ygopro-server.js
ygopro-server.js
+44
-28
ygopro.coffee
ygopro.coffee
+12
-5
ygopro.js
ygopro.js
+16
-26
No files found.
ygopro-server.coffee
View file @
a180954a
This diff is collapsed.
Click to expand it.
ygopro-server.js
View file @
a180954a
...
...
@@ -1321,7 +1321,7 @@
ref
=
room
.
get_playing_player
();
for
(
l
=
0
,
len1
=
ref
.
length
;
l
<
len1
;
l
++
)
{
player
=
ref
[
l
];
if (!player.
c
losed && player.name === client.name && (settings.modules.challonge.enabled || player.pass === client.pass) && (settings.modules.mycard.enabled || settings.modules.tournament_mode.enabled || player.ip === client.ip || (client.vpass && client.vpass === player.vpass)) && (!deckbuf || deckbuf.compare(player.start_deckbuf) === 0)) {
if
(
!
player
.
isC
losed
&&
player
.
name
===
client
.
name
&&
(
settings
.
modules
.
challonge
.
enabled
||
player
.
pass
===
client
.
pass
)
&&
(
settings
.
modules
.
mycard
.
enabled
||
settings
.
modules
.
tournament_mode
.
enabled
||
player
.
ip
===
client
.
ip
||
(
client
.
vpass
&&
client
.
vpass
===
player
.
vpass
))
&&
(
!
deckbuf
||
deckbuf
.
compare
(
player
.
start_deckbuf
)
===
0
))
{
return
player
;
}
}
...
...
@@ -1481,7 +1481,7 @@
};
CLIENT_heartbeat_register
=
global
.
CLIENT_heartbeat_register
=
function
(
client
,
send
)
{
if (!settings.modules.heartbeat_detection.enabled || client.
c
losed || client.is_post_watcher || client.pre_reconnecting || client.reconnecting || client.waiting_for_last || client.pos > 3 || client.heartbeat_protected) {
if
(
!
settings
.
modules
.
heartbeat_detection
.
enabled
||
client
.
isC
losed
||
client
.
is_post_watcher
||
client
.
pre_reconnecting
||
client
.
reconnecting
||
client
.
waiting_for_last
||
client
.
pos
>
3
||
client
.
heartbeat_protected
)
{
return
false
;
}
if
(
client
.
heartbeat_timeout
)
{
...
...
@@ -1500,7 +1500,7 @@
}
client
.
heartbeat_timeout
=
setTimeout
(
function
()
{
CLIENT_heartbeat_unregister
(
client
);
if (!(client.
c
losed || client.heartbeat_responsed)) {
if
(
!
(
client
.
isC
losed
||
client
.
heartbeat_responsed
))
{
client
.
destroy
();
}
},
settings
.
modules
.
heartbeat_detection
.
wait_time
);
...
...
@@ -1514,7 +1514,7 @@
CLIENT_send_replays
=
global
.
CLIENT_send_replays
=
function
(
client
,
room
)
{
var
buffer
,
i
,
j
,
len
,
ref
;
if (!(settings.modules.replay_delay && !(settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.block_replay_to_player) && room.replays.length && room.hostinfo.mode === 1 && !client.replays_sent && !client.
c
losed)) {
if
(
!
(
settings
.
modules
.
replay_delay
&&
!
(
settings
.
modules
.
tournament_mode
.
enabled
&&
settings
.
modules
.
tournament_mode
.
block_replay_to_player
)
&&
room
.
replays
.
length
&&
room
.
hostinfo
.
mode
===
1
&&
!
client
.
replays_sent
&&
!
client
.
isC
losed
))
{
return
false
;
}
client
.
replays_sent
=
true
;
...
...
@@ -1533,7 +1533,7 @@
SOCKET_flush_data
=
global
.
SOCKET_flush_data
=
async
function
(
sk
,
datas
)
{
var
buffer
;
if (!sk || sk.
c
losed) {
if
(
!
sk
||
sk
.
isC
losed
)
{
return
false
;
}
while
(
datas
.
length
)
{
...
...
@@ -2002,7 +2002,7 @@
ref
=
this
.
get_playing_player
();
for
(
j
=
0
,
len
=
ref
.
length
;
j
<
len
;
j
++
)
{
player
=
ref
[
j
];
if (player.
c
losed) {
if
(
player
.
isC
losed
)
{
found
++
;
}
}
...
...
@@ -2397,12 +2397,28 @@
}
}
addRecorderBuffer(buffer
, isChat
) {
if (settings.modules.cloud_replay.enabled
&& (!isChat || this.arena || settings.modules.tournament_mode.enabled)
) {
addRecorderBuffer
(
buffer
)
{
if
(
settings
.
modules
.
cloud_replay
.
enabled
)
{
this
.
recorder_buffers
.
push
(
buffer
);
}
}
recordChatMessage
(
msg
,
player
)
{
var
chat_buf
,
j
,
len
,
line
,
ref
;
if
(
!
(
settings
.
modules
.
cloud_replay
.
enabled
&&
(
this
.
arena
||
settings
.
modules
.
tournament_mode
.
enabled
)))
{
return
;
}
ref
=
ygopro
.
split_chat_lines
(
msg
,
player
,
settings
.
modules
.
i18n
.
default
);
for
(
j
=
0
,
len
=
ref
.
length
;
j
<
len
;
j
++
)
{
line
=
ref
[
j
];
chat_buf
=
ygopro
.
helper
.
prepareMessage
(
"
STOC_CHAT
"
,
{
player
:
player
,
msg
:
line
});
this
.
addRecorderBuffer
(
chat_buf
);
}
}
};
// 网络连接
...
...
@@ -2432,9 +2448,9 @@
// 释放处理
closeHandler
=
function
(
error
)
{
var
room
;
log.info("client closed", client.name, error, client.closed);
log.info("disconnect", client.ip, ROOM_connected_ip[client.ip]);
if (client.
c
losed) {
//log.info "client closed", client.name, error, client.isClosed
//log.info "disconnect", client.ip, ROOM_connected_ip[client.ip]
if
(
client
.
isC
losed
)
{
return
;
}
room
=
ROOM_all
[
client
.
rid
];
...
...
@@ -2443,7 +2459,7 @@
connect_count
--
;
}
ROOM_connected_ip
[
client
.
ip
]
=
connect_count
;
client.
c
losed = true;
client
.
isC
losed
=
true
;
if
(
settings
.
modules
.
heartbeat_detection
.
enabled
)
{
CLIENT_heartbeat_unregister
(
client
);
}
...
...
@@ -2474,19 +2490,19 @@
client
.
on
(
'
error
'
,
closeHandler
);
server
.
on
(
'
close
'
,
function
(
had_error
)
{
var
room
;
if (!server.
c
losed) {
server.
c
losed = true;
if
(
!
server
.
isC
losed
)
{
server
.
isC
losed
=
true
;
}
if
(
!
server
.
client
)
{
return
;
}
//log.info "server
c
losed", server.client.name, had_error
//log.info "server
isC
losed", server.client.name, had_error
room
=
ROOM_all
[
server
.
client
.
rid
];
if
(
room
&&
!
server
.
system_kicked
&&
!
server
.
had_new_reconnection
)
{
//log.info "server close", server.client.ip, ROOM_connected_ip[server.client.ip]
room
.
disconnector
=
'
server
'
;
}
if (!server.client.
c
losed) {
if
(
!
server
.
client
.
isC
losed
)
{
ygopro
.
stoc_send_chat
(
server
.
client
,
"
${server_closed}
"
,
ygopro
.
constants
.
COLORS
.
RED
);
//if room and settings.modules.replay_delay
// room.send_replays()
...
...
@@ -2496,7 +2512,7 @@
});
server
.
on
(
'
error
'
,
function
(
error
)
{
var
room
;
server.
c
losed = error;
server
.
isC
losed
=
error
;
if
(
!
server
.
client
)
{
return
;
}
...
...
@@ -2506,7 +2522,7 @@
//log.info "server err close", client.ip, ROOM_connected_ip[client.ip]
room
.
disconnector
=
'
server
'
;
}
if (!server.client.
c
losed) {
if
(
!
server
.
client
.
isC
losed
)
{
ygopro
.
stoc_send_chat
(
server
.
client
,
`\${server_error}:
${
error
}
`
,
ygopro
.
constants
.
COLORS
.
RED
);
//if room and settings.modules.replay_delay
// room.send_replays()
...
...
@@ -2594,7 +2610,7 @@
return
;
}
}
if (client.
c
losed || !client.server) {
if
(
client
.
isC
losed
||
!
client
.
server
)
{
return
;
}
if
(
client
.
established
)
{
...
...
@@ -2627,7 +2643,7 @@
return
;
}
}
if (server.client && !server.client.
c
losed) {
if
(
server
.
client
&&
!
server
.
client
.
isC
losed
)
{
ref
=
handle_data
.
datas
;
for
(
j
=
0
,
len
=
ref
.
length
;
j
<
len
;
j
++
)
{
buffer
=
ref
[
j
];
...
...
@@ -2809,7 +2825,7 @@
};
create_room_with_action
=
async
function
(
buffer
,
decrypted_buffer
)
{
var
action
,
e
,
firstByte
,
len2
,
m
,
matchPermitRes
,
match_permit
,
name
,
opt0
,
opt1
,
opt2
,
opt3
,
options
,
player
,
ref
,
ref1
,
room
,
room_title
,
title
;
if (client.
c
losed) {
if
(
client
.
isC
losed
)
{
return
;
}
firstByte
=
buffer
.
readUInt8
(
1
);
...
...
@@ -2904,7 +2920,7 @@
e
=
error1
;
log
.
warn
(
`match permit fail
${
e
.
toString
()}
`
);
}
if (client.
c
losed) {
if
(
client
.
isC
losed
)
{
return
;
}
if
(
match_permit
&&
match_permit
.
permit
===
false
)
{
...
...
@@ -2981,12 +2997,12 @@
//console.log userData
e
=
error1
;
log
.
warn
(
"
READ USER FAIL
"
,
client
.
name
,
e
.
toString
());
if (!client.
c
losed) {
if
(
!
client
.
isC
losed
)
{
ygopro
.
stoc_die
(
client
,
'
${load_user_info_fail}
'
);
}
return
;
}
if (client.
c
losed) {
if
(
client
.
isC
losed
)
{
return
;
}
users_cache
[
client
.
name
]
=
userData
.
user
.
id
;
...
...
@@ -3023,7 +3039,7 @@
recover_match
=
info
.
pass
.
match
(
/^
(
RC|RECOVER
)(\d
*
)
T
(\d
*
)
$/
);
tournament_data
=
(
await
challonge
.
getTournament
(
!!
recover_match
));
if
(
!
tournament_data
)
{
if (!client.
c
losed) {
if
(
!
client
.
isC
losed
)
{
ygopro
.
stoc_die
(
client
,
'
${challonge_match_load_failed}
'
);
}
return
;
...
...
@@ -3032,7 +3048,7 @@
return
p
.
participant
.
name
&&
deck_name_match
(
p
.
participant
.
name
,
client
.
name
);
});
if
(
!
matching_participant
)
{
if (!client.
c
losed) {
if
(
!
client
.
isC
losed
)
{
ygopro
.
stoc_die
(
client
,
'
${challonge_user_not_found}
'
);
}
return
;
...
...
@@ -3042,7 +3058,7 @@
return
match
.
match
&&
!
match
.
match
.
winner_id
&&
match
.
match
.
state
!==
"
complete
"
&&
match
.
match
.
player1_id
&&
match
.
match
.
player2_id
&&
(
match
.
match
.
player1_id
===
client
.
challonge_info
.
id
||
match
.
match
.
player2_id
===
client
.
challonge_info
.
id
);
});
if
(
!
matching_match
)
{
if (!client.
c
losed) {
if
(
!
client
.
isC
losed
)
{
ygopro
.
stoc_die
(
client
,
'
${challonge_match_not_found}
'
);
}
return
;
...
...
@@ -4502,7 +4518,7 @@
return
true
;
}
if
(
settings
.
modules
.
reconnect
.
enabled
)
{
if (client.
c
losed) {
if
(
client
.
isC
losed
)
{
ygopro
.
ctos_send
(
server
,
'
TIME_CONFIRM
'
);
return
true
;
}
else
{
...
...
ygopro.coffee
View file @
a180954a
...
...
@@ -59,15 +59,21 @@ translateHandler = (handler) ->
return
@
helper
.
sendMessage
(
socket
,
"CTOS_
#{
proto
}
"
,
info
)
#util
@
stoc_send_chat
=
(
client
,
msg
,
player
=
8
)
->
if
!
client
console
.
log
"err stoc_send_chat"
return
@
split_chat_lines
=
(
msg
,
player
,
lang
)
->
lines
=
[]
for
line
in
_
.
lines
(
msg
)
if
player
>=
10
line
=
"[Server]: "
+
line
for
o
,
r
of
@
i18nR
[
client
.
lang
]
for
o
,
r
of
@
i18nR
[
lang
]
line
=
line
.
replace
(
r
.
regex
,
r
.
text
)
lines
.
push
(
line
)
return
lines
@
stoc_send_chat
=
(
client
,
msg
,
player
=
8
)
->
if
!
client
console
.
log
"err stoc_send_chat"
return
for
line
in
@
split_chat_lines
(
msg
,
player
,
client
.
lang
)
await
@
stoc_send
client
,
'CHAT'
,
{
player
:
player
msg
:
line
...
...
@@ -82,6 +88,7 @@ translateHandler = (handler) ->
@
stoc_send_chat
(
client
,
msg
,
player
)
if
client
for
client
in
room
.
watchers
@
stoc_send_chat
(
client
,
msg
,
player
)
if
client
room
.
recordChatMessage
(
msg
,
player
)
return
@
stoc_send_hint_card_to_room
=
(
room
,
card
)
->
...
...
ygopro.js
View file @
a180954a
...
...
@@ -94,7 +94,8 @@
return
this
.
helper
.
sendMessage
(
socket
,
`CTOS_
${
proto
}
`
,
info
);
};
this
.
splitLines
=
function
(
msg
,
player
)
{
//util
this
.
split_chat_lines
=
function
(
msg
,
player
,
lang
)
{
var
i
,
len
,
line
,
lines
,
o
,
r
,
ref
,
ref1
;
lines
=
[];
ref
=
_
.
lines
(
msg
);
...
...
@@ -103,7 +104,7 @@
if
(
player
>=
10
)
{
line
=
"
[Server]:
"
+
line
;
}
ref1
=
this
.
i18nR
[
client
.
lang
];
ref1
=
this
.
i18nR
[
lang
];
for
(
o
in
ref1
)
{
r
=
ref1
[
o
];
line
=
line
.
replace
(
r
.
regex
,
r
.
text
);
...
...
@@ -113,14 +114,13 @@
return
lines
;
};
//util
this
.
stoc_send_chat
=
async
function
(
client
,
msg
,
player
=
8
)
{
var
i
,
len
,
line
,
ref
;
if
(
!
client
)
{
console
.
log
(
"
err stoc_send_chat
"
);
return
;
}
ref
=
this
.
split
Lines
(
msg
,
player
);
ref
=
this
.
split
_chat_lines
(
msg
,
player
,
client
.
lang
);
for
(
i
=
0
,
len
=
ref
.
length
;
i
<
len
;
i
++
)
{
line
=
ref
[
i
];
await
this
.
stoc_send
(
client
,
'
CHAT
'
,
{
...
...
@@ -131,36 +131,26 @@
};
this
.
stoc_send_chat_to_room
=
function
(
room
,
msg
,
player
=
8
)
{
var
c
hat_buffer
,
client
,
i
,
j
,
k
,
len
,
len1
,
len2
,
line
,
ref
,
ref1
,
ref2
;
var
c
lient
,
i
,
j
,
len
,
len1
,
ref
,
ref1
;
if
(
!
room
)
{
console
.
log
(
"
err stoc_send_chat_to_room
"
);
return
;
}
ref
=
this
.
splitLines
(
msg
,
player
)
;
ref
=
room
.
players
;
for
(
i
=
0
,
len
=
ref
.
length
;
i
<
len
;
i
++
)
{
line
=
ref
[
i
];
chat_buffer
=
this
.
helper
.
prepareMessage
(
"
STOC_CHAT
"
,
{
player
:
player
,
msg
:
line
});
ref1
=
room
.
players
;
for
(
j
=
0
,
len1
=
ref1
.
length
;
j
<
len1
;
j
++
)
{
client
=
ref1
[
j
];
if
(
client
)
{
this
.
helper
.
send
(
client
,
chat_buffer
);
}
}
ref2
=
room
.
watchers
;
for
(
k
=
0
,
len2
=
ref2
.
length
;
k
<
len2
;
k
++
)
{
client
=
ref2
[
k
];
if
(
client
)
{
this
.
helper
.
send
(
client
,
chat_buffer
);
}
client
=
ref
[
i
];
if
(
client
)
{
this
.
stoc_send_chat
(
client
,
msg
,
player
);
}
if
(
room
.
duel_stage
!==
this
.
constants
.
DUEL_STAGE
.
BEGIN
)
{
room
.
addRecorderBuffer
(
chat_buffer
,
true
);
}
ref1
=
room
.
watchers
;
for
(
j
=
0
,
len1
=
ref1
.
length
;
j
<
len1
;
j
++
)
{
client
=
ref1
[
j
];
if
(
client
)
{
this
.
stoc_send_chat
(
client
,
msg
,
player
);
}
}
room
.
recordChatMessage
(
msg
,
player
);
};
this
.
stoc_send_hint_card_to_room
=
function
(
room
,
card
)
{
...
...
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