| 3952 | } |
| 3953 | |
| 3954 | bool 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 ) |