Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion KBotExt/Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <vector>
#include <string>

#define RandomInt(min, max) (rand() % (max - min + 1) + min)
//#define RandomInt(min, max) (rand() % (max - min + 1) + min)

struct ChampMinimal
{
Expand Down
4 changes: 2 additions & 2 deletions KBotExt/KBotExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ int WINAPI wWinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPWSTR
#endif

//Randomize using current time, todo swap with recent c++ random
srand(static_cast<unsigned>(time(0)));
//srand(static_cast<unsigned>(time(0)));

Config::Load();
std::wstring sClassName = Utils::RandomWString(RandomInt(5, 10), { 0x2e80, 0xfffff });
std::wstring sClassName = Utils::RandomWString(Utils::RandomInt(5, 10), { 0x2e80, 0xfffff });
LPCWSTR lpszOverlayClassName = sClassName.c_str();
//Register window class information
WNDCLASSEXW wc = { sizeof(WNDCLASSEXW), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, sClassName.c_str(), NULL };
Expand Down
10 changes: 10 additions & 0 deletions KBotExt/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@
#include <filesystem>
#include <array>
#include <cwctype>
#include <random>
//URLDownloadToFileA
#include <urlmon.h>
#pragma comment(lib, "urlmon.lib")

#include "Utils.h"
#include "Definitions.h"

int Utils::RandomInt(int min, int max)
{
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> distr(min, max);

return distr(gen);
}

std::string Utils::ToLower(std::string str)
{
std::transform(str.begin(), str.end(), str.begin(),
Expand Down
2 changes: 2 additions & 0 deletions KBotExt/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class Utils
Utils() = default;
~Utils() = default;

static int RandomInt(int min, int max);

static std::string ToLower(std::string str);
static std::wstring ToLower(std::wstring wstr);

Expand Down