Skip to content

Commit f49baf1

Browse files
committed
Randomize window title
1 parent 5f62440 commit f49baf1

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

app/window.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <stdexcept>
88
#include <imgui/backends/imgui_impl_dx9.h>
99
#include <imgui/backends/imgui_impl_win32.h>
10+
#include <random>
1011

1112
#include <maniac/common.h>
1213

@@ -87,6 +88,32 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
8788
return ::DefWindowProc(hWnd, msg, wParam, lParam);
8889
}
8990

91+
static std::string generate_random_string(int length) {
92+
std::string random_string;
93+
std::random_device rd;
94+
std::mt19937 gen(rd());
95+
std::uniform_int_distribution<> distrib(0, 61);
96+
97+
for (int i = 0; i < length; ++i) {
98+
int random_index = distrib(gen);
99+
char random_char;
100+
if (random_index < 10) {
101+
random_char = '0' + random_index;
102+
} else if (random_index < 36) {
103+
random_char = 'A' + (random_index - 10);
104+
} else {
105+
random_char = 'a' + (random_index - 36);
106+
}
107+
random_string += random_char;
108+
}
109+
110+
return random_string;
111+
}
112+
113+
static void randomize_window_title(const HWND window) {
114+
SetWindowTextA(window, generate_random_string(16).c_str());
115+
}
116+
90117
void window::start(const std::function<void()> &body) {
91118
// TODO: Refactor this into something readable
92119

@@ -98,6 +125,8 @@ void window::start(const std::function<void()> &body) {
98125
HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("maniac"), WS_OVERLAPPEDWINDOW, 100, 100, 550,
99126
420, NULL, NULL, wc.hInstance, NULL);
100127

128+
randomize_window_title(hwnd);
129+
101130
// Initialize Direct3D
102131
if (!CreateDeviceD3D(hwnd)) {
103132
CleanupDeviceD3D();

lib/osu.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ std::vector<HitObject> Osu::get_hit_objects() {
7474
debug("failed getting map player, rescanning")
7575
player_pointer = read_memory<uintptr_t>(find_signature(signatures::player));
7676

77+
// TODO: Break recursion at some point if it keeps failing, maybe exponential back off for some
78+
// time and then fatal error.
7779
return get_hit_objects();
7880
}
7981
}

0 commit comments

Comments
 (0)