From 008d6d6589e9709efdede92a94f1bd706df9fe06 Mon Sep 17 00:00:00 2001 From: Nathan Jeffords Date: Sun, 30 Dec 2012 14:59:09 -0800 Subject: [PATCH 1/4] added additional library search paths to find bullet This allowed CMake to correctly build Visual Studio 2010 project files against a windows compiled version of bullet (2.81 rev 2613) --- cmake/FindBullet.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/FindBullet.cmake b/cmake/FindBullet.cmake index 8d5ea2f1e..97feddffe 100644 --- a/cmake/FindBullet.cmake +++ b/cmake/FindBullet.cmake @@ -27,6 +27,8 @@ macro(_FIND_BULLET_LIBRARY _var) ${ARGN} PATHS ${BULLET_ROOT} + ${BULLET_ROOT}/lib/Debug + ${BULLET_ROOT}/lib/Release ${BULLET_ROOT}/out/release8/libs ${BULLET_ROOT}/out/debug8/libs PATH_SUFFIXES lib From 7228f5d696fa641a0bced370b86bb875330f2534 Mon Sep 17 00:00:00 2001 From: Nathan Jeffords Date: Sun, 30 Dec 2012 21:16:54 -0800 Subject: [PATCH 2/4] added missing reference to added missing reference to that was causing Visual Studio 2010 to fail to compile stringops.hpp --- components/misc/stringops.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/components/misc/stringops.hpp b/components/misc/stringops.hpp index 112d66bb8..029b617e1 100644 --- a/components/misc/stringops.hpp +++ b/components/misc/stringops.hpp @@ -1,6 +1,7 @@ #ifndef MISC_STRINGOPS_H #define MISC_STRINGOPS_H +#include #include #include From a842fc2c11e30d189a41be930cf9db55eaddddfa Mon Sep 17 00:00:00 2001 From: Nathan Jeffords Date: Sun, 30 Dec 2012 22:02:55 -0800 Subject: [PATCH 3/4] added hack to fix an alignment issue in MSVC 2010 The default allocator in Visual Studio 2010 does not respect the alignment requirements of classes it is allocating memory for. This results in a potential crash when using OEngine::Physics::PhysicActor that has been allocated on the heap if it is built against a version of Bullet that has SSE intrinsics enabled. --- libs/openengine/bullet/physic.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index f320d009d..76bdb491d 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -122,8 +122,13 @@ namespace Physic */ void runPmove(); - - +//HACK: in Visual Studio 2010 and presumably above, this structures alignment +// must be 16, but the built in operator new & delete don't properly +// perform this alignment. +#if _MSC_VER >= 1600 + void * operator new (size_t Size) { return _aligned_malloc (Size, 16); } + void operator delete (void * Data) { _aligned_free (Data); } +#endif private: From 08fa9dcd3ebe6a92eb38be671dfe63800647c4fc Mon Sep 17 00:00:00 2001 From: Nathan Jeffords Date: Tue, 1 Jan 2013 11:59:05 -0800 Subject: [PATCH 4/4] replaced std::string concatenation with std::ostringstream Changed a block of code that was performing a series of string concatenations to use an ostringstream instead. This allowed the removal of calls to std::to_string (not C++03 compliant) and fixes an compile error in MSVC 2010 (ambigous overload when calling std::to_string). --- components/interpreter/defines.cpp | 87 +++++++++++++++--------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/components/interpreter/defines.cpp b/components/interpreter/defines.cpp index 29c78200d..18e5f81c1 100644 --- a/components/interpreter/defines.cpp +++ b/components/interpreter/defines.cpp @@ -1,6 +1,7 @@ #include "defines.hpp" #include +#include #include #include @@ -24,113 +25,113 @@ namespace Interpreter{ std::string fixDefinesReal(std::string text, char eschar, bool isBook, Context& context){ unsigned int start = 0; - std::string retval = ""; + std::ostringstream retval; for(unsigned int i = 0; i < text.length(); i++){ if(text[i] == eschar){ - retval += text.substr(start, i - start); + retval << text.substr(start, i - start); std::string temp = text.substr(i+1, 100); transform(temp.begin(), temp.end(), temp.begin(), ::tolower); bool found; if( (found = Check(temp, "actionslideright", &i, &start))){ - retval += context.getActionBinding("#{sRight}"); + retval << context.getActionBinding("#{sRight}"); } else if((found = Check(temp, "actionreadymagic", &i, &start))){ - retval += context.getActionBinding("#{sReady_Magic}"); + retval << context.getActionBinding("#{sReady_Magic}"); } else if((found = Check(temp, "actionprevweapon", &i, &start))){ - retval += "PLACEHOLDER_ACTION_PREV_WEAPON"; + retval << "PLACEHOLDER_ACTION_PREV_WEAPON"; } else if((found = Check(temp, "actionnextweapon", &i, &start))){ - retval += "PLACEHOLDER_ACTION_PREV_WEAPON"; + retval << "PLACEHOLDER_ACTION_PREV_WEAPON"; } else if((found = Check(temp, "actiontogglerun", &i, &start))){ - retval += context.getActionBinding("#{sAuto_Run}"); + retval << context.getActionBinding("#{sAuto_Run}"); } else if((found = Check(temp, "actionslideleft", &i, &start))){ - retval += context.getActionBinding("#{sLeft}"); + retval << context.getActionBinding("#{sLeft}"); } else if((found = Check(temp, "actionreadyitem", &i, &start))){ - retval += context.getActionBinding("#{sReady_Weapon}"); + retval << context.getActionBinding("#{sReady_Weapon}"); } else if((found = Check(temp, "actionprevspell", &i, &start))){ - retval += "PLACEHOLDER_ACTION_PREV_SPELL"; + retval << "PLACEHOLDER_ACTION_PREV_SPELL"; } else if((found = Check(temp, "actionnextspell", &i, &start))){ - retval += "PLACEHOLDER_ACTION_NEXT_SPELL"; + retval << "PLACEHOLDER_ACTION_NEXT_SPELL"; } else if((found = Check(temp, "actionrestmenu", &i, &start))){ - retval += context.getActionBinding("#{sRestKey}"); + retval << context.getActionBinding("#{sRestKey}"); } else if((found = Check(temp, "actionmenumode", &i, &start))){ - retval += context.getActionBinding("#{sJournal}"); + retval << context.getActionBinding("#{sJournal}"); } else if((found = Check(temp, "actionactivate", &i, &start))){ - retval += context.getActionBinding("#{sActivate}"); + retval << context.getActionBinding("#{sActivate}"); } else if((found = Check(temp, "actionjournal", &i, &start))){ - retval += context.getActionBinding("#{sJournal}"); + retval << context.getActionBinding("#{sJournal}"); } else if((found = Check(temp, "actionforward", &i, &start))){ - retval += context.getActionBinding("#{sForward}"); + retval << context.getActionBinding("#{sForward}"); } else if((found = Check(temp, "pccrimelevel", &i, &start))){ - retval += std::to_string(context.getPCBounty()); + retval << context.getPCBounty(); } else if((found = Check(temp, "actioncrouch", &i, &start))){ - retval += context.getActionBinding("#{sCrouch_Sneak}"); + retval << context.getActionBinding("#{sCrouch_Sneak}"); } else if((found = Check(temp, "actionjump", &i, &start))){ - retval += context.getActionBinding("#{sJump}"); + retval << context.getActionBinding("#{sJump}"); } else if((found = Check(temp, "actionback", &i, &start))){ - retval += context.getActionBinding("#{sBack}"); + retval << context.getActionBinding("#{sBack}"); } else if((found = Check(temp, "actionuse", &i, &start))){ - retval += "PLACEHOLDER_ACTION_USE"; + retval << "PLACEHOLDER_ACTION_USE"; } else if((found = Check(temp, "actionrun", &i, &start))){ - retval += "PLACEHOLDER_ACTION_RUN"; + retval << "PLACEHOLDER_ACTION_RUN"; } else if((found = Check(temp, "pcclass", &i, &start))){ - retval += context.getPCClass(); + retval << context.getPCClass(); } else if((found = Check(temp, "pcrace", &i, &start))){ - retval += context.getPCRace(); + retval << context.getPCRace(); } else if((found = Check(temp, "pcname", &i, &start))){ - retval += context.getPCName(); + retval << context.getPCName(); } else if((found = Check(temp, "cell", &i, &start))){ - retval += context.getCurrentCellName(); + retval << context.getCurrentCellName(); } else if(eschar == '%' && !isBook) { // In Dialogue, not messagebox if( (found = Check(temp, "faction", &i, &start))){ - retval += context.getNPCFaction(); + retval << context.getNPCFaction(); } else if((found = Check(temp, "nextpcrank", &i, &start))){ - retval += context.getPCNextRank(); + retval << context.getPCNextRank(); } else if((found = Check(temp, "pcnextrank", &i, &start))){ - retval += context.getPCNextRank(); + retval << context.getPCNextRank(); } else if((found = Check(temp, "pcrank", &i, &start))){ - retval += context.getPCRank(); + retval << context.getPCRank(); } else if((found = Check(temp, "rank", &i, &start))){ - retval += context.getNPCRank(); + retval << context.getNPCRank(); } else if((found = Check(temp, "class", &i, &start))){ - retval += context.getNPCClass(); + retval << context.getNPCClass(); } else if((found = Check(temp, "race", &i, &start))){ - retval += context.getNPCRace(); + retval << context.getNPCRace(); } else if((found = Check(temp, "name", &i, &start))){ - retval += context.getNPCName(); + retval << context.getNPCName(); } } else { // In messagebox or book, not dialogue @@ -144,13 +145,13 @@ namespace Interpreter{ /* uses pc in messageboxes */ else if((found = Check(temp, "class", &i, &start))){ - retval += context.getPCClass(); + retval << context.getPCClass(); } else if((found = Check(temp, "race", &i, &start))){ - retval += context.getPCRace(); + retval << context.getPCRace(); } else if((found = Check(temp, "name", &i, &start))){ - retval += context.getPCName(); + retval << context.getPCName(); } } @@ -172,9 +173,9 @@ namespace Interpreter{ char type = context.getGlobalType(globals[j]); switch(type){ - case 's': retval += std::to_string(context.getGlobalShort(globals[j])); break; - case 'l': retval += std::to_string(context.getGlobalLong(globals[j])); break; - case 'f': retval += std::to_string(context.getGlobalFloat(globals[j])); break; + case 's': retval << context.getGlobalShort(globals[j]); break; + case 'l': retval << context.getGlobalLong(globals[j]); break; + case 'f': retval << context.getGlobalFloat(globals[j]); break; } break; } @@ -186,12 +187,12 @@ namespace Interpreter{ /* leave unmodified */ i += 1; start = i; - retval += eschar; + retval << eschar; } } } - retval += text.substr(start, text.length() - start); - return retval; + retval << text.substr(start, text.length() - start); + return retval.str (); } std::string fixDefinesDialog(std::string text, Context& context){