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
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-core
Commits
3d4f2ed9
Commit
3d4f2ed9
authored
Jun 17, 2024
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'patch-counter' of github.com:Fluorohydride/ygopro-core into develop
parents
1cc92175
ea275fa6
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
63 deletions
+44
-63
card.cpp
card.cpp
+36
-48
card.h
card.h
+1
-1
field.h
field.h
+1
-1
libcard.cpp
libcard.cpp
+1
-1
libdebug.cpp
libdebug.cpp
+2
-9
operations.cpp
operations.cpp
+2
-2
playerop.cpp
playerop.cpp
+1
-1
No files found.
card.cpp
View file @
3d4f2ed9
...
@@ -350,8 +350,8 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
...
@@ -350,8 +350,8 @@ int32 card::get_infos(byte* buf, uint32 query_flag, int32 use_cache) {
if
(
query_flag
&
QUERY_COUNTERS
)
{
if
(
query_flag
&
QUERY_COUNTERS
)
{
buffer_write
<
int32_t
>
(
p
,
(
int32_t
)
counters
.
size
());
buffer_write
<
int32_t
>
(
p
,
(
int32_t
)
counters
.
size
());
for
(
const
auto
&
cmit
:
counters
)
{
for
(
const
auto
&
cmit
:
counters
)
{
int32
tdata
=
cmit
.
first
+
((
cmit
.
second
[
0
]
+
cmit
.
second
[
1
])
<<
16
);
uint32
tdata
=
cmit
.
first
+
((
uint32
)
cmit
.
second
<<
16
);
buffer_write
<
int32_t
>
(
p
,
tdata
);
buffer_write
<
u
int32_t
>
(
p
,
tdata
);
}
}
}
}
if
(
query_flag
&
QUERY_OWNER
)
{
if
(
query_flag
&
QUERY_OWNER
)
{
...
@@ -2006,7 +2006,7 @@ void card::remove_effect(effect* peffect, effect_container::iterator it) {
...
@@ -2006,7 +2006,7 @@ void card::remove_effect(effect* peffect, effect_container::iterator it) {
pduel
->
write_buffer8
(
current
.
controler
);
pduel
->
write_buffer8
(
current
.
controler
);
pduel
->
write_buffer8
(
current
.
location
);
pduel
->
write_buffer8
(
current
.
location
);
pduel
->
write_buffer8
(
current
.
sequence
);
pduel
->
write_buffer8
(
current
.
sequence
);
pduel
->
write_buffer16
(
cmit
->
second
[
0
]
+
cmit
->
second
[
1
]
);
pduel
->
write_buffer16
(
cmit
->
second
);
counters
.
erase
(
cmit
);
counters
.
erase
(
cmit
);
}
}
}
}
...
@@ -2156,18 +2156,18 @@ void card::reset(uint32 id, uint32 reset_type) {
...
@@ -2156,18 +2156,18 @@ void card::reset(uint32 id, uint32 reset_type) {
}
}
if
(
id
&
RESET_DISABLE
)
{
if
(
id
&
RESET_DISABLE
)
{
for
(
auto
cmit
=
counters
.
begin
();
cmit
!=
counters
.
end
();)
{
for
(
auto
cmit
=
counters
.
begin
();
cmit
!=
counters
.
end
();)
{
if
(
cmit
->
second
[
1
]
>
0
)
{
if
((
uint32
)
cmit
->
first
&
COUNTER_WITHOUT_PERMIT
)
{
++
cmit
;
continue
;
}
if
(
cmit
->
second
>
0
)
{
pduel
->
write_buffer8
(
MSG_REMOVE_COUNTER
);
pduel
->
write_buffer8
(
MSG_REMOVE_COUNTER
);
pduel
->
write_buffer16
(
cmit
->
first
);
pduel
->
write_buffer16
(
cmit
->
first
);
pduel
->
write_buffer8
(
current
.
controler
);
pduel
->
write_buffer8
(
current
.
controler
);
pduel
->
write_buffer8
(
current
.
location
);
pduel
->
write_buffer8
(
current
.
location
);
pduel
->
write_buffer8
(
current
.
sequence
);
pduel
->
write_buffer8
(
current
.
sequence
);
pduel
->
write_buffer16
(
cmit
->
second
[
1
]);
pduel
->
write_buffer16
(
cmit
->
second
);
cmit
->
second
[
1
]
=
0
;
cmit
=
counters
.
erase
(
cmit
);
if
(
cmit
->
second
[
0
]
==
0
)
cmit
=
counters
.
erase
(
cmit
);
else
++
cmit
;
}
}
else
else
++
cmit
;
++
cmit
;
...
@@ -2355,35 +2355,26 @@ int32 card::destination_redirect(uint8 destination, uint32 reason) {
...
@@ -2355,35 +2355,26 @@ int32 card::destination_redirect(uint8 destination, uint32 reason) {
}
}
return
0
;
return
0
;
}
}
// cmit->second[0]: permanent
// cmit->second[1]: reset while negated
int32
card
::
add_counter
(
uint8
playerid
,
uint16
countertype
,
uint16
count
,
uint8
singly
)
{
int32
card
::
add_counter
(
uint8
playerid
,
uint16
countertype
,
uint16
count
,
uint8
singly
)
{
if
(
!
is_can_add_counter
(
playerid
,
countertype
,
count
,
singly
,
0
))
if
(
!
is_can_add_counter
(
playerid
,
countertype
,
count
,
singly
,
0
))
return
FALSE
;
return
FALSE
;
uint16
cttype
=
countertype
;
uint16
cttype
=
countertype
;
auto
pr
=
counters
.
emplace
(
cttype
,
counter_map
::
mapped_type
()
);
auto
pr
=
counters
.
emplace
(
cttype
,
0
);
auto
cmit
=
pr
.
first
;
auto
cmit
=
pr
.
first
;
if
(
pr
.
second
)
{
int32
pcount
=
count
;
cmit
->
second
[
0
]
=
0
;
cmit
->
second
[
1
]
=
0
;
}
uint16
pcount
=
count
;
if
(
singly
)
{
if
(
singly
)
{
effect_set
eset
;
effect_set
eset
;
uint16
limit
=
0
;
int32
limit
=
0
;
filter_effect
(
EFFECT_COUNTER_LIMIT
+
cttype
,
&
eset
);
filter_effect
(
EFFECT_COUNTER_LIMIT
+
cttype
,
&
eset
);
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
if
(
eset
.
size
()
)
limit
=
eset
[
i
]
->
get_value
();
limit
=
eset
.
get_last
()
->
get_value
();
if
(
limit
)
{
if
(
limit
)
{
uint16
mcount
=
limit
-
get_counter
(
cttype
);
int32
mcount
=
limit
-
get_counter
(
cttype
);
if
(
pcount
>
mcount
)
if
(
mcount
>
0
&&
pcount
>
mcount
)
pcount
=
mcount
;
pcount
=
mcount
;
}
}
}
}
if
(
countertype
&
COUNTER_WITHOUT_PERMIT
)
cmit
->
second
+=
pcount
;
cmit
->
second
[
0
]
+=
pcount
;
else
cmit
->
second
[
1
]
+=
pcount
;
pduel
->
write_buffer8
(
MSG_ADD_COUNTER
);
pduel
->
write_buffer8
(
MSG_ADD_COUNTER
);
pduel
->
write_buffer16
(
cttype
);
pduel
->
write_buffer16
(
cttype
);
pduel
->
write_buffer8
(
current
.
controler
);
pduel
->
write_buffer8
(
current
.
controler
);
...
@@ -2398,22 +2389,20 @@ int32 card::remove_counter(uint16 countertype, uint16 count) {
...
@@ -2398,22 +2389,20 @@ int32 card::remove_counter(uint16 countertype, uint16 count) {
auto
cmit
=
counters
.
find
(
countertype
);
auto
cmit
=
counters
.
find
(
countertype
);
if
(
cmit
==
counters
.
end
())
if
(
cmit
==
counters
.
end
())
return
FALSE
;
return
FALSE
;
if
(
cmit
->
second
[
1
]
<=
count
)
{
int32
remove_count
=
count
;
uint16
remains
=
count
;
if
(
cmit
->
second
<=
count
)
{
remains
-=
cmit
->
second
[
1
];
remove_count
=
cmit
->
second
;
cmit
->
second
[
1
]
=
0
;
counters
.
erase
(
cmit
);
if
(
cmit
->
second
[
0
]
<=
remains
)
}
counters
.
erase
(
cmit
);
else
{
else
cmit
->
second
[
0
]
-=
remains
;
cmit
->
second
-=
count
;
}
else
{
cmit
->
second
[
1
]
-=
count
;
}
}
pduel
->
write_buffer8
(
MSG_REMOVE_COUNTER
);
pduel
->
write_buffer8
(
MSG_REMOVE_COUNTER
);
pduel
->
write_buffer16
(
countertype
);
pduel
->
write_buffer16
(
countertype
);
pduel
->
write_buffer8
(
current
.
controler
);
pduel
->
write_buffer8
(
current
.
controler
);
pduel
->
write_buffer8
(
current
.
location
);
pduel
->
write_buffer8
(
current
.
location
);
pduel
->
write_buffer8
(
current
.
sequence
);
pduel
->
write_buffer8
(
current
.
sequence
);
pduel
->
write_buffer16
(
count
);
pduel
->
write_buffer16
(
remove_
count
);
return
TRUE
;
return
TRUE
;
}
}
// return: the player can put a counter on this or not
// return: the player can put a counter on this or not
...
@@ -2423,9 +2412,9 @@ int32 card::is_can_add_counter(uint8 playerid, uint16 countertype, uint16 count,
...
@@ -2423,9 +2412,9 @@ int32 card::is_can_add_counter(uint8 playerid, uint16 countertype, uint16 count,
return
FALSE
;
return
FALSE
;
if
(
!
loc
&&
(
!
(
current
.
location
&
LOCATION_ONFIELD
)
||
!
is_position
(
POS_FACEUP
)))
if
(
!
loc
&&
(
!
(
current
.
location
&
LOCATION_ONFIELD
)
||
!
is_position
(
POS_FACEUP
)))
return
FALSE
;
return
FALSE
;
uint32
check
=
countertype
&
COUNTER_WITHOUT_PERMIT
;
uint32
check
=
(
uint32
)
countertype
&
COUNTER_WITHOUT_PERMIT
;
if
(
!
check
)
{
if
(
!
check
)
{
filter_effect
(
EFFECT_COUNTER_PERMIT
+
(
countertype
&
0xffff
)
,
&
eset
);
filter_effect
(
EFFECT_COUNTER_PERMIT
+
countertype
,
&
eset
);
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
{
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
{
uint32
prange
=
eset
[
i
]
->
range
;
uint32
prange
=
eset
[
i
]
->
range
;
if
(
loc
)
if
(
loc
)
...
@@ -2439,15 +2428,14 @@ int32 card::is_can_add_counter(uint8 playerid, uint16 countertype, uint16 count,
...
@@ -2439,15 +2428,14 @@ int32 card::is_can_add_counter(uint8 playerid, uint16 countertype, uint16 count,
}
}
if
(
!
check
)
if
(
!
check
)
return
FALSE
;
return
FALSE
;
uint16
cttype
=
countertype
;
int32
limit
=
-
1
;
int32
limit
=
-
1
;
int32
cur
=
0
;
int32
cur
=
0
;
auto
cmit
=
counters
.
find
(
c
t
type
);
auto
cmit
=
counters
.
find
(
c
ounter
type
);
if
(
cmit
!=
counters
.
end
())
if
(
cmit
!=
counters
.
end
())
cur
=
cmit
->
second
[
0
]
+
cmit
->
second
[
1
]
;
cur
=
cmit
->
second
;
filter_effect
(
EFFECT_COUNTER_LIMIT
+
c
t
type
,
&
eset
);
filter_effect
(
EFFECT_COUNTER_LIMIT
+
c
ounter
type
,
&
eset
);
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
if
(
eset
.
size
()
)
limit
=
eset
[
i
]
->
get_value
();
limit
=
eset
.
get_last
()
->
get_value
();
if
(
limit
>
0
&&
(
cur
+
(
singly
?
1
:
count
)
>
limit
))
if
(
limit
>
0
&&
(
cur
+
(
singly
?
1
:
count
)
>
limit
))
return
FALSE
;
return
FALSE
;
return
TRUE
;
return
TRUE
;
...
@@ -2458,7 +2446,7 @@ int32 card::is_can_have_counter(uint16 countertype) {
...
@@ -2458,7 +2446,7 @@ int32 card::is_can_have_counter(uint16 countertype) {
if
(
countertype
&
COUNTER_WITHOUT_PERMIT
)
if
(
countertype
&
COUNTER_WITHOUT_PERMIT
)
return
FALSE
;
return
FALSE
;
else
{
else
{
filter_self_effect
(
EFFECT_COUNTER_PERMIT
+
(
countertype
&
0xffff
)
,
&
eset
);
filter_self_effect
(
EFFECT_COUNTER_PERMIT
+
countertype
,
&
eset
);
if
(
current
.
is_location
(
LOCATION_ONFIELD
))
{
if
(
current
.
is_location
(
LOCATION_ONFIELD
))
{
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
{
for
(
int32
i
=
0
;
i
<
eset
.
size
();
++
i
)
{
if
(
eset
[
i
]
->
is_single_ready
())
if
(
eset
[
i
]
->
is_single_ready
())
...
@@ -2477,7 +2465,7 @@ int32 card::get_counter(uint16 countertype) {
...
@@ -2477,7 +2465,7 @@ int32 card::get_counter(uint16 countertype) {
auto
cmit
=
counters
.
find
(
countertype
);
auto
cmit
=
counters
.
find
(
countertype
);
if
(
cmit
==
counters
.
end
())
if
(
cmit
==
counters
.
end
())
return
0
;
return
0
;
return
cmit
->
second
[
0
]
+
cmit
->
second
[
1
]
;
return
cmit
->
second
;
}
}
void
card
::
set_material
(
card_set
*
materials
)
{
void
card
::
set_material
(
card_set
*
materials
)
{
if
(
!
materials
)
{
if
(
!
materials
)
{
...
...
card.h
View file @
3d4f2ed9
...
@@ -119,7 +119,7 @@ public:
...
@@ -119,7 +119,7 @@ public:
using
effect_indexer
=
std
::
unordered_map
<
effect
*
,
effect_container
::
iterator
>
;
using
effect_indexer
=
std
::
unordered_map
<
effect
*
,
effect_container
::
iterator
>
;
using
effect_relation
=
std
::
unordered_set
<
std
::
pair
<
effect
*
,
uint16
>
,
effect_relation_hash
>
;
using
effect_relation
=
std
::
unordered_set
<
std
::
pair
<
effect
*
,
uint16
>
,
effect_relation_hash
>
;
using
relation_map
=
std
::
unordered_map
<
card
*
,
uint32
>
;
using
relation_map
=
std
::
unordered_map
<
card
*
,
uint32
>
;
using
counter_map
=
std
::
map
<
uint16
,
std
::
array
<
uint16
,
2
>
>
;
using
counter_map
=
std
::
map
<
uint16
,
uint16
>
;
using
effect_count
=
std
::
map
<
uint32
,
int32
>
;
using
effect_count
=
std
::
map
<
uint32
,
int32
>
;
class
attacker_map
:
public
std
::
unordered_map
<
uint16
,
std
::
pair
<
card
*
,
uint32
>>
{
class
attacker_map
:
public
std
::
unordered_map
<
uint16
,
std
::
pair
<
card
*
,
uint32
>>
{
public:
public:
...
...
field.h
View file @
3d4f2ed9
...
@@ -161,7 +161,7 @@ constexpr int SIZE_IVALUE = SIZE_RETURN_VALUE / 4;
...
@@ -161,7 +161,7 @@ constexpr int SIZE_IVALUE = SIZE_RETURN_VALUE / 4;
constexpr
int
SIZE_LVALUE
=
SIZE_RETURN_VALUE
/
8
;
constexpr
int
SIZE_LVALUE
=
SIZE_RETURN_VALUE
/
8
;
union
return_value
{
union
return_value
{
uint8
bvalue
[
SIZE_RETURN_VALUE
];
uint8
bvalue
[
SIZE_RETURN_VALUE
];
int16
svalue
[
SIZE_SVALUE
];
u
int16
svalue
[
SIZE_SVALUE
];
int32
ivalue
[
SIZE_IVALUE
];
int32
ivalue
[
SIZE_IVALUE
];
int64
lvalue
[
SIZE_LVALUE
];
int64
lvalue
[
SIZE_LVALUE
];
};
};
...
...
libcard.cpp
View file @
3d4f2ed9
...
@@ -2879,7 +2879,7 @@ int32 scriptlib::card_remove_counter(lua_State *L) {
...
@@ -2879,7 +2879,7 @@ int32 scriptlib::card_remove_counter(lua_State *L) {
pduel
->
write_buffer8
(
pcard
->
current
.
controler
);
pduel
->
write_buffer8
(
pcard
->
current
.
controler
);
pduel
->
write_buffer8
(
pcard
->
current
.
location
);
pduel
->
write_buffer8
(
pcard
->
current
.
location
);
pduel
->
write_buffer8
(
pcard
->
current
.
sequence
);
pduel
->
write_buffer8
(
pcard
->
current
.
sequence
);
pduel
->
write_buffer16
(
cmit
.
second
[
0
]
+
cmit
.
second
[
1
]
);
pduel
->
write_buffer16
(
cmit
.
second
);
}
}
pcard
->
counters
.
clear
();
pcard
->
counters
.
clear
();
return
0
;
return
0
;
...
...
libdebug.cpp
View file @
3d4f2ed9
...
@@ -128,16 +128,9 @@ int32 scriptlib::debug_pre_add_counter(lua_State *L) {
...
@@ -128,16 +128,9 @@ int32 scriptlib::debug_pre_add_counter(lua_State *L) {
uint32
countertype
=
(
uint32
)
lua_tointeger
(
L
,
2
);
uint32
countertype
=
(
uint32
)
lua_tointeger
(
L
,
2
);
uint32
count
=
(
uint32
)
lua_tointeger
(
L
,
3
);
uint32
count
=
(
uint32
)
lua_tointeger
(
L
,
3
);
uint16
cttype
=
countertype
;
uint16
cttype
=
countertype
;
auto
pr
=
pcard
->
counters
.
emplace
(
cttype
,
card
::
counter_map
::
mapped_type
()
);
auto
pr
=
pcard
->
counters
.
emplace
(
cttype
,
0
);
auto
cmit
=
pr
.
first
;
auto
cmit
=
pr
.
first
;
if
(
pr
.
second
)
{
cmit
->
second
+=
count
;
cmit
->
second
[
0
]
=
0
;
cmit
->
second
[
1
]
=
0
;
}
if
(
countertype
&
COUNTER_WITHOUT_PERMIT
)
cmit
->
second
[
0
]
+=
count
;
else
cmit
->
second
[
1
]
+=
count
;
return
0
;
return
0
;
}
}
int32
scriptlib
::
debug_reload_field_begin
(
lua_State
*
L
)
{
int32
scriptlib
::
debug_reload_field_begin
(
lua_State
*
L
)
{
...
...
operations.cpp
View file @
3d4f2ed9
...
@@ -710,7 +710,7 @@ int32 field::remove_counter(uint16 step, uint32 reason, card* pcard, uint8 rplay
...
@@ -710,7 +710,7 @@ int32 field::remove_counter(uint16 step, uint32 reason, card* pcard, uint8 rplay
core
.
select_effects
.
clear
();
core
.
select_effects
.
clear
();
if
((
pcard
&&
pcard
->
get_counter
(
countertype
)
>=
count
)
||
(
!
pcard
&&
get_field_counter
(
rplayer
,
s
,
o
,
countertype
)))
{
if
((
pcard
&&
pcard
->
get_counter
(
countertype
)
>=
count
)
||
(
!
pcard
&&
get_field_counter
(
rplayer
,
s
,
o
,
countertype
)))
{
core
.
select_options
.
push_back
(
10
);
core
.
select_options
.
push_back
(
10
);
core
.
select_effects
.
push_back
(
0
);
core
.
select_effects
.
push_back
(
nullptr
);
}
}
auto
pr
=
effects
.
continuous_effect
.
equal_range
(
EFFECT_RCOUNTER_REPLACE
+
countertype
);
auto
pr
=
effects
.
continuous_effect
.
equal_range
(
EFFECT_RCOUNTER_REPLACE
+
countertype
);
tevent
e
;
tevent
e
;
...
@@ -733,7 +733,7 @@ int32 field::remove_counter(uint16 step, uint32 reason, card* pcard, uint8 rplay
...
@@ -733,7 +733,7 @@ int32 field::remove_counter(uint16 step, uint32 reason, card* pcard, uint8 rplay
return
TRUE
;
return
TRUE
;
if
(
core
.
select_options
.
size
()
==
1
)
if
(
core
.
select_options
.
size
()
==
1
)
returns
.
ivalue
[
0
]
=
0
;
returns
.
ivalue
[
0
]
=
0
;
else
if
(
core
.
select_effects
[
0
]
==
0
&&
core
.
select_effects
.
size
()
==
2
)
else
if
(
core
.
select_effects
[
0
]
==
nullptr
&&
core
.
select_effects
.
size
()
==
2
)
add_process
(
PROCESSOR_SELECT_EFFECTYN
,
0
,
0
,
(
group
*
)
core
.
select_effects
[
1
]
->
handler
,
rplayer
,
220
);
add_process
(
PROCESSOR_SELECT_EFFECTYN
,
0
,
0
,
(
group
*
)
core
.
select_effects
[
1
]
->
handler
,
rplayer
,
220
);
else
else
add_process
(
PROCESSOR_SELECT_OPTION
,
0
,
0
,
0
,
rplayer
,
0
);
add_process
(
PROCESSOR_SELECT_OPTION
,
0
,
0
,
0
,
rplayer
,
0
);
...
...
playerop.cpp
View file @
3d4f2ed9
...
@@ -615,7 +615,7 @@ int32 field::select_counter(uint16 step, uint8 playerid, uint16 countertype, uin
...
@@ -615,7 +615,7 @@ int32 field::select_counter(uint16 step, uint8 playerid, uint16 countertype, uin
}
}
return
FALSE
;
return
FALSE
;
}
else
{
}
else
{
uint16
ct
=
0
;
int32
ct
=
0
;
for
(
int32
i
=
0
;
i
<
(
int32
)
core
.
select_cards
.
size
();
++
i
)
{
for
(
int32
i
=
0
;
i
<
(
int32
)
core
.
select_cards
.
size
();
++
i
)
{
if
(
core
.
select_cards
[
i
]
->
get_counter
(
countertype
)
<
returns
.
svalue
[
i
])
{
if
(
core
.
select_cards
[
i
]
->
get_counter
(
countertype
)
<
returns
.
svalue
[
i
])
{
pduel
->
write_buffer8
(
MSG_RETRY
);
pduel
->
write_buffer8
(
MSG_RETRY
);
...
...
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