svkaiser / Doom64EX

Doom64EX is a reverse-engineering project aimed to recreate Doom64 as close as possible with additional modding features.
http://doom64ex.wordpress.com/
GNU General Public License v2.0
237 stars 49 forks source link

Setting a custom installation directory causes doom64ex.pk3/IWAD load failure #92

Open MiltosKoutsokeras opened 5 years ago

MiltosKoutsokeras commented 5 years ago

Installing in a custom directory with CMAKE_INSTALL_PREFIX will cause an exception during startup:

Could not find doom64ex.pk3

or

Could not find IWAD

This is caused due to a static list of search directories in the code, in file src/App.cc:

Optional<String> app::find_data_file(StringView name, StringView dir_hint)
{
    String path;

    if (!dir_hint.empty()) {
        path = format("{}{}", dir_hint, name);
        if (app::file_exists(path))
            return { inplace, path };
    }

    path = format("{}{}", _base_dir, name);
    if (app::file_exists(path))
        return { inplace, path };

    path = format("{}{}", _data_dir, name);
    if (app::file_exists(path))
        return { inplace, path };

#if defined(__LINUX__) || defined(__OpenBSD__)
    const char *paths[] = {
        "/usr/local/share/games/doom64ex/",
        "/usr/local/share/doom64ex/",
        "/usr/local/share/doom/",
        "/usr/share/games/doom64ex/",
        "/usr/share/doom64ex/",
        "/usr/share/doom/",
        "/opt/doom64ex/",
    };

    for (auto p : paths) {
        path = format("{}{}", p, name);
        if (app::file_exists(path))
            return { inplace, path };
    }
#endif

    return nullopt;
}

This list does not take into consideration the custom installation path <CMAKE_INSTALL_PREFIX>/share/games/doom64ex/doom64ex.pk3. The same holds for the IWAD file doom64.wad. A fix would be to include the custom installation prefix path to the search directory list or use some Linux environmental variables like XDG_DATA_HOME.

MiltosKoutsokeras commented 5 years ago

Pull request with fix: https://github.com/svkaiser/Doom64EX/pull/95