Skip to content

Commit

Permalink
set LanguageStandard=stdcpp14 for xrGame. Fix building other projects…
Browse files Browse the repository at this point in the history
… with stdcpp17
  • Loading branch information
q4a committed Jun 3, 2018
1 parent c163d32 commit 9b8cc35
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/utils/xrAI/level_spawn_constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "xrServerEntities/clsid_game.h"
#include "xrServerEntities/xrMessages.h"
#include "factory_api.h"
#include <random>

#define IGNORE_ZERO_SPAWN_POSITIONS

Expand Down Expand Up @@ -482,7 +483,9 @@ void CLevelSpawnConstructor::generate_artefact_spawn_positions()
#endif
}
else*/
std::random_shuffle(l_tpaStack.begin(), l_tpaStack.end());
std::random_device rd;
std::mt19937 g(rd());
std::shuffle(l_tpaStack.begin(), l_tpaStack.end(), g);

zone->m_artefact_position_offset = m_level_points.size();
m_level_points.resize(zone->m_artefact_position_offset + zone->m_artefact_spawn_count);
Expand Down
5 changes: 4 additions & 1 deletion src/utils/xrAI/xr_graph_merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "game_graph_builder.h"
#include "xrServerEntities/xrMessages.h"
#include <direct.h>
#include <random>

extern LPCSTR GAME_CONFIG;

Expand Down Expand Up @@ -357,7 +358,9 @@ class CLevelGameGraph

R_ASSERT2(!l_dwaNodes.empty(), "Can't create at least one death point for specified graph point");

std::random_shuffle(l_dwaNodes.begin(), l_dwaNodes.end());
std::random_device rd;
std::mt19937 g(rd());
std::shuffle(l_dwaNodes.begin(), l_dwaNodes.end(), g);

u32 m = l_dwaNodes.size() > 10 ? std::min(iFloor(.1f * l_dwaNodes.size()), 255) : l_dwaNodes.size(),
l_dwStartIndex = m_tpLevelPoints.size();
Expand Down
5 changes: 4 additions & 1 deletion src/utils/xrLC/xrLight.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "stdafx.h"
#include "build.h"
#include <random>

#include "utils/xrLC_Light/xrdeflector.h"
#include "utils/xrLCUtil/xrThread.hpp"
Expand Down Expand Up @@ -73,7 +74,9 @@ void CBuild::LMapsLocal()

// Randomize deflectors
#ifndef NET_CMP
std::random_shuffle(lc_global_data()->g_deflectors().begin(), lc_global_data()->g_deflectors().end());
std::random_device rd;
std::mt19937 g(rd());
std::shuffle(lc_global_data()->g_deflectors().begin(), lc_global_data()->g_deflectors().end(), g);
#endif

#ifndef NET_CMP
Expand Down
10 changes: 6 additions & 4 deletions src/utils/xrLC_Light/fitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ void vfOptimizeParameters(xr_vector<xr_vector<REAL>>& A, xr_vector<xr_vector<REA
{
dPreviousFunctional = dFunctional;
dafGradient(daEvalResults, daGradient, B, dNormaFactor);
std::transform(
daGradient.begin(), daGradient.end(), daGradient.begin(), std::bind2nd(std::multiplies<REAL>(), -dAlpha));
std::transform(daDelta.begin(), daDelta.end(), daDelta.begin(), std::bind2nd(std::multiplies<REAL>(), dBeta));
std::transform(daGradient.begin(), daGradient.end(), daGradient.begin(),
std::bind(std::multiplies<REAL>(), std::placeholders::_1, -dAlpha));
std::transform(daDelta.begin(), daDelta.end(), daDelta.begin(),
std::bind(std::multiplies<REAL>(), std::placeholders::_1, dBeta));
std::transform(daGradient.begin(), daGradient.end(), daDelta.begin(), daDelta.begin(), std::plus<REAL>());
std::transform(C.begin(), C.end(), daDelta.begin(), C.begin(), std::plus<REAL>());
std::transform(D.begin(), D.end(), daDelta.begin(), D.begin(), std::plus<REAL>());
Expand All @@ -95,7 +96,8 @@ void vfOptimizeParameters(xr_vector<xr_vector<REAL>>& A, xr_vector<xr_vector<REA

if (dPreviousFunctional < dFunctional)
{
std::transform(daDelta.begin(), daDelta.end(), daDelta.begin(), std::bind2nd(std::multiplies<REAL>(), -1.f));
std::transform(daDelta.begin(), daDelta.end(), daDelta.begin(),
std::bind(std::multiplies<REAL>(), std::placeholders::_1, -1.f));
std::transform(C.begin(), C.end(), daDelta.begin(), C.begin(), std::plus<REAL>());
std::transform(D.begin(), D.end(), daDelta.begin(), D.begin(), std::plus<REAL>());
}
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/xrGame.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp14</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand Down

0 comments on commit 9b8cc35

Please sign in to comment.