Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
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
1
Merge Requests
1
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
Commits
3e2be8dd
Commit
3e2be8dd
authored
Jul 06, 2025
by
Chen Bill
Committed by
GitHub
Jul 06, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redefine CardDataC structure and remove inheritance from card_data (#2867)
parent
844a96d9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
48 deletions
+69
-48
gframe/client_field.cpp
gframe/client_field.cpp
+10
-3
gframe/data_manager.cpp
gframe/data_manager.cpp
+24
-26
gframe/data_manager.h
gframe/data_manager.h
+33
-17
gframe/deck_con.cpp
gframe/deck_con.cpp
+1
-1
gframe/game.cpp
gframe/game.cpp
+1
-1
No files found.
gframe/client_field.cpp
View file @
3e2be8dd
...
...
@@ -1402,7 +1402,8 @@ bool ClientField::check_sum_trib(std::set<ClientCard*>::const_iterator index, st
||
check_sum_trib
(
index
,
end
,
acc
+
l2
)
||
check_sum_trib
(
index
,
end
,
acc
);
}
static
bool
is_declarable
(
const
CardData
&
cd
,
const
std
::
vector
<
unsigned
int
>&
opcode
)
{
template
<
class
T
>
static
bool
is_declarable
(
const
T
&
cd
,
const
std
::
vector
<
unsigned
int
>&
opcode
)
{
std
::
stack
<
int
>
stack
;
for
(
auto
it
=
opcode
.
begin
();
it
!=
opcode
.
end
();
++
it
)
{
switch
(
*
it
)
{
...
...
@@ -1492,9 +1493,15 @@ static bool is_declarable(const CardData& cd, const std::vector<unsigned int>& o
}
case
OPCODE_ISSETCARD
:
{
if
(
stack
.
size
()
>=
1
)
{
in
t
set_code
=
stack
.
top
();
uint32_
t
set_code
=
stack
.
top
();
stack
.
pop
();
bool
res
=
cd
.
is_setcode
(
set_code
);
bool
res
=
false
;
for
(
const
auto
&
x
:
cd
.
setcode
)
{
if
(
check_setcode
(
x
,
set_code
))
{
res
=
true
;
break
;
}
}
stack
.
push
(
res
);
}
break
;
...
...
gframe/data_manager.cpp
View file @
3e2be8dd
...
...
@@ -15,31 +15,20 @@ DataManager::DataManager() : _datas(32768), _strings(32768) {
bool
DataManager
::
ReadDB
(
sqlite3
*
pDB
)
{
sqlite3_stmt
*
pStmt
=
nullptr
;
const
char
*
sql
=
"select * from datas,texts where datas.id=texts.id"
;
if
(
sqlite3_prepare_v2
(
pDB
,
sql
,
-
1
,
&
pStmt
,
0
)
!=
SQLITE_OK
)
if
(
sqlite3_prepare_v2
(
pDB
,
sql
,
-
1
,
&
pStmt
,
nullptr
)
!=
SQLITE_OK
)
return
Error
(
pDB
,
pStmt
);
wchar_t
strBuffer
[
4096
];
int
step
=
0
;
do
{
CardDataC
cd
;
CardString
cs
;
step
=
sqlite3_step
(
pStmt
);
if
(
step
==
SQLITE_ROW
)
{
cd
.
code
=
sqlite3_column_int
(
pStmt
,
0
);
uint32_t
code
=
sqlite3_column_int
(
pStmt
,
0
);
auto
&
cd
=
_datas
[
code
];
cd
.
code
=
code
;
cd
.
ot
=
sqlite3_column_int
(
pStmt
,
1
);
cd
.
alias
=
sqlite3_column_int
(
pStmt
,
2
);
uint64_t
setcode
=
static_cast
<
uint64_t
>
(
sqlite3_column_int64
(
pStmt
,
3
));
if
(
setcode
)
{
auto
it
=
extra_setcode
.
find
(
cd
.
code
);
if
(
it
!=
extra_setcode
.
end
())
{
int
len
=
it
->
second
.
size
();
if
(
len
>
SIZE_SETCODE
)
len
=
SIZE_SETCODE
;
if
(
len
)
std
::
memcpy
(
cd
.
setcode
,
it
->
second
.
data
(),
len
*
sizeof
(
uint16_t
));
}
else
cd
.
set_setcode
(
setcode
);
}
write_setcode
(
cd
.
setcode
,
setcode
);
cd
.
type
=
static_cast
<
decltype
(
cd
.
type
)
>
(
sqlite3_column_int64
(
pStmt
,
4
));
cd
.
attack
=
sqlite3_column_int
(
pStmt
,
5
);
cd
.
defense
=
sqlite3_column_int
(
pStmt
,
6
);
...
...
@@ -56,7 +45,7 @@ bool DataManager::ReadDB(sqlite3* pDB) {
cd
.
race
=
static_cast
<
decltype
(
cd
.
race
)
>
(
sqlite3_column_int64
(
pStmt
,
8
));
cd
.
attribute
=
static_cast
<
decltype
(
cd
.
attribute
)
>
(
sqlite3_column_int64
(
pStmt
,
9
));
cd
.
category
=
static_cast
<
decltype
(
cd
.
category
)
>
(
sqlite3_column_int64
(
pStmt
,
10
));
_datas
[
cd
.
code
]
=
cd
;
auto
&
cs
=
_strings
[
code
]
;
if
(
const
char
*
text
=
(
const
char
*
)
sqlite3_column_text
(
pStmt
,
12
))
{
BufferIO
::
DecodeUTF8
(
text
,
strBuffer
);
cs
.
name
=
strBuffer
;
...
...
@@ -72,12 +61,21 @@ bool DataManager::ReadDB(sqlite3* pDB) {
cs
.
desc
[
i
]
=
strBuffer
;
}
}
_strings
[
cd
.
code
]
=
cs
;
}
else
if
(
step
!=
SQLITE_DONE
)
return
Error
(
pDB
,
pStmt
);
}
while
(
step
==
SQLITE_ROW
);
sqlite3_finalize
(
pStmt
);
for
(
const
auto
&
entry
:
extra_setcode
)
{
const
auto
&
code
=
entry
.
first
;
const
auto
&
list
=
entry
.
second
;
if
(
list
.
size
()
>
SIZE_SETCODE
||
list
.
empty
())
continue
;
auto
it
=
_datas
.
find
(
code
);
if
(
it
==
_datas
.
end
())
continue
;
std
::
memcpy
(
it
->
second
.
setcode
,
list
.
data
(),
list
.
size
()
*
sizeof
(
uint16_t
));
}
return
true
;
}
bool
DataManager
::
LoadDB
(
const
wchar_t
*
wfile
)
{
...
...
@@ -172,10 +170,10 @@ bool DataManager::Error(sqlite3* pDB, sqlite3_stmt* pStmt) {
sqlite3_finalize
(
pStmt
);
return
false
;
}
code_pointer
DataManager
::
GetCodePointer
(
u
nsigned
in
t
code
)
const
{
code_pointer
DataManager
::
GetCodePointer
(
u
int32_
t
code
)
const
{
return
_datas
.
find
(
code
);
}
string_pointer
DataManager
::
GetStringPointer
(
u
nsigned
in
t
code
)
const
{
string_pointer
DataManager
::
GetStringPointer
(
u
int32_
t
code
)
const
{
return
_strings
.
find
(
code
);
}
code_pointer
DataManager
::
datas_begin
()
const
{
...
...
@@ -190,16 +188,16 @@ string_pointer DataManager::strings_begin() const {
string_pointer
DataManager
::
strings_end
()
const
{
return
_strings
.
cend
();
}
bool
DataManager
::
GetData
(
u
nsigned
in
t
code
,
CardData
*
pData
)
const
{
bool
DataManager
::
GetData
(
u
int32_
t
code
,
CardData
*
pData
)
const
{
auto
cdit
=
_datas
.
find
(
code
);
if
(
cdit
==
_datas
.
end
())
return
false
;
if
(
pData
)
{
*
pData
=
cdit
->
second
;
std
::
memcpy
(
pData
,
&
cdit
->
second
,
sizeof
(
CardData
))
;
}
return
true
;
}
bool
DataManager
::
GetString
(
u
nsigned
in
t
code
,
CardString
*
pStr
)
const
{
bool
DataManager
::
GetString
(
u
int32_
t
code
,
CardString
*
pStr
)
const
{
auto
csit
=
_strings
.
find
(
code
);
if
(
csit
==
_strings
.
end
())
{
pStr
->
name
=
unknown_string
;
...
...
@@ -209,7 +207,7 @@ bool DataManager::GetString(unsigned int code, CardString* pStr) const {
*
pStr
=
csit
->
second
;
return
true
;
}
const
wchar_t
*
DataManager
::
GetName
(
u
nsigned
in
t
code
)
const
{
const
wchar_t
*
DataManager
::
GetName
(
u
int32_
t
code
)
const
{
auto
csit
=
_strings
.
find
(
code
);
if
(
csit
==
_strings
.
end
())
return
unknown_string
;
...
...
@@ -217,7 +215,7 @@ const wchar_t* DataManager::GetName(unsigned int code) const {
return
csit
->
second
.
name
.
c_str
();
return
unknown_string
;
}
const
wchar_t
*
DataManager
::
GetText
(
u
nsigned
in
t
code
)
const
{
const
wchar_t
*
DataManager
::
GetText
(
u
int32_
t
code
)
const
{
auto
csit
=
_strings
.
find
(
code
);
if
(
csit
==
_strings
.
end
())
return
unknown_string
;
...
...
@@ -225,7 +223,7 @@ const wchar_t* DataManager::GetText(unsigned int code) const {
return
csit
->
second
.
text
.
c_str
();
return
unknown_string
;
}
const
wchar_t
*
DataManager
::
GetDesc
(
u
nsigned
in
t
strCode
)
const
{
const
wchar_t
*
DataManager
::
GetDesc
(
u
int32_
t
strCode
)
const
{
if
(
strCode
<
(
MIN_CARD_ID
<<
4
))
return
GetSysString
(
strCode
);
unsigned
int
code
=
(
strCode
>>
4
)
&
0x0fffffff
;
...
...
gframe/data_manager.h
View file @
3e2be8dd
...
...
@@ -16,18 +16,34 @@ namespace irr {
namespace
ygo
{
constexpr
int
MAX_STRING_ID
=
0x7ff
;
constexpr
u
nsigned
int
MIN_CARD_ID
=
(
unsigned
in
t
)(
MAX_STRING_ID
+
1
)
>>
4
;
constexpr
u
nsigned
in
t
MAX_CARD_ID
=
0x0fffffffU
;
constexpr
u
int32_t
MIN_CARD_ID
=
(
uint32_
t
)(
MAX_STRING_ID
+
1
)
>>
4
;
constexpr
u
int32_
t
MAX_CARD_ID
=
0x0fffffffU
;
using
CardData
=
card_data
;
struct
CardDataC
:
card_data
{
struct
CardDataC
{
uint32_t
code
{};
uint32_t
alias
{};
uint16_t
setcode
[
SIZE_SETCODE
]{};
uint32_t
type
{};
uint32_t
level
{};
uint32_t
attribute
{};
uint32_t
race
{};
int32_t
attack
{};
int32_t
defense
{};
uint32_t
lscale
{};
uint32_t
rscale
{};
uint32_t
link_marker
{};
uint32_t
ot
{};
uint32_t
category
{};
bool
is_setcodes
(
const
std
::
vector
<
unsigned
int
>&
values
)
const
{
for
(
auto
&
value
:
values
)
{
if
(
is_setcode
(
value
))
return
true
;
for
(
const
auto
&
x
:
setcode
)
{
if
(
!
x
)
break
;
if
(
check_setcode
(
x
,
value
))
return
true
;
}
}
return
false
;
}
...
...
@@ -37,8 +53,8 @@ struct CardString {
std
::
wstring
text
;
std
::
wstring
desc
[
16
];
};
using
code_pointer
=
std
::
unordered_map
<
u
nsigned
in
t
,
CardDataC
>::
const_iterator
;
using
string_pointer
=
std
::
unordered_map
<
u
nsigned
in
t
,
CardString
>::
const_iterator
;
using
code_pointer
=
std
::
unordered_map
<
u
int32_
t
,
CardDataC
>::
const_iterator
;
using
string_pointer
=
std
::
unordered_map
<
u
int32_
t
,
CardString
>::
const_iterator
;
class
DataManager
{
public:
...
...
@@ -50,17 +66,17 @@ public:
void
ReadStringConfLine
(
const
char
*
linebuf
);
bool
Error
(
sqlite3
*
pDB
,
sqlite3_stmt
*
pStmt
=
nullptr
);
code_pointer
GetCodePointer
(
u
nsigned
in
t
code
)
const
;
string_pointer
GetStringPointer
(
u
nsigned
in
t
code
)
const
;
code_pointer
GetCodePointer
(
u
int32_
t
code
)
const
;
string_pointer
GetStringPointer
(
u
int32_
t
code
)
const
;
code_pointer
datas_begin
()
const
;
code_pointer
datas_end
()
const
;
string_pointer
strings_begin
()
const
;
string_pointer
strings_end
()
const
;
bool
GetData
(
u
nsigned
in
t
code
,
CardData
*
pData
)
const
;
bool
GetString
(
u
nsigned
in
t
code
,
CardString
*
pStr
)
const
;
const
wchar_t
*
GetName
(
u
nsigned
in
t
code
)
const
;
const
wchar_t
*
GetText
(
u
nsigned
in
t
code
)
const
;
const
wchar_t
*
GetDesc
(
u
nsigned
in
t
strCode
)
const
;
bool
GetData
(
u
int32_
t
code
,
CardData
*
pData
)
const
;
bool
GetString
(
u
int32_
t
code
,
CardString
*
pStr
)
const
;
const
wchar_t
*
GetName
(
u
int32_
t
code
)
const
;
const
wchar_t
*
GetText
(
u
int32_
t
code
)
const
;
const
wchar_t
*
GetDesc
(
u
int32_
t
strCode
)
const
;
const
wchar_t
*
GetSysString
(
int
code
)
const
;
const
wchar_t
*
GetVictoryString
(
int
code
)
const
;
const
wchar_t
*
GetCounterName
(
int
code
)
const
;
...
...
@@ -98,9 +114,9 @@ public:
static
bool
deck_sort_name
(
code_pointer
l1
,
code_pointer
l2
);
private:
std
::
unordered_map
<
u
nsigned
in
t
,
CardDataC
>
_datas
;
std
::
unordered_map
<
u
nsigned
in
t
,
CardString
>
_strings
;
std
::
unordered_map
<
u
nsigned
in
t
,
std
::
vector
<
uint16_t
>>
extra_setcode
;
std
::
unordered_map
<
u
int32_
t
,
CardDataC
>
_datas
;
std
::
unordered_map
<
u
int32_
t
,
CardString
>
_strings
;
std
::
unordered_map
<
u
int32_
t
,
std
::
vector
<
uint16_t
>>
extra_setcode
;
};
extern
DataManager
dataManager
;
...
...
gframe/deck_con.cpp
View file @
3e2be8dd
...
...
@@ -1551,7 +1551,7 @@ void DeckBuilder::FilterCards() {
match
=
CardNameContains
(
strings
.
name
.
c_str
(),
elements_iterator
->
keyword
.
c_str
());
}
else
if
(
elements_iterator
->
type
==
element_t
::
type_t
::
setcode
)
{
match
=
data
.
is_setcodes
(
elements_iterator
->
setcodes
);
}
else
if
(
trycode
&&
(
data
.
code
==
trycode
||
data
.
alias
==
trycode
&&
data
.
is_alternative
(
))){
}
else
if
(
trycode
&&
(
data
.
code
==
trycode
||
data
.
alias
==
trycode
&&
is_alternative
(
data
.
code
,
data
.
alias
))){
match
=
true
;
}
else
{
match
=
CardNameContains
(
strings
.
name
.
c_str
(),
elements_iterator
->
keyword
.
c_str
())
...
...
gframe/game.cpp
View file @
3e2be8dd
...
...
@@ -1544,7 +1544,7 @@ void Game::ShowCardInfo(int code, bool resize) {
imgCard
->
setImage
(
imageManager
.
GetTexture
(
code
,
true
));
if
(
is_valid
)
{
auto
&
cd
=
cit
->
second
;
if
(
cd
.
is_alternative
(
))
if
(
is_alternative
(
cd
.
code
,
cd
.
alias
))
myswprintf
(
formatBuffer
,
L"%ls[%08d]"
,
dataManager
.
GetName
(
cd
.
alias
),
cd
.
alias
);
else
myswprintf
(
formatBuffer
,
L"%ls[%08d]"
,
dataManager
.
GetName
(
code
),
code
);
...
...
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