From 0cb49374a6d86100cd6f3bf838e79bdbac242a8e Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Mon, 4 Nov 2019 08:43:31 -0800 Subject: Starting to clean up... --- Source/Memory.cpp | 24 +++++++++++++------- Source/Memory.h | 3 ++- Source/Randomizer.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ Source/Randomizer.h | 2 +- Source/Source.vcxproj | 20 ++++------------ 5 files changed, 87 insertions(+), 25 deletions(-) (limited to 'Source') diff --git a/Source/Memory.cpp b/Source/Memory.cpp index 7bc3b2f..1f1ae0a 100644 --- a/Source/Memory.cpp +++ b/Source/Memory.cpp @@ -6,12 +6,16 @@ #undef PROCESSENTRY32 #undef Process32Next -Memory::Memory(const std::string& processName) { +Memory::Memory() { +} + +[[nodiscard]] +bool Memory::Initialize(const std::wstring& processName) { // First, get the handle of the process - PROCESSENTRY32 entry; + PROCESSENTRY32W entry; entry.dwSize = sizeof(entry); HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - while (Process32Next(snapshot, &entry)) { + while (Process32NextW(snapshot, &entry)) { if (processName == entry.szExeFile) { _handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID); break; @@ -19,7 +23,7 @@ Memory::Memory(const std::string& processName) { } if (!_handle) { std::cerr << "Couldn't find " << processName.c_str() << ", is it open?" << std::endl; - throw std::exception("Unable to find process!"); + return false; } // Next, get the process base address @@ -27,9 +31,9 @@ Memory::Memory(const std::string& processName) { std::vector moduleList(1024); EnumProcessModulesEx(_handle, &moduleList[0], static_cast(moduleList.size()), &numModules, 3); - std::string name(64, '\0'); + std::wstring name(64, '\0'); for (DWORD i = 0; i < numModules / sizeof(HMODULE); i++) { - int length = GetModuleBaseNameA(_handle, moduleList[i], &name[0], static_cast(name.size())); + int length = GetModuleBaseNameW(_handle, moduleList[i], &name[0], static_cast(name.size())); name.resize(length); if (processName == name) { _baseAddress = (uintptr_t)moduleList[i]; @@ -37,12 +41,16 @@ Memory::Memory(const std::string& processName) { } } if (_baseAddress == 0) { - throw std::exception("Couldn't find the base process address!"); + std::cerr << "Couldn't locate base address" << std::endl; + return false; } + return true; } Memory::~Memory() { - CloseHandle(_handle); + if (_handle != nullptr) { + CloseHandle(_handle); + } } int Memory::GetCurrentFrame() diff --git a/Source/Memory.h b/Source/Memory.h index cce06ba..9c00dab 100644 --- a/Source/Memory.h +++ b/Source/Memory.h @@ -14,7 +14,8 @@ class Memory { public: - Memory(const std::string& processName); + Memory(); + bool Initialize(const std::wstring& processName); ~Memory(); Memory(const Memory& memory) = delete; diff --git a/Source/Randomizer.cpp b/Source/Randomizer.cpp index 5e57ca3..71ec89b 100644 --- a/Source/Randomizer.cpp +++ b/Source/Randomizer.cpp @@ -1,3 +1,66 @@ +/* +Things to do for V2: +- Better interface design. It's way too simplistic, take (some) notes from talos. + - Seed: [ ] (Randomize) + ?? Challenge + + - [] Prevent speedrun snipes // Shadows, Swamp, Town, Quarry stairs + - [] Speed up various autoscrollers // Swamp platforms, Desert/Mountain elevators, Desert rotating panels + + (Additional required panels) + - [] Desert 8 + - [] Pond 5 + - [] Both keep halves + - [] Town lattice requires stars door // and stars door will be randomized + + (Debug version only) + - [] Noclip + - [] Noclip speed + + +- Really randomize panels. Sorted by ROI + - Random with style + - Tutorial + - Mountain 1 orange, green, blue, purple + - Mountain 2 multipanel + - Mountain 3 pillars + - Laser areas (Glass Factory, Symmetry, Quarry, Treehouse, Swamp, Keep pressure plates, Town 25 dots) + - (low) Discarded panels + - (low) Tutorials // Dots, Stones, Swamp + + - Keep Hedges become like hedges 4, intersection between path and panel + - Keep Pressure plates: Random with style + + - No idea how to randomize: + - Symmetry transparent + - Desert + - Shadows + - Town (lattice, RGB area, snipes, triple) + - Monastery + - Jungle + - Bunker + - UTM + - Mountain 2 rainbow + - Challenge + +- Any RNG rerolls should be based on previous seed so that everyone can go to next seed easily + +- Stability. Duh. I need to clearly define the ownership between the randomizer and the game. + +- Challenge should have some way to 'reroll every run' +- Challenge should not turn off after time limit? +- Challenge triangles should not turn off + + + + +*/ + + + + + + /* * Try to wire up both keep halves * Wire up both halves of symmetry laser diff --git a/Source/Randomizer.h b/Source/Randomizer.h index 6029513..020851b 100644 --- a/Source/Randomizer.h +++ b/Source/Randomizer.h @@ -45,7 +45,7 @@ private: void ReassignTargets(const std::vector& panels, const std::vector& order, std::vector targets = {}); void ReassignNames(const std::vector& panels, const std::vector& order); - std::shared_ptr _memory = std::make_shared("witness64_d3d11.exe"); + std::shared_ptr _memory = std::make_shared(L"witness64_d3d11.exe"); friend class SwapTests_Shipwreck_Test; }; diff --git a/Source/Source.vcxproj b/Source/Source.vcxproj index cf6756a..3e66f83 100644 --- a/Source/Source.vcxproj +++ b/Source/Source.vcxproj @@ -23,32 +23,32 @@ {6B5DF051-A51A-48CB-8ACD-C6FAD726019F} Win32Proj Source - 10.0.17134.0 + 10.0 StaticLibrary true - v141 + v142 Unicode StaticLibrary false - v141 + v142 true Unicode StaticLibrary true - v141 + v142 Unicode StaticLibrary false - v141 + v142 true Unicode @@ -157,20 +157,10 @@ - - - - - - - - - - -- cgit 1.4.1