- Removed dependencies on Boost/string in mtg sources

- Removes dependencies on Boost/shared_ptr in mtg sources only for WP8 for the moment
- Various compilation fixes on WP8
This commit is contained in:
Xawotihs@gmail.com
2013-09-30 21:25:17 +00:00
parent 7894ca3ace
commit 490752e9da
11 changed files with 34 additions and 18 deletions
+3 -1
View File
@@ -21,9 +21,11 @@
#include "GameOptions.h" #include "GameOptions.h"
#ifndef WP8
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#endif
#if defined (IOS) || defined (ANDROID) || defined (QT_CONFIG) || defined (SDL_CONFIG) #if defined (WP8) || defined (IOS) || defined (ANDROID) || defined (QT_CONFIG) || defined (SDL_CONFIG)
#define TOUCH_ENABLED #define TOUCH_ENABLED
#endif #endif
+1 -2
View File
@@ -173,8 +173,7 @@ protected:
int *mGBCode; int *mGBCode;
int mCurr; int mCurr;
u32 * mCharBuffer; PIXEL_TYPE* mCharBuffer;
virtual int PreCacheChar(const u8 *ch); virtual int PreCacheChar(const u8 *ch);
}; };
+5 -1
View File
@@ -1,8 +1,12 @@
#ifndef WRESOURCE_FWD_H #ifndef WRESOURCE_FWD_H
#define WRESOURCE_FWD_H #define WRESOURCE_FWD_H
#ifndef WP8
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
typedef boost::shared_ptr<JQuad> JQuadPtr; typedef boost::shared_ptr<JQuad> JQuadPtr;
#else
#include <memory>
typedef std::shared_ptr<JQuad> JQuadPtr;
#endif
#endif #endif
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef _DEBUG_H_ #ifndef _DEBUG_H_
#define _DEBUG_H_ #define _DEBUG_H_
#if (defined WIN32) && (!defined QT_CONFIG) #if ((defined WIN32) || (defined WP8)) && (!defined QT_CONFIG)
#define snprintf sprintf_s #define snprintf sprintf_s
#endif #endif
+4
View File
@@ -136,4 +136,8 @@ template <class T> istream& operator>>(istream& in, T& p)
return in; return in;
} }
*/ */
/* replace_all ... replacement to avoid depending on boost for that */
void ReplaceString(std::string& subject, const std::string& search, const std::string& replace);
#endif #endif
+3 -4
View File
@@ -2,7 +2,6 @@
#include "AbilityParser.h" #include "AbilityParser.h"
#include "utils.h" #include "utils.h"
#include <boost/algorithm/string.hpp>
using std::string; using std::string;
using std::vector; using std::vector;
@@ -46,7 +45,7 @@ void AutoLineMacro::parse(const string& stringMacro)
mResult = s.substr(firstSpace + 1); mResult = s.substr(firstSpace + 1);
} }
boost::replace_all(mResult, "\\n", "\n"); ReplaceString(mResult, "\\n", "\n");
} }
string AutoLineMacro::process(const string& s) string AutoLineMacro::process(const string& s)
@@ -55,7 +54,7 @@ string AutoLineMacro::process(const string& s)
if (!mParams.size()) if (!mParams.size())
{ {
//no params, simple macro //no params, simple macro
boost::replace_all(temp, mName, mResult); ReplaceString(temp, mName, mResult);
return temp; return temp;
} }
@@ -81,7 +80,7 @@ string AutoLineMacro::process(const string& s)
string tempResult = mResult; string tempResult = mResult;
for (size_t i = 0; i < vParams.size(); ++i) for (size_t i = 0; i < vParams.size(); ++i)
{ {
boost::replace_all(tempResult, mParams[i], vParams[i]); ReplaceString(tempResult, mParams[i], vParams[i]);
} }
result.append(tempResult); result.append(tempResult);
+1 -2
View File
@@ -1,7 +1,6 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "AllAbilities.h" #include "AllAbilities.h"
#include "Translate.h" #include "Translate.h"
#include <boost/algorithm/string.hpp>
//display a text animation, this is not a real ability. //display a text animation, this is not a real ability.
@@ -5501,7 +5500,7 @@ ATutorialMessage::ATutorialMessage(GameObserver* observer, MTGCardInstance * sou
else else
{ {
mMessage = _(message); //translate directly here, remove this and translate at rendering time if it bites us mMessage = _(message); //translate directly here, remove this and translate at rendering time if it bites us
boost::replace_all(mMessage, "\\n", "\n"); ReplaceString(mMessage, "\\n", "\n");
} }
} }
+2
View File
@@ -1,5 +1,7 @@
#ifndef _CLOSEST_H_ #ifndef _CLOSEST_H_
#define _CLOSEST_H_ #define _CLOSEST_H_
#include "PrecompiledHeader.h"
#include "CardSelector.h"
template<typename T, typename Target> template<typename T, typename Target>
static inline Target* closest(vector<Target*>& cards, Limitor* limitor, Target* ref) static inline Target* closest(vector<Target*>& cards, Limitor* limitor, Target* ref)
+1 -3
View File
@@ -1,5 +1,4 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include <boost/algorithm/string.hpp>
#include "ManaCost.h" #include "ManaCost.h"
#include "ManaCostHybrid.h" #include "ManaCostHybrid.h"
#include "ExtraCost.h" #include "ExtraCost.h"
@@ -8,7 +7,6 @@
#include "Player.h" #include "Player.h"
#include "WEvent.h" #include "WEvent.h"
#include "MTGAbility.h" #include "MTGAbility.h"
#include "iterator" #include "iterator"
SUPPORT_OBJECT_ANALYTICS(ManaCost) SUPPORT_OBJECT_ANALYTICS(ManaCost)
@@ -95,7 +93,7 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
} }
//switch on the first letter. If two costs share their first letter, add an "if" within the switch //switch on the first letter. If two costs share their first letter, add an "if" within the switch
boost::algorithm::to_lower(value); std::transform(value.begin(), value.end(), value.begin(), ::tolower);
switch (value[0]) switch (value[0])
{ {
case 'x': case 'x':
+4 -4
View File
@@ -205,7 +205,7 @@ WFBFont::WFBFont(int inFontID, const char *fontname, int lineheight, bool) :
mGBCode = NEW int[mCacheSize]; mGBCode = NEW int[mCacheSize];
#if !defined (PSP) #if !defined (PSP)
mCharBuffer = NEW u32[mFontSize*mFontSize]; mCharBuffer = NEW PIXEL_TYPE[mFontSize*mFontSize];
#endif #endif
mTexture = mRenderer->CreateTexture(mCacheImageWidth, mCacheImageHeight, true); mTexture = mRenderer->CreateTexture(mCacheImageWidth, mCacheImageHeight, true);
@@ -359,7 +359,7 @@ int WFBFont::PreCacheChar(const u8 *ch)
#else #else
x = (int)mSprites[index]->mX; x = (int)mSprites[index]->mX;
y = (int)mSprites[index]->mY; y = (int)mSprites[index]->mY;
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, mFontSize, mFontSize, GL_RGBA, GL_UNSIGNED_BYTE, mCharBuffer); mTexture->UpdateBits(x, y, mFontSize, mFontSize, mCharBuffer);
#endif #endif
return index; return index;
} }
@@ -645,7 +645,7 @@ WGBKFont::WGBKFont(int inFontID, const char *fontname, int lineheight, bool) :
mGBCode = NEW int[mCacheSize]; mGBCode = NEW int[mCacheSize];
#if !defined (PSP) #if !defined (PSP)
mCharBuffer = NEW u32[mFontSize*mFontSize]; mCharBuffer = NEW PIXEL_TYPE[mFontSize*mFontSize];
#endif #endif
mTexture = mRenderer->CreateTexture(mCacheImageWidth, mCacheImageHeight, true); mTexture = mRenderer->CreateTexture(mCacheImageWidth, mCacheImageHeight, true);
@@ -758,7 +758,7 @@ int WGBKFont::PreCacheChar(const u8 *ch)
#else #else
x = (int)mSprites[index]->mX; x = (int)mSprites[index]->mX;
y = (int)mSprites[index]->mY; y = (int)mSprites[index]->mY;
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, mFontSize, mFontSize, GL_RGBA, GL_UNSIGNED_BYTE, mCharBuffer); mTexture->UpdateBits(x, y, mFontSize, mFontSize, mCharBuffer);
#endif #endif
return index; return index;
} }
+9
View File
@@ -390,3 +390,12 @@ std::string ensureFolder(const std::string & folderName)
} }
return result; return result;
} }
void ReplaceString(std::string& subject, const std::string& search, const std::string& replace) {
size_t pos = 0;
while ((pos = subject.find(search, pos)) != std::string::npos) {
subject.replace(pos, search.length(), replace);
pos += replace.length();
}
}