mirror of
https://github.com/rwengine/openrw.git
synced 2025-04-28 21:08:05 +03:00
rwengine,rwgame: Avoid loading models/gta3.img
twice.
This commit is contained in:
parent
7d73e199c8
commit
edaab68525
3 changed files with 16 additions and 14 deletions
|
@ -41,7 +41,11 @@ GameData::GameData(Logger* log, const rwfs::path& path)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameData::load() {
|
bool GameData::load() {
|
||||||
|
if (!isValidGameDirectory()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
index.indexTree(datpath);
|
index.indexTree(datpath);
|
||||||
|
|
||||||
loadIMG("models/gta3.img");
|
loadIMG("models/gta3.img");
|
||||||
|
@ -78,6 +82,8 @@ void GameData::load() {
|
||||||
|
|
||||||
// Load ped groups after IDEs so they can resolve
|
// Load ped groups after IDEs so they can resolve
|
||||||
loadPedGroups("data/pedgrp.dat");
|
loadPedGroups("data/pedgrp.dat");
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameData::loadLevelFile(const std::string& path) {
|
void GameData::loadLevelFile(const std::string& path) {
|
||||||
|
@ -759,13 +765,11 @@ float GameData::getWaveHeightAt(const glm::vec3& ws) const {
|
||||||
WATER_HEIGHT;
|
WATER_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameData::isValidGameDirectory(const rwfs::path& path) {
|
bool GameData::isValidGameDirectory() const {
|
||||||
rwfs::error_code ec;
|
rwfs::error_code ec;
|
||||||
if (!rwfs::is_directory(path, ec)) {
|
if (!rwfs::is_directory(datpath, ec)) {
|
||||||
std::cerr << "first test failed\n";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoaderIMG i;
|
return !ec;
|
||||||
return i.load(path / "models/gta3.img");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ public:
|
||||||
void loadWaterpro(const std::string& path);
|
void loadWaterpro(const std::string& path);
|
||||||
void loadWater(const std::string& path);
|
void loadWater(const std::string& path);
|
||||||
|
|
||||||
void load();
|
bool load();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads model, placement, models and textures from a level file
|
* Loads model, placement, models and textures from a level file
|
||||||
|
@ -359,10 +359,11 @@ public:
|
||||||
|
|
||||||
GameTexts texts;
|
GameTexts texts;
|
||||||
|
|
||||||
|
private:
|
||||||
/**
|
/**
|
||||||
* Determines whether the given path is a valid game directory.
|
* Determines whether the given path is a valid game directory.
|
||||||
*/
|
*/
|
||||||
static bool isValidGameDirectory(const rwfs::path& path);
|
bool isValidGameDirectory() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -72,17 +72,14 @@ RWGame::RWGame(Logger& log, const std::optional<RWArgConfigLayer> &args)
|
||||||
benchFile = args->benchmarkPath;
|
benchFile = args->benchmarkPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("Game", "Game directory: " + config.gamedataPath());
|
imgui.init();
|
||||||
|
|
||||||
if (!GameData::isValidGameDirectory(config.gamedataPath())) {
|
log.info("Game", "Game directory: " + config.gamedataPath());
|
||||||
|
if (!data.load()) {
|
||||||
throw std::runtime_error("Invalid game directory path: " +
|
throw std::runtime_error("Invalid game directory path: " +
|
||||||
config.gamedataPath());
|
config.gamedataPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
imgui.init();
|
|
||||||
|
|
||||||
data.load();
|
|
||||||
|
|
||||||
for (const auto& [specialModel, fileName, name] : kSpecialModels) {
|
for (const auto& [specialModel, fileName, name] : kSpecialModels) {
|
||||||
auto model = data.loadClump(fileName, name);
|
auto model = data.loadClump(fileName, name);
|
||||||
renderer.setSpecialModel(specialModel, model);
|
renderer.setSpecialModel(specialModel, model);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue