about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--Installer/Installer.vdproj6
-rw-r--r--Source/Main.cpp13
-rw-r--r--Source/Random.h3
-rw-r--r--Source/Randomizer.cpp17
-rw-r--r--Source/Randomizer.h2
-rw-r--r--Source/RandomizerCore.cpp19
-rw-r--r--Source/RandomizerCore.h9
-rw-r--r--Source/Resource.h26
-rw-r--r--Source/Source.vcxproj5
-rw-r--r--Source/Source.vcxproj.filters3
-rw-r--r--Source/Version.h10
-rw-r--r--Source/Version.rc24
-rw-r--r--WitnessRandomizer.sln2
13 files changed, 63 insertions, 76 deletions
diff --git a/Installer/Installer.vdproj b/Installer/Installer.vdproj index 11c53ed..de7194b 100644 --- a/Installer/Installer.vdproj +++ b/Installer/Installer.vdproj
@@ -162,15 +162,15 @@
162 { 162 {
163 "Name" = "8:Microsoft Visual Studio" 163 "Name" = "8:Microsoft Visual Studio"
164 "ProductName" = "8:Witness Randomizer" 164 "ProductName" = "8:Witness Randomizer"
165 "ProductCode" = "8:{03F86460-1996-4804-B316-2D403F37CADE}" 165 "ProductCode" = "8:{332FC406-9528-47A7-9BCE-6EA315BDB863}"
166 "PackageCode" = "8:{4F55E8DA-1DC7-4319-9DC7-91D8F1BBC605}" 166 "PackageCode" = "8:{41851CA8-50AA-4E86-B041-9664C9777480}"
167 "UpgradeCode" = "8:{4CB5496B-A47E-41D3-B4A7-677E29AB7513}" 167 "UpgradeCode" = "8:{4CB5496B-A47E-41D3-B4A7-677E29AB7513}"
168 "AspNetVersion" = "8:2.0.50727.0" 168 "AspNetVersion" = "8:2.0.50727.0"
169 "RestartWWWService" = "11:FALSE" 169 "RestartWWWService" = "11:FALSE"
170 "RemovePreviousVersions" = "11:TRUE" 170 "RemovePreviousVersions" = "11:TRUE"
171 "DetectNewerInstalledVersion" = "11:TRUE" 171 "DetectNewerInstalledVersion" = "11:TRUE"
172 "InstallAllUsers" = "11:FALSE" 172 "InstallAllUsers" = "11:FALSE"
173 "ProductVersion" = "8:3.0.0" 173 "ProductVersion" = "8:3.0.3"
174 "Manufacturer" = "8:jbzdarkid" 174 "Manufacturer" = "8:jbzdarkid"
175 "ARPHELPTELEPHONE" = "8:" 175 "ARPHELPTELEPHONE" = "8:"
176 "ARPHELPLINK" = "8:https://www.github.com/jbzdarkid/witness-randomizer/issues" 176 "ARPHELPLINK" = "8:https://www.github.com/jbzdarkid/witness-randomizer/issues"
diff --git a/Source/Main.cpp b/Source/Main.cpp index 28bc472..8336c77 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp
@@ -1,8 +1,6 @@
1#include "windows.h" 1#include "windows.h"
2#include "resource.h"
3#include <Richedit.h> 2#include <Richedit.h>
4 3
5#include <ctime>
6#include <string> 4#include <string>
7 5
8#include "Randomizer.h" 6#include "Randomizer.h"
@@ -40,18 +38,19 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
40 GetWindowText(hwndSeed, &text[0], 100); 38 GetWindowText(hwndSeed, &text[0], 100);
41 int seed = 0; 39 int seed = 0;
42 if (wasSeedRandomlyGenerated || wcslen(text.c_str()) == 0) { 40 if (wasSeedRandomlyGenerated || wcslen(text.c_str()) == 0) {
43 Random::SetSeed(time(nullptr)); // Seed from the time in milliseconds
44 seed = Random::RandInt(0, 100000); 41 seed = Random::RandInt(0, 100000);
45 std::wstring seedString = std::to_wstring(seed);
46 SetWindowText(hwndSeed, seedString.c_str());
47 wasSeedRandomlyGenerated = true; 42 wasSeedRandomlyGenerated = true;
48 } else { 43 } else {
49 seed = _wtoi(text.c_str()); 44 seed = _wtoi(text.c_str());
50 wasSeedRandomlyGenerated = false; 45 wasSeedRandomlyGenerated = false;
51 } 46 }
52 Random::SetSeed(seed); 47
53 Randomizer randomizer; 48 Randomizer randomizer;
54 randomizer.Randomize(); 49 short metadata = randomizer.Randomize(seed);
50 if (metadata & 0x1) break; // Was already randomized
51
52 std::wstring seedString = std::to_wstring(seed);
53 SetWindowText(hwndSeed, seedString.c_str());
55 if (IsDlgButtonChecked(hwnd, IDC_TOGGLESPEED)) { 54 if (IsDlgButtonChecked(hwnd, IDC_TOGGLESPEED)) {
56 randomizer.AdjustSpeed(); 55 randomizer.AdjustSpeed();
57 } 56 }
diff --git a/Source/Random.h b/Source/Random.h index e4700f3..40998de 100644 --- a/Source/Random.h +++ b/Source/Random.h
@@ -1,6 +1,7 @@
1#pragma once 1#pragma once
2#include <chrono>
2 3
3static int s_seed; 4static int s_seed = time(nullptr); // Seed from the time in milliseconds
4 5
5class Random 6class Random
6{ 7{
diff --git a/Source/Randomizer.cpp b/Source/Randomizer.cpp index 83f5571..9622601 100644 --- a/Source/Randomizer.cpp +++ b/Source/Randomizer.cpp
@@ -4,21 +4,21 @@
4 * Swamp <-> symmetry has non-invisible background 4 * Swamp <-> symmetry has non-invisible background
5 * Tutorial sounds don't always play 5 * Tutorial sounds don't always play
6 * FEATURES: 6 * FEATURES:
7 * Prevent re-randomization (?) 7 * Clear "Randomized" button after short delay
8 * Clear "Randomized" state on NG (?) -- Or on a short delay
9 * Randomize audio logs -- Hard, seem to be unloaded some times? 8 * Randomize audio logs -- Hard, seem to be unloaded some times?
10 * Swap sounds in jungle (along with panels) -- maybe impossible 9 * Swap sounds in jungle (along with panels) -- maybe impossible
11 * Make orange 7 (all of oranges?) hard. Like big = hard. 10 * Make orange 7 (all of oranges?) hard. Like big = hard.
12 * Start the game if it isn't running? 11 * Start the game if it isn't running?
13 * Stop swapping colors in desert 12 * Stop swapping colors in desert
13 * Allow users to enter seed after randomly generating seed (aka detect user input in the text box)
14*/ 14*/
15#include "Memory.h" 15#include "Memory.h"
16#include "Randomizer.h" 16#include "Randomizer.h"
17#include "Panels.h" 17#include "Panels.h"
18#include "Random.h"
18#include <string> 19#include <string>
19#include <iostream> 20#include <iostream>
20#include <numeric> 21#include <numeric>
21#include <chrono>
22 22
23template <class T> 23template <class T>
24int find(const std::vector<T> &data, T search, size_t startIndex = 0) { 24int find(const std::vector<T> &data, T search, size_t startIndex = 0) {
@@ -29,8 +29,16 @@ int find(const std::vector<T> &data, T search, size_t startIndex = 0) {
29 exit(-1); 29 exit(-1);
30} 30}
31 31
32void Randomizer::Randomize() 32short Randomizer::Randomize(int seed)
33{ 33{
34 short metadata = _core.ReadMetadata();
35 if (metadata & 0x1) {
36 // Already randomized -- exit.
37 return metadata;
38 }
39 _core.WriteMetadata(metadata | 0x1);
40 Random::SetSeed(seed);
41
34 // Content swaps -- must happen before squarePanels 42 // Content swaps -- must happen before squarePanels
35 _core.Randomize(upDownPanels, SWAP_LINES); 43 _core.Randomize(upDownPanels, SWAP_LINES);
36 _core.Randomize(leftForwardRightPanels, SWAP_LINES); 44 _core.Randomize(leftForwardRightPanels, SWAP_LINES);
@@ -53,6 +61,7 @@ void Randomizer::Randomize()
53 RandomizeMountain(); 61 RandomizeMountain();
54 // RandomizeChallenge(); 62 // RandomizeChallenge();
55 // RandomizeAudioLogs(); 63 // RandomizeAudioLogs();
64 return metadata;
56} 65}
57 66
58void Randomizer::AdjustSpeed() { 67void Randomizer::AdjustSpeed() {
diff --git a/Source/Randomizer.h b/Source/Randomizer.h index b0da4fe..8c332b0 100644 --- a/Source/Randomizer.h +++ b/Source/Randomizer.h
@@ -3,7 +3,7 @@
3 3
4class Randomizer { 4class Randomizer {
5public: 5public:
6 void Randomize(); 6 short Randomize(int seed);
7 void AdjustSpeed(); 7 void AdjustSpeed();
8 8
9private: 9private:
diff --git a/Source/RandomizerCore.cpp b/Source/RandomizerCore.cpp index 684e19d..f14a76f 100644 --- a/Source/RandomizerCore.cpp +++ b/Source/RandomizerCore.cpp
@@ -3,6 +3,17 @@
3#include "Random.h" 3#include "Random.h"
4#include <sstream> 4#include <sstream>
5 5
6static int lastKnownFrame = 1 << 30;
7
8RandomizerCore::RandomizerCore() {
9 int currentFrame = _memory.ReadData<int>({SCRIPT_FRAMES}, 1)[0];
10 if (currentFrame < lastKnownFrame) {
11 // Time went backwards, indicates new game
12 WriteMetadata(0);
13 }
14 lastKnownFrame = currentFrame;
15}
16
6void RandomizerCore::Randomize(std::vector<int>& panels, int flags) { 17void RandomizerCore::Randomize(std::vector<int>& panels, int flags) {
7 return RandomizeRange(panels, flags, 0, panels.size()); 18 return RandomizeRange(panels, flags, 0, panels.size());
8} 19}
@@ -125,3 +136,11 @@ void RandomizerCore::ReassignNames(const std::vector<int>& panels, const std::ve
125 WritePanelData<int64_t>(panels[i], AUDIO_LOG_NAME, {names[order[i]]}); 136 WritePanelData<int64_t>(panels[i], AUDIO_LOG_NAME, {names[order[i]]});
126 } 137 }
127} 138}
139
140short RandomizerCore::ReadMetadata() {
141 return _memory.ReadData<short>({GLOBALS + METADATA}, 1)[0];
142}
143
144void RandomizerCore::WriteMetadata(short metadata) {
145 return _memory.WriteData<short>({GLOBALS + METADATA}, {metadata});
146} \ No newline at end of file
diff --git a/Source/RandomizerCore.h b/Source/RandomizerCore.h index e8d3661..7ec8e33 100644 --- a/Source/RandomizerCore.h +++ b/Source/RandomizerCore.h
@@ -12,6 +12,8 @@ __declspec(selectany) int SWAP_AUDIO_NAMES = 0x4;
12class RandomizerCore 12class RandomizerCore
13{ 13{
14public: 14public:
15 RandomizerCore();
16
15 void Randomize(std::vector<int>& panels, int flags); 17 void Randomize(std::vector<int>& panels, int flags);
16 void RandomizeRange(std::vector<int> &panels, int flags, size_t startIndex, size_t endIndex); 18 void RandomizeRange(std::vector<int> &panels, int flags, size_t startIndex, size_t endIndex);
17 void SwapPanels(int panel1, int panel2, int flags); 19 void SwapPanels(int panel1, int panel2, int flags);
@@ -28,6 +30,9 @@ public:
28 _memory.WriteData<T>({GLOBALS, 0x18, panel*8, offset}, data); 30 _memory.WriteData<T>({GLOBALS, 0x18, panel*8, offset}, data);
29 } 31 }
30 32
33 short ReadMetadata();
34 void WriteMetadata(short metadata);
35
31private: 36private:
32 Memory _memory = Memory("witness64_d3d11.exe"); 37 Memory _memory = Memory("witness64_d3d11.exe");
33}; 38};
@@ -95,6 +100,8 @@ private:
95#define CABLE_TARGET_2 0xD8 100#define CABLE_TARGET_2 0xD8
96#define AUDIO_LOG_NAME 0xC8 101#define AUDIO_LOG_NAME 0xC8
97#define OPEN_RATE 0xE8 102#define OPEN_RATE 0xE8
103#define METADATA 0xF2 // sizeof(short)
104#define SCRIPT_FRAMES 0x5BE3B0
98#elif GLOBALS == 0x62A080 105#elif GLOBALS == 0x62A080
99#define PATH_COLOR 0xC0 106#define PATH_COLOR 0xC0
100#define REFLECTION_PATH_COLOR 0xD0 107#define REFLECTION_PATH_COLOR 0xD0
@@ -158,4 +165,6 @@ private:
158#define CABLE_TARGET_2 0xD0 165#define CABLE_TARGET_2 0xD0
159#define AUDIO_LOG_NAME 0x0 166#define AUDIO_LOG_NAME 0x0
160#define OPEN_RATE 0xE0 167#define OPEN_RATE 0xE0
168#define METADATA 0x13A // sizeof(short)
169#define SCRIPT_FRAMES 0x63651C
161#endif \ No newline at end of file 170#endif \ No newline at end of file
diff --git a/Source/Resource.h b/Source/Resource.h deleted file mode 100644 index 426abc1..0000000 --- a/Source/Resource.h +++ /dev/null
@@ -1,26 +0,0 @@
1//{{NO_DEPENDENCIES}}
2// Microsoft Visual C++ generated include file.
3// Used by Source.rc
4//
5#define IDC_MYICON 2
6#define IDD_SOURCE_DIALOG 102
7#define IDS_APP_TITLE 103
8#define IDM_ABOUT 104
9#define IDM_EXIT 105
10#define IDI_SOURCE 107
11#define IDI_SMALL 108
12#define IDC_SOURCE 109
13#define IDR_MAINFRAME 128
14#define IDC_STATIC -1
15
16// Next default values for new objects
17//
18#ifdef APSTUDIO_INVOKED
19#ifndef APSTUDIO_READONLY_SYMBOLS
20#define _APS_NO_MFC 1
21#define _APS_NEXT_RESOURCE_VALUE 129
22#define _APS_NEXT_COMMAND_VALUE 32771
23#define _APS_NEXT_CONTROL_VALUE 1000
24#define _APS_NEXT_SYMED_VALUE 110
25#endif
26#endif
diff --git a/Source/Source.vcxproj b/Source/Source.vcxproj index afd4fd3..38914a6 100644 --- a/Source/Source.vcxproj +++ b/Source/Source.vcxproj
@@ -103,7 +103,7 @@
103 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> 103 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
104 <ClCompile> 104 <ClCompile>
105 <PrecompiledHeader>NotUsing</PrecompiledHeader> 105 <PrecompiledHeader>NotUsing</PrecompiledHeader>
106 <WarningLevel>Level3</WarningLevel> 106 <WarningLevel>Level2</WarningLevel>
107 <Optimization>Disabled</Optimization> 107 <Optimization>Disabled</Optimization>
108 <SDLCheck>true</SDLCheck> 108 <SDLCheck>true</SDLCheck>
109 <PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> 109 <PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -142,7 +142,7 @@
142 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> 142 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
143 <ClCompile> 143 <ClCompile>
144 <PrecompiledHeader>NotUsing</PrecompiledHeader> 144 <PrecompiledHeader>NotUsing</PrecompiledHeader>
145 <WarningLevel>Level1</WarningLevel> 145 <WarningLevel>Level2</WarningLevel>
146 <Optimization>MaxSpeed</Optimization> 146 <Optimization>MaxSpeed</Optimization>
147 <FunctionLevelLinking>true</FunctionLevelLinking> 147 <FunctionLevelLinking>true</FunctionLevelLinking>
148 <IntrinsicFunctions>true</IntrinsicFunctions> 148 <IntrinsicFunctions>true</IntrinsicFunctions>
@@ -167,7 +167,6 @@
167 <ClInclude Include="Random.h" /> 167 <ClInclude Include="Random.h" />
168 <ClInclude Include="Randomizer.h" /> 168 <ClInclude Include="Randomizer.h" />
169 <ClInclude Include="RandomizerCore.h" /> 169 <ClInclude Include="RandomizerCore.h" />
170 <ClInclude Include="Resource.h" />
171 <ClInclude Include="Version.h" /> 170 <ClInclude Include="Version.h" />
172 </ItemGroup> 171 </ItemGroup>
173 <ItemGroup> 172 <ItemGroup>
diff --git a/Source/Source.vcxproj.filters b/Source/Source.vcxproj.filters index dbb50f9..2f8f60b 100644 --- a/Source/Source.vcxproj.filters +++ b/Source/Source.vcxproj.filters
@@ -15,9 +15,6 @@
15 </Filter> 15 </Filter>
16 </ItemGroup> 16 </ItemGroup>
17 <ItemGroup> 17 <ItemGroup>
18 <ClInclude Include="Resource.h">
19 <Filter>Header Files</Filter>
20 </ClInclude>
21 <ClInclude Include="Memory.h"> 18 <ClInclude Include="Memory.h">
22 <Filter>Header Files</Filter> 19 <Filter>Header Files</Filter>
23 </ClInclude> 20 </ClInclude>
diff --git a/Source/Version.h b/Source/Version.h index ed79ee5..5aac53d 100644 --- a/Source/Version.h +++ b/Source/Version.h
@@ -1,14 +1,14 @@
1#pragma once 1#pragma once
2 2
3#define TO_STRING2(s) L#s
4#define TO_STRING(s) TO_STRING2(s)
5
3#define MAJOR 3 6#define MAJOR 3
4#define MINOR 0 7#define MINOR 0
5#define PATCH 1 8#define PATCH 3
6
7#define VERSION MAJOR, MINOR, PATCH
8 9
9#define TO_STRING2(s) L#s
10#define TO_STRING(s) TO_STRING2(s)
11#define VERSION_STR TO_STRING(MAJOR) L"." TO_STRING(MINOR) L"." TO_STRING(PATCH) 10#define VERSION_STR TO_STRING(MAJOR) L"." TO_STRING(MINOR) L"." TO_STRING(PATCH)
11#define VERSION MAJOR, MINOR, PATCH
12 12
13#define PRODUCT_NAME L"Witness Randomizer" 13#define PRODUCT_NAME L"Witness Randomizer"
14#define WINDOW_CLASS L"WitnessRandomizer" 14#define WINDOW_CLASS L"WitnessRandomizer"
diff --git a/Source/Version.rc b/Source/Version.rc index fe44a47..9b90884 100644 --- a/Source/Version.rc +++ b/Source/Version.rc
@@ -1,28 +1,6 @@
1#include "version.h" 1#include "version.h"
2#include "resource.h"
3#include <SDKDDKVer.h>
4#include "windows.h"
5
6STRINGTABLE
7BEGIN
8 IDC_SOURCE "SOURCE"
9END
10 2
11VS_VERSION_INFO VERSIONINFO 3VS_VERSION_INFO VERSIONINFO
12 FILEVERSION VERSION 4 FILEVERSION VERSION
13 PRODUCTVERSION VERSION
14BEGIN 5BEGIN
15 BLOCK "StringFileInfo"
16 BEGIN
17 BLOCK "040904b0"
18 BEGIN
19 VALUE "FileDescription", "Randomizer for The Witness"
20 VALUE "FileVersion", VERSION_STR
21 VALUE "InternalName", "Source.exe"
22 VALUE "LegalCopyright", "Copyright (C) 2018"
23 VALUE "OriginalFilename", "Source.exe"
24 VALUE "ProductName", PRODUCT_NAME
25 VALUE "ProductVersion", VERSION_STR
26 END
27 END
28END 6END
diff --git a/WitnessRandomizer.sln b/WitnessRandomizer.sln index bc19048..7d6b1c2 100644 --- a/WitnessRandomizer.sln +++ b/WitnessRandomizer.sln
@@ -26,8 +26,10 @@ Global
26 {CED79182-F36B-4D07-AD0E-249C15BFAD73}.Release|x86.ActiveCfg = Release|Win32 26 {CED79182-F36B-4D07-AD0E-249C15BFAD73}.Release|x86.ActiveCfg = Release|Win32
27 {CED79182-F36B-4D07-AD0E-249C15BFAD73}.Release|x86.Build.0 = Release|Win32 27 {CED79182-F36B-4D07-AD0E-249C15BFAD73}.Release|x86.Build.0 = Release|Win32
28 {90113AEC-8765-4A8D-B7A1-6C9BE730E5D5}.Debug|x64.ActiveCfg = Debug 28 {90113AEC-8765-4A8D-B7A1-6C9BE730E5D5}.Debug|x64.ActiveCfg = Debug
29 {90113AEC-8765-4A8D-B7A1-6C9BE730E5D5}.Debug|x64.Build.0 = Debug
29 {90113AEC-8765-4A8D-B7A1-6C9BE730E5D5}.Debug|x86.ActiveCfg = Release 30 {90113AEC-8765-4A8D-B7A1-6C9BE730E5D5}.Debug|x86.ActiveCfg = Release
30 {90113AEC-8765-4A8D-B7A1-6C9BE730E5D5}.Release|x64.ActiveCfg = Release 31 {90113AEC-8765-4A8D-B7A1-6C9BE730E5D5}.Release|x64.ActiveCfg = Release
32 {90113AEC-8765-4A8D-B7A1-6C9BE730E5D5}.Release|x64.Build.0 = Release
31 {90113AEC-8765-4A8D-B7A1-6C9BE730E5D5}.Release|x86.ActiveCfg = Release 33 {90113AEC-8765-4A8D-B7A1-6C9BE730E5D5}.Release|x86.ActiveCfg = Release
32 {98BC35B9-EE1A-4D77-85F2-ADAA72DB16F7}.Debug|x64.ActiveCfg = Debug|x64 34 {98BC35B9-EE1A-4D77-85F2-ADAA72DB16F7}.Debug|x64.ActiveCfg = Debug|x64
33 {98BC35B9-EE1A-4D77-85F2-ADAA72DB16F7}.Debug|x64.Build.0 = Debug|x64 35 {98BC35B9-EE1A-4D77-85F2-ADAA72DB16F7}.Debug|x64.Build.0 = Debug|x64