NoTroop

My Awesome Config Generator

Jun 2nd, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.25 KB | None | 0 0
  1. #include <iostream> //Input/Output
  2. #include <string> //Manipulate Strings
  3. #include <fstream> //use <fstream> if you need to write as well.
  4.  
  5. using namespace std;
  6.  
  7. void addAutoexecLine();
  8. bool fileExists(const char *fileName);
  9. bool hasExec();
  10. void addMainConfig();
  11.  
  12. int main()
  13. {
  14.     addAutoexecLine();
  15.     addMainConfig();
  16.     return 0;
  17. }
  18.  
  19. void addAutoexecLine()
  20. {
  21.     if(fileExists("autoexec.cfg"))
  22.     {
  23.         fstream notroopsOpener;
  24.         notroopsOpener.open("autoexec.cfg", fstream::in | fstream::out | fstream::app);
  25.         if(!hasExec())
  26.         {
  27.             notroopsOpener << endl << "exec rxgservers.cfg";
  28.             notroopsOpener.close();
  29.         }
  30.         else
  31.         {
  32.             notroopsOpener.close();
  33.         }
  34.     }
  35.     else
  36.     {
  37.         ofstream outfile("autoexec.cfg");
  38.         addAutoexecLine();
  39.     }
  40. }
  41.  
  42. bool fileExists(const char *fileName)
  43. {
  44.     fstream infile(fileName);
  45.     return infile.good();
  46. }
  47.  
  48. bool hasExec()
  49. {
  50.     fstream checker;
  51.     checker.open("autoexec.cfg");
  52.     string line;
  53.    
  54.     while(getline( checker, line))
  55.     {
  56.         if ( line.find("exec rxgservers.cfg") != string::npos )
  57.         {
  58.             return true;
  59.         }
  60.     }
  61.     return false;
  62. }
  63.  
  64. void addMainConfig()
  65. {
  66.     if(!fileExists("rxgservers.cfg"))
  67.     {
  68.         ofstream outfile("rxgservers.cfg");
  69.         addMainConfig();
  70.     }
  71.     else
  72.     {
  73.         fstream notroopsOpenerTwo;
  74.         notroopsOpenerTwo.open("rxgservers.cfg");
  75.         notroopsOpenerTwo << "//Created by NoTroop, Idea shamelessly stolen from the below post on reddit\n//http://www.reddit.com/r/truetf2/comments/1fbn2x/server_aliases_for_pugna_tf2mix_dm_mge_jump_surf/\n\n//Reflex-Gamers 24/7 Stock Rotation.\nalias \"stock\" \"connect 74.91.120.34:27015;\"\n\n//Reflex-Gamers 24/7 Turbine.\nalias \"turbine\" \"connect 74.201.57.124:27015;\"\n\n//Reflex-Gamers 24/7 Payload Rotation.\nalias \"payload\" \"connect 74.91.126.28:27015;\"\n\n//Reflex-Gamers 24/7 2Fort.\nalias \"2fort\" \"connect 74.91.114.113:27015;\"\n\n//Reflex-Gamers 24/7 10x Mayhem\nalias \"mayhem\" \"connect 74.201.57.57:27015;\"\n\n//Reflex-Gamers 24/7 Scrim Server //Just a note about this one, it won't work for matches, as the server will be passworded.\nalias \"mge\" \"connect 66.150.214.229:27015;\" //Used mge because it won't work during matches.\n\n//Reflex-Gamers24/7 Events\nalias \"events\" \"connect 66.151.244.135:27015;\"";
  76.     }
  77. }
Add Comment
Please, Sign In to add comment