Update Windows source/project to c++17.

This commit is contained in:
Devn00b 2022-10-08 12:32:31 -07:00
parent a1f2f27ebf
commit 54fe1942aa
2 changed files with 22 additions and 2 deletions

View file

@ -1,7 +1,13 @@
#include "ChestTrap.h"
#include <vector>
#include <algorithm> // std::random_shuffle
#include <string.h>
//required for c++17 compat (random_shuffle removed, replaced with shuffle)
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#include <random>
#else
#include <algorithm> // std::random_shuffle
#endif
int32 ChestTrapList::Size() {
@ -252,10 +258,21 @@ void ChestTrapList::shuffleMap(ChestTrapList* list) {
tmp_chests.push_back(curTrap);
}
#ifdef WIN32
//c++17/windows removed random_shuffle replaced with this ugly bullshit 9/22/22
//taken right from their example.
std::random_device rd;
std::mt19937 g(rd());
std::shuffle(tmp_chests.begin(), tmp_chests.end(),g);
#else
//let linux continue on, with the function as is since it still works.
std::random_shuffle(tmp_chests.begin(), tmp_chests.end());
#endif
chesttrap_list.clear();
int count = 0;
for (std::vector<ChestTrap*>::iterator it = tmp_chests.begin(); it != tmp_chests.end(); ++it)

View file

@ -76,7 +76,9 @@
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>DEBUG;WORLD;_DEBUG;_EQDEBUG;WIN32;_CONSOLE;EQ2;EQN_DEBUG;_CRT_SECURE_NO_DEPRECATE;GLM_ENABLE_EXPERIMENTAL;GLM_FORCE_CTOR_INIT;GLM_FORCE_RADIANS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>DEBUG;WORLD;_DEBUG;_EQDEBUG;WIN32;_CONSOLE;EQ2;EQN_DEBUG;_CRT_SECURE_NO_DEPRECATE;GLM_ENABLE_EXPERIMENTAL;GLM_FORCE_CTOR_INIT;GLM_FORCE_RADIANS;_HAS_STD_BYTE=0
;
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Sync</ExceptionHandling>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
@ -103,6 +105,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<IntrinsicFunctions>false</IntrinsicFunctions>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>