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
YGOPRO-520DIY
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 @@
...
@@ -5,6 +5,7 @@
namespace
ygo
{
namespace
ygo
{
char
DeckManager
::
deckBuffer
[
0x10000
];
DeckManager
deckManager
;
DeckManager
deckManager
;
void
DeckManager
::
LoadLFListSingle
(
const
char
*
path
)
{
void
DeckManager
::
LoadLFListSingle
(
const
char
*
path
)
{
...
@@ -254,20 +255,38 @@ FILE* DeckManager::OpenDeckFile(const wchar_t* file, const char* mode) {
...
@@ -254,20 +255,38 @@ FILE* DeckManager::OpenDeckFile(const wchar_t* file, const char* mode) {
#endif
#endif
return
fp
;
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
)
{
bool
DeckManager
::
LoadDeck
(
const
wchar_t
*
file
,
bool
is_packlist
)
{
int
sp
=
0
,
ct
=
0
,
mainc
=
0
,
sidec
=
0
,
code
;
IReadFile
*
reader
=
OpenDeckReader
(
file
);
FILE
*
fp
=
OpenDeckFile
(
file
,
"r"
);
if
(
!
reader
)
{
if
(
!
fp
)
{
wchar_t
localfile
[
64
];
wchar_t
localfile
[
64
];
myswprintf
(
localfile
,
L"./deck/%ls.ydk"
,
file
);
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
;
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
];
int
cardlist
[
300
];
bool
is_side
=
false
;
bool
is_side
=
false
;
char
linebuf
[
256
]
;
std
::
string
linebuf
;
while
(
fgets
(
linebuf
,
256
,
fp
)
&&
ct
<
300
)
{
while
(
std
::
getline
(
deckStream
,
linebuf
)
&&
ct
<
300
)
{
if
(
linebuf
[
0
]
==
'!'
)
{
if
(
linebuf
[
0
]
==
'!'
)
{
is_side
=
true
;
is_side
=
true
;
continue
;
continue
;
...
@@ -277,12 +296,11 @@ bool DeckManager::LoadDeck(const wchar_t* file, bool is_packlist) {
...
@@ -277,12 +296,11 @@ bool DeckManager::LoadDeck(const wchar_t* file, bool is_packlist) {
sp
=
0
;
sp
=
0
;
while
(
linebuf
[
sp
]
>=
'0'
&&
linebuf
[
sp
]
<=
'9'
)
sp
++
;
while
(
linebuf
[
sp
]
>=
'0'
&&
linebuf
[
sp
]
<=
'9'
)
sp
++
;
linebuf
[
sp
]
=
0
;
linebuf
[
sp
]
=
0
;
code
=
atoi
(
linebuf
);
code
=
atoi
(
linebuf
.
c_str
()
);
cardlist
[
ct
++
]
=
code
;
cardlist
[
ct
++
]
=
code
;
if
(
is_side
)
sidec
++
;
if
(
is_side
)
sidec
++
;
else
mainc
++
;
else
mainc
++
;
}
}
fclose
(
fp
);
LoadDeck
(
current_deck
,
cardlist
,
mainc
,
sidec
,
is_packlist
);
LoadDeck
(
current_deck
,
cardlist
,
mainc
,
sidec
,
is_packlist
);
return
true
;
return
true
;
}
}
...
...
gframe/deck_manager.h
View file @
113e0e8b
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include "client_card.h"
#include "client_card.h"
#include <unordered_map>
#include <unordered_map>
#include <vector>
#include <vector>
#include <sstream>
namespace
ygo
{
namespace
ygo
{
...
@@ -35,6 +36,8 @@ public:
...
@@ -35,6 +36,8 @@ public:
Deck
current_deck
;
Deck
current_deck
;
std
::
vector
<
LFList
>
_lfList
;
std
::
vector
<
LFList
>
_lfList
;
static
char
deckBuffer
[
0x10000
];
void
LoadLFListSingle
(
const
char
*
path
);
void
LoadLFListSingle
(
const
char
*
path
);
void
LoadLFList
();
void
LoadLFList
();
const
wchar_t
*
GetLFListName
(
int
lfhash
);
const
wchar_t
*
GetLFListName
(
int
lfhash
);
...
@@ -45,7 +48,8 @@ public:
...
@@ -45,7 +48,8 @@ public:
void
GetCategoryPath
(
wchar_t
*
ret
,
int
index
,
const
wchar_t
*
text
);
void
GetCategoryPath
(
wchar_t
*
ret
,
int
index
,
const
wchar_t
*
text
);
void
GetDeckFile
(
wchar_t
*
ret
,
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
void
GetDeckFile
(
wchar_t
*
ret
,
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
bool
LoadDeck
(
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
LoadDeck
(
const
wchar_t
*
file
,
bool
is_packlist
=
false
);
bool
SaveDeck
(
Deck
&
deck
,
const
wchar_t
*
file
);
bool
SaveDeck
(
Deck
&
deck
,
const
wchar_t
*
file
);
bool
DeleteDeck
(
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