Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataManager: add DefaultScriptReader #2624

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

salix5
Copy link
Collaborator

@salix5 salix5 commented Nov 30, 2024

single mode will read the wrong script

In single
1234.lua

In expansions/abc.zip
single/1234.lua

choose 1234.lua in listbox
The single mode will read the file in expansions/abc.zip.
如果存在以上檔名
在單人模式選擇1234.lua
將會讀取expansions/abc.zip內部的檔案
而不是實體目錄./single的檔案

gameConf.prefer_expansion_script does not work

In expansions/abc.zip
script/constant.lua

set gameConf.prefer_expansion_script to 0
It will still read the file in expansions/abc.zip.
即使gameConf.prefer_expansion_script設為0
仍然會優先讀取expansions/abc.zip內部的constant.lua

Reason:

dataManager.FileSystem->addFileArchive(fpath, true, false, EFAT_ZIP);

In dataManager.FileSystem, ./script/constant.lua refers to the file in zip.
ScriptReader uses dataManager.FileSystem to read the script, so it will always read the file in zip.

如果使用dataManager.FileSystem讀取
constant.lua會被加入./script取代原本的檔案
ScriptReader使用dataManager.FileSystem
因此不管選項是on/off都會讀到zip內部的constant.lua

nested directive

In expansions/abc.zip
expansions/script/constant.lua

set gameConf.prefer_expansion_script to 1
It will read the file in expansions/abc.zip.
如果gameConf.prefer_expansion_script設為1
ScriptReader將會讀取zip內部的expansions/script/constant.lua

solution

DefaultScriptReader
It will read the script by C function fread, and it will not read from zip file.
使用fread,只讀取實體目錄而不包含zip

Single mode script
It will search from ./single
只在./single搜尋

Card script
It will search from the following path
dataManager.FileSystem (including files in zip)
./script
./expansions/script
從以上路徑搜尋

@mercury233
@purerosefallen
@Wind2009-Louse
@fallenstardust

@purerosefallen
Copy link
Collaborator

A merge solution to server branch is needed for this PR https://github.com/mycard/ygopro/tree/server

Note: the server behavior differs, always reading specials first, and then expansions/script, and at last script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants