Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile-Cn-Ko-En
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
fallenstardust
YGOMobile-Cn-Ko-En
Commits
bc24c894
Commit
bc24c894
authored
Feb 23, 2025
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update Gframe
parent
24b39d1c
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
134 additions
and
135 deletions
+134
-135
Classes/gframe/client_field.cpp
Classes/gframe/client_field.cpp
+2
-1
Classes/gframe/config.h
Classes/gframe/config.h
+5
-3
Classes/gframe/data_manager.cpp
Classes/gframe/data_manager.cpp
+9
-12
Classes/gframe/deck_con.cpp
Classes/gframe/deck_con.cpp
+19
-11
Classes/gframe/deck_manager.cpp
Classes/gframe/deck_manager.cpp
+30
-38
Classes/gframe/deck_manager.h
Classes/gframe/deck_manager.h
+2
-2
Classes/gframe/game.cpp
Classes/gframe/game.cpp
+14
-15
Classes/gframe/image_manager.cpp
Classes/gframe/image_manager.cpp
+6
-6
Classes/gframe/materials.h
Classes/gframe/materials.h
+4
-4
Classes/gframe/menu_handler.cpp
Classes/gframe/menu_handler.cpp
+19
-19
Classes/gframe/replay.cpp
Classes/gframe/replay.cpp
+23
-23
Classes/gframe/single_mode.cpp
Classes/gframe/single_mode.cpp
+1
-1
No files found.
Classes/gframe/client_field.cpp
View file @
bc24c894
...
...
@@ -615,7 +615,7 @@ void ClientField::ShowLocationCard() {
if
(
display_cards
[
i
]
->
code
)
mainGame
->
imageLoading
.
insert
(
std
::
make_pair
(
mainGame
->
btnCardDisplay
[
i
],
display_cards
[
i
]
->
code
));
else
mainGame
->
btnCardDisplay
[
i
]
->
setImage
(
imageManager
.
tCover
[
display_cards
[
i
]
->
controler
]);
mainGame
->
btnCardDisplay
[
i
]
->
setImage
(
imageManager
.
tCover
[
display_cards
[
i
]
->
controler
+
2
]);
mainGame
->
btnCardDisplay
[
i
]
->
setRelativePosition
(
mainGame
->
Resize_Y
(
startpos
+
125
*
i
,
65
,
startpos
+
120
+
125
*
i
,
65
+
170
));
mainGame
->
btnCardDisplay
[
i
]
->
setPressed
(
false
);
mainGame
->
btnCardDisplay
[
i
]
->
setVisible
(
true
);
...
...
@@ -713,6 +713,7 @@ void ClientField::ShowSelectOption(int select_hint) {
recti
pos
=
mainGame
->
wOptions
->
getRelativePosition
();
pos
.
LowerRightCorner
.
Y
=
pos
.
UpperLeftCorner
.
Y
+
180
*
mainGame
->
yScale
;
mainGame
->
wOptions
->
setRelativePosition
(
pos
);
mainGame
->
bgOptions
->
setRelativePosition
(
pos
);
}
if
(
select_hint
)
myswprintf
(
textBuffer
,
L"%ls"
,
dataManager
.
GetDesc
(
select_hint
));
...
...
Classes/gframe/config.h
View file @
bc24c894
...
...
@@ -16,6 +16,8 @@
#include <android/CustomShaderConstantSetCallBack.h>
#endif
#define socklen_t int
#ifndef TEXT
#ifdef UNICODE
#define TEXT(x) L##x
...
...
@@ -44,7 +46,7 @@
#define mywcsncasecmp wcsncasecmp
#define mystrncasecmp strncasecmp
#include <
stdio.h
>
#include <
cstdio
>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
...
...
@@ -57,11 +59,11 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
return
std
::
swprintf
(
buf
,
N
,
fmt
,
args
...);
}
inline
FILE
*
myfopen
(
const
wchar_t
*
filename
,
const
char
*
mode
)
{
inline
FILE
*
my
w
fopen
(
const
wchar_t
*
filename
,
const
char
*
mode
)
{
FILE
*
fp
{};
char
fname
[
1024
]{};
BufferIO
::
EncodeUTF8
(
filename
,
fname
);
fp
=
fopen
(
fname
,
mode
);
fp
=
std
::
fopen
(
fname
,
mode
);
return
fp
;
}
...
...
Classes/gframe/data_manager.cpp
View file @
bc24c894
#include "data_manager.h"
#include "game.h"
#include <stdio.h>
#include "spmemvfs/spmemvfs.h"
namespace
ygo
{
...
...
@@ -105,14 +104,14 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
return
ret
;
}
bool
DataManager
::
LoadStrings
(
const
char
*
file
)
{
FILE
*
fp
=
fopen
(
file
,
"r"
);
FILE
*
fp
=
std
::
fopen
(
file
,
"r"
);
if
(
!
fp
)
return
false
;
char
linebuf
[
TEXT_LINE_SIZE
]{};
while
(
fgets
(
linebuf
,
sizeof
linebuf
,
fp
))
{
while
(
std
::
fgets
(
linebuf
,
sizeof
linebuf
,
fp
))
{
ReadStringConfLine
(
linebuf
);
}
fclose
(
fp
);
std
::
fclose
(
fp
);
return
true
;
}
bool
DataManager
::
LoadStrings
(
irr
::
io
::
IReadFile
*
reader
)
{
...
...
@@ -136,26 +135,26 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
char
strbuf
[
TEXT_LINE_SIZE
]{};
int
value
{};
wchar_t
strBuffer
[
4096
]{};
if
(
sscanf
(
linebuf
,
"!%63s"
,
strbuf
)
!=
1
)
if
(
s
td
::
s
scanf
(
linebuf
,
"!%63s"
,
strbuf
)
!=
1
)
return
;
if
(
!
std
::
strcmp
(
strbuf
,
"system"
))
{
if
(
sscanf
(
&
linebuf
[
7
],
"%d %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
if
(
s
td
::
s
scanf
(
&
linebuf
[
7
],
"%d %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
return
;
BufferIO
::
DecodeUTF8
(
strbuf
,
strBuffer
);
_sysStrings
[
value
]
=
strBuffer
;
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"victory"
))
{
if
(
sscanf
(
&
linebuf
[
8
],
"%x %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
if
(
s
td
::
s
scanf
(
&
linebuf
[
8
],
"%x %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
return
;
BufferIO
::
DecodeUTF8
(
strbuf
,
strBuffer
);
_victoryStrings
[
value
]
=
strBuffer
;
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"counter"
))
{
if
(
sscanf
(
&
linebuf
[
8
],
"%x %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
if
(
s
td
::
s
scanf
(
&
linebuf
[
8
],
"%x %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
return
;
BufferIO
::
DecodeUTF8
(
strbuf
,
strBuffer
);
_counterStrings
[
value
]
=
strBuffer
;
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"setname"
))
{
//using tab for comment
if
(
sscanf
(
&
linebuf
[
8
],
"%x %240[^
\t\n
]"
,
&
value
,
strbuf
)
!=
2
)
if
(
s
td
::
s
scanf
(
&
linebuf
[
8
],
"%x %240[^
\t\n
]"
,
&
value
,
strbuf
)
!=
2
)
return
;
BufferIO
::
DecodeUTF8
(
strbuf
,
strBuffer
);
_setnameStrings
[
value
]
=
strBuffer
;
...
...
@@ -423,9 +422,7 @@ unsigned char* DataManager::ReadScriptFromIrrFS(const char* script_name, int* sl
return
scriptBuffer
;
}
unsigned
char
*
DataManager
::
ReadScriptFromFile
(
const
char
*
script_name
,
int
*
slen
)
{
wchar_t
fname
[
256
]{};
BufferIO
::
DecodeUTF8
(
script_name
,
fname
);
FILE
*
fp
=
myfopen
(
fname
,
"rb"
);
FILE
*
fp
=
std
::
fopen
(
script_name
,
"rb"
);
if
(
!
fp
)
return
nullptr
;
size_t
len
=
std
::
fread
(
scriptBuffer
,
1
,
sizeof
scriptBuffer
,
fp
);
...
...
Classes/gframe/deck_con.cpp
View file @
bc24c894
...
...
@@ -57,6 +57,14 @@ void SetCategoryDeckNameOnButton(irr::gui::IGUIButton* button, wchar_t* string){
button
->
setText
(
cate_deck
);
}
static
inline
void
get_deck_file
(
wchar_t
*
ret
)
{
deckManager
.
GetDeckFile
(
ret
,
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
}
static
inline
void
load_current_deck
(
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
)
{
deckManager
.
LoadCurrentDeck
(
cbCategory
,
cbDeck
);
}
void
DeckBuilder
::
Initialize
()
{
mainGame
->
is_building
=
true
;
mainGame
->
is_siding
=
false
;
...
...
@@ -200,7 +208,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
if
(
sel
==
-
1
)
break
;
wchar_t
filepath
[
256
];
deckManager
.
GetDeckFile
(
filepath
,
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
get_deck_file
(
filepath
);
if
(
deckManager
.
SaveDeck
(
deckManager
.
current_deck
,
filepath
))
{
mainGame
->
stACMessage
->
setText
(
dataManager
.
GetSysString
(
1335
));
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
...
...
@@ -564,7 +572,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
int
decksel
=
mainGame
->
lstDecks
->
getSelected
();
const
wchar_t
*
catename
=
mainGame
->
lstCategories
->
getListItem
(
catesel
);
wchar_t
oldfilepath
[
256
];
deckManager
.
GetDeckFile
(
oldfilepath
,
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
get_deck_file
(
oldfilepath
);
const
wchar_t
*
newdeckname
=
mainGame
->
ebDMName
->
getText
();
wchar_t
newfilepath
[
256
];
if
(
catesel
==
2
)
{
...
...
@@ -596,7 +604,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case
BUTTON_DELETE_DECK_DM
:
{
int
decksel
=
mainGame
->
lstDecks
->
getSelected
();
wchar_t
filepath
[
256
];
deckManager
.
GetDeckFile
(
filepath
,
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
get_deck_file
(
filepath
);
if
(
deckManager
.
DeleteDeck
(
filepath
))
{
mainGame
->
lstDecks
->
removeItem
(
decksel
);
mainGame
->
cbDBDecks
->
removeItem
(
decksel
);
...
...
@@ -607,7 +615,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
if
(
decksel
!=
-
1
)
{
mainGame
->
lstDecks
->
setSelected
(
decksel
);
mainGame
->
cbDBDecks
->
setSelected
(
decksel
);
deckManager
.
LoadCurrentD
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
load_current_d
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
}
RefreshReadonly
(
prev_category
);
prev_deck
=
decksel
;
...
...
@@ -626,7 +634,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
wchar_t
deckname
[
256
];
BufferIO
::
CopyWideString
(
olddeckname
,
deckname
);
wchar_t
oldfilepath
[
256
];
deckManager
.
GetDeckFile
(
oldfilepath
,
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
get_deck_file
(
oldfilepath
);
wchar_t
newfilepath
[
256
];
if
(
oldcatesel
!=
2
&&
newcatesel
==
0
)
{
myswprintf
(
newfilepath
,
L"./deck/%ls.ydk"
,
deckname
);
...
...
@@ -741,7 +749,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break
;
}
case
BUTTON_SIDE_RELOAD
:
{
deckManager
.
LoadCurrentD
eck
(
mainGame
->
cbCategorySelect
,
mainGame
->
cbDeckSelect
);
load_current_d
eck
(
mainGame
->
cbCategorySelect
,
mainGame
->
cbDeckSelect
);
break
;
}
case
BUTTON_MSG_OK
:
{
...
...
@@ -761,7 +769,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
int
sel
=
prev_sel
;
mainGame
->
cbDBDecks
->
setSelected
(
sel
);
wchar_t
filepath
[
256
];
deckManager
.
GetDeckFile
(
filepath
,
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
get_deck_file
(
filepath
);
if
(
deckManager
.
DeleteDeck
(
filepath
))
{
mainGame
->
cbDBDecks
->
removeItem
(
sel
);
int
count
=
mainGame
->
cbDBDecks
->
getItemCount
();
...
...
@@ -769,7 +777,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
sel
=
count
-
1
;
mainGame
->
cbDBDecks
->
setSelected
(
sel
);
if
(
sel
!=
-
1
)
deckManager
.
LoadCurrentD
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
load_current_d
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
mainGame
->
stACMessage
->
setText
(
dataManager
.
GetSysString
(
1338
));
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
prev_deck
=
sel
;
...
...
@@ -784,7 +792,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
ChangeCategory
(
catesel
);
}
else
if
(
prev_operation
==
COMBOBOX_DBDECKS
)
{
int
decksel
=
mainGame
->
cbDBDecks
->
getSelected
();
deckManager
.
LoadCurrentD
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
load_current_d
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
prev_deck
=
decksel
;
is_modified
=
false
;
}
else
if
(
prev_operation
==
BUTTON_MANAGE_DECK
)
{
...
...
@@ -901,7 +909,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
int
decksel
=
mainGame
->
cbDBDecks
->
getSelected
();
if
(
decksel
>=
0
)
{
deckManager
.
LoadCurrentD
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
load_current_d
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
}
prev_deck
=
decksel
;
is_modified
=
false
;
...
...
@@ -1690,7 +1698,7 @@ void DeckBuilder::ChangeCategory(int catesel) {
mainGame
->
RefreshDeck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
mainGame
->
cbDBDecks
->
setSelected
(
0
);
RefreshReadonly
(
catesel
);
deckManager
.
LoadCurrentD
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
load_current_d
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
is_modified
=
false
;
prev_category
=
catesel
;
prev_deck
=
0
;
...
...
Classes/gframe/deck_manager.cpp
View file @
bc24c894
#include "deck_manager.h"
#include "game.h"
#include "myfilesystem.h"
#include "network.h"
#include "game.h"
namespace
ygo
{
...
...
@@ -10,30 +10,27 @@ DeckManager deckManager;
void
DeckManager
::
LoadLFListSingle
(
const
char
*
path
)
{
auto
cur
=
_lfList
.
rend
();
FILE
*
fp
=
fopen
(
path
,
"r"
);
FILE
*
fp
=
std
::
fopen
(
path
,
"r"
);
char
linebuf
[
256
]{};
wchar_t
strBuffer
[
256
]{};
if
(
fp
)
{
while
(
fgets
(
linebuf
,
256
,
fp
))
{
while
(
std
::
fgets
(
linebuf
,
256
,
fp
))
{
if
(
linebuf
[
0
]
==
'#'
)
continue
;
if
(
linebuf
[
0
]
==
'!'
)
{
int
sa
=
BufferIO
::
DecodeUTF8
(
&
linebuf
[
1
],
strBuffer
);
while
(
strBuffer
[
sa
-
1
]
==
L'\r'
||
strBuffer
[
sa
-
1
]
==
L'\n'
)
sa
--
;
strBuffer
[
sa
]
=
0
;
auto
len
=
std
::
strcspn
(
linebuf
,
"
\r\n
"
);
linebuf
[
len
]
=
0
;
BufferIO
::
DecodeUTF8
(
&
linebuf
[
1
],
strBuffer
);
LFList
newlist
;
newlist
.
listName
=
strBuffer
;
newlist
.
hash
=
0x7dfcee6a
;
_lfList
.
push_back
(
newlist
);
cur
=
_lfList
.
rbegin
();
cur
->
listName
=
strBuffer
;
cur
->
hash
=
0x7dfcee6a
;
continue
;
}
if
(
linebuf
[
0
]
==
0
)
continue
;
int
code
=
0
;
int
count
=
-
1
;
if
(
sscanf
(
linebuf
,
"%d %d"
,
&
code
,
&
count
)
!=
2
)
if
(
s
td
::
s
scanf
(
linebuf
,
"%d %d"
,
&
code
,
&
count
)
!=
2
)
continue
;
if
(
code
<=
0
||
code
>
MAX_CARD_ID
)
continue
;
...
...
@@ -45,7 +42,7 @@ void DeckManager::LoadLFListSingle(const char* path) {
cur
->
content
[
code
]
=
count
;
cur
->
hash
=
cur
->
hash
^
((
hcode
<<
18
)
|
(
hcode
>>
14
))
^
((
hcode
<<
(
27
+
count
))
|
(
hcode
>>
(
5
-
count
)));
}
fclose
(
fp
);
std
::
fclose
(
fp
);
}
}
void
DeckManager
::
LoadLFList
(
android
::
InitOptions
*
options
)
{
...
...
@@ -73,12 +70,12 @@ const std::unordered_map<int, int>* DeckManager::GetLFListContent(int lfhash) {
return
&
lit
->
content
;
return
nullptr
;
}
static
int
checkAvail
(
unsigned
int
ot
,
unsigned
int
avail
)
{
static
unsigned
int
checkAvail
(
unsigned
int
ot
,
unsigned
int
avail
)
{
if
((
ot
&
avail
)
==
avail
)
return
0
;
if
((
ot
&
AVAIL_OCG
)
&&
!
(
avail
=
=
AVAIL_OCG
))
if
((
ot
&
AVAIL_OCG
)
&&
(
avail
!
=
AVAIL_OCG
))
return
DECKERROR_OCGONLY
;
if
((
ot
&
AVAIL_TCG
)
&&
!
(
avail
=
=
AVAIL_TCG
))
if
((
ot
&
AVAIL_TCG
)
&&
(
avail
!
=
AVAIL_TCG
))
return
DECKERROR_TCGONLY
;
return
DECKERROR_NOTAVAIL
;
}
...
...
@@ -279,13 +276,13 @@ void DeckManager::GetDeckFile(wchar_t* ret, irr::gui::IGUIComboBox* cbCategory,
}
}
FILE
*
DeckManager
::
OpenDeckFile
(
const
wchar_t
*
file
,
const
char
*
mode
)
{
FILE
*
fp
=
myfopen
(
file
,
mode
);
FILE
*
fp
=
my
w
fopen
(
file
,
mode
);
return
fp
;
}
IReadFile
*
DeckManager
::
OpenDeckReader
(
const
wchar_t
*
file
)
{
irr
::
io
::
IReadFile
*
DeckManager
::
OpenDeckReader
(
const
wchar_t
*
file
)
{
char
file2
[
256
];
BufferIO
::
EncodeUTF8
(
file
,
file2
);
IReadFile
*
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
file2
);
auto
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
file2
);
return
reader
;
}
bool
DeckManager
::
LoadCurrentDeck
(
const
wchar_t
*
file
,
bool
is_packlist
)
{
...
...
@@ -328,28 +325,23 @@ bool DeckManager::SaveDeck(Deck& deck, const wchar_t* file) {
FILE
*
fp
=
OpenDeckFile
(
file
,
"w"
);
if
(
!
fp
)
return
false
;
fprintf
(
fp
,
"#created by ygomobile
\n
#main
\n
"
);
std
::
fprintf
(
fp
,
"#created by ygomobile
\n
#main
\n
"
);
for
(
size_t
i
=
0
;
i
<
deck
.
main
.
size
();
++
i
)
fprintf
(
fp
,
"%d
\n
"
,
deck
.
main
[
i
]
->
first
);
fprintf
(
fp
,
"#extra
\n
"
);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deck
.
main
[
i
]
->
first
);
std
::
fprintf
(
fp
,
"#extra
\n
"
);
for
(
size_t
i
=
0
;
i
<
deck
.
extra
.
size
();
++
i
)
fprintf
(
fp
,
"%d
\n
"
,
deck
.
extra
[
i
]
->
first
);
fprintf
(
fp
,
"!side
\n
"
);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deck
.
extra
[
i
]
->
first
);
std
::
fprintf
(
fp
,
"!side
\n
"
);
for
(
size_t
i
=
0
;
i
<
deck
.
side
.
size
();
++
i
)
fprintf
(
fp
,
"%d
\n
"
,
deck
.
side
[
i
]
->
first
);
fclose
(
fp
);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deck
.
side
[
i
]
->
first
);
std
::
fclose
(
fp
);
return
true
;
}
bool
DeckManager
::
DeleteDeck
(
const
wchar_t
*
file
)
{
#ifdef _WIN32
BOOL
result
=
DeleteFileW
(
file
);
return
!!
result
;
#else
char
filefn
[
256
];
BufferIO
::
EncodeUTF8
(
file
,
filefn
);
int
result
=
unlink
(
filefn
);
return
result
==
0
;
#endif
}
bool
DeckManager
::
CreateCategory
(
const
wchar_t
*
name
)
{
if
(
!
FileSystem
::
IsDirExists
(
L"./deck"
)
&&
!
FileSystem
::
MakeDir
(
L"./deck"
))
...
...
@@ -387,26 +379,26 @@ bool DeckManager::SaveDeckBuffer(const int deckbuf[], const wchar_t* name) {
int
it
=
0
;
const
int
mainc
=
deckbuf
[
it
];
++
it
;
fprintf
(
fp
,
"#created by ...
\n
#main
\n
"
);
std
::
fprintf
(
fp
,
"#created by ...
\n
#main
\n
"
);
for
(
int
i
=
0
;
i
<
mainc
;
++
i
)
{
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
++
it
;
}
const
int
extrac
=
deckbuf
[
it
];
++
it
;
fprintf
(
fp
,
"#extra
\n
"
);
std
::
fprintf
(
fp
,
"#extra
\n
"
);
for
(
int
i
=
0
;
i
<
extrac
;
++
i
)
{
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
++
it
;
}
const
int
sidec
=
deckbuf
[
it
];
++
it
;
fprintf
(
fp
,
"!side
\n
"
);
std
::
fprintf
(
fp
,
"!side
\n
"
);
for
(
int
i
=
0
;
i
<
sidec
;
++
i
)
{
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
++
it
;
}
fclose
(
fp
);
std
::
fclose
(
fp
);
return
true
;
}
int
DeckManager
::
TypeCount
(
std
::
vector
<
code_pointer
>
list
,
unsigned
int
ctype
)
{
...
...
Classes/gframe/deck_manager.h
View file @
bc24c894
...
...
@@ -2,10 +2,10 @@
#define DECKMANAGER_H
#include "config.h"
#include "data_manager.h"
#include <unordered_map>
#include <vector>
#include <sstream>
#include "data_manager.h"
namespace
ygo
{
constexpr
int
DECK_MAX_SIZE
=
60
;
...
...
@@ -54,7 +54,7 @@ public:
void
GetCategoryPath
(
wchar_t
*
ret
,
int
index
,
const
wchar_t
*
text
,
bool
showPack
);
//
void
GetDeckFile
(
wchar_t
*
ret
,
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
FILE
*
OpenDeckFile
(
const
wchar_t
*
file
,
const
char
*
mode
);
IReadFile
*
OpenDeckReader
(
const
wchar_t
*
file
);
irr
::
io
::
IReadFile
*
OpenDeckReader
(
const
wchar_t
*
file
);
bool
LoadCurrentDeck
(
const
wchar_t
*
file
,
bool
is_packlist
=
false
);
bool
LoadCurrentDeck
(
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
bool
SaveDeck
(
Deck
&
deck
,
const
wchar_t
*
file
);
...
...
Classes/gframe/game.cpp
View file @
bc24c894
...
...
@@ -1483,7 +1483,6 @@ void Game::MainLoop() {
if
(
cur_time
<
fps
*
17
-
20
)
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
20
));
if
(
cur_time
>=
1000
)
{
#ifdef _IRR_ANDROID_PLATFORM_
if
(
stat
)
{
stringw
str
=
L"FPS: "
;
...
...
@@ -1503,7 +1502,7 @@ void Game::MainLoop() {
#ifdef _IRR_ANDROID_PLATFORM_
device
->
yield
();
// probably nicer to the battery
#endif
}
}
DuelClient
::
StopClient
(
true
);
if
(
dInfo
.
isSingleMode
)
SingleMode
::
StopPlay
(
true
);
...
...
@@ -1720,29 +1719,29 @@ void Game::RefreshBot() {
if
(
!
gameConf
.
enable_bot_mode
)
return
;
botInfo
.
clear
();
FILE
*
fp
=
fopen
(
"bot.conf"
,
"r"
);
FILE
*
fp
=
std
::
fopen
(
"bot.conf"
,
"r"
);
char
linebuf
[
256
]{};
char
strbuf
[
256
]{};
if
(
fp
)
{
while
(
fgets
(
linebuf
,
256
,
fp
))
{
while
(
std
::
fgets
(
linebuf
,
256
,
fp
))
{
if
(
linebuf
[
0
]
==
'#'
)
continue
;
if
(
linebuf
[
0
]
==
'!'
)
{
BotInfo
newinfo
;
if
(
sscanf
(
linebuf
,
"!%240[^
\n
]"
,
strbuf
)
!=
1
)
if
(
s
td
::
s
scanf
(
linebuf
,
"!%240[^
\n
]"
,
strbuf
)
!=
1
)
continue
;
BufferIO
::
DecodeUTF8
(
strbuf
,
newinfo
.
name
);
if
(
!
fgets
(
linebuf
,
256
,
fp
))
if
(
!
std
::
fgets
(
linebuf
,
256
,
fp
))
break
;
if
(
sscanf
(
linebuf
,
"%240[^
\n
]"
,
strbuf
)
!=
1
)
if
(
s
td
::
s
scanf
(
linebuf
,
"%240[^
\n
]"
,
strbuf
)
!=
1
)
continue
;
BufferIO
::
DecodeUTF8
(
strbuf
,
newinfo
.
command
);
if
(
!
fgets
(
linebuf
,
256
,
fp
))
if
(
!
std
::
fgets
(
linebuf
,
256
,
fp
))
break
;
if
(
sscanf
(
linebuf
,
"%240[^
\n
]"
,
strbuf
)
!=
1
)
if
(
s
td
::
s
scanf
(
linebuf
,
"%240[^
\n
]"
,
strbuf
)
!=
1
)
continue
;
BufferIO
::
DecodeUTF8
(
strbuf
,
newinfo
.
desc
);
if
(
!
fgets
(
linebuf
,
256
,
fp
))
if
(
!
std
::
fgets
(
linebuf
,
256
,
fp
))
break
;
newinfo
.
support_master_rule_3
=
!!
std
::
strstr
(
linebuf
,
"SUPPORT_MASTER_RULE_3"
);
newinfo
.
support_new_master_rule
=
!!
std
::
strstr
(
linebuf
,
"SUPPORT_NEW_MASTER_RULE"
);
...
...
@@ -1756,7 +1755,7 @@ void Game::RefreshBot() {
continue
;
}
}
fclose
(
fp
);
std
::
fclose
(
fp
);
}
lstBotList
->
clear
();
stBotInfo
->
setText
(
L""
);
...
...
@@ -2049,19 +2048,19 @@ void Game::AddDebugMsg(const char* msg) {
}
if
(
enable_log
&
0x2
)
{
char
msgbuf
[
1040
];
snprintf
(
msgbuf
,
sizeof
msgbuf
,
"[Script Error]: %s"
,
msg
);
s
td
::
s
nprintf
(
msgbuf
,
sizeof
msgbuf
,
"[Script Error]: %s"
,
msg
);
ErrorLog
(
msgbuf
);
}
}
void
Game
::
ErrorLog
(
const
char
*
msg
)
{
FILE
*
fp
=
fopen
(
"error.log"
,
"at"
);
FILE
*
fp
=
std
::
fopen
(
"error.log"
,
"at"
);
if
(
!
fp
)
return
;
time_t
nowtime
=
std
::
time
(
nullptr
);
char
timebuf
[
40
];
std
::
strftime
(
timebuf
,
sizeof
timebuf
,
"%Y-%m-%d %H:%M:%S"
,
std
::
localtime
(
&
nowtime
));
fprintf
(
fp
,
"[%s]%s
\n
"
,
timebuf
,
msg
);
fclose
(
fp
);
std
::
fprintf
(
fp
,
"[%s]%s
\n
"
,
timebuf
,
msg
);
std
::
fclose
(
fp
);
}
void
Game
::
addMessageBox
(
const
wchar_t
*
caption
,
const
wchar_t
*
text
)
{
SetStaticText
(
stSysMessage
,
370
*
xScale
,
guiFont
,
text
);
...
...
Classes/gframe/image_manager.cpp
View file @
bc24c894
...
...
@@ -191,10 +191,10 @@ irr::video::ITexture* ImageManager::GetBigPicture(int code, float zoom) {
}
irr
::
video
::
ITexture
*
texture
;
char
file
[
256
];
snprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
irr
::
video
::
IImage
*
srcimg
=
driver
->
createImageFromFile
(
file
);
if
(
srcimg
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
srcimg
=
driver
->
createImageFromFile
(
file
);
}
if
(
srcimg
==
nullptr
)
{
...
...
@@ -222,18 +222,18 @@ irr::video::ITexture* ImageManager::GetTextureField(int code) {
auto
tit
=
tFields
.
find
(
code
);
if
(
tit
==
tFields
.
end
())
{
char
file
[
256
];
snprintf
(
file
,
sizeof
file
,
"field/%s/%d.jpg"
,
irr
::
android
::
getCardImagePath
(
mainGame
->
appMain
).
c_str
(),
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"field/%s/%d.jpg"
,
irr
::
android
::
getCardImagePath
(
mainGame
->
appMain
).
c_str
(),
code
);
irr
::
video
::
ITexture
*
img
=
driver
->
getTexture
(
file
);
if
(
img
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"field/%s/%d.jpg"
,
irr
::
android
::
getCardImagePath
(
mainGame
->
appMain
).
c_str
(),
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"field/%s/%d.jpg"
,
irr
::
android
::
getCardImagePath
(
mainGame
->
appMain
).
c_str
(),
code
);
img
=
driver
->
getTexture
(
file
);
}
if
(
img
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"field/%s/%d.png"
,
irr
::
android
::
getCardImagePath
(
mainGame
->
appMain
).
c_str
(),
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"field/%s/%d.png"
,
irr
::
android
::
getCardImagePath
(
mainGame
->
appMain
).
c_str
(),
code
);
img
=
driver
->
getTexture
(
file
);
}
if
(
img
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"pics/field/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"pics/field/%d.jpg"
,
code
);
img
=
driver
->
getTexture
(
file
);
if
(
img
==
nullptr
)
{
tFields
[
code
]
=
nullptr
;
...
...
Classes/gframe/materials.h
View file @
bc24c894
...
...
@@ -27,11 +27,11 @@ public:
S3DVertex
vSelField
[
4
];
//S3DVertex vBackLine[76];
S3DVertex
vFieldDeck
[
2
][
4
];
S3DVertex
vFieldGrave
[
2
][
2
][
4
];
S3DVertex
vFieldGrave
[
2
][
2
][
4
];
//[player][rule], rule = 0: dule_rule <= 3, 1: dule_rule >= 4
S3DVertex
vFieldExtra
[
2
][
4
];
S3DVertex
vFieldRemove
[
2
][
2
][
4
];
S3DVertex
vFieldMzone
[
2
][
7
][
4
];
S3DVertex
vFieldSzone
[
2
][
8
][
2
][
4
];
S3DVertex
vFieldRemove
[
2
][
2
][
4
];
//[player][rule]
S3DVertex
vFieldMzone
[
2
][
7
][
4
];
//[player][sequence]
S3DVertex
vFieldSzone
[
2
][
8
][
2
][
4
];
//[player][sequence][rule]
irr
::
core
::
vector3df
vFieldContiAct
[
4
];
S3DVertex
vArrow
[
40
];
SColor
c2d
[
4
];
...
...
Classes/gframe/menu_handler.cpp
View file @
bc24c894
...
...
@@ -79,7 +79,7 @@ void ChangeHostPrepareDeckCategory(int catesel) {
mainGame
->
deckBuilder
.
prev_deck
=
0
;
}
void
reSetCategoryDeckNameOnButton
(
irr
::
gui
::
IGUIButton
*
button
,
wchar_t
*
string
){
void
reSetCategoryDeckNameOnButton
(
irr
::
gui
::
IGUIButton
*
button
,
const
wchar_t
*
string
){
wchar_t
cate
[
256
];
wchar_t
cate_deck
[
256
];
myswprintf
(
cate
,
L"%ls%ls"
,
(
mainGame
->
lstCategories
->
getSelected
())
==
1
?
L""
:
mainGame
->
lstCategories
->
getListItem
(
mainGame
->
lstCategories
->
getSelected
()),
(
mainGame
->
lstCategories
->
getSelected
())
==
1
?
L""
:
string
);
...
...
@@ -369,23 +369,23 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
prev_sel
=
sel
;
break
;
}
case
BUTTON_SHARE_REPLAY
:
{
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
if
(
sel
==
-
1
)
break
;
mainGame
->
gMutex
.
lock
();
char
name
[
1024
];
BufferIO
::
EncodeUTF8
(
mainGame
->
lstReplayList
->
getListItem
(
sel
),
name
);
mainGame
->
gMutex
.
unlock
();
prev_operation
=
id
;
prev_sel
=
sel
;
case
BUTTON_SHARE_REPLAY
:
{
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
if
(
sel
==
-
1
)
break
;
mainGame
->
gMutex
.
lock
();
char
name
[
1024
];
BufferIO
::
EncodeUTF8
(
mainGame
->
lstReplayList
->
getListItem
(
sel
),
name
);
mainGame
->
gMutex
.
unlock
();
prev_operation
=
id
;
prev_sel
=
sel
;
#ifdef _IRR_ANDROID_PLATFORM_
ALOGD
(
"cc menu_handler: 1share replay file=%s"
,
name
);
android
::
OnShareFile
(
mainGame
->
appMain
,
"yrp"
,
name
);
ALOGD
(
"cc menu_handler: 2after share replay file:index=%d"
,
sel
);
ALOGD
(
"cc menu_handler: 1share replay file=%s"
,
name
);
android
::
OnShareFile
(
mainGame
->
appMain
,
"yrp"
,
name
);
ALOGD
(
"cc menu_handler: 2after share replay file:index=%d"
,
sel
);
#endif
break
;
}
break
;
}
case
BUTTON_RENAME_REPLAY
:
{
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
if
(
sel
==
-
1
)
...
...
@@ -676,7 +676,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
const
wchar_t
*
name
=
mainGame
->
lstSinglePlayList
->
getListItem
(
sel
);
wchar_t
fname
[
256
];
myswprintf
(
fname
,
L"./single/%ls"
,
name
);
FILE
*
fp
=
myfopen
(
fname
,
"rb"
);
FILE
*
fp
=
my
w
fopen
(
fname
,
"rb"
);
if
(
!
fp
)
{
mainGame
->
stSinglePlayInfo
->
setText
(
L""
);
break
;
...
...
@@ -685,7 +685,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
wchar_t
wlinebuf
[
1024
];
std
::
wstring
message
=
L""
;
bool
in_message
=
false
;
while
(
fgets
(
linebuf
,
1024
,
fp
))
{
while
(
std
::
fgets
(
linebuf
,
1024
,
fp
))
{
if
(
!
std
::
strncmp
(
linebuf
,
"--[[message"
,
11
))
{
size_t
len
=
std
::
strlen
(
linebuf
);
char
*
msgend
=
std
::
strrchr
(
linebuf
,
']'
);
...
...
@@ -708,7 +708,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
message
.
append
(
wlinebuf
);
}
}
fclose
(
fp
);
std
::
fclose
(
fp
);
mainGame
->
SetStaticText
(
mainGame
->
stSinglePlayInfo
,
200
*
mainGame
->
xScale
,
mainGame
->
guiFont
,
message
.
c_str
());
break
;
}
...
...
Classes/gframe/replay.cpp
View file @
bc24c894
...
...
@@ -23,8 +23,8 @@ void Replay::BeginRecord() {
return
;
#else
if
(
is_recording
)
fclose
(
fp
);
fp
=
fopen
(
"./replay/_LastReplay.yrp"
,
"wb"
);
std
::
fclose
(
fp
);
fp
=
std
::
fopen
(
"./replay/_LastReplay.yrp"
,
"wb"
);
if
(
!
fp
)
return
;
#endif
...
...
@@ -39,8 +39,8 @@ void Replay::WriteHeader(ReplayHeader& header) {
DWORD
size
;
WriteFile
(
recording_fp
,
&
header
,
sizeof
(
header
),
&
size
,
nullptr
);
#else
fwrite
(
&
header
,
sizeof
(
header
),
1
,
fp
);
fflush
(
fp
);
std
::
fwrite
(
&
header
,
sizeof
(
header
),
1
,
fp
);
std
::
fflush
(
fp
);
#endif
}
void
Replay
::
WriteData
(
const
void
*
data
,
size_t
length
,
bool
flush
)
{
...
...
@@ -54,9 +54,9 @@ void Replay::WriteData(const void* data, size_t length, bool flush) {
DWORD
size
;
WriteFile
(
recording_fp
,
data
,
length
,
&
size
,
nullptr
);
#else
fwrite
(
data
,
length
,
1
,
fp
);
std
::
fwrite
(
data
,
length
,
1
,
fp
);
if
(
flush
)
fflush
(
fp
);
std
::
fflush
(
fp
);
#endif
}
void
Replay
::
WriteInt32
(
int32_t
data
,
bool
flush
)
{
...
...
@@ -67,7 +67,7 @@ void Replay::Flush() {
return
;
#ifdef _WIN32
#else
fflush
(
fp
);
std
::
fflush
(
fp
);
#endif
}
void
Replay
::
EndRecord
()
{
...
...
@@ -76,7 +76,7 @@ void Replay::EndRecord() {
#ifdef _WIN32
CloseHandle
(
recording_fp
);
#else
fclose
(
fp
);
std
::
fclose
(
fp
);
#endif
pheader
.
datasize
=
replay_size
;
pheader
.
flag
|=
REPLAY_COMPRESSED
;
...
...
@@ -94,19 +94,19 @@ void Replay::SaveReplay(const wchar_t* name) {
return
;
wchar_t
fname
[
256
];
myswprintf
(
fname
,
L"./replay/%ls.yrp"
,
name
);
FILE
*
rfp
=
myfopen
(
fname
,
"wb"
);
FILE
*
rfp
=
my
w
fopen
(
fname
,
"wb"
);
if
(
!
rfp
)
return
;
fwrite
(
&
pheader
,
sizeof
pheader
,
1
,
rfp
);
fwrite
(
comp_data
,
comp_size
,
1
,
rfp
);
fclose
(
rfp
);
std
::
fwrite
(
&
pheader
,
sizeof
pheader
,
1
,
rfp
);
std
::
fwrite
(
comp_data
,
comp_size
,
1
,
rfp
);
std
::
fclose
(
rfp
);
}
bool
Replay
::
OpenReplay
(
const
wchar_t
*
name
)
{
FILE
*
rfp
=
myfopen
(
name
,
"rb"
);
FILE
*
rfp
=
my
w
fopen
(
name
,
"rb"
);
if
(
!
rfp
)
{
wchar_t
fname
[
256
];
myswprintf
(
fname
,
L"./replay/%ls"
,
name
);
rfp
=
myfopen
(
fname
,
"rb"
);
rfp
=
my
w
fopen
(
fname
,
"rb"
);
}
if
(
!
rfp
)
return
false
;
...
...
@@ -116,13 +116,13 @@ bool Replay::OpenReplay(const wchar_t* name) {
is_replaying
=
false
;
replay_size
=
0
;
comp_size
=
0
;
if
(
fread
(
&
pheader
,
sizeof
pheader
,
1
,
rfp
)
<
1
)
{
fclose
(
rfp
);
if
(
std
::
fread
(
&
pheader
,
sizeof
pheader
,
1
,
rfp
)
<
1
)
{
std
::
fclose
(
rfp
);
return
false
;
}
if
(
pheader
.
flag
&
REPLAY_COMPRESSED
)
{
comp_size
=
fread
(
comp_data
,
1
,
MAX_COMP_SIZE
,
rfp
);
fclose
(
rfp
);
comp_size
=
std
::
fread
(
comp_data
,
1
,
MAX_COMP_SIZE
,
rfp
);
std
::
fclose
(
rfp
);
if
(
pheader
.
datasize
>
MAX_REPLAY_SIZE
)
return
false
;
replay_size
=
pheader
.
datasize
;
...
...
@@ -133,8 +133,8 @@ bool Replay::OpenReplay(const wchar_t* name) {
return
false
;
}
}
else
{
replay_size
=
fread
(
replay_data
,
1
,
MAX_REPLAY_SIZE
,
rfp
);
fclose
(
rfp
);
replay_size
=
std
::
fread
(
replay_data
,
1
,
MAX_REPLAY_SIZE
,
rfp
);
std
::
fclose
(
rfp
);
comp_size
=
0
;
}
is_replaying
=
true
;
...
...
@@ -143,12 +143,12 @@ bool Replay::OpenReplay(const wchar_t* name) {
bool
Replay
::
CheckReplay
(
const
wchar_t
*
name
)
{
wchar_t
fname
[
256
];
myswprintf
(
fname
,
L"./replay/%ls"
,
name
);
FILE
*
rfp
=
myfopen
(
fname
,
"rb"
);
FILE
*
rfp
=
my
w
fopen
(
fname
,
"rb"
);
if
(
!
rfp
)
return
false
;
ReplayHeader
rheader
;
size_t
count
=
fread
(
&
rheader
,
sizeof
rheader
,
1
,
rfp
);
fclose
(
rfp
);
size_t
count
=
std
::
fread
(
&
rheader
,
sizeof
rheader
,
1
,
rfp
);
std
::
fclose
(
rfp
);
return
count
==
1
&&
rheader
.
id
==
0x31707279
&&
rheader
.
version
>=
0x12d0u
&&
(
rheader
.
version
<
0x1353u
||
(
rheader
.
flag
&
REPLAY_UNIFORM
));
}
bool
Replay
::
DeleteReplay
(
const
wchar_t
*
name
)
{
...
...
Classes/gframe/single_mode.cpp
View file @
bc24c894
...
...
@@ -61,7 +61,7 @@ int SingleMode::SinglePlayThread() {
wchar_t
fname
[
256
]{};
myswprintf
(
fname
,
L"./single/%ls"
,
name
);
slen
=
BufferIO
::
EncodeUTF8
(
fname
,
filename
);
if
(
!
preload_script
(
pduel
,
filename
))
if
(
!
preload_script
(
pduel
,
filename
))
slen
=
0
;
if
(
slen
==
0
)
{
end_duel
(
pduel
);
...
...
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