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
c4533935
Commit
c4533935
authored
Dec 17, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix shuffle
parent
8842134c
Pipeline
#18619
passed with stages
in 1 minute and 59 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
78 deletions
+92
-78
gframe/deck_manager.h
gframe/deck_manager.h
+22
-0
gframe/single_duel.cpp
gframe/single_duel.cpp
+28
-30
gframe/tag_duel.cpp
gframe/tag_duel.cpp
+42
-48
No files found.
gframe/deck_manager.h
View file @
c4533935
...
...
@@ -67,6 +67,28 @@ public:
bool
RenameCategory
(
const
wchar_t
*
oldname
,
const
wchar_t
*
newname
);
bool
DeleteCategory
(
const
wchar_t
*
name
);
#endif //YGOPRO_SERVER_MODE
template
<
typename
T
>
std
::
vector
<
T
>
DuplicateVector
(
std
::
vector
<
T
>
vector
,
int32
count
)
{
std
::
vector
<
T
>
result
;
for
(
int32
i
=
0
;
i
<
count
;
++
i
)
for
(
auto
it
:
vector
)
result
.
push_back
(
it
);
return
result
;
}
Deck
DuplicateDeck
(
Deck
deck
)
{
Deck
result
;
result
.
main
=
DuplicateVector
(
deck
.
main
,
10
);
result
.
extra
=
DuplicateVector
(
deck
.
extra
,
5
);
result
.
side
=
DuplicateVector
(
deck
.
side
,
1
);
return
result
;
}
void
DuplicateDecks
(
Deck
*
originalDecks
,
Deck
*
result
,
int32
count
)
{
for
(
int32
i
=
0
;
i
<
count
;
++
i
)
result
[
i
]
=
DuplicateDeck
(
originalDecks
[
i
]);
}
};
extern
DeckManager
deckManager
;
...
...
gframe/single_duel.cpp
View file @
c4533935
...
...
@@ -452,11 +452,11 @@ void SingleDuel::StartDuel(DuelPlayer* dp) {
#endif
char
deckbuff
[
12
];
char
*
pbuf
=
deckbuff
;
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
0
].
main
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
0
].
extra
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
0
].
main
.
size
()
*
10
);
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
0
].
extra
.
size
()
*
5
);
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
0
].
side
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
1
].
main
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
1
].
extra
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
1
].
main
.
size
()
*
10
);
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
1
].
extra
.
size
()
*
5
);
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
1
].
side
.
size
());
NetServer
::
SendBufferToPlayer
(
players
[
0
],
STOC_DECK_COUNT
,
deckbuff
,
12
);
char
tempbuff
[
6
];
...
...
@@ -553,9 +553,11 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
last_replay
.
WriteHeader
(
rh
);
last_replay
.
WriteData
(
players
[
0
]
->
name
,
40
,
false
);
last_replay
.
WriteData
(
players
[
1
]
->
name
,
40
,
false
);
Deck
duplicatedDeck
[
2
];
deckManager
.
DuplicateDecks
(
pdeck
,
duplicatedDeck
,
2
);
if
(
!
host_info
.
no_shuffle_deck
)
{
rnd
.
shuffle_vector
(
pd
eck
[
0
].
main
);
rnd
.
shuffle_vector
(
pd
eck
[
1
].
main
);
rnd
.
shuffle_vector
(
duplicatedD
eck
[
0
].
main
);
rnd
.
shuffle_vector
(
duplicatedD
eck
[
1
].
main
);
}
time_limit
[
0
]
=
host_info
.
time_limit
;
time_limit
[
1
]
=
host_info
.
time_limit
;
...
...
@@ -575,30 +577,26 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
last_replay
.
WriteInt32
(
host_info
.
draw_count
,
false
);
last_replay
.
WriteInt32
(
opt
,
false
);
last_replay
.
Flush
();
last_replay
.
WriteInt32
(
pdeck
[
0
].
main
.
size
()
*
10
,
false
);
for
(
int32
o
=
0
;
o
<
10
;
++
o
)
for
(
int32
i
=
(
int32
)
pdeck
[
0
].
main
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_card
(
pduel
,
pdeck
[
0
].
main
[
i
]
->
first
,
0
,
0
,
LOCATION_DECK
,
0
,
POS_FACEDOWN_DEFENSE
);
last_replay
.
WriteInt32
(
pdeck
[
0
].
main
[
i
]
->
first
,
false
);
}
last_replay
.
WriteInt32
(
pdeck
[
0
].
extra
.
size
()
*
5
,
false
);
for
(
int32
o
=
0
;
o
<
5
;
++
o
)
for
(
int32
i
=
(
int32
)
pdeck
[
0
].
extra
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_card
(
pduel
,
pdeck
[
0
].
extra
[
i
]
->
first
,
0
,
0
,
LOCATION_EXTRA
,
0
,
POS_FACEDOWN_DEFENSE
);
last_replay
.
WriteInt32
(
pdeck
[
0
].
extra
[
i
]
->
first
,
false
);
}
last_replay
.
WriteInt32
(
pdeck
[
1
].
main
.
size
()
*
10
,
false
);
for
(
int32
o
=
0
;
o
<
10
;
++
o
)
for
(
int32
i
=
(
int32
)
pdeck
[
1
].
main
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_card
(
pduel
,
pdeck
[
1
].
main
[
i
]
->
first
,
1
,
1
,
LOCATION_DECK
,
0
,
POS_FACEDOWN_DEFENSE
);
last_replay
.
WriteInt32
(
pdeck
[
1
].
main
[
i
]
->
first
,
false
);
}
last_replay
.
WriteInt32
(
pdeck
[
1
].
extra
.
size
()
*
5
,
false
);
for
(
int32
o
=
0
;
o
<
5
;
++
o
)
for
(
int32
i
=
(
int32
)
pdeck
[
1
].
extra
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_card
(
pduel
,
pdeck
[
1
].
extra
[
i
]
->
first
,
1
,
1
,
LOCATION_EXTRA
,
0
,
POS_FACEDOWN_DEFENSE
);
last_replay
.
WriteInt32
(
pdeck
[
1
].
extra
[
i
]
->
first
,
false
);
}
last_replay
.
WriteInt32
(
duplicatedDeck
[
0
].
main
.
size
()
*
10
,
false
);
for
(
int32
i
=
(
int32
)
duplicatedDeck
[
0
].
main
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_card
(
pduel
,
duplicatedDeck
[
0
].
main
[
i
]
->
first
,
0
,
0
,
LOCATION_DECK
,
0
,
POS_FACEDOWN_DEFENSE
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
0
].
main
[
i
]
->
first
,
false
);
}
last_replay
.
WriteInt32
(
duplicatedDeck
[
0
].
extra
.
size
(),
false
);
for
(
int32
i
=
(
int32
)
duplicatedDeck
[
0
].
extra
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_card
(
pduel
,
duplicatedDeck
[
0
].
extra
[
i
]
->
first
,
0
,
0
,
LOCATION_EXTRA
,
0
,
POS_FACEDOWN_DEFENSE
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
0
].
extra
[
i
]
->
first
,
false
);
}
last_replay
.
WriteInt32
(
duplicatedDeck
[
1
].
main
.
size
(),
false
);
for
(
int32
i
=
(
int32
)
duplicatedDeck
[
1
].
main
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_card
(
pduel
,
duplicatedDeck
[
1
].
main
[
i
]
->
first
,
1
,
1
,
LOCATION_DECK
,
0
,
POS_FACEDOWN_DEFENSE
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
1
].
main
[
i
]
->
first
,
false
);
}
last_replay
.
WriteInt32
(
duplicatedDeck
[
1
].
extra
.
size
(),
false
);
for
(
int32
i
=
(
int32
)
duplicatedDeck
[
1
].
extra
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_card
(
pduel
,
duplicatedDeck
[
1
].
extra
[
i
]
->
first
,
1
,
1
,
LOCATION_EXTRA
,
0
,
POS_FACEDOWN_DEFENSE
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
1
].
extra
[
i
]
->
first
,
false
);
}
last_replay
.
Flush
();
char
startbuf
[
32
],
*
pbuf
=
startbuf
;
BufferIO
::
WriteInt8
(
pbuf
,
MSG_START
);
...
...
gframe/tag_duel.cpp
View file @
c4533935
...
...
@@ -412,11 +412,11 @@ void TagDuel::StartDuel(DuelPlayer* dp) {
#endif
char
deckbuff
[
12
];
char
*
pbuf
=
deckbuff
;
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
0
].
main
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
0
].
extra
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
0
].
main
.
size
()
*
10
);
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
0
].
extra
.
size
()
*
5
);
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
0
].
side
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
2
].
main
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
2
].
extra
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
2
].
main
.
size
()
*
10
);
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
2
].
extra
.
size
()
*
5
);
BufferIO
::
WriteInt16
(
pbuf
,
pdeck
[
2
].
side
.
size
());
NetServer
::
SendBufferToPlayer
(
players
[
0
],
STOC_DECK_COUNT
,
deckbuff
,
12
);
NetServer
::
ReSendToPlayer
(
players
[
1
]);
...
...
@@ -523,11 +523,13 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
last_replay
.
WriteData
(
players
[
1
]
->
name
,
40
,
false
);
last_replay
.
WriteData
(
players
[
2
]
->
name
,
40
,
false
);
last_replay
.
WriteData
(
players
[
3
]
->
name
,
40
,
false
);
Deck
duplicatedDeck
[
4
];
deckManager
.
DuplicateDecks
(
pdeck
,
duplicatedDeck
,
4
);
if
(
!
host_info
.
no_shuffle_deck
)
{
rnd
.
shuffle_vector
(
pd
eck
[
0
].
main
);
rnd
.
shuffle_vector
(
pd
eck
[
1
].
main
);
rnd
.
shuffle_vector
(
pd
eck
[
2
].
main
);
rnd
.
shuffle_vector
(
pd
eck
[
3
].
main
);
rnd
.
shuffle_vector
(
duplicatedD
eck
[
0
].
main
);
rnd
.
shuffle_vector
(
duplicatedD
eck
[
1
].
main
);
rnd
.
shuffle_vector
(
duplicatedD
eck
[
2
].
main
);
rnd
.
shuffle_vector
(
duplicatedD
eck
[
3
].
main
);
}
time_limit
[
0
]
=
host_info
.
time_limit
;
time_limit
[
1
]
=
host_info
.
time_limit
;
...
...
@@ -549,56 +551,48 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
last_replay
.
WriteInt32
(
opt
,
false
);
last_replay
.
Flush
();
//
last_replay
.
WriteInt32
(
pdeck
[
0
].
main
.
size
()
*
10
,
false
);
for
(
int32
o
=
0
;
o
<
10
;
++
o
)
for
(
int32
i
=
(
int32
)
pdeck
[
0
].
main
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_card
(
pduel
,
pdeck
[
0
].
main
[
i
]
->
first
,
0
,
0
,
LOCATION_DECK
,
0
,
POS_FACEDOWN_DEFENSE
);
last_replay
.
WriteInt32
(
pdeck
[
0
].
main
[
i
]
->
first
,
false
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
0
].
main
.
size
(),
false
);
for
(
int32
i
=
(
int32
)
duplicatedDeck
[
0
].
main
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_card
(
pduel
,
duplicatedDeck
[
0
].
main
[
i
]
->
first
,
0
,
0
,
LOCATION_DECK
,
0
,
POS_FACEDOWN_DEFENSE
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
0
].
main
[
i
]
->
first
,
false
);
}
last_replay
.
WriteInt32
(
pdeck
[
0
].
extra
.
size
()
*
5
,
false
);
for
(
int32
o
=
0
;
o
<
5
;
++
o
)
for
(
int32
i
=
(
int32
)
pdeck
[
0
].
extra
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_card
(
pduel
,
pdeck
[
0
].
extra
[
i
]
->
first
,
0
,
0
,
LOCATION_EXTRA
,
0
,
POS_FACEDOWN_DEFENSE
);
last_replay
.
WriteInt32
(
pdeck
[
0
].
extra
[
i
]
->
first
,
false
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
0
].
extra
.
size
(),
false
);
for
(
int32
i
=
(
int32
)
duplicatedDeck
[
0
].
extra
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_card
(
pduel
,
duplicatedDeck
[
0
].
extra
[
i
]
->
first
,
0
,
0
,
LOCATION_EXTRA
,
0
,
POS_FACEDOWN_DEFENSE
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
0
].
extra
[
i
]
->
first
,
false
);
}
//
last_replay
.
WriteInt32
(
pdeck
[
1
].
main
.
size
()
*
10
,
false
);
for
(
int32
o
=
0
;
o
<
10
;
++
o
)
for
(
int32
i
=
(
int32
)
pdeck
[
1
].
main
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_tag_card
(
pduel
,
pdeck
[
1
].
main
[
i
]
->
first
,
0
,
LOCATION_DECK
);
last_replay
.
WriteInt32
(
pdeck
[
1
].
main
[
i
]
->
first
,
false
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
1
].
main
.
size
(),
false
);
for
(
int32
i
=
(
int32
)
duplicatedDeck
[
1
].
main
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_tag_card
(
pduel
,
duplicatedDeck
[
1
].
main
[
i
]
->
first
,
0
,
LOCATION_DECK
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
1
].
main
[
i
]
->
first
,
false
);
}
last_replay
.
WriteInt32
(
pdeck
[
1
].
extra
.
size
()
*
5
,
false
);
for
(
int32
o
=
0
;
o
<
5
;
++
o
)
for
(
int32
i
=
(
int32
)
pdeck
[
1
].
extra
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_tag_card
(
pduel
,
pdeck
[
1
].
extra
[
i
]
->
first
,
0
,
LOCATION_EXTRA
);
last_replay
.
WriteInt32
(
pdeck
[
1
].
extra
[
i
]
->
first
,
false
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
1
].
extra
.
size
(),
false
);
for
(
int32
i
=
(
int32
)
duplicatedDeck
[
1
].
extra
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_tag_card
(
pduel
,
duplicatedDeck
[
1
].
extra
[
i
]
->
first
,
0
,
LOCATION_EXTRA
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
1
].
extra
[
i
]
->
first
,
false
);
}
//
last_replay
.
WriteInt32
(
pdeck
[
3
].
main
.
size
()
*
10
,
false
);
for
(
int32
o
=
0
;
o
<
10
;
++
o
)
for
(
int32
i
=
(
int32
)
pdeck
[
3
].
main
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_card
(
pduel
,
pdeck
[
3
].
main
[
i
]
->
first
,
1
,
1
,
LOCATION_DECK
,
0
,
POS_FACEDOWN_DEFENSE
);
last_replay
.
WriteInt32
(
pdeck
[
3
].
main
[
i
]
->
first
,
false
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
3
].
main
.
size
(),
false
);
for
(
int32
i
=
(
int32
)
duplicatedDeck
[
3
].
main
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_card
(
pduel
,
duplicatedDeck
[
3
].
main
[
i
]
->
first
,
1
,
1
,
LOCATION_DECK
,
0
,
POS_FACEDOWN_DEFENSE
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
3
].
main
[
i
]
->
first
,
false
);
}
last_replay
.
WriteInt32
(
pdeck
[
3
].
extra
.
size
()
*
5
,
false
);
for
(
int32
o
=
0
;
o
<
5
;
++
o
)
for
(
int32
i
=
(
int32
)
pdeck
[
3
].
extra
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_card
(
pduel
,
pdeck
[
3
].
extra
[
i
]
->
first
,
1
,
1
,
LOCATION_EXTRA
,
0
,
POS_FACEDOWN_DEFENSE
);
last_replay
.
WriteInt32
(
pdeck
[
3
].
extra
[
i
]
->
first
,
false
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
3
].
extra
.
size
(),
false
);
for
(
int32
i
=
(
int32
)
duplicatedDeck
[
3
].
extra
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_card
(
pduel
,
duplicatedDeck
[
3
].
extra
[
i
]
->
first
,
1
,
1
,
LOCATION_EXTRA
,
0
,
POS_FACEDOWN_DEFENSE
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
3
].
extra
[
i
]
->
first
,
false
);
}
//
last_replay
.
WriteInt32
(
pdeck
[
2
].
main
.
size
()
*
10
,
false
);
for
(
int32
o
=
0
;
o
<
10
;
++
o
)
for
(
int32
i
=
(
int32
)
pdeck
[
2
].
main
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_tag_card
(
pduel
,
pdeck
[
2
].
main
[
i
]
->
first
,
1
,
LOCATION_DECK
);
last_replay
.
WriteInt32
(
pdeck
[
2
].
main
[
i
]
->
first
,
false
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
2
].
main
.
size
(),
false
);
for
(
int32
i
=
(
int32
)
duplicatedDeck
[
2
].
main
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_tag_card
(
pduel
,
duplicatedDeck
[
2
].
main
[
i
]
->
first
,
1
,
LOCATION_DECK
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
2
].
main
[
i
]
->
first
,
false
);
}
last_replay
.
WriteInt32
(
pdeck
[
2
].
extra
.
size
()
*
5
,
false
);
for
(
int32
o
=
0
;
o
<
5
;
++
o
)
for
(
int32
i
=
(
int32
)
pdeck
[
2
].
extra
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_tag_card
(
pduel
,
pdeck
[
2
].
extra
[
i
]
->
first
,
1
,
LOCATION_EXTRA
);
last_replay
.
WriteInt32
(
pdeck
[
2
].
extra
[
i
]
->
first
,
false
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
2
].
extra
.
size
(),
false
);
for
(
int32
i
=
(
int32
)
duplicatedDeck
[
2
].
extra
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
new_tag_card
(
pduel
,
duplicatedDeck
[
2
].
extra
[
i
]
->
first
,
1
,
LOCATION_EXTRA
);
last_replay
.
WriteInt32
(
duplicatedDeck
[
2
].
extra
[
i
]
->
first
,
false
);
}
last_replay
.
Flush
();
char
startbuf
[
32
],
*
pbuf
=
startbuf
;
...
...
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