diff --git a/src/game.cc b/src/game.cc index d774337..18e58ba 100644 --- a/src/game.cc +++ b/src/game.cc @@ -1382,6 +1382,29 @@ static int gameDbInit() dbOpen("f2_res.dat", 0, nullptr, 1); } + if (const auto mods = fileOpen("mods/mods_order.txt", "rt")) + { + char line[260]; + while (fileReadString(line, sizeof(line) - 2, mods)) + { + if (line[0] != ';') + { + auto len = strlen(line); + while (len && std::isspace(line[len - 1])) + { + len--; + } + if (len) + { + const auto dir = "mods/" + std::string(l pi@raspberrypi:~/sources/fallout2-ce $ vim src/game.cc pi@raspberrypi:~/sources/fallout2-ce $ git diff diff --git a/src/game.cc b/src/game.cc index d774337..3bf7699 100644 --- a/src/game.cc +++ b/src/game.cc @@ -1382,6 +1382,29 @@ static int gameDbInit() dbOpen("f2_res.dat", 0, nullptr, 1); } + if (const auto mods = fileOpen("mods/mods_order.txt", "rt")) + { + char line[260]; + while (fileReadString(line, sizeof(line) - 2, mods)) + { + if (line[0] != ';') + { + auto len = strlen(line); + while (len && std::isspace(line[len - 1])) + { + len--; + } + if (len) + { + const auto dir = "mods/" + std::string(line, len); + dbOpen(dir.c_str(), 0, nullptr, 1); + dbOpen((dir + "/scripts").c_str(), 0, nullptr, 1); + } + } + } + fileClose(mods); + } + return 0; } diff --git a/src/game_movie.cc b/src/game_movie.cc index 29a63de..9eb8e1f 100644 --- a/src/game_movie.cc +++ b/src/game_movie.cc @@ -52,6 +52,8 @@ static const char* gMovieFileNames[MOVIE_COUNT] = { "credits.mve", }; +static std::string gMovieFileNamesOverrides[MOVIE_COUNT]; + // 0x518DE4 static const char* gMoviePaletteFilePaths[MOVIE_COUNT] = { nullptr, @@ -89,6 +91,20 @@ static char gGameMovieSubtitlesFilePath[COMPAT_MAX_PATH]; // 0x44E5C0 int gameMoviesInit() { + Config moviesConfig; + if (configInit(&moviesConfig)) { + if (configRead(&moviesConfig, "ddraw.ini", false)) { + for (int movie = 0; movie < MOVIE_COUNT; movie++) { + char* movieOverride; + if (configGetString(&moviesConfig, "Misc", ("Movie" + std::to_s tring(movie + 1)).c_str(), &movieOverride)) { + gMovieFileNamesOverrides[movie] = movieOverride; + gMovieFileNames[movie] = gMovieFileNamesOverrides[movie].c_ str(); + } + } + } + configFree(&moviesConfig); + } + int v1 = 0; if (backgroundSoundIsEnabled()) { v1 = backgroundSoundGetVolume(); diff --git a/src/platform_compat.cc b/src/platform_compat.cc index 95c6eba..fd79ba5 100644 --- a/src/platform_compat.cc +++ b/src/platform_compat.cc @@ -361,6 +361,39 @@ void compat_resolve_path(char* path) pch = sep + 1; } +#else + char* mask = malloc(strlen(path) * 4 + 1); + { + char* m = mask; + for (const char* p = path; *p; p++) + { + if (std::isletter(*p)) + { + *m++ = '['; + *m++ = std::toupper(*p); + *m++ = std::tolower(*p); + *m++ = ']'; + } + else if (*p == '/') nullptr, @@ -89,6 +91,20 @@ static char gGameMovieSubtitlesFilePath[COMPAT_MAX_PATH]; // 0x44E5C0 int gameMoviesInit() { + Config moviesConfig; + if (configInit(&moviesConfig)) { + if (configRead(&moviesConfig, "ddraw.ini", false)) { + for (int movie = 0; movie < MOVIE_COUNT; movie++) { + char* movieOverride; + if (configGetString(&moviesConfig, "Misc", ("Movie" + std::to_s tring(movie + 1)).c_str(), &movieOverride)) { + gMovieFileNamesOverrides[movie] = movieOverride; + gMovieFileNames[movie] = gMovieFileNamesOverrides[movie].c_ str(); + } + } + } + configFree(&moviesConfig); + } + int v1 = 0; if (backgroundSoundIsEnabled()) { v1 = backgroundSoundGetVolume(); diff --git a/src/platform_compat.cc b/src/platform_compat.cc index 95c6eba..fd79ba5 100644 --- a/src/platform_compat.cc +++ b/src/platform_compat.cc @@ -361,6 +361,39 @@ void compat_resolve_path(char* path) pch = sep + 1; } +#else + char* mask = malloc(strlen(path) * 4 + 1); + { + char* m = mask; + for (const char* p = path; *p; p++) + { + if (std::isletter(*p)) + { + *m++ = '['; + *m++ = std::toupper(*p); + *m++ = std::tolower(*p); + *m++ = ']'; + } + else if (*p == '/') pi@raspberrypi:~/sources/fallout2-ce $ vim src/platform_compat.cc pi@raspberrypi:~/sources/fallout2-ce $ git diff diff --git a/src/game.cc b/src/game.cc index d774337..3bf7699 100644 --- a/src/game.cc +++ b/src/game.cc @@ -1382,6 +1382,29 @@ static int gameDbInit() dbOpen("f2_res.dat", 0, nullptr, 1); } + if (const auto mods = fileOpen("mods/mods_order.txt", "rt")) + { + char line[260]; + while (fileReadString(line, sizeof(line) - 2, mods)) + { + if (line[0] != ';') + { + auto len = strlen(line); + while (len && std::isspace(line[len - 1])) + { + len--; + } + if (len) + { + const auto dir = "mods/" + std::string(line, len); + dbOpen(dir.c_str(), 0, nullptr, 1); + dbOpen((dir + "/scripts").c_str(), 0, nullptr, 1); + } + } + } + fileClose(mods); + } + return 0; } diff --git a/src/game_movie.cc b/src/game_movie.cc index 29a63de..9eb8e1f 100644 --- a/src/game_movie.cc +++ b/src/game_movie.cc @@ -52,6 +52,8 @@ static const char* gMovieFileNames[MOVIE_COUNT] = { "credits.mve", }; +static std::string gMovieFileNamesOverrides[MOVIE_COUNT]; + // 0x518DE4 static const char* gMoviePaletteFilePaths[MOVIE_COUNT] = { nullptr, @@ -89,6 +91,20 @@ static char gGameMovieSubtitlesFilePath[COMPAT_MAX_PATH]; // 0x44E5C0 int gameMoviesInit() { + Config moviesConfig; + if (configInit(&moviesConfig)) { + if (configRead(&moviesConfig, "ddraw.ini", false)) { + for (int movie = 0; movie < MOVIE_COUNT; movie++) { + char* movieOverride; + if (configGetString(&moviesConfig, "Misc", ("Movie" + std::to_s tring(movie + 1)).c_str(), &movieOverride)) { + gMovieFileNamesOverrides[movie] = movieOverride; + gMovieFileNames[movie] = gMovieFileNamesOverrides[movie].c_ str(); + } + } + } + configFree(&moviesConfig); + } + int v1 = 0; if (backgroundSoundIsEnabled()) { v1 = backgroundSoundGetVolume(); diff --git a/src/platform_compat.cc b/src/platform_compat.cc index 95c6eba..188f16c 100644 --- a/src/platform_compat.cc +++ b/src/platform_compat.cc @@ -361,6 +361,39 @@ void compat_resolve_path(char* path) pch = sep + 1; } +#else + char* mask = malloc(strlen(path) * 4 + 1); + { + char* m = mask; + for (const char* p = path; *p; p++) + { + if (std::isletter(*p)) + { + *m++ = '['; + *m++ = std::toupper(*p); + *m++ = std::tolower(*p); + *m++ = ']'; + } + else if (*p == '/') + { + *m++ = *p; + } + else + { + *m++ = '\\'; + *m++ = *p; + } + } + *m = '\0'; + } + glob_t g; + glob(mask, 0, nullptr, &g); + if (g.gl_pathc) + { + assert(strlen(path) == strlen(g.gl_pathv[0])); + strcpy(path, g.gl_pathv[0]); + } + free(mask); #endif } diff --git a/src/worldmap.cc b/src/worldmap.cc index 4d2495f..7c76c80 100644 --- a/src/worldmap.cc +++ b/src/worldmap.cc @@ -2530,10 +2530,12 @@ static int wmAreaInit() configFree(&cfg); +#if 0 if (wmMaxAreaNum != CITY_COUNT) { showMesageBox("\nwmAreaInit::Error loading Cities!"); exit(1); } +#endif return 0; }