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
f1b62cc7
Commit
f1b62cc7
authored
Sep 23, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move lflist reader to deckmanager cpp
parent
3214865a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
50 deletions
+46
-50
gframe/deck_manager.cpp
gframe/deck_manager.cpp
+44
-3
gframe/deck_manager.h
gframe/deck_manager.h
+2
-47
No files found.
gframe/deck_manager.cpp
View file @
f1b62cc7
...
@@ -8,10 +8,51 @@ namespace ygo {
...
@@ -8,10 +8,51 @@ namespace ygo {
DeckManager
deckManager
;
DeckManager
deckManager
;
void
DeckManager
::
LoadLFListFromLineProvider
(
const
std
::
function
<
bool
(
char
*
,
size_t
)
>&
getLine
,
bool
insert
)
{
std
::
vector
<
LFList
>
loadedLists
;
auto
cur
=
loadedLists
.
rend
();
char
linebuf
[
256
]{};
wchar_t
strBuffer
[
256
]{};
while
(
getLine
(
linebuf
,
sizeof
(
linebuf
)))
{
if
(
linebuf
[
0
]
==
'#'
)
continue
;
if
(
linebuf
[
0
]
==
'!'
)
{
auto
len
=
std
::
strcspn
(
linebuf
,
"
\r\n
"
);
linebuf
[
len
]
=
0
;
BufferIO
::
DecodeUTF8
(
&
linebuf
[
1
],
strBuffer
);
LFList
newlist
;
newlist
.
listName
=
strBuffer
;
newlist
.
hash
=
0x7dfcee6a
;
loadedLists
.
push_back
(
newlist
);
cur
=
loadedLists
.
rbegin
();
continue
;
}
if
(
cur
==
loadedLists
.
rend
())
continue
;
char
*
pos
=
linebuf
;
errno
=
0
;
auto
result
=
std
::
strtoul
(
pos
,
&
pos
,
10
);
if
(
errno
||
result
>
UINT32_MAX
)
continue
;
if
(
pos
==
linebuf
||
*
pos
!=
' '
)
continue
;
uint32_t
code
=
static_cast
<
uint32_t
>
(
result
);
errno
=
0
;
int
count
=
std
::
strtol
(
pos
,
&
pos
,
10
);
if
(
errno
)
continue
;
if
(
count
<
0
||
count
>
2
)
continue
;
cur
->
content
[
code
]
=
count
;
cur
->
hash
=
cur
->
hash
^
((
code
<<
18
)
|
(
code
>>
14
))
^
((
code
<<
(
27
+
count
))
|
(
code
>>
(
5
-
count
)));
}
if
(
insert
)
{
_lfList
.
insert
(
_lfList
.
begin
(),
loadedLists
.
begin
(),
loadedLists
.
end
());
}
else
{
_lfList
.
insert
(
_lfList
.
end
(),
loadedLists
.
begin
(),
loadedLists
.
end
());
}
}
void
DeckManager
::
LoadLFListSingle
(
const
char
*
path
,
bool
insert
)
{
void
DeckManager
::
LoadLFListSingle
(
const
char
*
path
,
bool
insert
)
{
FILE
*
fp
=
myfopen
(
path
,
"r"
);
FILE
*
fp
=
myfopen
(
path
,
"r"
);
if
(
!
fp
)
return
;
if
(
!
fp
)
return
;
_
LoadLFListFromLineProvider
([
&
](
char
*
buf
,
size_t
sz
)
{
LoadLFListFromLineProvider
([
&
](
char
*
buf
,
size_t
sz
)
{
return
std
::
fgets
(
buf
,
sz
,
fp
)
!=
nullptr
;
return
std
::
fgets
(
buf
,
sz
,
fp
)
!=
nullptr
;
},
insert
);
},
insert
);
std
::
fclose
(
fp
);
std
::
fclose
(
fp
);
...
@@ -19,7 +60,7 @@ void DeckManager::LoadLFListSingle(const char* path, bool insert) {
...
@@ -19,7 +60,7 @@ void DeckManager::LoadLFListSingle(const char* path, bool insert) {
void
DeckManager
::
LoadLFListSingle
(
const
wchar_t
*
path
,
bool
insert
)
{
void
DeckManager
::
LoadLFListSingle
(
const
wchar_t
*
path
,
bool
insert
)
{
FILE
*
fp
=
mywfopen
(
path
,
"r"
);
FILE
*
fp
=
mywfopen
(
path
,
"r"
);
if
(
!
fp
)
return
;
if
(
!
fp
)
return
;
_
LoadLFListFromLineProvider
([
&
](
char
*
buf
,
size_t
sz
)
{
LoadLFListFromLineProvider
([
&
](
char
*
buf
,
size_t
sz
)
{
return
std
::
fgets
(
buf
,
sz
,
fp
)
!=
nullptr
;
return
std
::
fgets
(
buf
,
sz
,
fp
)
!=
nullptr
;
},
insert
);
},
insert
);
std
::
fclose
(
fp
);
std
::
fclose
(
fp
);
...
@@ -27,7 +68,7 @@ void DeckManager::LoadLFListSingle(const wchar_t* path, bool insert) {
...
@@ -27,7 +68,7 @@ void DeckManager::LoadLFListSingle(const wchar_t* path, bool insert) {
void
DeckManager
::
LoadLFListSingle
(
irr
::
io
::
IReadFile
*
reader
,
bool
insert
)
{
void
DeckManager
::
LoadLFListSingle
(
irr
::
io
::
IReadFile
*
reader
,
bool
insert
)
{
std
::
string
linebuf
;
std
::
string
linebuf
;
char
ch
{};
char
ch
{};
_
LoadLFListFromLineProvider
([
&
](
char
*
buf
,
size_t
sz
)
{
LoadLFListFromLineProvider
([
&
](
char
*
buf
,
size_t
sz
)
{
while
(
reader
->
read
(
&
ch
,
1
))
{
while
(
reader
->
read
(
&
ch
,
1
))
{
if
(
ch
==
'\0'
)
break
;
if
(
ch
==
'\0'
)
break
;
linebuf
.
push_back
(
ch
);
linebuf
.
push_back
(
ch
);
...
...
gframe/deck_manager.h
View file @
f1b62cc7
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include <unordered_map>
#include <unordered_map>
#include <vector>
#include <vector>
#include <sstream>
#include <sstream>
#include <functional>
#include "data_manager.h"
#include "data_manager.h"
#include "bufferio.h"
#include "bufferio.h"
...
@@ -105,53 +106,7 @@ public:
...
@@ -105,53 +106,7 @@ public:
static
bool
SaveDeckArray
(
const
DeckArray
&
deck
,
const
wchar_t
*
name
);
static
bool
SaveDeckArray
(
const
DeckArray
&
deck
,
const
wchar_t
*
name
);
private:
private:
template
<
typename
LineProvider
>
void
LoadLFListFromLineProvider
(
const
std
::
function
<
bool
(
char
*
,
size_t
)
>&
getLine
,
bool
insert
=
false
);
void
_LoadLFListFromLineProvider
(
LineProvider
getLine
,
bool
insert
=
false
)
{
std
::
vector
<
LFList
>
loadedLists
;
auto
cur
=
loadedLists
.
rend
();
// 注意:在临时 list 上操作
char
linebuf
[
256
]{};
wchar_t
strBuffer
[
256
]{};
while
(
getLine
(
linebuf
,
sizeof
(
linebuf
)))
{
if
(
linebuf
[
0
]
==
'#'
)
continue
;
if
(
linebuf
[
0
]
==
'!'
)
{
auto
len
=
std
::
strcspn
(
linebuf
,
"
\r\n
"
);
linebuf
[
len
]
=
0
;
BufferIO
::
DecodeUTF8
(
&
linebuf
[
1
],
strBuffer
);
LFList
newlist
;
newlist
.
listName
=
strBuffer
;
newlist
.
hash
=
0x7dfcee6a
;
loadedLists
.
push_back
(
newlist
);
cur
=
loadedLists
.
rbegin
();
continue
;
}
if
(
cur
==
loadedLists
.
rend
())
continue
;
char
*
pos
=
linebuf
;
errno
=
0
;
auto
result
=
std
::
strtoul
(
pos
,
&
pos
,
10
);
if
(
errno
||
result
>
UINT32_MAX
)
continue
;
if
(
pos
==
linebuf
||
*
pos
!=
' '
)
continue
;
uint32_t
code
=
static_cast
<
uint32_t
>
(
result
);
errno
=
0
;
int
count
=
std
::
strtol
(
pos
,
&
pos
,
10
);
if
(
errno
)
continue
;
if
(
count
<
0
||
count
>
2
)
continue
;
cur
->
content
[
code
]
=
count
;
cur
->
hash
=
cur
->
hash
^
((
code
<<
18
)
|
(
code
>>
14
))
^
((
code
<<
(
27
+
count
))
|
(
code
>>
(
5
-
count
)));
}
if
(
insert
)
{
_lfList
.
insert
(
_lfList
.
begin
(),
loadedLists
.
begin
(),
loadedLists
.
end
());
}
else
{
_lfList
.
insert
(
_lfList
.
end
(),
loadedLists
.
begin
(),
loadedLists
.
end
());
}
}
};
};
extern
DeckManager
deckManager
;
extern
DeckManager
deckManager
;
...
...
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