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
f2171fdd
Commit
f2171fdd
authored
Nov 07, 2025
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持ypk内lflist.conf加载,并置顶优先
parent
d9fa2044
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
180 additions
and
6 deletions
+180
-6
Classes/gframe/deck_manager.cpp
Classes/gframe/deck_manager.cpp
+65
-0
Classes/gframe/deck_manager.h
Classes/gframe/deck_manager.h
+1
-0
Classes/gframe/game.cpp
Classes/gframe/game.cpp
+9
-4
mobile/src/main/java/ocgcore/LimitManager.java
mobile/src/main/java/ocgcore/LimitManager.java
+105
-2
No files found.
Classes/gframe/deck_manager.cpp
View file @
f2171fdd
...
@@ -49,6 +49,71 @@ void DeckManager::LoadLFListSingle(const char* path) {
...
@@ -49,6 +49,71 @@ void DeckManager::LoadLFListSingle(const char* path) {
std
::
fclose
(
fp
);
std
::
fclose
(
fp
);
}
}
}
}
void
DeckManager
::
LoadLFListSingle
(
irr
::
io
::
IReadFile
*
reader
)
{
if
(
!
reader
)
return
;
auto
cur
=
_lfList
.
rend
();
char
linebuf
[
256
]{};
wchar_t
strBuffer
[
256
]{};
// 读取文件内容直到结束
while
(
reader
->
getPos
()
<
reader
->
getSize
())
{
// 手动读取一行
int
i
=
0
;
char
ch
;
while
(
i
<
sizeof
(
linebuf
)
-
1
&&
reader
->
getPos
()
<
reader
->
getSize
())
{
reader
->
read
(
&
ch
,
1
);
if
(
ch
==
'\n'
||
ch
==
'\r'
)
{
// 处理换行符
if
(
ch
==
'\r'
&&
reader
->
getPos
()
<
reader
->
getSize
())
{
// 检查是否有\n
long
pos
=
reader
->
getPos
();
char
nextCh
;
reader
->
read
(
&
nextCh
,
1
);
if
(
nextCh
!=
'\n'
)
{
reader
->
seek
(
pos
);
// 回退
}
}
break
;
}
linebuf
[
i
++
]
=
ch
;
}
linebuf
[
i
]
=
'\0'
;
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
;
_lfList
.
push_back
(
newlist
);
cur
=
_lfList
.
rbegin
();
continue
;
}
if
(
cur
==
_lfList
.
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
)));
}
}
void
DeckManager
::
LoadLFList
(
irr
::
android
::
InitOptions
*
options
)
{
void
DeckManager
::
LoadLFList
(
irr
::
android
::
InitOptions
*
options
)
{
irr
::
io
::
path
workingDir
=
options
->
getWorkDir
();
irr
::
io
::
path
workingDir
=
options
->
getWorkDir
();
LoadLFListSingle
((
workingDir
+
path
(
"/expansions/lflist.conf"
)).
c_str
());
LoadLFListSingle
((
workingDir
+
path
(
"/expansions/lflist.conf"
)).
c_str
());
...
...
Classes/gframe/deck_manager.h
View file @
f2171fdd
...
@@ -60,6 +60,7 @@ public:
...
@@ -60,6 +60,7 @@ public:
static
constexpr
int
MAX_YDK_SIZE
=
0x10000
;
static
constexpr
int
MAX_YDK_SIZE
=
0x10000
;
void
LoadLFListSingle
(
const
char
*
path
);
void
LoadLFListSingle
(
const
char
*
path
);
void
LoadLFListSingle
(
irr
::
io
::
IReadFile
*
reader
);
void
LoadLFList
(
irr
::
android
::
InitOptions
*
options
);
void
LoadLFList
(
irr
::
android
::
InitOptions
*
options
);
const
wchar_t
*
GetLFListName
(
unsigned
int
lfhash
);
const
wchar_t
*
GetLFListName
(
unsigned
int
lfhash
);
const
LFList
*
GetLFList
(
unsigned
int
lfhash
);
const
LFList
*
GetLFList
(
unsigned
int
lfhash
);
...
...
Classes/gframe/game.cpp
View file @
f2171fdd
...
@@ -223,7 +223,6 @@ bool Game::Initialize(ANDROID_APP app, irr::android::InitOptions *options) {
...
@@ -223,7 +223,6 @@ bool Game::Initialize(ANDROID_APP app, irr::android::InitOptions *options) {
is_building
=
false
;
is_building
=
false
;
menuHandler
.
prev_operation
=
0
;
menuHandler
.
prev_operation
=
0
;
menuHandler
.
prev_sel
=
-
1
;
menuHandler
.
prev_sel
=
-
1
;
deckManager
.
LoadLFList
(
options
);
driver
=
device
->
getVideoDriver
();
driver
=
device
->
getVideoDriver
();
#ifdef _IRR_ANDROID_PLATFORM_
#ifdef _IRR_ANDROID_PLATFORM_
int
quality
=
options
->
getCardQualityOp
();
int
quality
=
options
->
getCardQualityOp
();
...
@@ -274,7 +273,8 @@ bool Game::Initialize(ANDROID_APP app, irr::android::InitOptions *options) {
...
@@ -274,7 +273,8 @@ bool Game::Initialize(ANDROID_APP app, irr::android::InitOptions *options) {
ErrorLog
(
"Failed to load strings!"
);
ErrorLog
(
"Failed to load strings!"
);
return
false
;
return
false
;
}
}
LoadExpansions
();
LoadExpansions
();
deckManager
.
LoadLFList
(
options
);
env
=
device
->
getGUIEnvironment
();
env
=
device
->
getGUIEnvironment
();
bool
isAntialias
=
options
->
isFontAntiAliasEnabled
();
bool
isAntialias
=
options
->
isFontAntiAliasEnabled
();
numFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
numfont
,
18
*
yScale
,
isAntialias
,
false
);
numFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
numfont
,
18
*
yScale
,
isAntialias
,
false
);
...
@@ -1637,8 +1637,13 @@ void Game::LoadExpansions() {
...
@@ -1637,8 +1637,13 @@ void Game::LoadExpansions() {
continue
;
continue
;
}
}
if
(
IsExtension
(
fname
,
L".conf"
))
{
if
(
IsExtension
(
fname
,
L".conf"
))
{
auto
reader
=
dataManager
.
FileSystem
->
createAndOpenFile
(
uname
);
auto
reader
=
dataManager
.
FileSystem
->
createAndOpenFile
(
uname
);
dataManager
.
LoadStrings
(
reader
);
if
(
std
::
wcsstr
(
fname
,
L"lflist"
)
!=
nullptr
)
{
ALOGD
(
"uname=%s"
,
uname
);
deckManager
.
LoadLFListSingle
(
reader
);
}
else
{
dataManager
.
LoadStrings
(
reader
);
}
continue
;
continue
;
}
}
if
(
!
mywcsncasecmp
(
fname
,
L"pack/"
,
5
)
&&
IsExtension
(
fname
,
L".ydk"
))
{
if
(
!
mywcsncasecmp
(
fname
,
L"pack/"
,
5
)
&&
IsExtension
(
fname
,
L".ydk"
))
{
...
...
mobile/src/main/java/ocgcore/LimitManager.java
View file @
f2171fdd
...
@@ -5,13 +5,20 @@ import android.util.Log;
...
@@ -5,13 +5,20 @@ import android.util.Log;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
com.file.zip.ZipEntry
;
import
com.file.zip.ZipFile
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.Closeable
;
import
java.io.Closeable
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -19,6 +26,7 @@ import java.util.Map;
...
@@ -19,6 +26,7 @@ import java.util.Map;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
ocgcore.data.CardSet
;
import
ocgcore.data.LimitList
;
import
ocgcore.data.LimitList
;
public
class
LimitManager
implements
Closeable
{
public
class
LimitManager
implements
Closeable
{
...
@@ -61,20 +69,115 @@ public class LimitManager implements Closeable {
...
@@ -61,20 +69,115 @@ public class LimitManager implements Closeable {
return
mLimitLists
.
get
(
mLimitNames
.
get
(
0
));
return
mLimitLists
.
get
(
mLimitNames
.
get
(
0
));
}
}
/**
* 加载禁卡表lflist.conf数据
*
* @return boolean 加载成功返回true,否则返回false
*/
public
boolean
load
()
{
public
boolean
load
()
{
// 创建主资源路径下的限制文件对象
File
stringFile
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_LIMIT_PATH
);
File
stringFile
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_LIMIT_PATH
);
boolean
rs1
=
true
;
boolean
rs1
=
true
;
boolean
rs2
=
true
;
boolean
res3
=
true
;
// 如果需要读取扩展包数据,则加载扩展包中的限制文件
if
(
AppsSettings
.
get
().
isReadExpansions
())
{
if
(
AppsSettings
.
get
().
isReadExpansions
())
{
File
stringFile2
=
new
File
(
AppsSettings
.
get
().
getExpansionsPath
(),
Constants
.
CORE_LIMIT_PATH
);
File
stringFile2
=
new
File
(
AppsSettings
.
get
().
getExpansionsPath
(),
Constants
.
CORE_LIMIT_PATH
);
rs1
=
loadFile
(
stringFile2
);
rs1
=
loadFile
(
stringFile2
);
File
[]
files
=
AppsSettings
.
get
().
getExpansionsPath
().
listFiles
();
if
(
files
!=
null
)
{
for
(
File
file
:
files
)
{
if
(
file
.
isFile
()
&&
(
file
.
getName
().
endsWith
(
".zip"
)
||
file
.
getName
().
endsWith
(
Constants
.
YPK_FILE_EX
)))
{
Log
.
e
(
"LimitManager"
,
"读取压缩包"
);
try
{
ZipFile
zipFile
=
new
ZipFile
(
file
.
getAbsoluteFile
(),
"GBK"
);
Enumeration
<
ZipEntry
>
entris
=
zipFile
.
getEntries
();
ZipEntry
entry
;
while
(
entris
.
hasMoreElements
())
{
entry
=
entris
.
nextElement
();
if
(!
entry
.
isDirectory
())
{
if
(
entry
.
getName
().
contains
(
"lflist"
)
&&
entry
.
getName
().
endsWith
(
".conf"
))
{
rs2
&=
loadFile
(
zipFile
.
getInputStream
(
entry
));
}
}
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
res3
=
false
;
}
}
}
}
}
}
boolean
rs2
=
loadFile
(
stringFile
);
res3
=
loadFile
(
stringFile
);
LimitList
blank_list
=
new
LimitList
(
"N/A"
);
LimitList
blank_list
=
new
LimitList
(
"N/A"
);
mLimitLists
.
put
(
"N/A"
,
blank_list
);
mLimitLists
.
put
(
"N/A"
,
blank_list
);
mLimitNames
.
add
(
"N/A"
);
mLimitNames
.
add
(
"N/A"
);
++
mCount
;
++
mCount
;
return
rs1
&&
rs2
;
return
rs1
&&
rs2
&&
res3
;
}
}
/**
* 从输入流加载配置文件数据
* @param inputStream 配置文件的输入流
* @return 加载成功返回true
*/
public
boolean
loadFile
(
InputStream
inputStream
)
{
InputStreamReader
in
=
null
;
try
{
in
=
new
InputStreamReader
(
inputStream
,
StandardCharsets
.
UTF_8
);
BufferedReader
reader
=
new
BufferedReader
(
in
);
String
line
=
null
;
String
name
=
null
;
LimitList
tmp
=
null
;
// 逐行读取配置文件内容
while
((
line
=
reader
.
readLine
())
!=
null
)
{
// 跳过注释行
if
(
line
.
startsWith
(
"#"
))
{
continue
;
}
// 处理新的限制列表定义
if
(
line
.
startsWith
(
"!"
))
{
name
=
line
.
substring
(
1
);
tmp
=
new
LimitList
(
name
);
mLimitLists
.
put
(
name
,
tmp
);
mLimitNames
.
add
(
name
);
}
else
if
(
tmp
!=
null
)
{
// 解析限制项配置
String
[]
words
=
line
.
trim
().
split
(
"[\t| ]+"
);
if
(
words
.
length
>=
2
)
{
int
id
=
toNumber
(
words
[
0
]);
int
count
=
toNumber
(
words
[
1
]);
// 根据count值添加不同类型的限制
switch
(
count
)
{
case
0
:
tmp
.
addForbidden
(
id
);
break
;
case
1
:
tmp
.
addLimit
(
id
);
break
;
case
2
:
tmp
.
addSemiLimit
(
id
);
break
;
}
}
}
}
}
catch
(
Exception
e
)
{
Log
.
e
(
"kk"
,
"limit"
,
e
);
}
finally
{
IOUtils
.
close
(
inputStream
);
IOUtils
.
close
(
in
);
}
// 更新限制列表计数
mCount
=
mLimitLists
.
size
();
return
true
;
}
/**
/**
* 解析限制卡配置文件lflist.conf的内容
* 解析限制卡配置文件lflist.conf的内容
...
...
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