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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
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
MyCard
ygopro
Commits
4d917fb5
You need to sign in or sign up before continuing.
Commit
4d917fb5
authored
Mar 16, 2026
by
mercury233
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/Fluorohydride/ygopro
into server
parents
4559c42e
cea5fb79
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
82 additions
and
32 deletions
+82
-32
gframe/client_field.cpp
gframe/client_field.cpp
+4
-3
gframe/data_manager.cpp
gframe/data_manager.cpp
+28
-3
gframe/data_manager.h
gframe/data_manager.h
+11
-0
gframe/deck_con.cpp
gframe/deck_con.cpp
+8
-12
gframe/deck_manager.cpp
gframe/deck_manager.cpp
+3
-3
gframe/drawing.cpp
gframe/drawing.cpp
+1
-3
gframe/game.cpp
gframe/game.cpp
+6
-7
ocgcore
ocgcore
+1
-1
resource/migrate.sql
resource/migrate.sql
+20
-0
No files found.
gframe/client_field.cpp
View file @
4d917fb5
...
...
@@ -1401,6 +1401,8 @@ bool ClientField::check_sum_trib(std::set<ClientCard*>::const_iterator index, st
}
template
<
class
T
>
static
bool
is_declarable
(
const
T
&
cd
,
const
std
::
vector
<
unsigned
int
>&
opcode
)
{
if
(
cd
.
alias
)
return
false
;
std
::
stack
<
int
>
stack
;
for
(
auto
it
=
opcode
.
begin
();
it
!=
opcode
.
end
();
++
it
)
{
switch
(
*
it
)
{
...
...
@@ -1535,9 +1537,9 @@ static bool is_declarable(const T& cd, const std::vector<unsigned int>& opcode)
}
if
(
stack
.
size
()
!=
1
||
stack
.
top
()
==
0
)
return
false
;
if
(
cd
.
type
&
TYPE_TOKEN
)
if
(
!
second_code
.
count
(
cd
.
code
)
&&
(
cd
.
rule_code
||
(
cd
.
type
&
TYPE_TOKEN
))
)
return
false
;
return
!
cd
.
alias
||
second_code
.
find
(
cd
.
code
)
!=
second_code
.
end
()
;
return
true
;
}
void
ClientField
::
UpdateDeclarableList
()
{
const
wchar_t
*
pname
=
mainGame
->
ebANCard
->
getText
();
...
...
@@ -1567,7 +1569,6 @@ void ClientField::UpdateDeclarableList() {
auto
cp
=
_datas
.
find
(
code
);
if
(
cp
==
_datas
.
end
())
continue
;
//datas.alias can be double card names or alias
if
(
is_declarable
(
cp
->
second
,
declare_opcodes
))
{
if
(
pname
==
str
.
name
||
trycode
==
code
)
{
//exact match or last used
mainGame
->
lstANCard
->
insertItem
(
0
,
str
.
name
.
c_str
(),
-
1
);
...
...
gframe/data_manager.cpp
View file @
4d917fb5
...
...
@@ -16,6 +16,12 @@ static const char SELECT_STMT[] = "SELECT datas.id, datas.ot, datas.alias, datas
" texts.name, texts.desc, texts.str1, texts.str2, texts.str3, texts.str4, texts.str5, texts.str6, texts.str7, texts.str8,"
" texts.str9, texts.str10, texts.str11, texts.str12, texts.str13, texts.str14, texts.str15, texts.str16 FROM datas INNER JOIN texts ON datas.id = texts.id"
;
#endif
static
constexpr
int
DATAS_COUNT
=
11
;
static
constexpr
int
CARD_ARTWORK_VERSIONS_OFFSET
=
20
;
static
inline
bool
is_alternative
(
uint32_t
code
,
uint32_t
alias
)
{
return
alias
&&
(
alias
<
code
+
CARD_ARTWORK_VERSIONS_OFFSET
)
&&
(
code
<
alias
+
CARD_ARTWORK_VERSIONS_OFFSET
);
}
DataManager
::
DataManager
()
:
_datas
(
32768
),
_strings
(
32768
)
{
extra_setcode
=
{
...
...
@@ -25,6 +31,7 @@ DataManager::DataManager() : _datas(32768), _strings(32768) {
}
bool
DataManager
::
ReadDB
(
sqlite3
*
pDB
)
{
sqlite3_stmt
*
pStmt
=
nullptr
;
int
texts_offset
=
DATAS_COUNT
;
if
(
sqlite3_prepare_v2
(
pDB
,
SELECT_STMT
,
-
1
,
&
pStmt
,
nullptr
)
!=
SQLITE_OK
)
return
Error
(
pDB
,
pStmt
);
#ifndef YGOPRO_SERVER_MODE
...
...
@@ -56,18 +63,27 @@ 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
));
// rule_code
if
(
cd
.
code
==
5405695
)
{
cd
.
rule_code
=
cd
.
alias
;
cd
.
alias
=
0
;
}
else
if
(
cd
.
alias
&&
!
(
cd
.
type
&
TYPE_TOKEN
)
&&
!
is_alternative
(
cd
.
code
,
cd
.
alias
))
{
cd
.
rule_code
=
cd
.
alias
;
cd
.
alias
=
0
;
}
#ifndef YGOPRO_SERVER_MODE
auto
&
cs
=
_strings
[
code
];
if
(
const
char
*
text
=
(
const
char
*
)
sqlite3_column_text
(
pStmt
,
11
))
{
if
(
const
char
*
text
=
(
const
char
*
)
sqlite3_column_text
(
pStmt
,
texts_offset
+
0
))
{
BufferIO
::
DecodeUTF8
(
text
,
strBuffer
);
cs
.
name
=
strBuffer
;
}
if
(
const
char
*
text
=
(
const
char
*
)
sqlite3_column_text
(
pStmt
,
12
))
{
if
(
const
char
*
text
=
(
const
char
*
)
sqlite3_column_text
(
pStmt
,
texts_offset
+
1
))
{
BufferIO
::
DecodeUTF8
(
text
,
strBuffer
);
cs
.
text
=
strBuffer
;
}
for
(
int
i
=
0
;
i
<
DESC_COUNT
;
++
i
)
{
if
(
const
char
*
text
=
(
const
char
*
)
sqlite3_column_text
(
pStmt
,
13
+
i
))
{
if
(
const
char
*
text
=
(
const
char
*
)
sqlite3_column_text
(
pStmt
,
(
texts_offset
+
2
)
+
i
))
{
BufferIO
::
DecodeUTF8
(
text
,
strBuffer
);
cs
.
desc
[
i
]
=
strBuffer
;
}
...
...
@@ -75,6 +91,15 @@ bool DataManager::ReadDB(sqlite3* pDB) {
#endif //YGOPRO_SERVER_MODE
}
sqlite3_finalize
(
pStmt
);
for
(
auto
&
entry
:
_datas
)
{
auto
&
cd
=
entry
.
second
;
if
(
cd
.
rule_code
||
!
cd
.
alias
||
(
cd
.
type
&
TYPE_TOKEN
))
continue
;
auto
it
=
_datas
.
find
(
cd
.
alias
);
if
(
it
==
_datas
.
end
())
continue
;
cd
.
rule_code
=
it
->
second
.
rule_code
;
}
for
(
const
auto
&
entry
:
extra_setcode
)
{
const
auto
&
code
=
entry
.
first
;
const
auto
&
list
=
entry
.
second
;
...
...
gframe/data_manager.h
View file @
4d917fb5
...
...
@@ -34,6 +34,9 @@ struct CardDataC {
uint32_t
lscale
{};
uint32_t
rscale
{};
uint32_t
link_marker
{};
uint32_t
rule_code
{};
// extra columns
uint32_t
ot
{};
uint32_t
category
{};
...
...
@@ -48,6 +51,14 @@ struct CardDataC {
}
return
false
;
}
uint32_t
get_original_code
()
const
{
return
alias
?
alias
:
code
;
}
uint32_t
get_duel_code
()
const
{
return
rule_code
?
rule_code
:
get_original_code
();
}
};
constexpr
int
DESC_COUNT
=
16
;
struct
CardString
{
...
...
gframe/deck_con.cpp
View file @
4d917fb5
...
...
@@ -415,9 +415,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case
BUTTON_EXPORT_DECK_CODE
:
{
std
::
stringstream
textStream
;
deckManager
.
SaveDeck
(
deckManager
.
current_deck
,
textStream
);
wchar_t
text
[
0x10000
];
BufferIO
::
DecodeUTF8
(
textStream
.
str
().
c_str
(),
text
);
mainGame
->
env
->
getOSOperator
()
->
copyToClipboard
(
text
);
mainGame
->
env
->
getOSOperator
()
->
copyToClipboard
(
textStream
.
str
().
c_str
());
mainGame
->
stACMessage
->
setText
(
dataManager
.
GetSysString
(
1480
));
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
break
;
...
...
@@ -516,11 +514,9 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
deckManager
.
current_deck
.
extra
.
clear
();
deckManager
.
current_deck
.
side
.
clear
();
}
else
{
const
wchar_t
*
txt
=
mainGame
->
env
->
getOSOperator
()
->
getTextFromClipboard
();
const
char
*
txt
=
mainGame
->
env
->
getOSOperator
()
->
getTextFromClipboard
();
if
(
txt
)
{
char
text
[
0x10000
];
BufferIO
::
EncodeUTF8
(
txt
,
text
);
std
::
istringstream
textStream
(
text
);
std
::
istringstream
textStream
(
txt
);
deckManager
.
LoadCurrentDeck
(
textStream
);
}
}
...
...
@@ -1555,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
&&
is_alternative
(
data
.
code
,
data
.
alias
)))
{
}
else
if
(
trycode
&&
data
.
get_original_code
()
==
trycode
)
{
match
=
true
;
}
else
{
match
=
CardNameContains
(
strings
.
name
.
c_str
(),
elements_iterator
->
keyword
.
c_str
())
...
...
@@ -1875,21 +1871,21 @@ void DeckBuilder::pop_side(int seq) {
GetHoveredCard
();
}
bool
DeckBuilder
::
check_limit
(
code_pointer
pointer
)
{
auto
limitcode
=
pointer
->
second
.
alias
?
pointer
->
second
.
alias
:
pointer
->
first
;
auto
limitcode
=
pointer
->
second
.
get_duel_code
()
;
int
limit
=
3
;
auto
flit
=
filterList
->
content
.
find
(
limitcode
);
if
(
flit
!=
filterList
->
content
.
end
())
limit
=
flit
->
second
;
for
(
auto
&
card
:
deckManager
.
current_deck
.
main
)
{
if
(
card
->
first
==
limitcode
||
card
->
second
.
alias
==
limitcode
)
if
(
card
->
second
.
get_duel_code
()
==
limitcode
)
limit
--
;
}
for
(
auto
&
card
:
deckManager
.
current_deck
.
extra
)
{
if
(
card
->
first
==
limitcode
||
card
->
second
.
alias
==
limitcode
)
if
(
card
->
second
.
get_duel_code
()
==
limitcode
)
limit
--
;
}
for
(
auto
&
card
:
deckManager
.
current_deck
.
side
)
{
if
(
card
->
first
==
limitcode
||
card
->
second
.
alias
==
limitcode
)
if
(
card
->
second
.
get_duel_code
()
==
limitcode
)
limit
--
;
}
return
limit
>
0
;
...
...
gframe/deck_manager.cpp
View file @
4d917fb5
...
...
@@ -108,7 +108,7 @@ unsigned int DeckManager::CheckDeck(const Deck& deck, unsigned int lfhash, int r
return
(
gameruleDeckError
<<
28
)
|
cit
->
first
;
if
(
cit
->
second
.
type
&
(
TYPES_EXTRA_DECK
|
TYPE_TOKEN
))
return
(
DECKERROR_MAINCOUNT
<<
28
);
int
code
=
cit
->
second
.
alias
?
cit
->
second
.
alias
:
cit
->
first
;
auto
code
=
cit
->
second
.
get_duel_code
()
;
ccount
[
code
]
++
;
int
dc
=
ccount
[
code
];
if
(
dc
>
3
)
...
...
@@ -123,7 +123,7 @@ unsigned int DeckManager::CheckDeck(const Deck& deck, unsigned int lfhash, int r
return
(
gameruleDeckError
<<
28
)
|
cit
->
first
;
if
(
!
(
cit
->
second
.
type
&
TYPES_EXTRA_DECK
)
||
cit
->
second
.
type
&
TYPE_TOKEN
)
return
(
DECKERROR_EXTRACOUNT
<<
28
);
int
code
=
cit
->
second
.
alias
?
cit
->
second
.
alias
:
cit
->
first
;
auto
code
=
cit
->
second
.
get_duel_code
()
;
ccount
[
code
]
++
;
int
dc
=
ccount
[
code
];
if
(
dc
>
3
)
...
...
@@ -138,7 +138,7 @@ unsigned int DeckManager::CheckDeck(const Deck& deck, unsigned int lfhash, int r
return
(
gameruleDeckError
<<
28
)
|
cit
->
first
;
if
(
cit
->
second
.
type
&
TYPE_TOKEN
)
return
(
DECKERROR_SIDECOUNT
<<
28
);
int
code
=
cit
->
second
.
alias
?
cit
->
second
.
alias
:
cit
->
first
;
auto
code
=
cit
->
second
.
get_duel_code
()
;
ccount
[
code
]
++
;
int
dc
=
ccount
[
code
];
if
(
dc
>
3
)
...
...
gframe/drawing.cpp
View file @
4d917fb5
...
...
@@ -1125,9 +1125,7 @@ void Game::WaitFrameSignal(int frame) {
}
void
Game
::
DrawThumb
(
code_pointer
cp
,
irr
::
core
::
vector2di
pos
,
const
LFList
*
lflist
,
bool
drag
)
{
auto
code
=
cp
->
first
;
auto
lcode
=
cp
->
second
.
alias
;
if
(
lcode
==
0
)
lcode
=
code
;
auto
lcode
=
cp
->
second
.
get_duel_code
();
irr
::
video
::
ITexture
*
img
=
imageManager
.
GetTextureThumb
(
code
);
if
(
img
==
nullptr
)
return
;
//nullptr->getSize() will cause a crash
...
...
gframe/game.cpp
View file @
4d917fb5
...
...
@@ -1224,7 +1224,9 @@ void Game::LoadExpansions() {
}
if
(
!
mystrncasecmp
(
name
,
"pack/"
,
5
)
&&
IsExtension
(
name
,
".ydk"
))
{
wchar_t
fname
[
1024
];
BufferIO
::
DecodeUTF8
(
name
,
fname
);
int
len
=
BufferIO
::
DecodeUTF8
(
name
,
fname
);
// TODO: zip file may contain non-UTF8 file name. DecodeUTF8 can't parse it and returns 0.
if
(
!
len
)
continue
;
deckBuilder
.
expansionPacks
.
push_back
(
fname
);
continue
;
}
...
...
@@ -1589,10 +1591,7 @@ void Game::ShowCardInfo(int code, bool resize) {
imgCard
->
setImage
(
imageManager
.
GetTexture
(
code
,
true
));
if
(
is_valid
)
{
auto
&
cd
=
cit
->
second
;
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
);
myswprintf
(
formatBuffer
,
L"%ls[%08d]"
,
dataManager
.
GetName
(
cd
.
get_original_code
()),
cd
.
get_original_code
());
}
else
{
myswprintf
(
formatBuffer
,
L"%ls[%08d]"
,
dataManager
.
GetName
(
code
),
code
);
...
...
@@ -1606,8 +1605,8 @@ void Game::ShowCardInfo(int code, bool resize) {
if
(
is_valid
&&
!
gameConf
.
hide_setname
)
{
auto
&
cd
=
cit
->
second
;
auto
target
=
cit
;
if
(
cd
.
alias
&&
_datas
.
find
(
cd
.
alias
)
!=
_datas
.
end
(
))
{
target
=
_datas
.
find
(
cd
.
alias
);
if
(
cd
.
rule_code
&&
_datas
.
count
(
cd
.
rule_code
))
{
target
=
_datas
.
find
(
cd
.
rule_code
);
}
if
(
target
->
second
.
setcode
[
0
])
{
offset
=
23
;
// *yScale;
...
...
ocgcore
@
753ece19
Subproject commit
4e93b2781288021810939372a4920d970ff6cc0f
Subproject commit
753ece19f0e28bea1b206c0f919799803c25ac9a
resource/migrate.sql
0 → 100644
View file @
4d917fb5
--step 1: add new column
ALTER
TABLE
datas
ADD
COLUMN
rule_code
INTEGER
DEFAULT
0
;
--step 2: update "treated as X" cards
UPDATE
datas
SET
rule_code
=
alias
,
alias
=
0
WHERE
id
IN
(
SELECT
id
FROM
datas
WHERE
NOT
(
type
&
0
x4000
)
AND
alias
!=
0
AND
abs
(
id
-
alias
)
>=
20
);
--step 3: update special cards
UPDATE
datas
SET
rule_code
=
alias
,
alias
=
0
WHERE
id
=
5405695
;
UPDATE
datas
SET
rule_code
=
13331639
WHERE
alias
=
6218704
;
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