MCPcopy Create free account
hub / github.com/TurningWheel/Barony / physfsModelIndexUpdate

Function physfsModelIndexUpdate

src/files.cpp:3954–4056  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3952}
3953
3954bool physfsModelIndexUpdate(int &start, int &end)
3955{
3956 if ( !PHYSFS_getRealDir("models/models.txt") )
3957 {
3958 printlog("error: could not find file: %s", "models/models.txt");
3959 return false;
3960 }
3961
3962 std::string modelsDirectory = PHYSFS_getRealDir("models/models.txt");
3963 modelsDirectory.append(PHYSFS_getDirSeparator()).append("models/models.txt");
3964
3965 File* fp = openDataFile(modelsDirectory.c_str(), "rb");
3966 if ( !fp )
3967 {
3968 return false;
3969 }
3970 char modelName[PATH_MAX];
3971 int startnum = 0;
3972 int endnum = nummodels;
3973 for ( int c = 0; !fp->eof(); c++ )
3974 {
3975 fp->gets2(modelName, PATH_MAX);
3976 bool modelHasBeenModified = false;
3977 // has this model index been modified?
3978 std::vector<int>::iterator it = Mods::modelsListModifiedIndexes.end();
3979 if ( !Mods::modelsListModifiedIndexes.empty() )
3980 {
3981 it = std::find(Mods::modelsListModifiedIndexes.begin(),
3982 Mods::modelsListModifiedIndexes.end(), c);
3983 if ( it != Mods::modelsListModifiedIndexes.end() )
3984 {
3985 modelHasBeenModified = true; // found the model in the vector.
3986 }
3987 }
3988
3989 if ( !PHYSFS_getRealDir(modelName) )
3990 {
3991 printlog("error: could not find file: %s", modelName);
3992 continue;
3993 }
3994 std::string modelPath = PHYSFS_getRealDir(modelName);
3995 if ( modelHasBeenModified || modelPath.compare("./") != 0 )
3996 {
3997 if ( !modelHasBeenModified )
3998 {
3999 // add this model index to say we've modified it as the base dir is not default.
4000 Mods::modelsListModifiedIndexes.push_back(c);
4001 }
4002 else
4003 {
4004 if ( modelPath.compare("./") == 0 )
4005 {
4006 // model returned to base directory, remove from the modified index list.
4007 Mods::modelsListModifiedIndexes.erase(it);
4008 }
4009 }
4010
4011 if ( c < nummodels )

Callers 3

unloadModsMethod · 0.85
loadModsMethod · 0.85
handleMainMenuFunction · 0.85

Calls 11

printlogFunction · 0.85
openDataFileFunction · 0.85
findFunction · 0.85
loadVoxelFunction · 0.85
appendMethod · 0.80
c_strMethod · 0.80
eofMethod · 0.80
gets2Method · 0.80
endMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected