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
1
Merge Requests
1
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
8cab9493
Commit
8cab9493
authored
Feb 23, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add duel_flags and bo5
parent
fefe9fef
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
16 deletions
+74
-16
gframe/game.cpp
gframe/game.cpp
+1
-0
gframe/game.h
gframe/game.h
+1
-0
gframe/gframe.cpp
gframe/gframe.cpp
+3
-1
gframe/replay.h
gframe/replay.h
+3
-0
gframe/single_duel.cpp
gframe/single_duel.cpp
+38
-9
gframe/tag_duel.cpp
gframe/tag_duel.cpp
+28
-6
No files found.
gframe/game.cpp
View file @
8cab9493
...
...
@@ -95,6 +95,7 @@ bool IsExtension(const wchar_t* filename, const wchar_t* extension) {
unsigned
short
server_port
;
unsigned
short
replay_mode
;
unsigned
int
pre_seed
[
3
];
unsigned
int
duel_flags
;
HostInfo
game_info
;
void
Game
::
MainServerLoop
()
{
...
...
gframe/game.h
View file @
8cab9493
...
...
@@ -689,6 +689,7 @@ extern unsigned short server_port;
extern
unsigned
short
replay_mode
;
extern
HostInfo
game_info
;
extern
unsigned
int
pre_seed
[
3
];
extern
unsigned
int
duel_flags
;
#endif
}
...
...
gframe/gframe.cpp
View file @
8cab9493
...
...
@@ -66,6 +66,7 @@ int main(int argc, char* argv[]) {
enable_log
=
1
;
ygo
::
server_port
=
7911
;
ygo
::
replay_mode
=
0
;
ygo
::
duel_flags
=
0
;
ygo
::
game_info
.
lflist
=
0
;
ygo
::
game_info
.
rule
=
0
;
ygo
::
game_info
.
mode
=
0
;
...
...
@@ -100,7 +101,8 @@ int main(int argc, char* argv[]) {
else
if
(
argv
[
5
][
0
]
==
'F'
)
ygo
::
game_info
.
duel_rule
=
YGOPRO_DEFAULT_DUEL_RULE
;
else
{
int
master_rule
=
atoi
(
argv
[
5
]);
ygo
::
duel_flags
=
atoi
(
argv
[
5
]);
auto
master_rule
=
ygo
::
duel_flags
&
0xF
;
if
(
master_rule
)
ygo
::
game_info
.
duel_rule
=
master_rule
;
else
...
...
gframe/replay.h
View file @
8cab9493
...
...
@@ -20,6 +20,9 @@ constexpr int MAX_COMP_SIZE = UINT16_MAX + 1;
#define REPLAY_MODE_SAVE_IN_SERVER 0x1
#define REPLAY_MODE_WATCHER_NO_SEND 0x2
#define REPLAY_MODE_INCLUDE_CHAT 0x4
#define DUEL_FLAG_SIDEINS 0x10
#define DUEL_FLAG_BO5 0x20
#endif // YGOPRO_SERVER_MODE
struct
ReplayHeader
{
...
...
gframe/single_duel.cpp
View file @
8cab9493
...
...
@@ -460,12 +460,14 @@ void SingleDuel::StartDuel(DuelPlayer* dp) {
#endif
unsigned
char
deckbuff
[
12
];
auto
pbuf
=
deckbuff
;
#ifdef YGOPRO_SERVER_MODE
short
extra_size
[
2
];
for
(
int
i
=
0
;
i
<
2
;
++
i
)
{
extra_size
[
i
]
=
(
short
)
pdeck
[
i
].
extra
.
size
();
for
(
auto
cit
:
pdeck
[
i
].
side
)
if
(
cit
->
second
.
type
&
(
TYPE_FUSION
|
TYPE_SYNCHRO
|
TYPE_XYZ
|
TYPE_LINK
))
++
extra_size
[
i
];
if
(
duel_flags
&
DUEL_FLAG_SIDEINS
)
for
(
auto
cit
:
pdeck
[
i
].
side
)
if
(
cit
->
second
.
type
&
(
TYPE_FUSION
|
TYPE_SYNCHRO
|
TYPE_XYZ
|
TYPE_LINK
))
++
extra_size
[
i
];
}
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
0
].
main
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
extra_size
[
0
]);
...
...
@@ -473,6 +475,14 @@ void SingleDuel::StartDuel(DuelPlayer* dp) {
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
1
].
main
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
extra_size
[
1
]);
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
1
].
side
.
size
());
#else
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
0
].
main
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
0
].
extra
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
0
].
side
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
1
].
main
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
1
].
extra
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
1
].
side
.
size
());
#endif
NetServer
::
SendBufferToPlayer
(
players
[
0
],
STOC_DECK_COUNT
,
deckbuff
,
12
);
char
tempbuff
[
6
];
std
::
memcpy
(
tempbuff
,
deckbuff
,
6
);
...
...
@@ -597,20 +607,28 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
last_replay
.
WriteInt32
((
*
cit
)
->
first
,
false
);
}
};
#ifdef YGOPRO_SERVER_MODE
std
::
vector
<
ygo
::
code_pointer
>
extra_cards
;
auto
load_extra
=
[
&
](
uint8_t
p
)
{
extra_cards
.
clear
();
for
(
auto
cit
:
pdeck
[
p
].
extra
)
extra_cards
.
push_back
(
cit
);
for
(
auto
cit
:
pdeck
[
p
].
side
)
if
(
cit
->
second
.
type
&
(
TYPE_FUSION
|
TYPE_SYNCHRO
|
TYPE_XYZ
|
TYPE_LINK
))
extra_cards
.
push_back
(
cit
);
if
(
duel_flags
&
DUEL_FLAG_SIDEINS
)
for
(
auto
cit
:
pdeck
[
p
].
side
)
if
(
cit
->
second
.
type
&
(
TYPE_FUSION
|
TYPE_SYNCHRO
|
TYPE_XYZ
|
TYPE_LINK
))
extra_cards
.
push_back
(
cit
);
return
extra_cards
;
};
load
(
pdeck
[
0
].
main
,
0
,
LOCATION_DECK
);
load
(
load_extra
(
0
),
0
,
LOCATION_EXTRA
);
load
(
pdeck
[
1
].
main
,
1
,
LOCATION_DECK
);
load
(
load_extra
(
1
),
1
,
LOCATION_EXTRA
);
#else
load
(
pdeck
[
0
].
main
,
0
,
LOCATION_DECK
);
load
(
pdeck
[
0
].
extra
,
0
,
LOCATION_EXTRA
);
load
(
pdeck
[
1
].
main
,
1
,
LOCATION_DECK
);
load
(
pdeck
[
1
].
extra
,
1
,
LOCATION_EXTRA
);
#endif
last_replay
.
Flush
();
unsigned
char
startbuf
[
32
]{};
auto
pbuf
=
startbuf
;
...
...
@@ -695,10 +713,21 @@ void SingleDuel::DuelEndProc() {
int
winc
[
3
]
=
{
0
,
0
,
0
};
for
(
int
i
=
0
;
i
<
duel_count
;
++
i
)
winc
[
match_result
[
i
]]
++
;
if
(
match_kill
||
(
winc
[
0
]
==
2
||
(
winc
[
0
]
==
1
&&
winc
[
2
]
==
2
))
#ifdef YGOPRO_SERVER_MODE
auto
best_of_count
=
(
duel_flags
&
DUEL_FLAG_BO5
)
?
3
:
2
;
auto
total_count
=
(
duel_flags
&
DUEL_FLAG_BO5
)
?
5
:
3
;
#endif
if
(
match_kill
||
#ifdef YGOPRO_SERVER_MODE
duel_count
>=
total_count
||
winc
[
0
]
>=
best_of_count
||
winc
[
1
]
>=
best_of_count
#else
(
winc
[
0
]
==
2
||
(
winc
[
0
]
==
1
&&
winc
[
2
]
==
2
))
||
(
winc
[
1
]
==
2
||
(
winc
[
1
]
==
1
&&
winc
[
2
]
==
2
))
||
(
winc
[
2
]
==
3
||
(
winc
[
0
]
==
1
&&
winc
[
1
]
==
1
&&
winc
[
2
]
==
1
))
)
{
||
(
winc
[
2
]
==
3
||
(
winc
[
0
]
==
1
&&
winc
[
1
]
==
1
&&
winc
[
2
]
==
1
))
#endif
)
{
NetServer
::
SendPacketToPlayer
(
players
[
0
],
STOC_DUEL_END
);
NetServer
::
ReSendToPlayer
(
players
[
1
]);
for
(
auto
oit
=
observers
.
begin
();
oit
!=
observers
.
end
();
++
oit
)
...
...
gframe/tag_duel.cpp
View file @
8cab9493
...
...
@@ -428,13 +428,15 @@ void TagDuel::StartDuel(DuelPlayer* dp) {
#endif
unsigned
char
deckbuff
[
12
];
auto
pbuf
=
deckbuff
;
#ifdef YGOPRO_SERVER_MODE
short
extra_size
[
2
];
for
(
int
i
=
0
;
i
<
2
;
++
i
)
{
auto
p
=
i
*
2
;
extra_size
[
i
]
=
(
short
)
pdeck
[
p
].
extra
.
size
();
for
(
auto
cit
:
pdeck
[
p
].
side
)
if
(
cit
->
second
.
type
&
(
TYPE_FUSION
|
TYPE_SYNCHRO
|
TYPE_XYZ
|
TYPE_LINK
))
++
extra_size
[
i
];
if
(
duel_flags
&
DUEL_FLAG_SIDEINS
)
for
(
auto
cit
:
pdeck
[
p
].
side
)
if
(
cit
->
second
.
type
&
(
TYPE_FUSION
|
TYPE_SYNCHRO
|
TYPE_XYZ
|
TYPE_LINK
))
++
extra_size
[
i
];
}
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
0
].
main
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
extra_size
[
0
]);
...
...
@@ -442,6 +444,14 @@ void TagDuel::StartDuel(DuelPlayer* dp) {
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
2
].
main
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
extra_size
[
1
]);
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
2
].
side
.
size
());
#else
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
0
].
main
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
0
].
extra
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
0
].
side
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
2
].
main
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
2
].
extra
.
size
());
BufferIO
::
WriteInt16
(
pbuf
,
(
short
)
pdeck
[
2
].
side
.
size
());
#endif
NetServer
::
SendBufferToPlayer
(
players
[
0
],
STOC_DECK_COUNT
,
deckbuff
,
12
);
NetServer
::
ReSendToPlayer
(
players
[
1
]);
char
tempbuff
[
6
];
...
...
@@ -586,14 +596,16 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
last_replay
.
WriteInt32
((
*
cit
)
->
first
,
false
);
}
};
#ifdef YGOPRO_SERVER_MODE
std
::
vector
<
ygo
::
code_pointer
>
extra_cards
;
auto
load_extra
=
[
&
](
uint8_t
p
)
{
extra_cards
.
clear
();
for
(
auto
cit
:
pdeck
[
p
].
extra
)
extra_cards
.
push_back
(
cit
);
for
(
auto
cit
:
pdeck
[
p
].
side
)
if
(
cit
->
second
.
type
&
(
TYPE_FUSION
|
TYPE_SYNCHRO
|
TYPE_XYZ
|
TYPE_LINK
))
extra_cards
.
push_back
(
cit
);
if
(
duel_flags
&
DUEL_FLAG_SIDEINS
)
for
(
auto
cit
:
pdeck
[
p
].
side
)
if
(
cit
->
second
.
type
&
(
TYPE_FUSION
|
TYPE_SYNCHRO
|
TYPE_XYZ
|
TYPE_LINK
))
extra_cards
.
push_back
(
cit
);
return
extra_cards
;
};
load_single
(
pdeck
[
0
].
main
,
0
,
LOCATION_DECK
);
...
...
@@ -604,6 +616,16 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
load_single
(
load_extra
(
3
),
1
,
LOCATION_EXTRA
);
load_tag
(
pdeck
[
2
].
main
,
1
,
LOCATION_DECK
);
load_tag
(
load_extra
(
2
),
1
,
LOCATION_EXTRA
);
#else
load_single
(
pdeck
[
0
].
main
,
0
,
LOCATION_DECK
);
load_single
(
pdeck
[
0
].
extra
,
0
,
LOCATION_EXTRA
);
load_tag
(
pdeck
[
1
].
main
,
0
,
LOCATION_DECK
);
load_tag
(
pdeck
[
1
].
extra
,
0
,
LOCATION_EXTRA
);
load_single
(
pdeck
[
3
].
main
,
1
,
LOCATION_DECK
);
load_single
(
pdeck
[
3
].
extra
,
1
,
LOCATION_EXTRA
);
load_tag
(
pdeck
[
2
].
main
,
1
,
LOCATION_DECK
);
load_tag
(
pdeck
[
2
].
extra
,
1
,
LOCATION_EXTRA
);
#endif
last_replay
.
Flush
();
unsigned
char
startbuf
[
32
]{};
auto
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