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
48ecc05a
Commit
48ecc05a
authored
Oct 11, 2024
by
Chen Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix Game::LoadConfig
max length of filename should be determined by file system
parent
0b1e8a8c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
35 deletions
+24
-35
gframe/game.cpp
gframe/game.cpp
+24
-35
No files found.
gframe/game.cpp
View file @
48ecc05a
...
...
@@ -119,7 +119,7 @@ bool Game::Initialize() {
L"./fonts/numFont.otf"
};
for
(
const
wchar_t
*
path
:
numFontPaths
)
{
myswprintf
(
gameConf
.
numfont
,
path
);
BufferIO
::
CopyWideString
(
path
,
gameConf
.
numfont
);
numFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
numfont
,
16
);
if
(
numFont
)
break
;
...
...
@@ -144,14 +144,14 @@ bool Game::Initialize() {
L"./fonts/textFont.otf"
};
for
(
const
wchar_t
*
path
:
textFontPaths
)
{
myswprintf
(
gameConf
.
textfont
,
path
);
BufferIO
::
CopyWideString
(
path
,
gameConf
.
textfont
);
textFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
textfont
,
gameConf
.
textfontsize
);
if
(
textFont
)
break
;
}
}
if
(
!
numFont
||
!
textFont
)
{
wchar_t
fpath
[
1024
];
wchar_t
fpath
[
1024
]
{}
;
fpath
[
0
]
=
0
;
FileSystem
::
TraversalDir
(
L"./fonts"
,
[
&
fpath
](
const
wchar_t
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
(
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".ttf"
,
4
)
||
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".ttc"
,
4
)
||
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".otf"
,
4
)))
{
...
...
@@ -163,11 +163,11 @@ bool Game::Initialize() {
return
false
;
}
if
(
!
numFont
)
{
myswprintf
(
gameConf
.
numfont
,
fpath
);
BufferIO
::
CopyWideString
(
fpath
,
gameConf
.
numfont
);
numFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
numfont
,
16
);
}
if
(
!
textFont
)
{
myswprintf
(
gameConf
.
textfont
,
fpath
);
BufferIO
::
CopyWideString
(
fpath
,
gameConf
.
textfont
);
textFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
textfont
,
gameConf
.
textfontsize
);
}
}
...
...
@@ -1317,12 +1317,11 @@ void Game::LoadConfig() {
FILE
*
fp
=
fopen
(
"system.conf"
,
"r"
);
if
(
!
fp
)
return
;
char
linebuf
[
256
]{};
char
linebuf
[
CONFIG_LINE_SIZE
]{};
char
strbuf
[
64
]{};
char
valbuf
[
256
]{};
wchar_t
wstr
[
256
]{};
while
(
fgets
(
linebuf
,
256
,
fp
))
{
if
(
sscanf
(
linebuf
,
"%63s = %255s"
,
strbuf
,
valbuf
)
!=
2
)
char
valbuf
[
960
]{};
while
(
fgets
(
linebuf
,
sizeof
linebuf
,
fp
))
{
if
(
sscanf
(
linebuf
,
"%63s = %959s"
,
strbuf
,
valbuf
)
!=
2
)
continue
;
if
(
!
std
::
strcmp
(
strbuf
,
"antialias"
))
{
gameConf
.
antialias
=
strtol
(
valbuf
,
nullptr
,
10
);
...
...
@@ -1335,25 +1334,18 @@ void Game::LoadConfig() {
enable_log
=
val
&
0xff
;
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"textfont"
))
{
int
textfontsize
=
0
;
if
(
sscanf
(
linebuf
,
"%63s = %
255
s %d"
,
strbuf
,
valbuf
,
&
textfontsize
)
!=
3
)
if
(
sscanf
(
linebuf
,
"%63s = %
959
s %d"
,
strbuf
,
valbuf
,
&
textfontsize
)
!=
3
)
continue
;
gameConf
.
textfontsize
=
textfontsize
;
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
textfont
,
256
);
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
textfont
);
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"numfont"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
numfont
,
256
);
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
numfont
);
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"serverport"
))
{
gameConf
.
serverport
=
strtol
(
valbuf
,
nullptr
,
10
);
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"lasthost"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
lasthost
,
100
);
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
lasthost
);
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"lastport"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
lastport
,
20
);
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"roompass"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
roompass
,
20
);
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
lastport
);
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"automonsterpos"
))
{
gameConf
.
chkMAutoPos
=
strtol
(
valbuf
,
nullptr
,
10
);
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"autospellpos"
))
{
...
...
@@ -1440,23 +1432,20 @@ void Game::LoadConfig() {
#endif
}
else
{
// options allowing multiple words
if
(
sscanf
(
linebuf
,
"%63s = %
240
[^
\n
]"
,
strbuf
,
valbuf
)
!=
2
)
if
(
sscanf
(
linebuf
,
"%63s = %
959
[^
\n
]"
,
strbuf
,
valbuf
)
!=
2
)
continue
;
if
(
!
std
::
strcmp
(
strbuf
,
"nickname"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
nickname
,
20
);
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
nickname
);
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"gamename"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
gamename
,
20
);
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
gamename
);
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"roompass"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
roompass
);
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"lastcategory"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
lastcategory
,
64
);
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
lastcategory
);
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"lastdeck"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
lastdeck
,
64
);
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
lastdeck
);
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"bot_deck_path"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
bot_deck_path
,
64
);
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
bot_deck_path
);
}
}
}
...
...
@@ -1465,12 +1454,12 @@ void Game::LoadConfig() {
void
Game
::
SaveConfig
()
{
FILE
*
fp
=
fopen
(
"system.conf"
,
"w"
);
fprintf
(
fp
,
"#config file
\n
#nickname & gamename should be less than 20 characters
\n
"
);
char
linebuf
[
256
];
char
linebuf
[
CONFIG_LINE_SIZE
];
fprintf
(
fp
,
"use_d3d = %d
\n
"
,
gameConf
.
use_d3d
?
1
:
0
);
fprintf
(
fp
,
"use_image_scale = %d
\n
"
,
gameConf
.
use_image_scale
?
1
:
0
);
fprintf
(
fp
,
"antialias = %d
\n
"
,
gameConf
.
antialias
);
fprintf
(
fp
,
"errorlog = %u
\n
"
,
enable_log
);
BufferIO
::
CopyW
Str
(
ebNickName
->
getText
(),
gameConf
.
nickname
,
20
);
BufferIO
::
CopyW
ideString
(
ebNickName
->
getText
(),
gameConf
.
nickname
);
BufferIO
::
EncodeUTF8
(
gameConf
.
nickname
,
linebuf
);
fprintf
(
fp
,
"nickname = %s
\n
"
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
gamename
,
linebuf
);
...
...
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