Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: src/client/psengine.cpp
- ===================================================================
- --- src/client/psengine.cpp (Revision 7573)
- +++ src/client/psengine.cpp (Arbeitskopie)
- @@ -434,6 +434,87 @@
- csString skinPathBase = cfgmgr->GetStr("PlaneShift.GUI.Skin.Base","/planeshift/art/skins/base/client_base.zip");
- paws = new PawsManager(object_reg, skinPath, skinPathBase);
- + //get files in the mod folder
- + csString mod_folder = "/planeshift/art/mods/";
- + csRef<iStringArray> mod_files = vfs->FindFiles(mod_folder);
- +
- + if(mod_files.IsValid())
- + {
- + csString mod_tmp = "/planeshift/tmp_mod/";
- + csArray<csString> mod_realpaths;
- + csArray<csString> mod_mountpaths;
- + csArray<csString> xml_realpaths;
- + csArray<csString> xml_mountpaths;
- +
- + // sort the files and get the size
- + mod_files->Sort();
- + size_t mod_size = mod_files->GetSize();
- + mod_realpaths.SetSize(mod_size);
- + mod_mountpaths.SetSize(mod_size);
- + size_t j = 0; // counter for unwanted files
- +
- + // get mountpaths for mod files from xml
- + for(size_t i = 0; i < mod_size; i++)
- + {
- + csString file = mod_files->Get(i);
- + size_t dot = file.FindLast(".");
- + csString ext = file.Slice(dot+1);
- +
- + if(ext == "zip")
- + {
- + printf("Mounting mod: %s\n", file.GetData());
- +
- + csRef<iDataBuffer> mod_realPath = vfs->GetRealPath(file);
- + if(mod_realPath.IsValid())
- + mod_realpaths[i] = mod_realPath->GetData();
- + else
- + Error2("Could not mount the mod at %s. Bad virtual path.",file.GetData());
- +
- + if(!vfs->Mount(mod_tmp, mod_realpaths[i]))
- + Error2("Could not mount the mod at %s!",file.GetData());
- +
- + csRef<iDocument> mod_xml = ParseFile(object_reg,mod_tmp + "mod.xml");
- + if(!mod_xml)
- + Error2("Could not read mod.xml in %s!",file.GetData());
- +
- + csRef<iDocumentNode> mod_root = mod_xml->GetRoot();
- + if(!mod_root)
- + Error2( "mod.xml badly formed in %s!",file.GetData());
- +
- + mod_root = mod_root->GetNode("xml");
- + if(!mod_root)
- + Error2( "Could not find xml node in %s!",file.GetData());
- +
- + csRef<iDocumentNode> mod_mount = mod_root->GetNode("mount_path");
- + if(!mod_mount)
- + Error1("There was no mount_path found in the mod.xml file. Please check the <xml> node to make sure mount_path is defined");
- +
- + // store mount paths in arrays
- + mod_mountpaths[i] = mod_mount->GetContentsValue();
- + xml_mountpaths.PushSmart(mod_mount->GetContentsValue());
- + csRef<iDataBuffer> xml_realPath = vfs->GetRealPath(mod_mountpaths[i]);
- + xml_realpaths.PushSmart(xml_realPath->GetData());
- +
- + // Unmount the temp location
- + vfs->Unmount(mod_tmp,0);
- + }
- + else
- + j++;
- + }
- +
- + // unmount all effected paths
- + for(size_t i = 0; i < xml_realpaths.GetSize(); i++)
- + vfs->Unmount(xml_mountpaths[i],xml_realpaths[i]);
- +
- + // mount mods
- + for(size_t i = 0; i < mod_size-j; i++)
- + vfs->Mount(mod_mountpaths[i],mod_realpaths[i]);
- +
- + // remount folders again
- + for(size_t i = 0; i < xml_realpaths.GetSize(); i++)
- + vfs->Mount(xml_mountpaths[i],xml_realpaths[i]);
- + }
- +
- options = new psOptions("/planeshift/userdata/options.cfg", vfs);
- // Default to maximum 71 fps
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement