Browse Source

Update Windows source/project to c++17.

Devn00b 1 year ago
parent
commit
54fe1942aa
2 changed files with 22 additions and 2 deletions
  1. 18 1
      EQ2/source/WorldServer/Zone/ChestTrap.cpp
  2. 4 1
      EQ2/win/VC10Projects/EQ2World.vcxproj

+ 18 - 1
EQ2/source/WorldServer/Zone/ChestTrap.cpp

@@ -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)

+ 4 - 1
EQ2/win/VC10Projects/EQ2World.vcxproj

@@ -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>