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

Unsorted scripts leads to fps drops or crash #16

Open
CrazyKnightGR opened this issue Jan 30, 2023 · 3 comments
Open

Unsorted scripts leads to fps drops or crash #16

CrazyKnightGR opened this issue Jan 30, 2023 · 3 comments

Comments

@CrazyKnightGR
Copy link

On projects like Zibomod B737-800X where one module depends (find_dataref) on previous created datarefs if the order of loading modules is (as current) unsorted leads to unexpected behavior that cause crashes or fps drops. All systems (win, lin, mac) are affected, but the problem is more obvious on mac and linux OS, as they don't need/use a hard disk defragment utilily. In windows as long defragment on folder have applied the file pointers are sorted out, so no big problem, but if you modify a file still there is a (big) chance to be unsorted. For more information take a look at Zibo1 and this Zibo2

With a "dirty hack" for testings with following changes in xlua.cpp the problem is fixed !!

void InitScripts(void)  {
.
. 
 struct script {
        string m_path {};
        string m_init_path {};
        string m_script_path {};
    };
    vector<script> my_scripts;`
.
.
if (strcmp(fptr, ".DS_Store") != 0)
		{
			string mod_path(scripts_dir_path);
			mod_path += "/";
			mod_path += fptr;
			mod_path += "/";
			string script_path(mod_path);
			script_path += fptr;
            script_path += ".lua";

            const script cur_script {mod_path,init_script_path,script_path};
            my_scripts.push_back(cur_script);
		}

		++offset;
		if (offset == mf)
			break;
	}
    if (fcount) {
        sort(my_scripts.begin(), my_scripts.end(),
    [] (script const& a, script const& b){return a.m_path < b.m_path; });

        for (auto& cur_script : my_scripts) {
             g_modules.push_back(new module(
                    cur_script.m_path.c_str(),
                    cur_script.m_init_path.c_str(),
                    cur_script.m_script_path.c_str(),
                    lj_alloc_f,
                    NULL));
        }
    }

@Danita
Copy link
Member

Danita commented Jan 30, 2023

Hi @CrazyKnightGR , thank you for the report. Can you please create a pull request with your changes that we can merge? Thank you!

@CrazyKnightGR
Copy link
Author

If you want the 'dirty hack' sure I will do it right now, but for a proper pull you should wait until Wednesday.

@CrazyKnightGR
Copy link
Author

I closed it because it only compiles with c++17 or c++23. However, I have confirmation that it solves the problems.

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

No branches or pull requests

2 participants