diff --git a/sfall/Cpp11_emu.h b/sfall/Cpp11_emu.h new file mode 100644 index 00000000..48d21c66 --- /dev/null +++ b/sfall/Cpp11_emu.h @@ -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 . + */ + +#pragma once + +// https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/nullptr +const // It is a const object... +class nullptr_t { + public: + template + inline operator T*() const // convertible to any type of null non-member pointer... + { return 0; } + + template + 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 +T* std_begin(T (&a)[N]) { return a; } + +template +T* std_end(T (&a)[N]) { return a + N; } diff --git a/sfall/PartyControl.cpp b/sfall/PartyControl.cpp index f30524e0..dd17acea 100644 --- a/sfall/PartyControl.cpp +++ b/sfall/PartyControl.cpp @@ -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 diff --git a/sfall/ddraw.vcxproj b/sfall/ddraw.vcxproj index 7389fb52..5a3fc59d 100644 --- a/sfall/ddraw.vcxproj +++ b/sfall/ddraw.vcxproj @@ -206,6 +206,7 @@ + diff --git a/sfall/ddraw.vcxproj.filters b/sfall/ddraw.vcxproj.filters index c83ff852..84a689c5 100644 --- a/sfall/ddraw.vcxproj.filters +++ b/sfall/ddraw.vcxproj.filters @@ -196,6 +196,9 @@ Headers + + Headers +