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
MobiusMei
ygopro
Commits
113e0e8b
Commit
113e0e8b
authored
Sep 01, 2022
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use reader in DeckManager::LoadDeck
parent
21a27fc4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
10 deletions
+32
-10
gframe/deck_manager.cpp
gframe/deck_manager.cpp
+27
-9
gframe/deck_manager.h
gframe/deck_manager.h
+5
-1
No files found.
gframe/deck_manager.cpp
View file @
113e0e8b
...
...
@@ -5,6 +5,7 @@
namespace
ygo
{
char
DeckManager
::
deckBuffer
[
0x10000
];
DeckManager
deckManager
;
void
DeckManager
::
LoadLFListSingle
(
const
char
*
path
)
{
...
...
@@ -254,20 +255,38 @@ FILE* DeckManager::OpenDeckFile(const wchar_t* file, const char* mode) {
#endif
return
fp
;
}
IReadFile
*
DeckManager
::
OpenDeckReader
(
const
wchar_t
*
file
)
{
#ifdef WIN32
IReadFile
*
reader
=
dataManager
.
FileSystem
->
createAndOpenFile
(
file
);
#else
char
file2
[
256
];
BufferIO
::
EncodeUTF8
(
file
,
file2
);
IReadFile
*
reader
=
dataManager
.
FileSystem
->
createAndOpenFile
(
file2
);
#endif
return
reader
;
}
bool
DeckManager
::
LoadDeck
(
const
wchar_t
*
file
,
bool
is_packlist
)
{
int
sp
=
0
,
ct
=
0
,
mainc
=
0
,
sidec
=
0
,
code
;
FILE
*
fp
=
OpenDeckFile
(
file
,
"r"
);
if
(
!
fp
)
{
IReadFile
*
reader
=
OpenDeckReader
(
file
);
if
(
!
reader
)
{
wchar_t
localfile
[
64
];
myswprintf
(
localfile
,
L"./deck/%ls.ydk"
,
file
);
fp
=
OpenDeckFile
(
localfile
,
"r"
);
reader
=
OpenDeckReader
(
localfile
);
}
if
(
!
fp
)
if
(
!
reader
)
return
false
;
size_t
size
=
reader
->
getSize
();
if
(
size
>=
0x20000
)
{
reader
->
drop
();
return
false
;
}
reader
->
read
(
deckBuffer
,
size
);
reader
->
drop
();
std
::
istringstream
deckStream
(
deckBuffer
);
int
sp
=
0
,
ct
=
0
,
mainc
=
0
,
sidec
=
0
,
code
;
int
cardlist
[
300
];
bool
is_side
=
false
;
char
linebuf
[
256
]
;
while
(
fgets
(
linebuf
,
256
,
fp
)
&&
ct
<
300
)
{
std
::
string
linebuf
;
while
(
std
::
getline
(
deckStream
,
linebuf
)
&&
ct
<
300
)
{
if
(
linebuf
[
0
]
==
'!'
)
{
is_side
=
true
;
continue
;
...
...
@@ -277,12 +296,11 @@ bool DeckManager::LoadDeck(const wchar_t* file, bool is_packlist) {
sp
=
0
;
while
(
linebuf
[
sp
]
>=
'0'
&&
linebuf
[
sp
]
<=
'9'
)
sp
++
;
linebuf
[
sp
]
=
0
;
code
=
atoi
(
linebuf
);
code
=
atoi
(
linebuf
.
c_str
()
);
cardlist
[
ct
++
]
=
code
;
if
(
is_side
)
sidec
++
;
else
mainc
++
;
}
fclose
(
fp
);
LoadDeck
(
current_deck
,
cardlist
,
mainc
,
sidec
,
is_packlist
);
return
true
;
}
...
...
gframe/deck_manager.h
View file @
113e0e8b
...
...
@@ -5,6 +5,7 @@
#include "client_card.h"
#include <unordered_map>
#include <vector>
#include <sstream>
namespace
ygo
{
...
...
@@ -35,6 +36,8 @@ public:
Deck
current_deck
;
std
::
vector
<
LFList
>
_lfList
;
static
char
deckBuffer
[
0x10000
];
void
LoadLFListSingle
(
const
char
*
path
);
void
LoadLFList
();
const
wchar_t
*
GetLFListName
(
int
lfhash
);
...
...
@@ -45,7 +48,8 @@ public:
void
GetCategoryPath
(
wchar_t
*
ret
,
int
index
,
const
wchar_t
*
text
);
void
GetDeckFile
(
wchar_t
*
ret
,
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
bool
LoadDeck
(
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
FILE
*
OpenDeckFile
(
const
wchar_t
*
file
,
const
char
*
mode
);
FILE
*
OpenDeckFile
(
const
wchar_t
*
file
,
const
char
*
mode
);
IReadFile
*
OpenDeckReader
(
const
wchar_t
*
file
);
bool
LoadDeck
(
const
wchar_t
*
file
,
bool
is_packlist
=
false
);
bool
SaveDeck
(
Deck
&
deck
,
const
wchar_t
*
file
);
bool
DeleteDeck
(
const
wchar_t
*
file
);
...
...
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