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
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
022ab5ed
Commit
022ab5ed
authored
Dec 24, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support Chinese everywhere
parent
39c86e4b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
5 deletions
+85
-5
gframe/data_manager.cpp
gframe/data_manager.cpp
+69
-0
gframe/data_manager.h
gframe/data_manager.h
+1
-0
gframe/game.cpp
gframe/game.cpp
+15
-5
No files found.
gframe/data_manager.cpp
View file @
022ab5ed
...
...
@@ -81,6 +81,75 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
spmemvfs_env_fini
();
return
true
;
}
bool
DataManager
::
LoadDB
(
const
char
*
file
)
{
IReadFile
*
reader
=
FileSystem
->
createAndOpenFile
(
file
);
if
(
reader
==
NULL
)
return
false
;
spmemvfs_db_t
db
;
spmembuffer_t
*
mem
=
(
spmembuffer_t
*
)
calloc
(
sizeof
(
spmembuffer_t
),
1
);
spmemvfs_env_init
();
mem
->
total
=
mem
->
used
=
reader
->
getSize
();
mem
->
data
=
(
char
*
)
malloc
(
mem
->
total
+
1
);
reader
->
read
(
mem
->
data
,
mem
->
total
);
reader
->
drop
();
(
mem
->
data
)[
mem
->
total
]
=
'\0'
;
if
(
spmemvfs_open_db
(
&
db
,
file
,
mem
)
!=
SQLITE_OK
)
return
Error
(
&
db
);
sqlite3
*
pDB
=
db
.
handle
;
sqlite3_stmt
*
pStmt
;
const
char
*
sql
=
"select * from datas,texts where datas.id=texts.id"
;
if
(
sqlite3_prepare_v2
(
pDB
,
sql
,
-
1
,
&
pStmt
,
0
)
!=
SQLITE_OK
)
return
Error
(
&
db
);
CardDataC
cd
;
CardString
cs
;
int
step
=
0
;
do
{
step
=
sqlite3_step
(
pStmt
);
if
(
step
==
SQLITE_BUSY
||
step
==
SQLITE_ERROR
||
step
==
SQLITE_MISUSE
)
return
Error
(
&
db
,
pStmt
);
else
if
(
step
==
SQLITE_ROW
)
{
cd
.
code
=
sqlite3_column_int
(
pStmt
,
0
);
cd
.
ot
=
sqlite3_column_int
(
pStmt
,
1
);
cd
.
alias
=
sqlite3_column_int
(
pStmt
,
2
);
cd
.
setcode
=
sqlite3_column_int64
(
pStmt
,
3
);
cd
.
type
=
sqlite3_column_int
(
pStmt
,
4
);
cd
.
attack
=
sqlite3_column_int
(
pStmt
,
5
);
cd
.
defense
=
sqlite3_column_int
(
pStmt
,
6
);
if
(
cd
.
type
&
TYPE_LINK
)
{
cd
.
link_marker
=
cd
.
defense
;
cd
.
defense
=
0
;
}
else
cd
.
link_marker
=
0
;
unsigned
int
level
=
sqlite3_column_int
(
pStmt
,
7
);
cd
.
level
=
level
&
0xff
;
cd
.
lscale
=
(
level
>>
24
)
&
0xff
;
cd
.
rscale
=
(
level
>>
16
)
&
0xff
;
cd
.
race
=
sqlite3_column_int
(
pStmt
,
8
);
cd
.
attribute
=
sqlite3_column_int
(
pStmt
,
9
);
cd
.
category
=
sqlite3_column_int
(
pStmt
,
10
);
_datas
.
insert
(
std
::
make_pair
(
cd
.
code
,
cd
));
if
(
const
char
*
text
=
(
const
char
*
)
sqlite3_column_text
(
pStmt
,
12
))
{
BufferIO
::
DecodeUTF8
(
text
,
strBuffer
);
cs
.
name
=
strBuffer
;
}
if
(
const
char
*
text
=
(
const
char
*
)
sqlite3_column_text
(
pStmt
,
13
))
{
BufferIO
::
DecodeUTF8
(
text
,
strBuffer
);
cs
.
text
=
strBuffer
;
}
for
(
int
i
=
0
;
i
<
16
;
++
i
)
{
if
(
const
char
*
text
=
(
const
char
*
)
sqlite3_column_text
(
pStmt
,
i
+
14
))
{
BufferIO
::
DecodeUTF8
(
text
,
strBuffer
);
cs
.
desc
[
i
]
=
strBuffer
;
}
}
_strings
.
emplace
(
cd
.
code
,
cs
);
}
}
while
(
step
!=
SQLITE_DONE
);
sqlite3_finalize
(
pStmt
);
spmemvfs_close_db
(
&
db
);
spmemvfs_env_fini
();
return
true
;
}
bool
DataManager
::
LoadStrings
(
const
char
*
file
)
{
FILE
*
fp
=
fopen
(
file
,
"r"
);
if
(
!
fp
)
...
...
gframe/data_manager.h
View file @
022ab5ed
...
...
@@ -13,6 +13,7 @@ class DataManager {
public:
DataManager
()
:
_datas
(
8192
),
_strings
(
8192
)
{}
bool
LoadDB
(
const
wchar_t
*
wfile
);
bool
LoadDB
(
const
char
*
file
);
bool
LoadStrings
(
const
char
*
file
);
bool
LoadStrings
(
IReadFile
*
reader
);
void
ReadStringConfLine
(
const
char
*
linebuf
);
...
...
gframe/game.cpp
View file @
022ab5ed
...
...
@@ -868,7 +868,13 @@ void Game::LoadExpansions() {
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".cdb"
,
4
))
{
wchar_t
fpath
[
1024
];
myswprintf
(
fpath
,
L"./expansions/%ls"
,
name
);
#ifdef _WIN32
dataManager
.
LoadDB
(
fpath
);
#else
char
fpath_utf8
[
1024
];
BufferIO
::
EncodeUTF8
(
fpath
,
fpath_utf8
);
dataManager
.
LoadDB
(
fpath_utf8
);
#endif
}
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".zip"
,
4
))
{
wchar_t
fpath
[
1024
];
...
...
@@ -887,17 +893,21 @@ void Game::LoadExpansions() {
for
(
u32
j
=
0
;
j
<
archive
->
getFileCount
();
++
j
)
{
#ifdef _WIN32
const
wchar_t
*
fname
=
archive
->
getFullFileName
(
j
).
c_str
();
#else
wchar_t
fname
[
1024
];
const
char
*
uname
=
archive
->
getFullFileName
(
j
).
c_str
();
BufferIO
::
DecodeUTF8
(
uname
,
fname
);
#endif
if
(
wcsrchr
(
fname
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
fname
,
'.'
),
L".cdb"
,
4
))
dataManager
.
LoadDB
(
fname
);
if
(
wcsrchr
(
fname
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
fname
,
'.'
),
L".conf"
,
5
))
{
IReadFile
*
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
fname
);
dataManager
.
LoadStrings
(
reader
);
}
#else
const
char
*
fname
=
archive
->
getFullFileName
(
j
).
c_str
();
if
(
strrchr
(
fname
,
'.'
)
&&
!
mystrncasecmp
(
strrchr
(
fname
,
'.'
),
".cdb"
,
4
))
dataManager
.
LoadDB
(
fname
);
if
(
strrchr
(
fname
,
'.'
)
&&
!
mystrncasecmp
(
strrchr
(
fname
,
'.'
),
".conf"
,
5
))
{
IReadFile
*
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
fname
);
dataManager
.
LoadStrings
(
reader
);
}
#endif
}
}
}
...
...
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