mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added a C++11 emulator for compiling with VS2008.
This commit is contained in:
@@ -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; }
|
||||||
@@ -29,6 +29,9 @@
|
|||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
#include "FalloutEngine.h"
|
#include "FalloutEngine.h"
|
||||||
#include "PartyControl.h"
|
#include "PartyControl.h"
|
||||||
|
#if (_MSC_VER < 1600)
|
||||||
|
#include "Cpp11_emu.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
static DWORD Mode;
|
static DWORD Mode;
|
||||||
static int IsControllingNPC = 0;
|
static int IsControllingNPC = 0;
|
||||||
@@ -105,7 +108,11 @@ static void SaveRealDudeState() {
|
|||||||
static void TakeControlOfNPC(TGameObj* npc) {
|
static void TakeControlOfNPC(TGameObj* npc) {
|
||||||
// remove skill tags
|
// remove skill tags
|
||||||
int tagSkill[4];
|
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);
|
std::fill(std::begin(tagSkill), std::end(tagSkill), -1);
|
||||||
|
#endif
|
||||||
SkillSetTags(tagSkill, 4);
|
SkillSetTags(tagSkill, 4);
|
||||||
|
|
||||||
// reset traits
|
// reset traits
|
||||||
@@ -326,6 +333,7 @@ skip:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prevents using sneak when controlling NPCs
|
||||||
static void __declspec(naked) pc_flag_toggle_hook() {
|
static void __declspec(naked) pc_flag_toggle_hook() {
|
||||||
__asm {
|
__asm {
|
||||||
cmp IsControllingNPC, 0
|
cmp IsControllingNPC, 0
|
||||||
|
|||||||
@@ -206,6 +206,7 @@
|
|||||||
<ClInclude Include="Bugs.h" />
|
<ClInclude Include="Bugs.h" />
|
||||||
<ClInclude Include="BurstMods.h" />
|
<ClInclude Include="BurstMods.h" />
|
||||||
<ClInclude Include="Console.h" />
|
<ClInclude Include="Console.h" />
|
||||||
|
<ClInclude Include="Cpp11_emu.h" />
|
||||||
<ClInclude Include="CRC.h" />
|
<ClInclude Include="CRC.h" />
|
||||||
<ClInclude Include="Credits.h" />
|
<ClInclude Include="Credits.h" />
|
||||||
<ClInclude Include="Criticals.h" />
|
<ClInclude Include="Criticals.h" />
|
||||||
|
|||||||
@@ -196,6 +196,9 @@
|
|||||||
<ClInclude Include="Message.h">
|
<ClInclude Include="Message.h">
|
||||||
<Filter>Headers</Filter>
|
<Filter>Headers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Cpp11_emu.h">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="AmmoMod.cpp">
|
<ClCompile Include="AmmoMod.cpp">
|
||||||
|
|||||||
Reference in New Issue
Block a user