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
c6066999
Commit
c6066999
authored
Jun 18, 2024
by
Chen Bill
Committed by
GitHub
Jun 18, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bounds checking in effect_set, effect_set_v (#598)
parent
301ae504
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
effectset.h
effectset.h
+8
-3
No files found.
effectset.h
View file @
c6066999
...
@@ -19,11 +19,12 @@ bool effect_sort_id(const effect* e1, const effect* e2);
...
@@ -19,11 +19,12 @@ bool effect_sort_id(const effect* e1, const effect* e2);
struct
effect_set
{
struct
effect_set
{
void
add_item
(
effect
*
peffect
)
{
void
add_item
(
effect
*
peffect
)
{
if
(
count
>=
64
)
return
;
if
(
count
>=
64
)
return
;
container
[
count
++
]
=
peffect
;
container
[
count
++
]
=
peffect
;
}
}
void
remove_item
(
int
index
)
{
void
remove_item
(
int
index
)
{
if
(
index
>=
count
)
if
(
index
<
0
||
index
>=
count
)
return
;
return
;
if
(
index
==
count
-
1
)
{
if
(
index
==
count
-
1
)
{
--
count
;
--
count
;
...
@@ -45,9 +46,11 @@ struct effect_set {
...
@@ -45,9 +46,11 @@ struct effect_set {
std
::
sort
(
container
.
begin
(),
container
.
begin
()
+
count
,
effect_sort_id
);
std
::
sort
(
container
.
begin
(),
container
.
begin
()
+
count
,
effect_sort_id
);
}
}
effect
*
const
&
get_last
()
const
{
effect
*
const
&
get_last
()
const
{
assert
(
count
);
return
container
[
count
-
1
];
return
container
[
count
-
1
];
}
}
effect
*&
get_last
()
{
effect
*&
get_last
()
{
assert
(
count
);
return
container
[
count
-
1
];
return
container
[
count
-
1
];
}
}
effect
*
const
&
operator
[]
(
int
index
)
const
{
effect
*
const
&
operator
[]
(
int
index
)
const
{
...
@@ -72,7 +75,7 @@ struct effect_set_v {
...
@@ -72,7 +75,7 @@ struct effect_set_v {
container
.
push_back
(
peffect
);
container
.
push_back
(
peffect
);
}
}
void
remove_item
(
int
index
)
{
void
remove_item
(
int
index
)
{
if
(
index
>=
(
int
)
container
.
size
())
if
(
index
<
0
||
index
>=
(
int
)
container
.
size
())
return
;
return
;
container
.
erase
(
container
.
begin
()
+
index
);
container
.
erase
(
container
.
begin
()
+
index
);
}
}
...
@@ -89,9 +92,11 @@ struct effect_set_v {
...
@@ -89,9 +92,11 @@ struct effect_set_v {
std
::
sort
(
container
.
begin
(),
container
.
begin
()
+
count
,
effect_sort_id
);
std
::
sort
(
container
.
begin
(),
container
.
begin
()
+
count
,
effect_sort_id
);
}
}
effect
*
const
&
get_last
()
const
{
effect
*
const
&
get_last
()
const
{
assert
(
container
.
size
());
return
container
.
back
();
return
container
.
back
();
}
}
effect
*&
get_last
()
{
effect
*&
get_last
()
{
assert
(
container
.
size
());
return
container
.
back
();
return
container
.
back
();
}
}
effect
*
const
&
operator
[]
(
int
index
)
const
{
effect
*
const
&
operator
[]
(
int
index
)
const
{
...
...
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