diff options
-rw-r--r-- | App/Main.cpp | 32 | ||||
-rw-r--r-- | Source/Memory.h | 8 | ||||
-rw-r--r-- | Source/Randomizer2.cpp | 2 |
3 files changed, 31 insertions, 11 deletions
diff --git a/App/Main.cpp b/App/Main.cpp index f780069..f5409ff 100644 --- a/App/Main.cpp +++ b/App/Main.cpp | |||
@@ -10,6 +10,7 @@ | |||
10 | #include "Memory.h" | 10 | #include "Memory.h" |
11 | #include "Random.h" | 11 | #include "Random.h" |
12 | #include "Randomizer.h" | 12 | #include "Randomizer.h" |
13 | #include "Randomizer2.h" | ||
13 | 14 | ||
14 | // Heartbeat is defined to 0x401 by Memory.h | 15 | // Heartbeat is defined to 0x401 by Memory.h |
15 | #define RANDOMIZE_READY 0x402 | 16 | #define RANDOMIZE_READY 0x402 |
@@ -23,7 +24,6 @@ | |||
23 | /* ------- Temp ------- */ | 24 | /* ------- Temp ------- */ |
24 | #include "Puzzle.h" | 25 | #include "Puzzle.h" |
25 | #include "Solver.h" | 26 | #include "Solver.h" |
26 | #include "Randomizer2.h" | ||
27 | #include "PuzzleSerializer.h" | 27 | #include "PuzzleSerializer.h" |
28 | #include <sstream> | 28 | #include <sstream> |
29 | 29 | ||
@@ -34,7 +34,9 @@ | |||
34 | 34 | ||
35 | HWND g_panelId; | 35 | HWND g_panelId; |
36 | Puzzle g_puzzle; | 36 | Puzzle g_puzzle; |
37 | std::shared_ptr<Randomizer2> g_randomizer2; | 37 | |
38 | HWND g_rngDebug; | ||
39 | #define TMP5 0x505 | ||
38 | /* ------- Temp ------- */ | 40 | /* ------- Temp ------- */ |
39 | 41 | ||
40 | // Globals | 42 | // Globals |
@@ -44,6 +46,7 @@ HWND g_randomizerStatus; | |||
44 | HINSTANCE g_hInstance; | 46 | HINSTANCE g_hInstance; |
45 | auto g_witnessProc = std::make_shared<Memory>(L"witness64_d3d11.exe"); | 47 | auto g_witnessProc = std::make_shared<Memory>(L"witness64_d3d11.exe"); |
46 | std::shared_ptr<Randomizer> g_randomizer; | 48 | std::shared_ptr<Randomizer> g_randomizer; |
49 | std::shared_ptr<Randomizer2> g_randomizer2; | ||
47 | void SetRandomSeed(); | 50 | void SetRandomSeed(); |
48 | 51 | ||
49 | LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { | 52 | LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { |
@@ -168,6 +171,16 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) | |||
168 | case TMP4: | 171 | case TMP4: |
169 | SetRandomSeed(); | 172 | SetRandomSeed(); |
170 | g_randomizer2->Randomize(); | 173 | g_randomizer2->Randomize(); |
174 | case TMP5: | ||
175 | { | ||
176 | std::wstring text; | ||
177 | for (int i=0; i<10; i++) { | ||
178 | Random::SetSeed(i); | ||
179 | int rng = Random::RandInt(0, 999999); | ||
180 | text += std::to_wstring(rng) + L"\n"; | ||
181 | } | ||
182 | SetWindowText(g_rngDebug, text.c_str()); | ||
183 | } | ||
171 | } | 184 | } |
172 | } | 185 | } |
173 | return DefWindowProc(hwnd, message, wParam, lParam); | 186 | return DefWindowProc(hwnd, message, wParam, lParam); |
@@ -250,11 +263,16 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance | |||
250 | CreateCheckbox(10, 340, SPEED_UP_AUTOSCROLLERS); | 263 | CreateCheckbox(10, 340, SPEED_UP_AUTOSCROLLERS); |
251 | CreateLabel(30, 340, 205, L"Speed up various autoscrollers"); | 264 | CreateLabel(30, 340, 205, L"Speed up various autoscrollers"); |
252 | 265 | ||
253 | g_panelId = CreateText(200, 100, 100, L"A3B2"); | 266 | CreateButton(200, 50, 200, L"Test RNG", TMP5); |
254 | CreateButton(200, 130, 100, L"Read", TMP1); | 267 | g_rngDebug = CreateWindow(L"STATIC", L"", |
255 | CreateButton(200, 160, 100, L"Write", TMP2); | 268 | WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT, |
256 | CreateButton(200, 190, 100, L"Solve", TMP3); | 269 | 200, 80, 200, 200, g_hwnd, NULL, g_hInstance, NULL); |
257 | CreateButton(200, 220, 100, L"Randomize2", TMP4); | 270 | |
271 | // g_panelId = CreateText(200, 100, 100, L"A3B2"); | ||
272 | // CreateButton(200, 130, 100, L"Read", TMP1); | ||
273 | // CreateButton(200, 160, 100, L"Write", TMP2); | ||
274 | // CreateButton(200, 190, 100, L"Solve", TMP3); | ||
275 | // CreateButton(200, 220, 100, L"Randomize2", TMP4); | ||
258 | 276 | ||
259 | g_witnessProc->StartHeartbeat(g_hwnd); | 277 | g_witnessProc->StartHeartbeat(g_hwnd); |
260 | 278 | ||
diff --git a/Source/Memory.h b/Source/Memory.h index 79fbaba..5332cc3 100644 --- a/Source/Memory.h +++ b/Source/Memory.h | |||
@@ -5,8 +5,8 @@ | |||
5 | #include <vector> | 5 | #include <vector> |
6 | #include <windows.h> | 6 | #include <windows.h> |
7 | 7 | ||
8 | #define GLOBALS 0x5B28C0 | 8 | // #define GLOBALS 0x5B28C0 |
9 | // #define GLOBALS 0x62D0A0 | 9 | #define GLOBALS 0x62D0A0 |
10 | 10 | ||
11 | #define HEARTBEAT 0x401 | 11 | #define HEARTBEAT 0x401 |
12 | enum class ProcStatus { | 12 | enum class ProcStatus { |
@@ -188,8 +188,8 @@ private: | |||
188 | #define METADATA 0xF2 // sizeof(short) | 188 | #define METADATA 0xF2 // sizeof(short) |
189 | #define HOTEL_EP_NAME 0x4BC640 | 189 | #define HOTEL_EP_NAME 0x4BC640 |
190 | #elif GLOBALS == 0x62D0A0 | 190 | #elif GLOBALS == 0x62D0A0 |
191 | #define POSITION #error | 191 | #define POSITION 0x24 |
192 | #define ORIENTATION #error | 192 | #define ORIENTATION 0x34 |
193 | #define PATH_COLOR 0xC0 | 193 | #define PATH_COLOR 0xC0 |
194 | #define REFLECTION_PATH_COLOR 0xD0 | 194 | #define REFLECTION_PATH_COLOR 0xD0 |
195 | #define DOT_COLOR 0xF0 | 195 | #define DOT_COLOR 0xF0 |
diff --git a/Source/Randomizer2.cpp b/Source/Randomizer2.cpp index adf8eb6..00b584e 100644 --- a/Source/Randomizer2.cpp +++ b/Source/Randomizer2.cpp | |||
@@ -34,6 +34,7 @@ void Randomizer2::RandomizeTutorial() { | |||
34 | Puzzle p; | 34 | Puzzle p; |
35 | p.NewGrid(6, 6); | 35 | p.NewGrid(6, 6); |
36 | 36 | ||
37 | // @Bug: Mid-segment endpoints are not yet supported. | ||
37 | switch (Random::RandInt(1, 4)) { | 38 | switch (Random::RandInt(1, 4)) { |
38 | case 1: | 39 | case 1: |
39 | p.grid[Random::RandInt(0, p.width-1)][0].end = Cell::Dir::UP; | 40 | p.grid[Random::RandInt(0, p.width-1)][0].end = Cell::Dir::UP; |
@@ -93,6 +94,7 @@ void Randomizer2::RandomizeTutorial() { | |||
93 | p.grid[12][12].start = true; | 94 | p.grid[12][12].start = true; |
94 | p.grid[6][0].end = Cell::Dir::UP; | 95 | p.grid[6][0].end = Cell::Dir::UP; |
95 | 96 | ||
97 | // @Cleanup | ||
96 | std::vector<Pos> cuts; | 98 | std::vector<Pos> cuts; |
97 | bool toTheRight; | 99 | bool toTheRight; |
98 | // Start by generating a cut line, to ensure one of the two startpoints is inaccessible | 100 | // Start by generating a cut line, to ensure one of the two startpoints is inaccessible |