Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-core
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
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
ygopro-core
Commits
11c3fdd0
Commit
11c3fdd0
authored
Jan 08, 2020
by
DailyShana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix swap card
close Fluorohydride/ygopro-core#270
parent
a1f55eec
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
55 deletions
+90
-55
field.cpp
field.cpp
+87
-10
field.h
field.h
+1
-0
libduel.cpp
libduel.cpp
+1
-10
operations.cpp
operations.cpp
+1
-35
No files found.
field.cpp
View file @
11c3fdd0
...
...
@@ -428,19 +428,96 @@ void field::move_card(uint8 playerid, card* pcard, uint8 location, uint8 sequenc
}
add_card
(
playerid
,
pcard
,
location
,
sequence
,
pzone
);
}
void
field
::
swap_card
(
card
*
pcard1
,
card
*
pcard2
)
{
void
field
::
swap_card
(
card
*
pcard1
,
card
*
pcard2
,
uint8
new_sequence1
,
uint8
new_sequence2
)
{
uint8
p1
=
pcard1
->
current
.
controler
,
p2
=
pcard2
->
current
.
controler
;
uint8
l1
=
pcard1
->
current
.
location
,
l2
=
pcard2
->
current
.
location
;
uint8
s1
=
pcard1
->
current
.
sequence
,
s2
=
pcard2
->
current
.
sequence
;
remove_card
(
pcard1
);
remove_card
(
pcard2
);
add_card
(
p2
,
pcard1
,
l2
,
s2
);
add_card
(
p1
,
pcard2
,
l1
,
s1
);
pduel
->
write_buffer8
(
MSG_SWAP
);
pduel
->
write_buffer32
(
pcard1
->
data
.
code
);
pduel
->
write_buffer32
(
pcard2
->
get_info_location
());
pduel
->
write_buffer32
(
pcard2
->
data
.
code
);
pduel
->
write_buffer32
(
pcard1
->
get_info_location
());
uint32
info1
=
pcard1
->
get_info_location
(),
info2
=
pcard2
->
get_info_location
();
if
(
!
(
l1
&
LOCATION_ONFIELD
)
||
!
(
l2
&
LOCATION_ONFIELD
))
return
;
if
(
new_sequence1
!=
s1
&&
!
is_location_useable
(
p1
,
l1
,
new_sequence1
)
||
new_sequence2
!=
s2
&&
!
is_location_useable
(
p2
,
l2
,
new_sequence2
))
return
;
if
(
p1
==
p2
&&
l1
==
l2
&&
(
new_sequence1
==
s2
||
new_sequence2
==
s1
))
return
;
if
(
l1
==
l2
)
{
pcard1
->
previous
.
controler
=
p1
;
pcard1
->
previous
.
location
=
l1
;
pcard1
->
previous
.
sequence
=
s1
;
pcard1
->
previous
.
position
=
pcard1
->
current
.
position
;
pcard1
->
previous
.
pzone
=
pcard1
->
current
.
pzone
;
pcard1
->
current
.
controler
=
p2
;
pcard1
->
current
.
location
=
l2
;
pcard1
->
current
.
sequence
=
new_sequence2
;
pcard2
->
previous
.
controler
=
p2
;
pcard2
->
previous
.
location
=
l2
;
pcard2
->
previous
.
sequence
=
s2
;
pcard2
->
previous
.
position
=
pcard2
->
current
.
position
;
pcard2
->
previous
.
pzone
=
pcard2
->
current
.
pzone
;
pcard2
->
current
.
controler
=
p1
;
pcard2
->
current
.
location
=
l1
;
pcard2
->
current
.
sequence
=
new_sequence1
;
if
(
p1
!=
p2
)
{
pcard1
->
fieldid
=
infos
.
field_id
++
;
pcard2
->
fieldid
=
infos
.
field_id
++
;
}
if
(
l1
==
LOCATION_MZONE
)
{
player
[
p1
].
list_mzone
[
s1
]
=
0
;
player
[
p1
].
used_location
&=
~
(
1
<<
s1
);
player
[
p2
].
list_mzone
[
s2
]
=
0
;
player
[
p2
].
used_location
&=
~
(
1
<<
s2
);
player
[
p2
].
list_mzone
[
new_sequence2
]
=
pcard1
;
player
[
p2
].
used_location
|=
1
<<
new_sequence2
;
player
[
p1
].
list_mzone
[
new_sequence1
]
=
pcard2
;
player
[
p1
].
used_location
|=
1
<<
new_sequence1
;
}
else
if
(
l1
==
LOCATION_SZONE
)
{
player
[
p1
].
list_szone
[
s1
]
=
0
;
player
[
p1
].
used_location
&=
~
(
256
<<
s1
);
player
[
p2
].
list_szone
[
s2
]
=
0
;
player
[
p2
].
used_location
&=
~
(
256
<<
s2
);
player
[
p2
].
list_szone
[
new_sequence2
]
=
pcard1
;
player
[
p2
].
used_location
|=
256
<<
new_sequence2
;
player
[
p1
].
list_szone
[
new_sequence1
]
=
pcard2
;
player
[
p1
].
used_location
|=
256
<<
new_sequence1
;
}
}
else
{
remove_card
(
pcard1
);
remove_card
(
pcard2
);
add_card
(
p2
,
pcard1
,
l2
,
new_sequence2
);
add_card
(
p1
,
pcard2
,
l1
,
new_sequence1
);
}
if
(
s1
==
new_sequence1
&&
s2
==
new_sequence2
)
{
pduel
->
write_buffer8
(
MSG_SWAP
);
pduel
->
write_buffer32
(
pcard1
->
data
.
code
);
pduel
->
write_buffer32
(
info1
);
pduel
->
write_buffer32
(
pcard2
->
data
.
code
);
pduel
->
write_buffer32
(
info2
);
}
else
if
(
s1
==
new_sequence1
)
{
pduel
->
write_buffer8
(
MSG_MOVE
);
pduel
->
write_buffer32
(
pcard1
->
data
.
code
);
pduel
->
write_buffer32
(
info1
);
pduel
->
write_buffer32
(
pcard1
->
get_info_location
());
pduel
->
write_buffer32
(
0
);
pduel
->
write_buffer8
(
MSG_MOVE
);
pduel
->
write_buffer32
(
pcard2
->
data
.
code
);
pduel
->
write_buffer32
(
info2
);
pduel
->
write_buffer32
(
pcard2
->
get_info_location
());
pduel
->
write_buffer32
(
0
);
}
else
{
pduel
->
write_buffer8
(
MSG_MOVE
);
pduel
->
write_buffer32
(
pcard2
->
data
.
code
);
pduel
->
write_buffer32
(
info2
);
pduel
->
write_buffer32
(
pcard2
->
get_info_location
());
pduel
->
write_buffer32
(
0
);
pduel
->
write_buffer8
(
MSG_MOVE
);
pduel
->
write_buffer32
(
pcard1
->
data
.
code
);
pduel
->
write_buffer32
(
info1
);
pduel
->
write_buffer32
(
pcard1
->
get_info_location
());
pduel
->
write_buffer32
(
0
);
}
}
void
field
::
swap_card
(
card
*
pcard1
,
card
*
pcard2
)
{
return
swap_card
(
pcard1
,
pcard2
,
pcard1
->
current
.
sequence
,
pcard2
->
current
.
sequence
);
}
void
field
::
set_control
(
card
*
pcard
,
uint8
playerid
,
uint16
reset_phase
,
uint8
reset_count
)
{
if
((
core
.
remove_brainwashing
&&
pcard
->
is_affected_by_effect
(
EFFECT_REMOVE_BRAINWASHING
))
||
pcard
->
refresh_control_status
()
==
playerid
)
...
...
field.h
View file @
11c3fdd0
...
...
@@ -363,6 +363,7 @@ public:
void
add_card
(
uint8
playerid
,
card
*
pcard
,
uint8
location
,
uint8
sequence
,
uint8
pzone
=
FALSE
);
void
remove_card
(
card
*
pcard
);
void
move_card
(
uint8
playerid
,
card
*
pcard
,
uint8
location
,
uint8
sequence
,
uint8
pzone
=
FALSE
);
void
swap_card
(
card
*
pcard1
,
card
*
pcard2
,
uint8
new_sequence1
,
uint8
new_sequence2
);
void
swap_card
(
card
*
pcard1
,
card
*
pcard2
);
void
set_control
(
card
*
pcard
,
uint8
playerid
,
uint16
reset_phase
,
uint8
reset_count
);
card
*
get_field_card
(
uint32
playerid
,
uint32
location
,
uint32
sequence
);
...
...
libduel.cpp
View file @
11c3fdd0
...
...
@@ -829,16 +829,7 @@ int32 scriptlib::duel_swap_sequence(lua_State *L) {
&&
location
==
LOCATION_MZONE
&&
pcard2
->
current
.
location
==
location
&&
pcard1
->
is_affect_by_effect
(
pduel
->
game_field
->
core
.
reason_effect
)
&&
pcard2
->
is_affect_by_effect
(
pduel
->
game_field
->
core
.
reason_effect
))
{
uint8
s1
=
pcard1
->
current
.
sequence
,
s2
=
pcard2
->
current
.
sequence
;
pduel
->
game_field
->
remove_card
(
pcard1
);
pduel
->
game_field
->
remove_card
(
pcard2
);
pduel
->
game_field
->
add_card
(
player
,
pcard1
,
location
,
s2
);
pduel
->
game_field
->
add_card
(
player
,
pcard2
,
location
,
s1
);
pduel
->
write_buffer8
(
MSG_SWAP
);
pduel
->
write_buffer32
(
pcard1
->
data
.
code
);
pduel
->
write_buffer32
(
pcard2
->
get_info_location
());
pduel
->
write_buffer32
(
pcard2
->
data
.
code
);
pduel
->
write_buffer32
(
pcard1
->
get_info_location
());
pduel
->
game_field
->
swap_card
(
pcard1
,
pcard2
);
field
::
card_set
swapped
;
swapped
.
insert
(
pcard1
);
swapped
.
insert
(
pcard2
);
...
...
operations.cpp
View file @
11c3fdd0
...
...
@@ -1063,48 +1063,14 @@ int32 field::swap_control(uint16 step, effect* reason_effect, uint8 reason_playe
card
*
pcard1
=
*
targets1
->
it
;
card
*
pcard2
=
*
targets2
->
it
;
uint8
p1
=
pcard1
->
current
.
controler
,
p2
=
pcard2
->
current
.
controler
;
uint8
s1
=
pcard1
->
current
.
sequence
,
s2
=
pcard2
->
current
.
sequence
;
uint8
new_s1
=
core
.
units
.
begin
()
->
arg4
,
new_s2
=
returns
.
bvalue
[
2
];
uint32
info1
=
pcard1
->
get_info_location
(),
info2
=
pcard2
->
get_info_location
();
remove_card
(
pcard1
);
remove_card
(
pcard2
);
add_card
(
p2
,
pcard1
,
LOCATION_MZONE
,
new_s2
);
add_card
(
p1
,
pcard2
,
LOCATION_MZONE
,
new_s1
);
swap_card
(
pcard1
,
pcard2
,
new_s1
,
new_s2
);
pcard1
->
reset
(
RESET_CONTROL
,
RESET_EVENT
);
pcard2
->
reset
(
RESET_CONTROL
,
RESET_EVENT
);
set_control
(
pcard1
,
p2
,
reset_phase
,
reset_count
);
set_control
(
pcard2
,
p1
,
reset_phase
,
reset_count
);
pcard1
->
set_status
(
STATUS_ATTACK_CANCELED
,
TRUE
);
pcard2
->
set_status
(
STATUS_ATTACK_CANCELED
,
TRUE
);
if
(
s1
==
new_s1
&&
s2
==
new_s2
)
{
pduel
->
write_buffer8
(
MSG_SWAP
);
pduel
->
write_buffer32
(
pcard1
->
data
.
code
);
pduel
->
write_buffer32
(
info1
);
pduel
->
write_buffer32
(
pcard2
->
data
.
code
);
pduel
->
write_buffer32
(
info2
);
}
else
if
(
s1
==
new_s1
)
{
pduel
->
write_buffer8
(
MSG_MOVE
);
pduel
->
write_buffer32
(
pcard1
->
data
.
code
);
pduel
->
write_buffer32
(
info1
);
pduel
->
write_buffer32
(
pcard1
->
get_info_location
());
pduel
->
write_buffer32
(
0
);
pduel
->
write_buffer8
(
MSG_MOVE
);
pduel
->
write_buffer32
(
pcard2
->
data
.
code
);
pduel
->
write_buffer32
(
info2
);
pduel
->
write_buffer32
(
pcard2
->
get_info_location
());
pduel
->
write_buffer32
(
0
);
}
else
{
pduel
->
write_buffer8
(
MSG_MOVE
);
pduel
->
write_buffer32
(
pcard2
->
data
.
code
);
pduel
->
write_buffer32
(
info2
);
pduel
->
write_buffer32
(
pcard2
->
get_info_location
());
pduel
->
write_buffer32
(
0
);
pduel
->
write_buffer8
(
MSG_MOVE
);
pduel
->
write_buffer32
(
pcard1
->
data
.
code
);
pduel
->
write_buffer32
(
info1
);
pduel
->
write_buffer32
(
pcard1
->
get_info_location
());
pduel
->
write_buffer32
(
0
);
}
++
targets1
->
it
;
++
targets2
->
it
;
core
.
units
.
begin
()
->
step
=
0
;
...
...
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