Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
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
ygopro
Commits
06a36c7c
Commit
06a36c7c
authored
May 28, 2024
by
Chen Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix DuelMode::UpdateDeck()
parent
a0af40c2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
16 deletions
+36
-16
gframe/network.h
gframe/network.h
+1
-1
gframe/single_duel.cpp
gframe/single_duel.cpp
+17
-7
gframe/single_duel.h
gframe/single_duel.h
+1
-1
gframe/tag_duel.cpp
gframe/tag_duel.cpp
+16
-6
gframe/tag_duel.h
gframe/tag_duel.h
+1
-1
No files found.
gframe/network.h
View file @
06a36c7c
...
...
@@ -136,7 +136,7 @@ public:
virtual
void
ToObserver
(
DuelPlayer
*
dp
)
{}
virtual
void
PlayerReady
(
DuelPlayer
*
dp
,
bool
is_ready
)
{}
virtual
void
PlayerKick
(
DuelPlayer
*
dp
,
unsigned
char
pos
)
{}
virtual
void
UpdateDeck
(
DuelPlayer
*
dp
,
void
*
pdata
,
unsigned
int
len
)
{}
virtual
void
UpdateDeck
(
DuelPlayer
*
dp
,
unsigned
char
*
pdata
,
int
len
)
{}
virtual
void
StartDuel
(
DuelPlayer
*
dp
)
{}
virtual
void
HandResult
(
DuelPlayer
*
dp
,
unsigned
char
res
)
{}
virtual
void
TPResult
(
DuelPlayer
*
dp
,
unsigned
char
tp
)
{}
...
...
gframe/single_duel.cpp
View file @
06a36c7c
...
...
@@ -274,25 +274,35 @@ void SingleDuel::PlayerKick(DuelPlayer* dp, unsigned char pos) {
return
;
LeaveGame
(
players
[
pos
]);
}
void
SingleDuel
::
UpdateDeck
(
DuelPlayer
*
dp
,
void
*
pdata
,
unsigned
int
len
)
{
void
SingleDuel
::
UpdateDeck
(
DuelPlayer
*
dp
,
unsigned
char
*
pdata
,
int
len
)
{
if
(
dp
->
type
>
1
||
ready
[
dp
->
type
])
return
;
unsigned
char
*
deckbuf
=
(
unsigned
char
*
)
pdata
;
if
(
len
<=
8
||
len
%
sizeof
(
int32_t
)
!=
0
)
return
;
bool
valid
=
true
;
auto
deckbuf
=
pdata
;
int
mainc
=
BufferIO
::
ReadInt32
(
deckbuf
);
int
sidec
=
BufferIO
::
ReadInt32
(
deckbuf
);
// verify data
const
unsigned
int
possibleMaxLength
=
(
len
-
8
)
/
4
;
if
((
unsigned
)
mainc
>
possibleMaxLength
||
(
unsigned
)
sidec
>
possibleMaxLength
||
(
unsigned
)
mainc
+
(
unsigned
)
sidec
>
possibleMaxLength
)
{
const
int
deck_size
=
len
-
2
*
sizeof
(
int32_t
);
if
(
mainc
<
DECK_MIN_SIZE
||
mainc
>
DECK_MAX_SIZE
+
EXTRA_MAX_SIZE
)
valid
=
false
;
else
if
(
sidec
<
0
||
sidec
>
SIDE_MAX_SIZE
)
valid
=
false
;
else
if
(
deck_size
!=
(
mainc
+
sidec
)
*
(
int
)
sizeof
(
int32_t
))
valid
=
false
;
if
(
!
valid
)
{
STOC_ErrorMsg
scem
;
scem
.
msg
=
ERRMSG_DECKERROR
;
scem
.
code
=
0
;
NetServer
::
SendPacketToPlayer
(
dp
,
STOC_ERROR_MSG
,
scem
);
return
;
}
int
deck_list
[
DECK_MAX_SIZE
+
EXTRA_MAX_SIZE
+
SIDE_MAX_SIZE
];
std
::
memcpy
(
deck_list
,
deckbuf
,
deck_size
);
if
(
duel_count
==
0
)
{
deck_error
[
dp
->
type
]
=
deckManager
.
LoadDeck
(
pdeck
[
dp
->
type
],
(
int
*
)
deckbuf
,
mainc
,
sidec
);
deck_error
[
dp
->
type
]
=
deckManager
.
LoadDeck
(
pdeck
[
dp
->
type
],
deck_list
,
mainc
,
sidec
);
}
else
{
if
(
deckManager
.
LoadSide
(
pdeck
[
dp
->
type
],
(
int
*
)
deckbuf
,
mainc
,
sidec
))
{
if
(
deckManager
.
LoadSide
(
pdeck
[
dp
->
type
],
deck_list
,
mainc
,
sidec
))
{
ready
[
dp
->
type
]
=
true
;
NetServer
::
SendPacketToPlayer
(
dp
,
STOC_DUEL_START
);
if
(
ready
[
0
]
&&
ready
[
1
])
{
...
...
gframe/single_duel.h
View file @
06a36c7c
...
...
@@ -18,7 +18,7 @@ public:
virtual
void
ToObserver
(
DuelPlayer
*
dp
);
virtual
void
PlayerReady
(
DuelPlayer
*
dp
,
bool
ready
);
virtual
void
PlayerKick
(
DuelPlayer
*
dp
,
unsigned
char
pos
);
virtual
void
UpdateDeck
(
DuelPlayer
*
dp
,
void
*
pdata
,
unsigned
int
len
);
virtual
void
UpdateDeck
(
DuelPlayer
*
dp
,
unsigned
char
*
pdata
,
int
len
);
virtual
void
StartDuel
(
DuelPlayer
*
dp
);
virtual
void
HandResult
(
DuelPlayer
*
dp
,
unsigned
char
res
);
virtual
void
TPResult
(
DuelPlayer
*
dp
,
unsigned
char
tp
);
...
...
gframe/tag_duel.cpp
View file @
06a36c7c
...
...
@@ -257,22 +257,32 @@ void TagDuel::PlayerKick(DuelPlayer* dp, unsigned char pos) {
return
;
LeaveGame
(
players
[
pos
]);
}
void
TagDuel
::
UpdateDeck
(
DuelPlayer
*
dp
,
void
*
pdata
,
unsigned
int
len
)
{
void
TagDuel
::
UpdateDeck
(
DuelPlayer
*
dp
,
unsigned
char
*
pdata
,
int
len
)
{
if
(
dp
->
type
>
3
||
ready
[
dp
->
type
])
return
;
unsigned
char
*
deckbuf
=
(
unsigned
char
*
)
pdata
;
if
(
len
<=
8
||
len
%
sizeof
(
int32_t
)
!=
0
)
return
;
bool
valid
=
true
;
auto
deckbuf
=
pdata
;
int
mainc
=
BufferIO
::
ReadInt32
(
deckbuf
);
int
sidec
=
BufferIO
::
ReadInt32
(
deckbuf
);
// verify data
const
unsigned
int
possibleMaxLength
=
(
len
-
8
)
/
4
;
if
((
unsigned
)
mainc
>
possibleMaxLength
||
(
unsigned
)
sidec
>
possibleMaxLength
||
(
unsigned
)
mainc
+
(
unsigned
)
sidec
>
possibleMaxLength
)
{
const
int
deck_size
=
len
-
2
*
sizeof
(
int32_t
);
if
(
mainc
<
DECK_MIN_SIZE
||
mainc
>
DECK_MAX_SIZE
+
EXTRA_MAX_SIZE
)
valid
=
false
;
else
if
(
sidec
<
0
||
sidec
>
SIDE_MAX_SIZE
)
valid
=
false
;
else
if
(
deck_size
!=
(
mainc
+
sidec
)
*
(
int
)
sizeof
(
int32_t
))
valid
=
false
;
if
(
!
valid
)
{
STOC_ErrorMsg
scem
;
scem
.
msg
=
ERRMSG_DECKERROR
;
scem
.
code
=
0
;
NetServer
::
SendPacketToPlayer
(
dp
,
STOC_ERROR_MSG
,
scem
);
return
;
}
deck_error
[
dp
->
type
]
=
deckManager
.
LoadDeck
(
pdeck
[
dp
->
type
],
(
int
*
)
deckbuf
,
mainc
,
sidec
);
int
deck_list
[
DECK_MAX_SIZE
+
EXTRA_MAX_SIZE
+
SIDE_MAX_SIZE
];
std
::
memcpy
(
deck_list
,
deckbuf
,
deck_size
);
deck_error
[
dp
->
type
]
=
deckManager
.
LoadDeck
(
pdeck
[
dp
->
type
],
deck_list
,
mainc
,
sidec
);
}
void
TagDuel
::
StartDuel
(
DuelPlayer
*
dp
)
{
if
(
dp
!=
host_player
)
...
...
gframe/tag_duel.h
View file @
06a36c7c
...
...
@@ -18,7 +18,7 @@ public:
virtual
void
ToObserver
(
DuelPlayer
*
dp
);
virtual
void
PlayerReady
(
DuelPlayer
*
dp
,
bool
ready
);
virtual
void
PlayerKick
(
DuelPlayer
*
dp
,
unsigned
char
pos
);
virtual
void
UpdateDeck
(
DuelPlayer
*
dp
,
void
*
pdata
,
unsigned
int
len
);
virtual
void
UpdateDeck
(
DuelPlayer
*
dp
,
unsigned
char
*
pdata
,
int
len
);
virtual
void
StartDuel
(
DuelPlayer
*
dp
);
virtual
void
HandResult
(
DuelPlayer
*
dp
,
unsigned
char
res
);
virtual
void
TPResult
(
DuelPlayer
*
dp
,
unsigned
char
tp
);
...
...
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