Guest User

Untitled

a guest
Jan 20th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. ifstream myfile ("Save.sav");
  2. string line = "";
  3. if (myfile.is_open())
  4. {
  5. while ( myfile.good() )
  6. {
  7. getline (myfile,line);
  8.  
  9. }
  10. myfile.close();
  11.  
  12. line = StaticFunctions::decrypt(line);
  13.  
  14. }
  15. vector<string> splitString = StaticFunctions::splitString(line, 's');
  16. return atoi(splitString[0].c_str());
  17.  
  18. vector<string> StaticFunctions::splitString(string str, char splitByThis)
  19. {
  20. vector<string> tempVector;
  21. unsigned int pos = str.find(splitByThis);
  22. unsigned int initialPos = 0;
  23.  
  24. // Decompose statement
  25. while( pos != std::string::npos ) {
  26. tempVector.push_back(str.substr( initialPos, pos - initialPos + 1 ) );
  27. initialPos = pos + 1;
  28.  
  29. pos = str.find(splitByThis, initialPos );
  30. }
  31.  
  32. // Add the last one
  33. tempVector.push_back(str.substr(initialPos, std::min(pos, str.size()) - initialPos + 1));
  34.  
  35. return tempVector;
  36.  
  37. string StaticFunctions::decrypt(string decryptThis)
  38. {
  39. for(int x = 0; x < decryptThis.length(); x++)
  40. {
  41. switch(decryptThis[x])
  42. {
  43. case '*':
  44. {
  45. decryptThis[x] = '0';
  46. break;
  47. }
  48. case '?':
  49. {
  50. decryptThis[x] = '1';
  51. break;
  52. }
  53. case '!':
  54. {
  55. decryptThis[x] = '2';
  56. break;
  57. }
  58. case '=':
  59. {
  60. decryptThis[x] = '3';
  61. break;
  62. }
  63. case '#':
  64. {
  65. decryptThis[x] = '4';
  66. break;
  67. }
  68. case '^':
  69. {
  70. decryptThis[x] = '5';
  71. break;
  72. }
  73. case '%':
  74. {
  75. decryptThis[x] = '6';
  76. break;
  77. }
  78. case '+':
  79. {
  80. decryptThis[x] = '7';
  81. break;
  82. }
  83. case '-':
  84. {
  85. decryptThis[x] = '8';
  86. break;
  87. }
  88. case '"':
  89. {
  90. decryptThis[x] = '9';
  91. break;
  92. }
  93. }
  94. }
  95. return decryptThis;
  96. }
Add Comment
Please, Sign In to add comment