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
45fc7229
Commit
45fc7229
authored
Dec 07, 2023
by
Chen Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check is_iterator_dirty for Group.Next
parent
a6f5cc42
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
group.h
group.h
+1
-0
libgroup.cpp
libgroup.cpp
+11
-1
No files found.
group.h
View file @
45fc7229
...
...
@@ -23,6 +23,7 @@ public:
card_set
::
iterator
it
;
int32
ref_handle
{
0
};
uint32
is_readonly
{
0
};
bool
is_iterator_dirty
{
true
};
inline
bool
has_card
(
card
*
c
)
{
return
container
.
find
(
c
)
!=
container
.
end
();
...
...
libgroup.cpp
View file @
45fc7229
...
...
@@ -46,6 +46,7 @@ int32 scriptlib::group_delete(lua_State *L) {
group
*
pgroup
=
*
(
group
**
)
lua_touserdata
(
L
,
1
);
if
(
pgroup
->
is_readonly
!=
2
)
return
0
;
pgroup
->
is_iterator_dirty
=
true
;
pgroup
->
is_readonly
=
0
;
pduel
->
sgroups
.
insert
(
pgroup
);
return
0
;
...
...
@@ -66,6 +67,7 @@ int32 scriptlib::group_clear(lua_State *L) {
check_param
(
L
,
PARAM_TYPE_GROUP
,
1
);
group
*
pgroup
=
*
(
group
**
)
lua_touserdata
(
L
,
1
);
if
(
pgroup
->
is_readonly
!=
1
)
{
pgroup
->
is_iterator_dirty
=
true
;
pgroup
->
container
.
clear
();
}
return
0
;
...
...
@@ -77,6 +79,7 @@ int32 scriptlib::group_add_card(lua_State *L) {
group
*
pgroup
=
*
(
group
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
2
);
if
(
pgroup
->
is_readonly
!=
1
)
{
pgroup
->
is_iterator_dirty
=
true
;
pgroup
->
container
.
insert
(
pcard
);
}
return
0
;
...
...
@@ -88,6 +91,7 @@ int32 scriptlib::group_remove_card(lua_State *L) {
group
*
pgroup
=
*
(
group
**
)
lua_touserdata
(
L
,
1
);
card
*
pcard
=
*
(
card
**
)
lua_touserdata
(
L
,
2
);
if
(
pgroup
->
is_readonly
!=
1
)
{
pgroup
->
is_iterator_dirty
=
true
;
pgroup
->
container
.
erase
(
pcard
);
}
return
0
;
...
...
@@ -96,6 +100,9 @@ int32 scriptlib::group_get_next(lua_State *L) {
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_GROUP
,
1
);
group
*
pgroup
=
*
(
group
**
)
lua_touserdata
(
L
,
1
);
if
(
pgroup
->
is_iterator_dirty
)
{
return
luaL_error
(
L
,
"Called Group.GetNext without calling Group.GetFirst first."
);
}
if
(
pgroup
->
it
==
pgroup
->
container
.
end
())
lua_pushnil
(
L
);
else
{
...
...
@@ -111,6 +118,7 @@ int32 scriptlib::group_get_first(lua_State *L) {
check_param_count
(
L
,
1
);
check_param
(
L
,
PARAM_TYPE_GROUP
,
1
);
group
*
pgroup
=
*
(
group
**
)
lua_touserdata
(
L
,
1
);
pgroup
->
is_iterator_dirty
=
false
;
if
(
pgroup
->
container
.
size
())
{
pgroup
->
it
=
pgroup
->
container
.
begin
();
interpreter
::
card2value
(
L
,
(
*
(
pgroup
->
it
)));
...
...
@@ -637,6 +645,7 @@ int32 scriptlib::group_remove(lua_State *L) {
uint32
extraargs
=
lua_gettop
(
L
)
-
3
;
if
(
pgroup
->
is_readonly
==
1
)
return
0
;
pgroup
->
is_iterator_dirty
=
true
;
for
(
auto
cit
=
pgroup
->
container
.
begin
();
cit
!=
pgroup
->
container
.
end
();)
{
if
((
*
cit
)
!=
pexception
&&
pduel
->
lua
->
check_matching
(
*
cit
,
2
,
extraargs
))
{
cit
=
pgroup
->
container
.
erase
(
cit
);
...
...
@@ -644,7 +653,6 @@ int32 scriptlib::group_remove(lua_State *L) {
else
++
cit
;
}
pgroup
->
it
=
pgroup
->
container
.
begin
();
return
0
;
}
int32
scriptlib
::
group_merge
(
lua_State
*
L
)
{
...
...
@@ -655,6 +663,7 @@ int32 scriptlib::group_merge(lua_State *L) {
group
*
mgroup
=
*
(
group
**
)
lua_touserdata
(
L
,
2
);
if
(
pgroup
->
is_readonly
==
1
)
return
0
;
pgroup
->
is_iterator_dirty
=
true
;
pgroup
->
container
.
insert
(
mgroup
->
container
.
begin
(),
mgroup
->
container
.
end
());
return
0
;
}
...
...
@@ -666,6 +675,7 @@ int32 scriptlib::group_sub(lua_State *L) {
group
*
sgroup
=
*
(
group
**
)
lua_touserdata
(
L
,
2
);
if
(
pgroup
->
is_readonly
==
1
)
return
0
;
pgroup
->
is_iterator_dirty
=
true
;
for
(
auto
&
pcard
:
sgroup
->
container
)
{
pgroup
->
container
.
erase
(
pcard
);
}
...
...
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