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
6eb1de84
Commit
6eb1de84
authored
Jun 13, 2017
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ctos, add surrender handling
parent
fbcf6db0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
39 deletions
+72
-39
ygopro-server.coffee
ygopro-server.coffee
+30
-17
ygopro-server.js
ygopro-server.js
+42
-22
No files found.
ygopro-server.coffee
View file @
6eb1de84
...
...
@@ -720,14 +720,14 @@ net.createServer (client) ->
cancel
=
false
if
ygopro
.
ctos_follows
[
ctos_proto
]
b
=
ctos_buffer
.
slice
(
3
,
ctos_message_length
-
1
+
3
)
info
=
null
if
struct
=
ygopro
.
structs
[
ygopro
.
proto_structs
.
CTOS
[
ygopro
.
constants
.
CTOS
[
ctos_proto
]]]
struct
.
_setBuff
(
b
)
info
=
_
.
clone
(
struct
.
fields
)
if
ygopro
.
ctos_follows
[
ctos_proto
].
synchronous
cancel
=
ygopro
.
ctos_follows
[
ctos_proto
].
callback
b
,
_
.
clone
(
struct
.
fields
)
,
client
,
server
cancel
=
ygopro
.
ctos_follows
[
ctos_proto
].
callback
b
,
info
,
client
,
server
else
ygopro
.
ctos_follows
[
ctos_proto
].
callback
b
,
_
.
clone
(
struct
.
fields
),
client
,
server
else
ygopro
.
ctos_follows
[
ctos_proto
].
callback
b
,
null
,
client
,
server
ygopro
.
ctos_follows
[
ctos_proto
].
callback
b
,
info
,
client
,
server
datas
.
push
ctos_buffer
.
slice
(
0
,
2
+
ctos_message_length
)
unless
cancel
ctos_buffer
=
ctos_buffer
.
slice
(
2
+
ctos_message_length
)
ctos_message_length
=
0
...
...
@@ -788,17 +788,14 @@ net.createServer (client) ->
stanzas
=
stoc_proto
if
ygopro
.
stoc_follows
[
stoc_proto
]
b
=
stoc_buffer
.
slice
(
3
,
stoc_message_length
-
1
+
3
)
info
=
null
if
struct
=
ygopro
.
structs
[
ygopro
.
proto_structs
.
STOC
[
ygopro
.
constants
.
STOC
[
stoc_proto
]]]
struct
.
_setBuff
(
b
)
info
=
_
.
clone
(
struct
.
fields
)
if
ygopro
.
stoc_follows
[
stoc_proto
].
synchronous
cancel
=
ygopro
.
stoc_follows
[
stoc_proto
].
callback
b
,
_
.
clone
(
struct
.
fields
),
client
,
server
else
ygopro
.
stoc_follows
[
stoc_proto
].
callback
b
,
_
.
clone
(
struct
.
fields
),
client
,
server
cancel
=
ygopro
.
stoc_follows
[
stoc_proto
].
callback
b
,
info
,
client
,
server
else
if
ygopro
.
stoc_follows
[
stoc_proto
].
synchronous
cancel
=
ygopro
.
stoc_follows
[
stoc_proto
].
callback
b
,
null
,
client
,
server
else
ygopro
.
stoc_follows
[
stoc_proto
].
callback
b
,
null
,
client
,
server
ygopro
.
stoc_follows
[
stoc_proto
].
callback
b
,
info
,
client
,
server
datas
.
push
stoc_buffer
.
slice
(
0
,
2
+
stoc_message_length
)
unless
cancel
stoc_buffer
=
stoc_buffer
.
slice
(
2
+
stoc_message_length
)
stoc_message_length
=
0
...
...
@@ -1221,10 +1218,15 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
playertype
=
buffer
.
readUInt8
(
1
)
client
.
is_first
=
!
(
playertype
&
0xf
)
client
.
lp
=
room
.
hostinfo
.
start_lp
if
client
.
is_host
room
.
turn
=
0
#ygopro.stoc_send_chat_to_room(room, "LP跟踪调试信息: #{client.name} 初始LP #{client.lp}")
if
ygopro
.
constants
.
MSG
[
msg
]
==
'NEW_TURN'
and
client
.
surrend_confirm
if
ygopro
.
constants
.
MSG
[
msg
]
==
'NEW_TURN'
if
client
.
is_host
room
.
turn
=
room
.
turn
+
1
if
client
.
surrend_confirm
client
.
surrend_confirm
=
false
ygopro
.
stoc_send_chat
(
client
,
"${surrender_canceled}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
...
...
@@ -1417,6 +1419,17 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)->
client
.
deck_saved
=
true
return
ygopro
.
ctos_follow
'SURRENDER'
,
true
,
(
buffer
,
info
,
client
,
server
)
->
room
=
ROOM_all
[
client
.
rid
]
return
unless
room
if
!
room
.
started
or
room
.
hostinfo
.
mode
==
2
return
true
if
room
.
random_type
and
room
.
turn
<
3
ygopro
.
stoc_send_chat
(
client
,
"${surrender_denied}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
return
true
return
false
ygopro
.
ctos_follow
'CHAT'
,
true
,
(
buffer
,
info
,
client
,
server
)
->
room
=
ROOM_all
[
client
.
rid
]
return
unless
room
...
...
@@ -1428,7 +1441,7 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
when
'/投降'
,
'/surrender'
if
!
room
.
started
or
room
.
hostinfo
.
mode
==
2
return
cancel
if
room
.
random_type
if
room
.
random_type
and
room
.
turn
<
3
ygopro
.
stoc_send_chat
(
client
,
"${surrender_denied}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
return
cancel
if
client
.
surrend_confirm
...
...
ygopro-server.js
View file @
6eb1de84
...
...
@@ -888,7 +888,7 @@
}
client
.
pre_establish_buffers
=
new
Array
();
client
.
on
(
'
data
'
,
function
(
ctos_buffer
)
{
var b, bad_ip_count, buffer, cancel, ctos_message_length, ctos_proto, datas, j, k, len, len1, looplimit, room, struct;
var
b
,
bad_ip_count
,
buffer
,
cancel
,
ctos_message_length
,
ctos_proto
,
datas
,
info
,
j
,
k
,
len
,
len1
,
looplimit
,
room
,
struct
;
if
(
client
.
is_post_watcher
)
{
room
=
ROOM_all
[
client
.
rid
];
if
(
room
)
{
...
...
@@ -921,15 +921,15 @@
cancel
=
false
;
if
(
ygopro
.
ctos_follows
[
ctos_proto
])
{
b
=
ctos_buffer
.
slice
(
3
,
ctos_message_length
-
1
+
3
);
info
=
null
;
if
(
struct
=
ygopro
.
structs
[
ygopro
.
proto_structs
.
CTOS
[
ygopro
.
constants
.
CTOS
[
ctos_proto
]]])
{
struct
.
_setBuff
(
b
);
if (ygopro.ctos_follows[ctos_proto].synchronous) {
cancel = ygopro.ctos_follows[ctos_proto].callback(b, _.clone(struct.fields), client, server);
} else {
ygopro.ctos_follows[ctos_proto].callback(b, _.clone(struct.fields), client, server);
info
=
_
.
clone
(
struct
.
fields
);
}
if
(
ygopro
.
ctos_follows
[
ctos_proto
].
synchronous
)
{
cancel
=
ygopro
.
ctos_follows
[
ctos_proto
].
callback
(
b
,
info
,
client
,
server
);
}
else
{
ygopro.ctos_follows[ctos_proto].callback(b,
null
, client, server);
ygopro
.
ctos_follows
[
ctos_proto
].
callback
(
b
,
info
,
client
,
server
);
}
}
if
(
!
cancel
)
{
...
...
@@ -972,7 +972,7 @@
}
});
server
.
on
(
'
data
'
,
function
(
stoc_buffer
)
{
var b, buffer, cancel, datas, j, len, looplimit, stanzas, stoc_message_length, stoc_proto, struct;
var
b
,
buffer
,
cancel
,
datas
,
info
,
j
,
len
,
looplimit
,
stanzas
,
stoc_message_length
,
stoc_proto
,
struct
;
stoc_message_length
=
0
;
stoc_proto
=
0
;
datas
=
[];
...
...
@@ -1000,19 +1000,15 @@
stanzas
=
stoc_proto
;
if
(
ygopro
.
stoc_follows
[
stoc_proto
])
{
b
=
stoc_buffer
.
slice
(
3
,
stoc_message_length
-
1
+
3
);
info
=
null
;
if
(
struct
=
ygopro
.
structs
[
ygopro
.
proto_structs
.
STOC
[
ygopro
.
constants
.
STOC
[
stoc_proto
]]])
{
struct
.
_setBuff
(
b
);
if (ygopro.stoc_follows[stoc_proto].synchronous) {
cancel = ygopro.stoc_follows[stoc_proto].callback(b, _.clone(struct.fields), client, server);
} else {
ygopro.stoc_follows[stoc_proto].callback(b, _.clone(struct.fields), client, server);
info
=
_
.
clone
(
struct
.
fields
);
}
} else {
if
(
ygopro
.
stoc_follows
[
stoc_proto
].
synchronous
)
{
cancel = ygopro.stoc_follows[stoc_proto].callback(b, null
, client, server);
cancel
=
ygopro
.
stoc_follows
[
stoc_proto
].
callback
(
b
,
info
,
client
,
server
);
}
else
{
ygopro.stoc_follows[stoc_proto].callback(b, null, client, server);
}
ygopro
.
stoc_follows
[
stoc_proto
].
callback
(
b
,
info
,
client
,
server
);
}
}
if
(
!
cancel
)
{
...
...
@@ -1466,11 +1462,19 @@
playertype
=
buffer
.
readUInt8
(
1
);
client
.
is_first
=
!
(
playertype
&
0xf
);
client
.
lp
=
room
.
hostinfo
.
start_lp
;
if
(
client
.
is_host
)
{
room
.
turn
=
0
;
}
}
if
(
ygopro
.
constants
.
MSG
[
msg
]
===
'
NEW_TURN
'
)
{
if
(
client
.
is_host
)
{
room
.
turn
=
room
.
turn
+
1
;
}
if (ygopro.constants.MSG[msg] === 'NEW_TURN' &&
client.surrend_confirm) {
if
(
client
.
surrend_confirm
)
{
client
.
surrend_confirm
=
false
;
ygopro
.
stoc_send_chat
(
client
,
"
${surrender_canceled}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
}
if
(
ygopro
.
constants
.
MSG
[
msg
]
===
'
WIN
'
&&
client
.
is_host
)
{
pos
=
buffer
.
readUInt8
(
1
);
if
(
!
(
client
.
is_first
||
pos
===
2
))
{
...
...
@@ -1737,6 +1741,22 @@
}
});
ygopro
.
ctos_follow
(
'
SURRENDER
'
,
true
,
function
(
buffer
,
info
,
client
,
server
)
{
var
room
;
room
=
ROOM_all
[
client
.
rid
];
if
(
!
room
)
{
return
;
}
if
(
!
room
.
started
||
room
.
hostinfo
.
mode
===
2
)
{
return
true
;
}
if
(
room
.
random_type
&&
room
.
turn
<
3
)
{
ygopro
.
stoc_send_chat
(
client
,
"
${surrender_denied}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
return
true
;
}
return
false
;
});
ygopro
.
ctos_follow
(
'
CHAT
'
,
true
,
function
(
buffer
,
info
,
client
,
server
)
{
var
cancel
,
cmd
,
msg
,
name
,
oldmsg
,
room
,
struct
,
windbot
;
room
=
ROOM_all
[
client
.
rid
];
...
...
@@ -1755,7 +1775,7 @@
if
(
!
room
.
started
||
room
.
hostinfo
.
mode
===
2
)
{
return
cancel
;
}
if (room.random_type) {
if
(
room
.
random_type
&&
room
.
turn
<
3
)
{
ygopro
.
stoc_send_chat
(
client
,
"
${surrender_denied}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
return
cancel
;
}
...
...
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