Guest User

Untitled

a guest
Feb 19th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. std::wstring TextMutator::MutateWText(const wchar_t* text)
  2. {
  3.     const wchar_t* replacements[] =
  4.     {
  5.         L"$COINS$",
  6.         //Добавить новый мутатор сюда
  7.     };
  8.     size_t replacements_count = sizeof(replacements) / sizeof(replacements[0]);
  9.  
  10.     size_t len = wcslen(text);
  11.     std::wstringstream result_stream;
  12.     result_stream.str().reserve(len);
  13.     for (size_t i = 0; i < len; i++)
  14.     {
  15.         const wchar_t c = text[i];
  16.        
  17.         if (c == L'$')
  18.         {
  19.             for (size_t j = 0; j < replacements_count; j++)
  20.                 if (mutator_cmp(&text[i], replacements[j]))
  21.                 {
  22.                     result_stream << gData->GetCurrency();
  23.                     i += wcslen(replacements[j]) - 1;
  24.                     continue;
  25.                 }
  26.         }
  27.        
  28.         result_stream << c;
  29.     }
  30.  
  31.     return result_stream.str();
  32. }
Add Comment
Please, Sign In to add comment