Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile-Cn-Ko-En
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
fallenstardust
YGOMobile-Cn-Ko-En
Commits
824f39ef
Commit
824f39ef
authored
May 15, 2024
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix card_operation_sort undefined behavior (#589)
parent
4b25a3bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
13 deletions
+24
-13
Classes/ocgcore/card.cpp
Classes/ocgcore/card.cpp
+14
-13
Classes/ocgcore/effect.cpp
Classes/ocgcore/effect.cpp
+10
-0
No files found.
Classes/ocgcore/card.cpp
View file @
824f39ef
...
...
@@ -98,13 +98,6 @@ bool card::card_operation_sort(card* c1, card* c2) {
else
return
c1
->
current
.
sequence
<
c2
->
current
.
sequence
;
}
else
if
(
c1
->
current
.
location
&
LOCATION_DECK
&&
!
pduel
->
game_field
->
core
.
select_deck_seq_preserved
)
{
// faceup deck cards should go at the very first
if
(
c1
->
current
.
position
!=
c2
->
current
.
position
)
{
if
(
c1
->
current
.
position
&
POS_FACEUP
)
return
false
;
else
return
true
;
}
// if deck reversed and the card being at the top, it should go first
if
(
pduel
->
game_field
->
core
.
deck_reversed
)
{
if
(
c1
->
current
.
sequence
==
pduel
->
game_field
->
player
[
cp1
].
list_main
.
size
()
-
1
)
...
...
@@ -112,6 +105,15 @@ bool card::card_operation_sort(card* c1, card* c2) {
if
(
c2
->
current
.
sequence
==
pduel
->
game_field
->
player
[
cp2
].
list_main
.
size
()
-
1
)
return
true
;
}
// faceup deck cards should go at the very first
auto
c1_faceup
=
c1
->
current
.
position
&
POS_FACEUP
;
auto
c2_faceup
=
c2
->
current
.
position
&
POS_FACEUP
;
if
(
c1_faceup
||
c2_faceup
)
{
if
(
c1_faceup
&&
c2_faceup
)
return
c1
->
current
.
sequence
>
c2
->
current
.
sequence
;
else
return
c2_faceup
;
}
// sort deck as card property
auto
c1_type
=
c1
->
data
.
type
&
0x7
;
auto
c2_type
=
c2
->
data
.
type
&
0x7
;
...
...
@@ -119,14 +121,13 @@ bool card::card_operation_sort(card* c1, card* c2) {
if
(
c1_type
!=
c2_type
)
return
c1_type
>
c2_type
;
if
(
c1_type
&
TYPE_MONSTER
)
{
// sort monster by level, then code
if
(
c1
->
data
.
level
!=
c2
->
data
.
level
)
if
(
c1
->
data
.
level
!=
c2
->
data
.
level
)
return
c1
->
data
.
level
<
c2
->
data
.
level
;
else
return
c1
->
data
.
code
>
c2
->
data
.
code
;
}
else
// spell and trap should go by code
// TODO: more sorts here
}
if
(
c1
->
data
.
code
!=
c2
->
data
.
code
)
return
c1
->
data
.
code
>
c2
->
data
.
code
;
return
c1
->
current
.
sequence
>
c2
->
current
.
sequence
;
}
else
{
if
(
c1
->
current
.
location
&
(
LOCATION_DECK
|
LOCATION_EXTRA
|
LOCATION_GRAVE
|
LOCATION_REMOVED
))
return
c1
->
current
.
sequence
>
c2
->
current
.
sequence
;
...
...
Classes/ocgcore/effect.cpp
View file @
824f39ef
...
...
@@ -206,9 +206,16 @@ int32 effect::get_required_handorset_effects(effect_set* eset, uint8 playerid, c
int32
available
=
0
;
effect_set
tmp_eset
;
handler
->
filter_effect
(
ecode
,
&
tmp_eset
);
if
(
!
tmp_eset
.
size
())
return
available
;
effect
*
oreason
=
pduel
->
game_field
->
core
.
reason_effect
;
uint8
op
=
pduel
->
game_field
->
core
.
reason_player
;
pduel
->
game_field
->
core
.
reason_player
=
playerid
;
pduel
->
game_field
->
save_lp_cost
();
for
(
int32
i
=
0
;
i
<
tmp_eset
.
size
();
++
i
)
{
auto
peffect
=
tmp_eset
[
i
];
if
(
peffect
->
check_count_limit
(
playerid
))
{
pduel
->
game_field
->
core
.
reason_effect
=
peffect
;
pduel
->
lua
->
add_param
(
peffect
,
PARAM_TYPE_EFFECT
);
pduel
->
lua
->
add_param
(
playerid
,
PARAM_TYPE_INT
);
pduel
->
lua
->
add_param
(
e
.
event_cards
,
PARAM_TYPE_GROUP
);
...
...
@@ -225,6 +232,9 @@ int32 effect::get_required_handorset_effects(effect_set* eset, uint8 playerid, c
}
}
}
pduel
->
game_field
->
core
.
reason_effect
=
oreason
;
pduel
->
game_field
->
core
.
reason_player
=
op
;
pduel
->
game_field
->
restore_lp_cost
();
return
available
;
}
// check if an EFFECT_TYPE_ACTIONS effect can be activated
...
...
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