Advertisement
Guest User

TorqueScript Mission Fixer

a guest
Jul 11th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.54 KB | None | 0 0
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 Jeff Hutchinson
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22.  
  23. function fixMissions()
  24. {
  25.    echo("Fixing missions in progress.");
  26.    echo("It might take a while depending on how many mission files there are.");
  27.    echo("This will ignore leaderboard missions.");
  28.    echo("REMEMBER: when you are finished fixing, remove missionFix.cs and missionFix.cs.dso");
  29.    echo("          so that the anti hack will stop in the leaderboards.");
  30.    
  31.    // in 50 milliseconds, we will start.  Give the system time to show the echo.
  32.    schedule(50, 0, fixThoseMissions);
  33. }
  34.  
  35. function fixThoseMissions()
  36. {
  37.    // input and output streams
  38.    %fIn  = new FileObject();
  39.    %fOut = new FileObject();    
  40.    
  41.    // Itterate through all of the mission files.
  42.    %search = "*.mis";
  43.    %file = findFirstFile(%search);
  44.    while (%file !$= "")
  45.    {
  46.       // ignore Lb files
  47.       if (strStr(%file, "lbmissions") != -1 || strStr(%file, "lb_custom") != -1)
  48.          continue;      
  49.      
  50.       // grab the contents of every line in the file so that we can rewrite it
  51.       if (%fIn.openForRead(%file))
  52.       {
  53.          %count = 0;
  54.          while (!%fIn.isEOF())
  55.          {
  56.             // Jeff: parse the line
  57.             %currLine = %fIn.readLine();
  58.            
  59.             // Jeff: replace occurrences of marble/data | platinum/data | ~
  60.             // with $usermods @ "/data
  61.             %firstWord = firstWord(trim(%currLine));
  62.             if (%firstWord $= "interiorFile" || %firstWord $= "interiorResource")
  63.             {
  64.                %currLine = strreplace(%currLine, "\"marble/data", "$usermods @ \"/data");
  65.                %currLine = strreplace(%currLine, "\"platinum/data", "$usermods @ \"/data");
  66.                %currLine = strreplace(%currLine, "\"~/data", "$usermods @ \"/data");
  67.                
  68.                // this will auto correct any errors
  69.                %currLine = strreplace(%currLine, "\"$usermods @ \"/data", "$usermods @ \"/data");
  70.             }
  71.            
  72.             %line[%count] = %currLine;
  73.             %count ++;
  74.          }
  75.       }
  76.       %fIn.close();
  77.      
  78.       // now we write it out!
  79.       if (%fOut.openForWrite(%file))
  80.       {
  81.          for (%i = 0; %i < %count; %i ++)
  82.             %fOut.writeLine(%line[%i]);
  83.       }
  84.       %fOut.close();
  85.      
  86.       %file = findNextFile(%search);
  87.    }
  88.    
  89.    echo("DONE!  Please restart marble blast.");
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement