Advertisement
Guest User

Untitled

a guest
Aug 1st, 2011
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. Index: src/client/psengine.cpp
  2. ===================================================================
  3. --- src/client/psengine.cpp (Revision 7573)
  4. +++ src/client/psengine.cpp (Arbeitskopie)
  5. @@ -434,6 +434,87 @@
  6. csString skinPathBase = cfgmgr->GetStr("PlaneShift.GUI.Skin.Base","/planeshift/art/skins/base/client_base.zip");
  7. paws = new PawsManager(object_reg, skinPath, skinPathBase);
  8.  
  9. + //get files in the mod folder
  10. + csString mod_folder = "/planeshift/art/mods/";
  11. + csRef<iStringArray> mod_files = vfs->FindFiles(mod_folder);
  12. +
  13. + if(mod_files.IsValid())
  14. + {
  15. + csString mod_tmp = "/planeshift/tmp_mod/";
  16. + csArray<csString> mod_realpaths;
  17. + csArray<csString> mod_mountpaths;
  18. + csArray<csString> xml_realpaths;
  19. + csArray<csString> xml_mountpaths;
  20. +
  21. + // sort the files and get the size
  22. + mod_files->Sort();
  23. + size_t mod_size = mod_files->GetSize();
  24. + mod_realpaths.SetSize(mod_size);
  25. + mod_mountpaths.SetSize(mod_size);
  26. + size_t j = 0; // counter for unwanted files
  27. +
  28. + // get mountpaths for mod files from xml
  29. + for(size_t i = 0; i < mod_size; i++)
  30. + {
  31. + csString file = mod_files->Get(i);
  32. + size_t dot = file.FindLast(".");
  33. + csString ext = file.Slice(dot+1);
  34. +
  35. + if(ext == "zip")
  36. + {
  37. + printf("Mounting mod: %s\n", file.GetData());
  38. +
  39. + csRef<iDataBuffer> mod_realPath = vfs->GetRealPath(file);
  40. + if(mod_realPath.IsValid())
  41. + mod_realpaths[i] = mod_realPath->GetData();
  42. + else
  43. + Error2("Could not mount the mod at %s. Bad virtual path.",file.GetData());
  44. +
  45. + if(!vfs->Mount(mod_tmp, mod_realpaths[i]))
  46. + Error2("Could not mount the mod at %s!",file.GetData());
  47. +
  48. + csRef<iDocument> mod_xml = ParseFile(object_reg,mod_tmp + "mod.xml");
  49. + if(!mod_xml)
  50. + Error2("Could not read mod.xml in %s!",file.GetData());
  51. +
  52. + csRef<iDocumentNode> mod_root = mod_xml->GetRoot();
  53. + if(!mod_root)
  54. + Error2( "mod.xml badly formed in %s!",file.GetData());
  55. +
  56. + mod_root = mod_root->GetNode("xml");
  57. + if(!mod_root)
  58. + Error2( "Could not find xml node in %s!",file.GetData());
  59. +
  60. + csRef<iDocumentNode> mod_mount = mod_root->GetNode("mount_path");
  61. + if(!mod_mount)
  62. + Error1("There was no mount_path found in the mod.xml file. Please check the <xml> node to make sure mount_path is defined");
  63. +
  64. + // store mount paths in arrays
  65. + mod_mountpaths[i] = mod_mount->GetContentsValue();
  66. + xml_mountpaths.PushSmart(mod_mount->GetContentsValue());
  67. + csRef<iDataBuffer> xml_realPath = vfs->GetRealPath(mod_mountpaths[i]);
  68. + xml_realpaths.PushSmart(xml_realPath->GetData());
  69. +
  70. + // Unmount the temp location
  71. + vfs->Unmount(mod_tmp,0);
  72. + }
  73. + else
  74. + j++;
  75. + }
  76. +
  77. + // unmount all effected paths
  78. + for(size_t i = 0; i < xml_realpaths.GetSize(); i++)
  79. + vfs->Unmount(xml_mountpaths[i],xml_realpaths[i]);
  80. +
  81. + // mount mods
  82. + for(size_t i = 0; i < mod_size-j; i++)
  83. + vfs->Mount(mod_mountpaths[i],mod_realpaths[i]);
  84. +
  85. + // remount folders again
  86. + for(size_t i = 0; i < xml_realpaths.GetSize(); i++)
  87. + vfs->Mount(xml_mountpaths[i],xml_realpaths[i]);
  88. + }
  89. +
  90. options = new psOptions("/planeshift/userdata/options.cfg", vfs);
  91.  
  92. // Default to maximum 71 fps
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement