Added a C++11 emulator for compiling with VS2008.

This commit is contained in:
NovaRain
2016-10-26 11:38:57 +08:00
parent ce72ef51f8
commit 47783c802e
4 changed files with 54 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
/*
* sfall
* Copyright (C) 2008-2016 The sfall team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
// https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/nullptr
const // It is a const object...
class nullptr_t {
public:
template<class T>
inline operator T*() const // convertible to any type of null non-member pointer...
{ return 0; }
template<class C, class T>
inline operator T C::*() const // or any type of null member pointer...
{ return 0; }
private:
void operator&() const; // Can't take address of nullptr
} nullptr = {};
// http://stackoverflow.com/questions/33026118/c-stdbeginc-for-vs-2008
template<typename T, std::size_t N>
T* std_begin(T (&a)[N]) { return a; }
template<typename T, std::size_t N>
T* std_end(T (&a)[N]) { return a + N; }
+8
View File
@@ -29,6 +29,9 @@
#include "Define.h"
#include "FalloutEngine.h"
#include "PartyControl.h"
#if (_MSC_VER < 1600)
#include "Cpp11_emu.h"
#endif
static DWORD Mode;
static int IsControllingNPC = 0;
@@ -105,7 +108,11 @@ static void SaveRealDudeState() {
static void TakeControlOfNPC(TGameObj* npc) {
// remove skill tags
int tagSkill[4];
#if (_MSC_VER < 1600)
std::fill(std_begin(tagSkill), std_end(tagSkill), -1);
#else
std::fill(std::begin(tagSkill), std::end(tagSkill), -1);
#endif
SkillSetTags(tagSkill, 4);
// reset traits
@@ -326,6 +333,7 @@ skip:
}
}
// prevents using sneak when controlling NPCs
static void __declspec(naked) pc_flag_toggle_hook() {
__asm {
cmp IsControllingNPC, 0
+1
View File
@@ -206,6 +206,7 @@
<ClInclude Include="Bugs.h" />
<ClInclude Include="BurstMods.h" />
<ClInclude Include="Console.h" />
<ClInclude Include="Cpp11_emu.h" />
<ClInclude Include="CRC.h" />
<ClInclude Include="Credits.h" />
<ClInclude Include="Criticals.h" />
+3
View File
@@ -196,6 +196,9 @@
<ClInclude Include="Message.h">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="Cpp11_emu.h">
<Filter>Headers</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="AmmoMod.cpp">