diff --git a/JGE/JGE.vcxproj b/JGE/JGE.vcxproj index 7dfb4c68c..eb5be74ef 100644 --- a/JGE/JGE.vcxproj +++ b/JGE/JGE.vcxproj @@ -73,7 +73,7 @@ MaxSpeed OnlyExplicitInline src/zipFS;Dependencies/SDL/include;Dependencies/include;$(JGEEXTRAS);../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories) - SDL_CONFIG;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + TIXML_USE_STL; SDL_CONFIG;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) true MultiThreadedDLL true @@ -101,7 +101,7 @@ Disabled src/zipFS;Dependencies/SDL/include;Dependencies/include;$(JGEEXTRAS);../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories) - SDL_CONFIG;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + TIXML_USE_STL; SDL_CONFIG;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDLL @@ -129,7 +129,7 @@ Full OnlyExplicitInline src/zipFS;Dependencies/SDL/include;Dependencies/include;$(JGEEXTRAS);../Boost;../projects/mtg/include;include;%(AdditionalIncludeDirectories) - SDL_CONFIG;WIN32;NDEBUG;_LIB;_SECURE_SCL=0;_HAS_ITERATOR_DEBBUGING=0;%(PreprocessorDefinitions) + TIXML_USE_STL; SDL_CONFIG;WIN32;NDEBUG;_LIB;_SECURE_SCL=0;_HAS_ITERATOR_DEBBUGING=0;%(PreprocessorDefinitions) true MultiThreadedDLL true diff --git a/JGE/Makefile b/JGE/Makefile index 2849fa678..3d86cc650 100644 --- a/JGE/Makefile +++ b/JGE/Makefile @@ -31,6 +31,7 @@ HGE_OBJS = src/hge/hgecolor.o src/hge/hgeparticle.o \ CXXFLAGS = -W -Wall -Werror -Wno-unused +CXXFLAGS += -DTIXML_USE_STL ifdef DEBUG CXXFLAGS += -ggdb3 diff --git a/JGE/src/JAnimator.cpp b/JGE/src/JAnimator.cpp index 08f704c6c..fca367832 100644 --- a/JGE/src/JAnimator.cpp +++ b/JGE/src/JAnimator.cpp @@ -67,7 +67,7 @@ bool JAnimator::Load(const char* scriptFile) element = script->ToElement(); printf("---- Loading %s:%s\n", element->Value(), element->Attribute("name")); - const char *type[] = + string type[] = { "ANIMATION_TYPE_LOOPING", "ANIMATION_TYPE_ONCE_AND_STAY", @@ -78,7 +78,7 @@ bool JAnimator::Load(const char* scriptFile) const char* aniType = element->Attribute("type"); for (int i=0;i<5;i++) - if (strcmp(type[i], aniType)==0) + if (type[i] == aniType) { SetAnimationType(i); break; @@ -108,7 +108,7 @@ bool JAnimator::Load(const char* scriptFile) element = param->ToElement(); if (element != NULL) { - if (strcmp(element->Value(), "settings")==0) + if (element->ValueStr() == "settings") { const char* quadName = element->Attribute("quad"); JQuad* quad = mResource->GetQuad(quadName); diff --git a/JGE/src/JGfx-fake.cpp b/JGE/src/JGfx-fake.cpp index 80a1b8c32..bb49c5b97 100644 --- a/JGE/src/JGfx-fake.cpp +++ b/JGE/src/JGfx-fake.cpp @@ -65,7 +65,7 @@ void JQuad::SetHotSpot(float x, float y) ////////////////////////////////////////////////////////////////////////// -JTexture::JTexture() : mBuffer(NULL) +JTexture::JTexture() : mWidth(0), mHeight(0), mBuffer(NULL) { mTexId = -1; } @@ -306,14 +306,12 @@ void JRenderer::TransferTextureToGLContext(JTexture& inTexture) JTexture* JRenderer::CreateTexture(int width, int height, int mode __attribute__((unused))) { JTexture *tex = new JTexture(); - return tex; } JTexture* JRenderer::LoadTexture(const char* filename, int mode, int textureFormat) { JTexture *tex = new JTexture(); - return tex; } diff --git a/JGE/src/JOBJModel.cpp b/JGE/src/JOBJModel.cpp index d30a0ed7b..04e504a02 100644 --- a/JGE/src/JOBJModel.cpp +++ b/JGE/src/JOBJModel.cpp @@ -75,10 +75,10 @@ bool JOBJModel::Load(const char *modelName, const char *textureName) int count; - while (filePtr < size) - { + while (filePtr < size) + { filePtr = ReadLine(tmpLine, buffer, filePtr, size); - { + { if ((tmpLine[0] == '#') || (strlen(tmpLine) < 3)) { @@ -89,19 +89,19 @@ bool JOBJModel::Load(const char *modelName, const char *textureName) if (count == 4) { - if (strcmp(s1, "vn") == 0) + if (string("vn") == s1) normalList.push_back(vert); - else if (strcmp(s1, "vt") == 0) + else if (string("vt") == s1) texList.push_back(vert); - else if (strcmp(s1, "v") == 0) + else if (string("v") == s1) vertList.push_back(vert); } else if (count == 3) { - if (strcmp(s1, "vt") == 0) + if (string("vt") == s1) texList.push_back(vert); } - + } else if (tmpLine[0] == 'f') { @@ -211,7 +211,7 @@ bool JOBJModel::Load(const char *modelName, const char *textureName) if (textureName != NULL) mTexture = JRenderer::GetInstance()->LoadTexture(textureName); - return true; + return true; } diff --git a/JGE/src/JParticleEffect.cpp b/JGE/src/JParticleEffect.cpp index e3411de03..a991b4f4e 100644 --- a/JGE/src/JParticleEffect.cpp +++ b/JGE/src/JParticleEffect.cpp @@ -90,7 +90,7 @@ bool JParticleEffect::Load(const char* filename) // FIELD_COUNT // }; - const char* lifeValues[] = + const string lifeValues[] = { "speed", "size", @@ -104,7 +104,7 @@ bool JParticleEffect::Load(const char* filename) "gravity" }; - const char* typeNames[] = + const string typeNames[] = { "POINT", "AREA", @@ -113,7 +113,7 @@ bool JParticleEffect::Load(const char* filename) "CIRCLE" }; - const char* modeNames[] = + const string modeNames[] = { "REPEAT", "ONCE", @@ -149,32 +149,32 @@ bool JParticleEffect::Load(const char* filename) { element = param->ToElement(); - if (strcmp(element->Attribute("name"), "settings")==0) + if (string("settings") == element->Attribute("name")) { - if (strcmp(element->Attribute("blend"), "NORMAL")==0) + if (string("NORMAL") == element->Attribute("blend")) mParticleEmitters[mEmitterCount]->SetBlending(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA); - else if (strcmp(element->Attribute("blend"), "ADDITIVE")==0) + else if (string("ADDITIVE") == element->Attribute("blend")) mParticleEmitters[mEmitterCount]->SetBlending(BLEND_SRC_ALPHA, BLEND_ONE); for (unsigned int i=0;iAttribute("mode"), modeNames[i])==0) + if (modeNames[i] == element->Attribute("mode")) { mParticleEmitters[mEmitterCount]->mEmitterMode = i; #if defined (_DEBUG) - printf("emitter mode:%s\n", modeNames[i]); + printf("emitter mode:%s\n", modeNames[i].c_str()); #endif break; } } for (unsigned i=0;iAttribute("type"), typeNames[i])==0) + if (typeNames[i] == element->Attribute("type")) { mParticleEmitters[mEmitterCount]->mType = i; #if defined (_DEBUG) - printf("emitter type:%s\n", typeNames[i]); + printf("emitter type:%s\n", typeNames[i].c_str()); #endif break; } @@ -213,7 +213,7 @@ bool JParticleEffect::Load(const char* filename) } } - else if (strcmp(element->Attribute("name"), "quantity")==0) + else if (string("quantity") == element->Attribute("name")) { for (key = param->FirstChild(); key; key = key->NextSibling()) { @@ -227,7 +227,7 @@ bool JParticleEffect::Load(const char* filename) } } - else if (strcmp(element->Attribute("name"), "lifex")==0) + else if (string("lifex") == element->Attribute("name")) { if (element->QueryFloatAttribute("base", &baseValue) == TIXML_SUCCESS && element->QueryFloatAttribute("max", &value) == TIXML_SUCCESS) @@ -236,7 +236,7 @@ bool JParticleEffect::Load(const char* filename) mParticleEmitters[mEmitterCount]->mLifeMax= value; } } - else if (strcmp(element->Attribute("name"), "anglex")==0) + else if (string("anglex") == element->Attribute("name")) { if (element->QueryFloatAttribute("base", &baseValue) == TIXML_SUCCESS && element->QueryFloatAttribute("max", &value) == TIXML_SUCCESS) @@ -245,7 +245,7 @@ bool JParticleEffect::Load(const char* filename) mParticleEmitters[mEmitterCount]->mAngleMax= value*DEG2RAD; } } - else if (strcmp(element->Attribute("name"), "speedx")==0) + else if (string("speedx") == element->Attribute("name")) { if (element->QueryFloatAttribute("base", &baseValue) == TIXML_SUCCESS && element->QueryFloatAttribute("max", &value) == TIXML_SUCCESS) @@ -254,7 +254,7 @@ bool JParticleEffect::Load(const char* filename) mParticleEmitters[mEmitterCount]->mSpeedMax= value; } } - else if (strcmp(element->Attribute("name"), "sizex")==0) + else if (string("sizex") == element->Attribute("name")) { if (element->QueryFloatAttribute("base", &baseValue) == TIXML_SUCCESS && element->QueryFloatAttribute("max", &value) == TIXML_SUCCESS) @@ -267,7 +267,7 @@ bool JParticleEffect::Load(const char* filename) { for (int i=0;iAttribute("name"), lifeValues[i])==0) + if (lifeValues[i] == element->Attribute("name")) { for (key = param->FirstChild(); key; key = key->NextSibling()) { diff --git a/JGE/src/JResourceManager.cpp b/JGE/src/JResourceManager.cpp index a5d3c75cd..bd557d1f4 100644 --- a/JGE/src/JResourceManager.cpp +++ b/JGE/src/JResourceManager.cpp @@ -119,11 +119,11 @@ bool JResourceManager::LoadResource(const string& resourceName) element = node->ToElement(); if (element != NULL) { - if (strcmp(element->Value(), "texture")==0) + if (element->ValueStr() == "texture") { CreateTexture(element->Attribute("name")); } - else if (strcmp(element->Value(), "quad")==0) + else if (element->ValueStr() == "quad") { string quadName = element->Attribute("name"); string textureName = element->Attribute("texture"); @@ -170,7 +170,7 @@ bool JResourceManager::LoadResource(const string& resourceName) GetQuad(id)->SetHotSpot(hotspotX, hotspotY); } } - else if (strcmp(element->Value(), "font")==0) + else if (element->ValueStr() == "font") { } diff --git a/JGE/src/pc/JGfx.cpp b/JGE/src/pc/JGfx.cpp index 041e128d8..ace1b7a30 100644 --- a/JGE/src/pc/JGfx.cpp +++ b/JGE/src/pc/JGfx.cpp @@ -358,7 +358,7 @@ void JQuad::SetHotSpot(float x, float y) ////////////////////////////////////////////////////////////////////////// -JTexture::JTexture() : mBuffer(NULL) +JTexture::JTexture() : mWidth(0), mHeight(0), mBuffer(NULL) { mTexId = -1; } diff --git a/projects/mtg/Android/jni/Android.mk b/projects/mtg/Android/jni/Android.mk index 4334cd0b4..78e273ce8 100644 --- a/projects/mtg/Android/jni/Android.mk +++ b/projects/mtg/Android/jni/Android.mk @@ -14,7 +14,7 @@ PNG_PATH := $(JGE_PATH)/Dependencies/libpng DEBUG ?= DEBUG LOCAL_CFLAGS += -DLINUX -DANDROID -DSDL_CONFIG -D_$(DEBUG) -LOCAL_CFLAGS += -D_STLP_USE_SIMPLE_NODE_ALLOC +LOCAL_CFLAGS += -D_STLP_USE_SIMPLE_NODE_ALLOC -DTIXML_USE_STL LOCAL_CFLAGS += -D__arm__ -D_REENTRANT -D_GLIBCXX__PTHREADS LOCAL_STATIC_LIBRARIES := libpng libjpeg LOCAL_SHARED_LIBRARIES := SDL diff --git a/projects/mtg/Makefile b/projects/mtg/Makefile index dc4f2b7fe..a77114104 100644 --- a/projects/mtg/Makefile +++ b/projects/mtg/Makefile @@ -73,7 +73,7 @@ PSP_EBOOT_UNKPNG = pic0.png PSP_EBOOT_PIC1 = pic1.png INCDIR = ../../JGE/include ../../JGE/src/zipFS ../../JGE/include/psp ../../JGE/include/psp/freetype2 ../../JGE/src ../../projects/mtg/include ../../Boost LIBDIR = ../../JGE/lib/psp -CFLAGS = -O2 -G0 -DPSPFW3XX -DDEVHOOK -DUSE_PRECOMPILED_HEADERS=1 -DPSP +CFLAGS = -O2 -G0 -DPSPFW3XX -DDEVHOOK -DUSE_PRECOMPILED_HEADERS=1 -DPSP -DTIXML_USE_STL else OBJS += objs/TestSuiteAI.o INCDIR = -I../../JGE/include -I../../JGE/src -I/usr/X11/include -I../../projects/mtg/include -I../../Boost -I../../JGE/src/zipFS diff --git a/projects/mtg/include/ActionElement.h b/projects/mtg/include/ActionElement.h index bdd7007fe..aa3830e43 100644 --- a/projects/mtg/include/ActionElement.h +++ b/projects/mtg/include/ActionElement.h @@ -72,7 +72,7 @@ public: { return 0; } - virtual const char * getMenuText() + virtual const string getMenuText() { return "Ability"; } diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 6ff6c7521..d947a3db4 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -1081,7 +1081,7 @@ public: ManaCost * cost = NULL); int resolve(); - const char* getMenuText(); + const string getMenuText(); AACounter * clone() const; }; @@ -1100,7 +1100,7 @@ public: bool all,ManaCost * cost = NULL); int resolve(); - const char* getMenuText(); + const string getMenuText(); AARemoveAllCounter * clone() const; }; @@ -1110,7 +1110,7 @@ class AAResetDamage: public ActivatedAbility public: AAResetDamage(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, ManaCost * cost = NULL); int resolve(); - const char* getMenuText(); + const string getMenuText(); AAResetDamage * clone() const; }; @@ -1120,7 +1120,7 @@ public: string named; AAFakeAbility(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target,string _newName, ManaCost * cost = NULL); int resolve(); - const char* getMenuText(); + const string getMenuText(); AAFakeAbility * clone() const; }; @@ -1131,7 +1131,7 @@ public: AAFizzler(GameObserver* observer, int _id, MTGCardInstance * card, Spell * _target, ManaCost * _cost = NULL); int resolve(); - const char * getMenuText(); + const string getMenuText(); AAFizzler* clone() const; }; @@ -1160,7 +1160,7 @@ public: string Cond; IfThenAbility(GameObserver* observer, int _id,MTGAbility * delayedAbility = NULL,MTGAbility * delayedElseAbility = NULL, MTGCardInstance * _source=NULL, Targetable * target = NULL, int type = 1,string Cond = ""); int resolve(); - const char * getMenuText(); + const string getMenuText(); IfThenAbility * clone() const; ~IfThenAbility(); }; @@ -1179,7 +1179,7 @@ public: void Update(float dt); - const char * getMenuText(); + const string getMenuText(); int testDestroy(); int isReactingToTargetClick(Targetable * card); @@ -1209,7 +1209,7 @@ public: bool CheckUserInput(JButton key); void Update(float dt); int resolve(); - const char * getMenuText(); + const string getMenuText(); int testDestroy(); int isReactingToTargetClick(Targetable * card); int reactToTargetClick(Targetable * object); @@ -1225,7 +1225,7 @@ class AAProliferate: public ActivatedAbility public: AAProliferate(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target,ManaCost * cost = NULL); int resolve(); - const char* getMenuText(); + const string getMenuText(); AAProliferate * clone() const; ~AAProliferate(); }; @@ -1243,7 +1243,7 @@ public: int resolve(); int addToGame(); int destroy(); - const char * getMenuText(); + const string getMenuText(); MultiAbility * clone() const; ~MultiAbility(); }; @@ -1258,8 +1258,9 @@ public: GenericActivatedAbility(GameObserver* observer, string newName,string castRestriction,int _id, MTGCardInstance * card, MTGAbility * a, ManaCost * _cost, string limit = "",MTGAbility * sideEffects = NULL,string usesBeforeSideEffects = "", int restrictions = 0, MTGGameZone * dest = NULL); + GenericActivatedAbility(const GenericActivatedAbility& other); int resolve(); - const char * getMenuText(); + const string getMenuText(); int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); void Update(float dt); int testDestroy(); @@ -1274,7 +1275,7 @@ class AALibraryBottom: public ActivatedAbility public: AALibraryBottom(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL); int resolve(); - const char * getMenuText(); + const string getMenuText(); AALibraryBottom * clone() const; }; @@ -1284,7 +1285,7 @@ class AACopier: public ActivatedAbility public: AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL); int resolve(); - const char * getMenuText(); + const string getMenuText(); AACopier * clone() const; }; //imprint @@ -1293,7 +1294,7 @@ class AAPhaseOut: public ActivatedAbility public: AAPhaseOut(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL); int resolve(); - const char * getMenuText(); + const string getMenuText(); AAPhaseOut * clone() const; }; //cloning...this makes a token thats a copy of the target. @@ -1310,7 +1311,7 @@ public: AACloner(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL, int who = 0, string abilitiesStringList = "",string typeslist = ""); int resolve(); - const char * getMenuText(); + const string getMenuText(); virtual ostream& toString(ostream& out) const; AACloner * clone() const; ~AACloner(); @@ -1326,7 +1327,7 @@ public: AAMover(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest,string _name, ManaCost * _cost = NULL); MTGGameZone * destinationZone(Targetable * target = NULL); int resolve(); - const char * getMenuText(); + const string getMenuText(); const char * getMenuText(TargetChooser * fromTc); AAMover * clone() const; ~AAMover(); @@ -1342,7 +1343,7 @@ public: AARandomMover(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target, string tcs, string from, string to); MTGGameZone * destinationZone(Targetable * target = NULL,string zone = ""); int resolve(); - const char * getMenuText(); + const string getMenuText(); AARandomMover * clone() const; ~AARandomMover(); }; @@ -1356,7 +1357,7 @@ public: string menu; AABuryCard(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target); int resolve(); - const char * getMenuText(); + const string getMenuText(); AABuryCard * clone() const; ~AABuryCard(); }; @@ -1367,7 +1368,7 @@ public: MTGAbility * andAbility; AADestroyCard(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target); int resolve(); - const char * getMenuText(); + const string getMenuText(); AADestroyCard * clone() const; ~AADestroyCard(); }; @@ -1378,7 +1379,7 @@ public: MTGAbility * andAbility; AASacrificeCard(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target); int resolve(); - const char * getMenuText(); + const string getMenuText(); AASacrificeCard * clone() const; ~AASacrificeCard(); }; @@ -1389,7 +1390,7 @@ public: MTGAbility * andAbility; AADiscardCard(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target); int resolve(); - const char * getMenuText(); + const string getMenuText(); AADiscardCard * clone() const; ~AADiscardCard(); }; @@ -1409,7 +1410,7 @@ public: string tcString; GenericTargetAbility(GameObserver* observer, string newName, string castRestriction, int _id, MTGCardInstance * _source, TargetChooser * _tc, MTGAbility * a, ManaCost * _cost = NULL, string limit = "",MTGAbility * sideEffects = NULL,string usesBeforeSideEffects = "", int restrictions = 0, MTGGameZone * dest = NULL,string tcString =""); - const char * getMenuText(); + const string getMenuText(); ~GenericTargetAbility(); GenericTargetAbility * clone() const; int resolve(); @@ -1447,7 +1448,7 @@ public: return 1; } - const char * getMenuText() + const string getMenuText() { return "Ninjutsu"; } @@ -1479,7 +1480,7 @@ public: return 1; } - const char * getMenuText() + const string getMenuText() { return "Remove From Combat"; } @@ -1501,7 +1502,7 @@ public: AADrawer(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, ManaCost * _cost,string nbcardsStr, int who = TargetChooser::UNSET,bool noReplace = false); int resolve(); - const char * getMenuText(); + const string getMenuText(); AADrawer * clone() const; int getNumCards(); }; @@ -1521,7 +1522,7 @@ public: ACastRestriction(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, TargetChooser * _restrictionsScope, WParsedInt * _value, bool _modifyExisting, int _zoneId, int who = TargetChooser::UNSET); int addToGame(); int destroy(); - const char * getMenuText(); + const string getMenuText(); ACastRestriction * clone() const; ~ACastRestriction(); @@ -1536,7 +1537,7 @@ public: AInstantCastRestrictionUEOT(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, TargetChooser * _restrictionsScope, WParsedInt * _value, bool _modifyExisting, int _zoneId, int who = TargetChooser::UNSET); int resolve(); - const char * getMenuText(); + const string getMenuText(); AInstantCastRestrictionUEOT * clone() const; ~AInstantCastRestrictionUEOT(); }; @@ -1549,7 +1550,7 @@ public: AALifer(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string life_s, ManaCost * _cost = NULL, int who = TargetChooser::UNSET); int resolve(); - const char * getMenuText(); + const string getMenuText(); AALifer * clone() const; int getLife(); @@ -1562,7 +1563,7 @@ public: AAWinGame(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, ManaCost * _cost = NULL, int who = TargetChooser::UNSET); int resolve(); - const char * getMenuText(); + const string getMenuText(); AAWinGame * clone() const; }; @@ -1603,7 +1604,7 @@ public: return 1; } - const char * getMenuText() + const string getMenuText() { return Constants::MTGBasicAbilities[ability]; } @@ -1645,7 +1646,7 @@ public: return InstantAbility::addToGame(); } - const char * getMenuText() + const string getMenuText() { return Constants::MTGBasicAbilities[ability]; } @@ -1706,7 +1707,7 @@ public: return ActivatedAbility::addToGame(); } - const char * getMenuText() + const string getMenuText() { return ability->getMenuText(); } @@ -1862,7 +1863,7 @@ public: return 1; } - const char * getMenuText() + const string getMenuText() { sprintf(menuText,"Protection from %s",tcstr.c_str()); return menuText; @@ -2054,7 +2055,7 @@ public: ((MTGCardInstance *) target)->addToToughness(-wppt->toughness.getValue()); return 1; } - const char * getMenuText() + const string getMenuText() { if(PT.size()) { @@ -2147,7 +2148,7 @@ public: return 1; } - const char * getMenuText() + const string getMenuText() { return ability->getMenuText(); } @@ -2189,7 +2190,7 @@ public: return toAdd->addToGame(); } - const char * getMenuText() + const string getMenuText() { return ability->getMenuText(); } @@ -2287,7 +2288,7 @@ public: return 1; } - const char * getMenuText() + const string getMenuText() { return "Regenerate"; } @@ -2494,7 +2495,7 @@ public: SAFE_DELETE(ability); } - const char * getMenuText() + const string getMenuText() { if(ability) { @@ -2620,7 +2621,7 @@ public: SAFE_DELETE(ability); } - const char * getMenuText() + const string getMenuText() { //Special case for move if (AAMover * move = dynamic_cast(ability)) @@ -2806,7 +2807,7 @@ public: int equip(MTGCardInstance * equipped); int resolve(); - const char * getMenuText(); + const string getMenuText(); int testDestroy(); int destroy(); @@ -3034,7 +3035,7 @@ public: card->setAttacker(1); } - const char * getMenuText() + const string getMenuText() { sprintf(menuText, "Create %s", name.c_str()); return menuText; @@ -3135,7 +3136,7 @@ public: } } - const char * getMenuText() + const string getMenuText() { if(name.size()) return name.c_str(); @@ -3308,7 +3309,7 @@ public: return 0; } - const char * getMenuText() + const string getMenuText() { return ability->getMenuText(); } @@ -3520,7 +3521,7 @@ public: } } - const char * getMenuText() + const string getMenuText() { return ability->getMenuText(); } @@ -3543,7 +3544,7 @@ public: AASetHand(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, int hand, ManaCost * _cost = NULL, int who = TargetChooser::UNSET); int resolve(); - const char * getMenuText(); + const string getMenuText(); AASetHand * clone() const; }; @@ -3557,7 +3558,7 @@ public: AALifeSet(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, WParsedInt * life, ManaCost * _cost = NULL, int who = TargetChooser::UNSET); int resolve(); - const char * getMenuText(); + const string getMenuText(); AALifeSet * clone() const; ~AALifeSet(); @@ -3574,7 +3575,7 @@ public: AADamager(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, string d, ManaCost * _cost = NULL, int who = TargetChooser::UNSET); int resolve(); - const char * getMenuText(); + const string getMenuText(); int getDamage(); AADamager * clone() const; @@ -3588,7 +3589,7 @@ public: AADamagePrevent(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, int preventing, ManaCost * _cost = NULL, int who = TargetChooser::UNSET); int resolve(); - const char * getMenuText(); + const string getMenuText(); AADamagePrevent * clone() const; ~AADamagePrevent(); }; @@ -3602,7 +3603,7 @@ public: AAAlterPoison(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, int poison, ManaCost * _cost = NULL, int who = TargetChooser::UNSET); int resolve(); - const char * getMenuText(); + const string getMenuText(); AAAlterPoison * clone() const; ~AAAlterPoison(); }; @@ -3630,7 +3631,7 @@ class AATapper: public ActivatedAbility public: AATapper(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL); int resolve(); - const char * getMenuText(); + const string getMenuText(); AATapper * clone() const; }; @@ -3640,7 +3641,7 @@ class AAUntapper: public ActivatedAbility public: AAUntapper(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL); int resolve(); - const char * getMenuText(); + const string getMenuText(); AAUntapper * clone() const; }; @@ -3661,7 +3662,7 @@ class AAFrozen: public ActivatedAbility public: AAFrozen(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL); int resolve(); - const char * getMenuText(); + const string getMenuText(); AAFrozen * clone() const; }; /* ghetto new target*/ @@ -3671,7 +3672,7 @@ public: bool retarget; AANewTarget(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,bool retarget = false, ManaCost * _cost = NULL); int resolve(); - const char * getMenuText(); + const string getMenuText(); AANewTarget * clone() const; }; /* morph*/ @@ -3682,7 +3683,7 @@ public: AAMorph(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL); int resolve(); int testDestroy(); - const char * getMenuText(); + const string getMenuText(); AAMorph * clone() const; }; /* flip*/ @@ -3694,7 +3695,7 @@ public: AAFlip(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target,string flipStats); int resolve(); int testDestroy(); - const char * getMenuText(); + const string getMenuText(); AAFlip * clone() const; }; /* dynamic ability build*/ @@ -3759,7 +3760,7 @@ string menu; int resolve(); int activateMainAbility(MTGAbility * toActivate,MTGCardInstance * source , Damageable * target); int activateStored(); - const char * getMenuText(); + const string getMenuText(); AADynamic * clone() const; ~AADynamic(); }; @@ -3812,7 +3813,7 @@ public: return 1; } - const char * getMenuText() + const string getMenuText() { return "Swap power and toughness"; } @@ -3828,7 +3829,7 @@ public: AAExchangeLife(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, ManaCost * _cost = NULL, int who = TargetChooser::UNSET); int resolve(); - const char * getMenuText(); + const string getMenuText(); AAExchangeLife * clone() const; }; @@ -4064,7 +4065,7 @@ public: int reapplyCountersBonus(MTGCardInstance * rtarget= NULL,bool powerapplied=false,bool toughnessapplied=false); int testDestroy(); int destroy(); - const char * getMenuText(); + const string getMenuText(); ATransformer * clone() const; ~ATransformer(); }; @@ -4087,7 +4088,7 @@ public: ATransformerInstant(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, string types = "", string abilities = "",string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vectornewAbilitiesList = vector(),bool newAbilityFound = false,bool aForever = false, bool UYNT = false,string menutext = ""); int resolve(); - const char * getMenuText(); + const string getMenuText(); ATransformerInstant * clone() const; ~ATransformerInstant(); }; @@ -4103,7 +4104,7 @@ public: WParsedPT * newWppt; PTInstant(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, WParsedPT * wppt,string s = "",bool nonstatic = false); int resolve(); - const char * getMenuText(); + const string getMenuText(); PTInstant * clone() const; ~PTInstant(); }; @@ -4162,7 +4163,7 @@ public: return 1; } - const char * getMenuText() + const string getMenuText() { return "Exalted"; } @@ -4180,7 +4181,7 @@ public: ASwapPT * ability; ASwapPTUEOT(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target); int resolve(); - const char * getMenuText(); + const string getMenuText(); ASwapPTUEOT * clone() const; ~ASwapPTUEOT(); }; @@ -4257,7 +4258,7 @@ public: APreventDamageTypesUEOT(GameObserver* observer, int id, MTGCardInstance * source, string to, string from, int type = 0); int resolve(); int destroy(); - const char * getMenuText(); + const string getMenuText(); APreventDamageTypesUEOT * clone() const; ~APreventDamageTypesUEOT(); }; @@ -4274,7 +4275,7 @@ public: AVanishing(GameObserver* observer, int _id, MTGCardInstance * card, ManaCost * _cost, int restrictions = 0,int amount = 0,string counterName = ""); void Update(float dt); int resolve(); - const char * getMenuText(); + const string getMenuText(); AVanishing * clone() const; ~AVanishing(); }; @@ -4296,7 +4297,7 @@ public: void Update(float dt); int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int resolve(); - const char * getMenuText(); + const string getMenuText(); virtual ostream& toString(ostream& out) const; AUpkeep * clone() const; ~AUpkeep(); @@ -4322,7 +4323,7 @@ public: MTG_PHASE_UPKEEP,bool forcedestroy = false,bool next = true,bool myturn = true,bool opponentturn = true,bool once = false); void Update(float dt); int resolve(); - const char * getMenuText(); + const string getMenuText(); APhaseAction * clone() const; ~APhaseAction(); }; @@ -4336,7 +4337,7 @@ public: APhaseActionGeneric(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * target, string sAbility, int restrictions = 0, int _phase = MTG_PHASE_UPKEEP,bool forcedestroy = false,bool next = true,bool myturn = false,bool opponentturn = false,bool once = false); int resolve(); - const char * getMenuText(); + const string getMenuText(); APhaseActionGeneric * clone() const; ~APhaseActionGeneric(); @@ -4356,7 +4357,7 @@ public: void Update(float dt); void resolveBlink(); int resolve(); - const char * getMenuText(); + const string getMenuText(); ABlink * clone() const; ~ABlink(); private: @@ -4374,7 +4375,7 @@ public: MTGAbility * stored; ABlinkGeneric(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * _target,bool blinkueot=false,bool blinkForSource = false,bool blinkhand = false,MTGAbility * stored = NULL); int resolve(); - const char * getMenuText(); + const string getMenuText(); ABlinkGeneric * clone() const; ~ABlinkGeneric(); @@ -5280,7 +5281,7 @@ public: return 1; } - const char * getMenuText() + const string getMenuText() { return "phase alter"; } @@ -5299,7 +5300,7 @@ public: AADepleter(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbcardsStr, ManaCost * _cost = NULL, int who = TargetChooser::UNSET); int resolve(); - const char * getMenuText(); + const string getMenuText(); AADepleter * clone() const; }; @@ -5312,7 +5313,7 @@ public: AAModTurn(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbTurnStr, ManaCost * _cost = NULL, int who = TargetChooser::UNSET); int resolve(); - const char * getMenuText(); + const string getMenuText(); AAModTurn * clone() const; }; @@ -5323,7 +5324,7 @@ public: AAShuffle(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, ManaCost * _cost = NULL, int who = TargetChooser::UNSET); int resolve(); - const char * getMenuText(); + const string getMenuText(); AAShuffle * clone() const; }; @@ -5336,7 +5337,7 @@ public: AARemoveMana(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, string ManaDesc, int who = TargetChooser::UNSET); int resolve(); - const char * getMenuText(); + const string getMenuText(); AARemoveMana * clone() const; ~AARemoveMana(); @@ -5351,7 +5352,7 @@ public: AARandomDiscarder(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbcardsStr, ManaCost * _cost = NULL, int who = TargetChooser::UNSET); int resolve(); - const char * getMenuText(); + const string getMenuText(); AARandomDiscarder * clone() const; }; @@ -5523,7 +5524,7 @@ public: int testDestroy(){return 0;}; void Update(float dt); - const char * getMenuText(); + const string getMenuText(); int isReactingToTargetClick(Targetable * card); int reactToTargetClick(Targetable * object); MTGCardInstance * makeCard(); @@ -5640,7 +5641,7 @@ public: MTGAbility * abilityAltered; AASetColorChosen(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, int _color = 0 ,string toAdd = ""); int resolve(); - const char* getMenuText(); + const string getMenuText(); AASetColorChosen * clone() const; ~AASetColorChosen(); }; @@ -5653,7 +5654,7 @@ public: MTGAbility * abilityAltered; AASetTypeChosen(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, int _type = 0,string menu = "error" ,string toAdd = ""); int resolve(); - const char* getMenuText(); + const string getMenuText(); AASetTypeChosen * clone() const; ~AASetTypeChosen(); }; @@ -5667,7 +5668,7 @@ public: bool ANonWall; GenericChooseTypeColor(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target, string toAdd = "",bool chooseColor = false,bool nonwall = false, ManaCost * cost = NULL); int resolve(); - const char* getMenuText(); + const string getMenuText(); GenericChooseTypeColor * clone() const; ~GenericChooseTypeColor(); @@ -5684,7 +5685,7 @@ public: MTGAbility * abilityAltered; AASetCoin(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target, int side = -1,string toAdd = ""); int resolve(); - const char* getMenuText(); + const string getMenuText(); AASetCoin * clone() const; ~AASetCoin(); }; @@ -5695,7 +5696,7 @@ public: AASetCoin * setCoin; GenericFlipACoin(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target, string toAdd = "", ManaCost * cost = NULL); int resolve(); - const char* getMenuText(); + const string getMenuText(); GenericFlipACoin * clone() const; ~GenericFlipACoin(); @@ -5714,7 +5715,7 @@ public: GenericPaidAbility(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target,string _newName,string _castRestriction,string _mayCost, string toAdd, ManaCost * cost = NULL); int resolve(); - const char* getMenuText(); + const string getMenuText(); GenericPaidAbility * clone() const; ~GenericPaidAbility(); diff --git a/projects/mtg/include/CardPrimitive.h b/projects/mtg/include/CardPrimitive.h index 6bad49cee..f02cd7d16 100644 --- a/projects/mtg/include/CardPrimitive.h +++ b/projects/mtg/include/CardPrimitive.h @@ -101,10 +101,9 @@ public: int removeType(string value, int removeAll = 0); int removeType(int value, int removeAll = 0); bool hasSubtype(int _subtype); - bool hasSubtype(const char * _subtype); bool hasSubtype(const string& _subtype); bool hasType(int _type); - bool hasType(const char * type); + bool hasType(const string& type); void setManaCost(const string& value); ManaCost * getManaCost(); diff --git a/projects/mtg/include/DeckEditorMenu.h b/projects/mtg/include/DeckEditorMenu.h index d252785ec..6191d88bb 100644 --- a/projects/mtg/include/DeckEditorMenu.h +++ b/projects/mtg/include/DeckEditorMenu.h @@ -17,7 +17,7 @@ private: StatsWrapper *stw; public: - DeckEditorMenu(int id, JGuiListener* listener = NULL, int fontId = 1, const char * _title = "", DeckDataWrapper *selectedDeck = NULL, StatsWrapper *stats = NULL); + DeckEditorMenu(int id, JGuiListener* listener = NULL, int fontId = 1, const string& _title = "", DeckDataWrapper *selectedDeck = NULL, StatsWrapper *stats = NULL); void Render(); virtual ~DeckEditorMenu(); }; diff --git a/projects/mtg/include/DeckMenu.h b/projects/mtg/include/DeckMenu.h index 0f2376634..fa3035efd 100644 --- a/projects/mtg/include/DeckMenu.h +++ b/projects/mtg/include/DeckMenu.h @@ -79,7 +79,7 @@ public: virtual void Render(); virtual void Update(float dt); using JGuiController::Add; - virtual void Add(int id, const char * Text, string desc = "", bool forceFocus = false, DeckMetaData *deckMetaData = NULL); + virtual void Add(int id, const string& Text, const string& desc = "", bool forceFocus = false, DeckMetaData *deckMetaData = NULL); virtual void Close(); void updateScroller(); void RenderBackground(); diff --git a/projects/mtg/include/DeckMenuItem.h b/projects/mtg/include/DeckMenuItem.h index 67d48e9b5..53ee35d5e 100644 --- a/projects/mtg/include/DeckMenuItem.h +++ b/projects/mtg/include/DeckMenuItem.h @@ -77,9 +77,7 @@ public: } // Setters - void setDescription( const string description ) { mDescription = description; }; - - ; + void setDescription( const string& description ) { mDescription = description; } }; #endif diff --git a/projects/mtg/include/DeckStats.h b/projects/mtg/include/DeckStats.h index 428b538c8..39238c533 100644 --- a/projects/mtg/include/DeckStats.h +++ b/projects/mtg/include/DeckStats.h @@ -98,7 +98,7 @@ public: string getManaColorIndex(); void updateStats(string filename, MTGAllCards * collection); void updateStats(DeckDataWrapper *mtgDeck); - int countCardsByType(const char * _type, DeckDataWrapper * myDeck); + int countCardsByType(const string& _type, DeckDataWrapper * myDeck); float noLuck(int n, int a, int x); vector aiDeckNames; diff --git a/projects/mtg/include/GameObserver.h b/projects/mtg/include/GameObserver.h index 281e742ba..5b3bfcbbe 100644 --- a/projects/mtg/include/GameObserver.h +++ b/projects/mtg/include/GameObserver.h @@ -98,8 +98,8 @@ class GameObserver{ int cardClick(MTGCardInstance * card,Targetable * _object = NULL, bool log = true); GamePhase getCurrentGamePhase(); void setCurrentGamePhase(GamePhase phase) { mCurrentGamePhase = phase; }; - const char * getCurrentGamePhaseName(); - const char * getNextGamePhaseName(); + const string& getCurrentGamePhaseName(); + const string& getNextGamePhaseName(); void nextCombatStep(); void userRequestNextGamePhase(bool allowInterrupt = true, bool log = true); void cleanupPhase(); diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index 71e04fd07..b9ecfa8cf 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -317,7 +317,7 @@ public: virtual TargetAbility* clone() const = 0; virtual void Render(); virtual int resolve(); - virtual const char * getMenuText(); + virtual const string getMenuText(); virtual ostream& toString(ostream& out) const; }; @@ -436,7 +436,7 @@ public: void Update(float dt); virtual GenericTriggeredAbility* clone() const; - const char * getMenuText(); + const string getMenuText(); ~GenericTriggeredAbility(); }; @@ -525,7 +525,7 @@ public: int isReactingToClick(MTGCardInstance * _card, ManaCost * mana = NULL); int resolve(); int reactToClick(MTGCardInstance* _card); - const char * getMenuText(); + const string getMenuText(); ~AManaProducer(); virtual AManaProducer * clone() const; }; diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 7317c4142..ab708e5db 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -129,11 +129,11 @@ public: //types - void addType(char * type_text); + void addType(const string& type_text); virtual void addType(int id); - void setType(const char * type_text); - void setSubtype( string value); - int removeType(string value, int removeAll = 0); + void setType(const string& type_text); + void setSubtype(const string &value); + int removeType(const string &value, int removeAll = 0); int removeType(int value, int removeAll = 0); //dangerranking is a hint to Ai which creatures are the ones it should be targetting for effects. diff --git a/projects/mtg/include/MTGDeck.h b/projects/mtg/include/MTGDeck.h index 3fe38b5f2..577d83c8f 100644 --- a/projects/mtg/include/MTGDeck.h +++ b/projects/mtg/include/MTGDeck.h @@ -19,7 +19,7 @@ class MTGPack; class MTGSetInfo { public: - MTGSetInfo(string _id); + MTGSetInfo(const string& _id); ~MTGSetInfo(); string id; //Short name: 10E, RAV, etc. Automatic from folder. string author; //Author of set, for crediting mod makers, etc. @@ -70,7 +70,7 @@ public: MTGSets(); ~MTGSets(); - int Add(const char * subtype); + int Add(const string& subtype); int findSet(string value); int findBlock(string s); int size(); @@ -127,8 +127,10 @@ public: MTGCard * getCardByName(string name); void loadFolder(const string& folder, const string& filename="" ); - int load(const char * config_file, const char * setName = NULL, int autoload = 1); - int countByType(const char * _type); + int load(const string& config_file); + int load(const string& config_file, const string& setName); + int load(const string& config_file, int set_id); + int countByType(const string& _type); int countByColor(int color); int countBySet(int setId); int totalCards(); @@ -218,8 +220,8 @@ public: int totalCards(); int totalPrice(); MTGDeck(MTGAllCards * _allcards); - MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only = 0,int difficultySetting = 0); - int addRandomCards(int howmany, int * setIds = NULL, int nbSets = 0, int rarity = -1, const char * subtype = NULL, + MTGDeck(const string& config_file, MTGAllCards * _allcards, int meta_only = 0,int difficultySetting = 0); + int addRandomCards(int howmany, int * setIds = NULL, int nbSets = 0, int rarity = -1, const string& subtype = "", int * colors = NULL, int nbcolors = 0); int add(int cardid); int add(MTGDeck * deck); // adds the contents of "deck" into myself diff --git a/projects/mtg/include/MTGDefinitions.h b/projects/mtg/include/MTGDefinitions.h index 0db903015..86d11e14d 100644 --- a/projects/mtg/include/MTGDefinitions.h +++ b/projects/mtg/include/MTGDefinitions.h @@ -293,7 +293,7 @@ class Constants static map MTGBasicAbilitiesMap; static const char* MTGBasicAbilities[]; - static const char* MTGPhaseNames[]; + static const string MTGPhaseNames[]; static const char* MTGPhaseCodeNames[]; static int GetBasicAbilityIndex(string mtgAbility); diff --git a/projects/mtg/include/MTGGameZones.h b/projects/mtg/include/MTGGameZones.h index 9970ff4d9..7310d65d0 100644 --- a/projects/mtg/include/MTGGameZones.h +++ b/projects/mtg/include/MTGGameZones.h @@ -95,7 +95,7 @@ class MTGGameZone { void cleanupPhase(); void beforeBeginPhase(); - unsigned int countByType(const char * value); + unsigned int countByType(const string &value); unsigned int countByCanTarget(TargetChooser * tc); unsigned int countTotalManaSymbols(TargetChooser * tc, int color); MTGCardInstance * findByName(string name); diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index b601bd130..b524e42e2 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -73,7 +73,7 @@ public: int reactToClick(MTGCardInstance * card); virtual ostream& toString(ostream& out) const; MTGPutInPlayRule(GameObserver* observer, int _id); - const char * getMenuText() + const string getMenuText() { return "cast card normally"; } @@ -87,7 +87,7 @@ public: int reactToClick(MTGCardInstance * card); virtual ostream& toString(ostream& out) const; MTGKickerRule(GameObserver* observer, int _id); - const char * getMenuText() + const string getMenuText() { return "pay kicker"; } @@ -105,7 +105,7 @@ public: int reactToClick(MTGCardInstance * card); virtual ostream& toString(ostream& out) const; MTGAlternativeCostRule(GameObserver* observer, int _id); - const char * getMenuText() + const string getMenuText() { if(alternativeName.size()) return alternativeName.c_str(); @@ -121,7 +121,7 @@ public: int reactToClick(MTGCardInstance * card); virtual ostream& toString(ostream& out) const; MTGBuyBackRule(GameObserver* observer, int _id); - const char * getMenuText() + const string getMenuText() { return "cast and buy back"; } @@ -136,7 +136,7 @@ public: int reactToClick(MTGCardInstance * card); virtual ostream& toString(ostream& out) const; MTGFlashBackRule(GameObserver* observer, int _id); - const char * getMenuText() + const string getMenuText() { return "flash back"; } @@ -150,7 +150,7 @@ public: int reactToClick(MTGCardInstance * card); virtual ostream& toString(ostream& out) const; MTGRetraceRule(GameObserver* observer, int _id); - const char * getMenuText() + const string getMenuText() { return "retrace"; } @@ -165,7 +165,7 @@ public: int reactToClick(MTGCardInstance * card); virtual ostream& toString(ostream& out) const; MTGMorphCostRule(GameObserver* observer, int _id); - const char * getMenuText() + const string getMenuText() { return "play morphed"; } @@ -181,7 +181,7 @@ public: string suspendmenu; virtual ostream& toString(ostream& out) const; MTGSuspendRule(GameObserver* observer, int _id); - const char * getMenuText(); + const string getMenuText(); virtual MTGSuspendRule * clone() const; }; @@ -195,7 +195,7 @@ public: int reactToClick(MTGCardInstance * card); virtual ostream& toString(ostream& out) const; MTGAttackRule(GameObserver* observer, int _id); - const char * getMenuText() + const string getMenuText() { return "Attacker"; } @@ -213,7 +213,7 @@ public: int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); MTGPlaneswalkerAttackRule(GameObserver* observer, int _id); - const char * getMenuText() + const string getMenuText() { return "Attack Planeswalker"; } @@ -226,7 +226,7 @@ public: MTGCardInstance* attacker; AAPlaneswalkerAttacked(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * target); int resolve(); - const char* getMenuText(); + const string getMenuText(); AAPlaneswalkerAttacked * clone() const; ~AAPlaneswalkerAttacked(); }; @@ -252,7 +252,7 @@ public: int reactToClick(MTGCardInstance * card); virtual ostream& toString(ostream& out) const; MTGBlockRule(GameObserver* observer, int _id); - const char * getMenuText(); + const string getMenuText(); virtual MTGBlockRule * clone() const; ~MTGBlockRule(); }; @@ -386,7 +386,7 @@ public: int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card, int id); - const char * getMenuText() + const string getMenuText() { return "Momir"; } @@ -406,7 +406,7 @@ public: MTGCardInstance * genEquip(int id); MTGStoneHewerRule(GameObserver* observer, int _id, MTGAllCards * _collection); int receiveEvent(WEvent * event); - const char * getMenuText() + const string getMenuText() { return "Stone Hewer"; } @@ -419,7 +419,7 @@ class MTGHermitRule: public PermanentAbility public: MTGHermitRule(GameObserver* observer, int _id); int receiveEvent(WEvent * event); - const char * getMenuText() + const string getMenuText() { return "Hermit"; } @@ -447,7 +447,7 @@ public: int receiveEvent(WEvent * event); - const char * getMenuText() + const string getMenuText() { return "Deathtouch"; } diff --git a/projects/mtg/include/PhaseRing.h b/projects/mtg/include/PhaseRing.h index 2c116c1bf..3c3afd7cd 100644 --- a/projects/mtg/include/PhaseRing.h +++ b/projects/mtg/include/PhaseRing.h @@ -62,7 +62,7 @@ public: int addCombatAfter(Player* player, int after_id, bool withMain = false); int addPhaseAfter(GamePhase id, Player* player, int after_id); int removePhase(int id); - const char * phaseName(int id); + const string& phaseName(int id); static GamePhase phaseStrToInt(string s); static string phaseIntToStr(int id); diff --git a/projects/mtg/include/SimpleMenu.h b/projects/mtg/include/SimpleMenu.h index b68ca466c..f50d492e8 100644 --- a/projects/mtg/include/SimpleMenu.h +++ b/projects/mtg/include/SimpleMenu.h @@ -43,7 +43,7 @@ public: virtual bool CheckUserInput(JButton key); virtual void Update(float dt); using JGuiController::Add; - virtual void Add(int id, const char * Text, string desc = "", bool forceFocus = false); + virtual void Add(int id, const string &Text, string desc = "", bool forceFocus = false); int getmCurr(){return mCurr;} float getWidth(){return mWidth; } virtual void Close(); diff --git a/projects/mtg/include/utils.h b/projects/mtg/include/utils.h index 2029f3219..3a3461b40 100644 --- a/projects/mtg/include/utils.h +++ b/projects/mtg/include/utils.h @@ -140,4 +140,20 @@ template istream& operator>>(istream& in, T& p) /* replace_all ... replacement to avoid depending on boost for that */ void ReplaceString(std::string& subject, const std::string& search, const std::string& replace); +/*! \brief Returns true if base starts with start, otherwise false + * + * Compares the first strlen(start) characters of base with start and + * returns true if both match. + */ +bool StartsWith(const std::string& base, const char *start); + +/*! \brief Returns true if base starts with start, otherwise false + * + * This version is slightly more efficient as strlen does not need to + * get called. Otherwise, it behaves exactly like + * StartsWith(const std::string& base, const char *start) + * + * \see StartsWith(const std::string& base, const char *start) + */ +bool StartsWith(const std::string& base, const std::string& start); #endif diff --git a/projects/mtg/src/ActionStack.cpp b/projects/mtg/src/ActionStack.cpp index 6509bc217..24b15752a 100644 --- a/projects/mtg/src/ActionStack.cpp +++ b/projects/mtg/src/ActionStack.cpp @@ -57,7 +57,7 @@ void NextGamePhase::Render() if (observer->currentActionPlayer == observer->players[1]) playerId = 2; - sprintf(buffer, "%s %i : %s", _("Player").c_str(), playerId, observer->getNextGamePhaseName()); + sprintf(buffer, "%s %i : %s", _("Player").c_str(), playerId, observer->getNextGamePhaseName().c_str()); mFont->DrawString(buffer, x + 15, y+10, JGETEXT_LEFT); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); @@ -675,6 +675,7 @@ ActionStack::ActionStack(GameObserver* game) currentState = -1; mode = ACTIONSTACK_STANDARD; checked = 0; + lastActionController = NULL; if(!observer->getResourceManager()) return; for (int i = 0; i < 8; ++i) diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index d0f2cad43..53ba1bcbe 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -55,6 +55,12 @@ GenericActivatedAbility::GenericActivatedAbility(GameObserver* observer, string target = ability->target; } +GenericActivatedAbility::GenericActivatedAbility(const GenericActivatedAbility &other): + ActivatedAbility(other), NestedAbility(other), activeZone(other.activeZone), newName(other.newName) +{ + +} + int GenericActivatedAbility::resolve() { //Note: I've seen a similar block in some other MTGAbility, can this be refactored . @@ -71,7 +77,7 @@ int GenericActivatedAbility::resolve() return 0; } -const char * GenericActivatedAbility::getMenuText() +const string GenericActivatedAbility::getMenuText() { if(newName.size()) return newName.c_str(); @@ -105,6 +111,7 @@ int GenericActivatedAbility::testDestroy() GenericActivatedAbility * GenericActivatedAbility::clone() const { GenericActivatedAbility * a = NEW GenericActivatedAbility(*this); + a->ability = ability->clone(); return a; } @@ -133,7 +140,7 @@ int AAAlterPoison::resolve() return 0; } -const char * AAAlterPoison::getMenuText() +const string AAAlterPoison::getMenuText() { return "Poison"; } @@ -165,7 +172,7 @@ int AADamagePrevent::resolve() return 0; } -const char * AADamagePrevent::getMenuText() +const string AADamagePrevent::getMenuText() { return "Prevent Damage"; } @@ -237,7 +244,7 @@ AADamager::AADamager(GameObserver* observer, int _id, MTGCardInstance * _source, return damage.getValue(); } - const char * AADamager::getMenuText() + const string AADamager::getMenuText() { MTGCardInstance * _target = dynamic_cast(target); if(_target && _target->hasType(Subtypes::TYPE_PLANESWALKER)) @@ -276,7 +283,7 @@ AADepleter::AADepleter(GameObserver* observer, int _id, MTGCardInstance * card, return 1; } -const char * AADepleter::getMenuText() +const string AADepleter::getMenuText() { return "Deplete"; } @@ -311,7 +318,7 @@ AAModTurn::AAModTurn(GameObserver* observer, int _id, MTGCardInstance * card, Ta return 1; } - const char * AAModTurn::getMenuText() + const string AAModTurn::getMenuText() { WParsedInt numTurns(nbTurnStr, NULL, source); if(numTurns.getValue() > 0) @@ -354,7 +361,7 @@ int AALibraryBottom::resolve() return 0; } -const char * AALibraryBottom::getMenuText() +const string AALibraryBottom::getMenuText() { return "Bottom Of Library"; } @@ -382,7 +389,7 @@ int AACopier::resolve() return 0; } -const char * AACopier::getMenuText() +const string AACopier::getMenuText() { return "Copy"; } @@ -415,7 +422,7 @@ int AAPhaseOut::resolve() return 0; } -const char * AAPhaseOut::getMenuText() +const string AAPhaseOut::getMenuText() { return "Phase Out"; } @@ -506,7 +513,7 @@ AACounter::AACounter(GameObserver* observer, int id, MTGCardInstance * source, M return 0; } -const char* AACounter::getMenuText() +const string AACounter::getMenuText() { if (menu.size()) { @@ -695,7 +702,7 @@ int AARemoveAllCounter::resolve() return nb; } -const char* AARemoveAllCounter::getMenuText() +const string AARemoveAllCounter::getMenuText() { if (menu.size()) { @@ -773,7 +780,7 @@ int AAProliferate::resolve() } -const char* AAProliferate::getMenuText() +const string AAProliferate::getMenuText() { return "Proliferate"; } @@ -837,7 +844,7 @@ int GenericChooseTypeColor::resolve() } -const char* GenericChooseTypeColor::getMenuText() +const string GenericChooseTypeColor::getMenuText() { if(chooseColor) return "Choose a color"; @@ -899,7 +906,7 @@ int AASetColorChosen::resolve() return 1; } -const char* AASetColorChosen::getMenuText() +const string AASetColorChosen::getMenuText() { return Constants::MTGColorStrings[color]; } @@ -956,7 +963,7 @@ int AASetTypeChosen::resolve() return 1; } -const char* AASetTypeChosen::getMenuText() +const string AASetTypeChosen::getMenuText() { return menutext.c_str(); } @@ -1003,7 +1010,7 @@ int GenericFlipACoin::resolve() } -const char* GenericFlipACoin::getMenuText() +const string GenericFlipACoin::getMenuText() { return "Flip A Coin"; } @@ -1095,7 +1102,7 @@ int AASetCoin::resolve() return 1; } -const char* AASetCoin::getMenuText() +const string AASetCoin::getMenuText() { if(side == 1) return "Tails"; @@ -1186,7 +1193,7 @@ int GenericPaidAbility::resolve() return 1; } -const char* GenericPaidAbility::getMenuText() +const string GenericPaidAbility::getMenuText() { if (newName.size()) return newName.c_str(); @@ -1288,7 +1295,7 @@ int AAResetDamage::resolve() return 1; } -const char* AAResetDamage::getMenuText() +const string AAResetDamage::getMenuText() { return "Reset Damages"; } @@ -1309,7 +1316,7 @@ int AAFakeAbility::resolve() return 1; } -const char* AAFakeAbility::getMenuText() +const string AAFakeAbility::getMenuText() { if(named.size()) return named.c_str(); @@ -1356,7 +1363,7 @@ int AAFizzler::resolve() return 1; } -const char * AAFizzler::getMenuText() +const string AAFizzler::getMenuText() { return "Fizzle"; } @@ -1403,7 +1410,7 @@ int AABuryCard::resolve() return 0; } -const char * AABuryCard::getMenuText() +const string AABuryCard::getMenuText() { if(menu.size()) return menu.c_str(); @@ -1459,7 +1466,7 @@ int AADestroyCard::resolve() return 0; } -const char * AADestroyCard::getMenuText() +const string AADestroyCard::getMenuText() { return "Destroy"; } @@ -1515,7 +1522,7 @@ int AASacrificeCard::resolve() return 0; } -const char * AASacrificeCard::getMenuText() +const string AASacrificeCard::getMenuText() { return "Sacrifice"; } @@ -1570,7 +1577,7 @@ int AADiscardCard::resolve() return 0; } -const char * AADiscardCard::getMenuText() +const string AADiscardCard::getMenuText() { return "Discard"; } @@ -1634,7 +1641,7 @@ AADrawer::AADrawer(GameObserver* observer, int _id, MTGCardInstance * card, Targ return numCards.getValue(); } -const char * AADrawer::getMenuText() +const string AADrawer::getMenuText() { return "Draw"; } @@ -1663,7 +1670,7 @@ int AAFrozen::resolve() return 1; } -const char * AAFrozen::getMenuText() +const string AAFrozen::getMenuText() { return "Freeze"; } @@ -1728,7 +1735,7 @@ int AANewTarget::resolve() return 1; } -const char * AANewTarget::getMenuText() +const string AANewTarget::getMenuText() { return "New Target"; } @@ -1809,7 +1816,7 @@ int AAMorph::testDestroy() return 0; } -const char * AAMorph::getMenuText() +const string AAMorph::getMenuText() { return "Morph"; } @@ -1946,7 +1953,7 @@ int AAFlip::testDestroy() return 0; } -const char * AAFlip::getMenuText() +const string AAFlip::getMenuText() { string s = flipStats; sprintf(menuText, "Transform:%s", s.c_str()); @@ -2252,7 +2259,7 @@ int AADynamic::activateStored() return 1; } -const char * AADynamic::getMenuText() +const string AADynamic::getMenuText() { if (menu.size()) { @@ -2367,7 +2374,7 @@ int AALifer::getLife() return life.getValue(); } -const char * AALifer::getMenuText() +const string AALifer::getMenuText() { if(getLife() < 0) return "Life Loss"; @@ -2400,7 +2407,7 @@ int AASetHand::resolve() return 1; } -const char * AASetHand::getMenuText() +const string AASetHand::getMenuText() { return "Set Hand Size"; } @@ -2431,7 +2438,7 @@ int AALifeSet::resolve() return 1; } -const char * AALifeSet::getMenuText() +const string AALifeSet::getMenuText() { return "Set Life"; } @@ -2513,7 +2520,7 @@ int AACloner::resolve() } -const char * AACloner::getMenuText() +const string AACloner::getMenuText() { if (who == 1) return "Clone For Opponent"; @@ -2588,7 +2595,7 @@ int ACastRestriction::destroy() return 1; } -const char * ACastRestriction::getMenuText() +const string ACastRestriction::getMenuText() { if (modifyExisting) return "Additional Lands"; //hardoced because only the lands rule allows to modify existing rule for now @@ -2623,7 +2630,7 @@ int AInstantCastRestrictionUEOT::resolve() wrapper->addToGame(); return 1; } -const char * AInstantCastRestrictionUEOT::getMenuText() +const string AInstantCastRestrictionUEOT::getMenuText() { return ability->getMenuText(); } @@ -2717,14 +2724,14 @@ int AAMover::resolve() return 0; } -const char * AAMover::getMenuText() +const string AAMover::getMenuText() { if(named.size()) return named.c_str(); return "Move"; } -const char * AAMover::getMenuText(TargetChooser * tc) +const char* AAMover::getMenuText(TargetChooser * tc) { if(named.size()) return named.c_str(); @@ -2864,7 +2871,7 @@ int AARandomMover::resolve() return 0; } -const char * AARandomMover::getMenuText() +const string AARandomMover::getMenuText() { return "Dig"; } @@ -2902,7 +2909,7 @@ int AARandomDiscarder::resolve() return 1; } -const char * AARandomDiscarder::getMenuText() +const string AARandomDiscarder::getMenuText() { return "Discard Random"; } @@ -2929,7 +2936,7 @@ int AAShuffle::resolve() return 1; } -const char * AAShuffle::getMenuText() +const string AAShuffle::getMenuText() { return "Shuffle"; } @@ -3027,7 +3034,7 @@ int AARemoveMana::resolve() return 1; } -const char * AARemoveMana::getMenuText() +const string AARemoveMana::getMenuText() { if (mRemoveAll && !mManaDesc) return "Empty Manapool"; @@ -3066,7 +3073,7 @@ int AATapper::resolve() return 1; } -const char * AATapper::getMenuText() +const string AATapper::getMenuText() { return "Tap"; } @@ -3096,7 +3103,7 @@ int AAUntapper::resolve() return 1; } -const char * AAUntapper::getMenuText() +const string AAUntapper::getMenuText() { return "Untap"; } @@ -3177,7 +3184,7 @@ int AAWinGame::resolve() return 1; } -const char * AAWinGame::getMenuText() +const string AAWinGame::getMenuText() { return "Win Game"; } @@ -3268,7 +3275,7 @@ int IfThenAbility::resolve() return 0; } -const char * IfThenAbility::getMenuText() +const string IfThenAbility::getMenuText() { return ""; } @@ -3320,7 +3327,7 @@ void MayAbility::Update(float dt) } } -const char * MayAbility::getMenuText() +const string MayAbility::getMenuText() { return ability->getMenuText(); } @@ -3456,7 +3463,7 @@ int MenuAbility::resolve() return a->addToGame(); } -const char * MenuAbility::getMenuText() +const string MenuAbility::getMenuText() { if((abilities.size() > 1 && must)||(abilities.size() > 2 && !must)) return "choose one"; @@ -3657,7 +3664,7 @@ int MultiAbility::destroy() return ActivatedAbility::destroy(); } -const char * MultiAbility::getMenuText() +const string MultiAbility::getMenuText() { if (abilities.size() && abilities[0]) return abilities[0]->getMenuText(); @@ -3696,7 +3703,7 @@ GenericTargetAbility::GenericTargetAbility(GameObserver* observer, string newNam counters = 0; } -const char * GenericTargetAbility::getMenuText() +const string GenericTargetAbility::getMenuText() { if (!ability) return "Error"; @@ -4249,7 +4256,7 @@ int ATransformer::destroy() return 1; } -const char * ATransformer::getMenuText() +const string ATransformer::getMenuText() { if(menutext.size()) return menutext.c_str(); @@ -4282,7 +4289,7 @@ int ATransformerInstant::resolve() wrapper->addToGame(); return 1; } -const char * ATransformerInstant::getMenuText() +const string ATransformerInstant::getMenuText() { if(menu.size()) return menu.c_str(); @@ -4316,7 +4323,7 @@ int PTInstant::resolve() wrapper->addToGame(); return 1; } -const char * PTInstant::getMenuText() +const string PTInstant::getMenuText() { return ability->getMenuText(); } @@ -4347,7 +4354,7 @@ int ASwapPTUEOT::resolve() return 1; } -const char * ASwapPTUEOT::getMenuText() +const string ASwapPTUEOT::getMenuText() { return ability->getMenuText(); } @@ -4417,7 +4424,7 @@ int AAExchangeLife::resolve() return 0; } -const char * AAExchangeLife::getMenuText() +const string AAExchangeLife::getMenuText() { return "Exchange life"; } @@ -4655,7 +4662,7 @@ int APreventDamageTypesUEOT::destroy() return 1; } -const char * APreventDamageTypesUEOT::getMenuText() +const string APreventDamageTypesUEOT::getMenuText() { return ability->getMenuText(); } @@ -4725,7 +4732,7 @@ int AVanishing::resolve() return 1; } -const char * AVanishing::getMenuText() +const string AVanishing::getMenuText() { if(counterName.find("fade") != string::npos) return "Fading"; @@ -4821,7 +4828,7 @@ int AUpkeep::resolve() return 1; } -const char * AUpkeep::getMenuText() +const string AUpkeep::getMenuText() { return "Upkeep"; } @@ -4921,7 +4928,7 @@ int APhaseAction::resolve() return 0; } -const char * APhaseAction::getMenuText() +const string APhaseAction::getMenuText() { if(psMenuText.size()) return psMenuText.c_str(); @@ -4958,7 +4965,7 @@ int APhaseActionGeneric::resolve() return 1; } -const char * APhaseActionGeneric::getMenuText() +const string APhaseActionGeneric::getMenuText() { return ability->getMenuText(); } @@ -5116,7 +5123,7 @@ int ABlink::resolve() { return 0; } -const char * ABlink::getMenuText() +const string ABlink::getMenuText() { return "Blink"; } @@ -5147,7 +5154,7 @@ int ABlinkGeneric::resolve() return 1; } -const char * ABlinkGeneric::getMenuText() +const string ABlinkGeneric::getMenuText() { return "Blink"; } @@ -5316,6 +5323,7 @@ int AEquip::unequip() { MTGAbility * a = currentAbilities[i]; if (dynamic_cast (a) || dynamic_cast (a) || dynamic_cast (a) + || dynamic_cast (AbilityFactory::getCoreAbility(a)) || (a->aType == MTGAbility::STANDARD_TOKENCREATOR && a->oneShot)) { SAFE_DELETE(a); @@ -5369,7 +5377,7 @@ int AEquip::resolve() return 1; } -const char * AEquip::getMenuText() +const string AEquip::getMenuText() { if (isAttach) return "Attach"; @@ -5583,7 +5591,7 @@ int AACastCard::resolveSpell() return 0; } -const char * AACastCard::getMenuText() +const string AACastCard::getMenuText() { if(nameThis.size()) return nameThis.c_str(); diff --git a/projects/mtg/src/CardPrimitive.cpp b/projects/mtg/src/CardPrimitive.cpp index 0af4460d5..8372eb0c1 100644 --- a/projects/mtg/src/CardPrimitive.cpp +++ b/projects/mtg/src/CardPrimitive.cpp @@ -84,6 +84,9 @@ int CardPrimitive::init() alias = 0; restrictions = NULL; dredgeAmount = 0; + + power = 0; + toughness = 0; return 1; } @@ -344,18 +347,12 @@ bool CardPrimitive::hasSubtype(int _subtype) return hasType(_subtype); } -bool CardPrimitive::hasType(const char * _type) +bool CardPrimitive::hasType(const string& _type) { int id = MTGAllCards::findType(_type); return hasType(id); } -bool CardPrimitive::hasSubtype(const char * _subtype) -{ - int id = MTGAllCards::findType(_subtype); - return hasType(id); -} - bool CardPrimitive::hasSubtype(const string& _subtype) { int id = MTGAllCards::findType(_subtype); diff --git a/projects/mtg/src/CardSelector.cpp b/projects/mtg/src/CardSelector.cpp index cae1bee14..ce94a404c 100644 --- a/projects/mtg/src/CardSelector.cpp +++ b/projects/mtg/src/CardSelector.cpp @@ -66,7 +66,7 @@ CardSelector::SelectorMemory::SelectorMemory() } CardSelector::CardSelector(GameObserver *observer, DuelLayers* duel) : - CardSelectorBase(observer), active(NULL), duel(duel), limitor(NULL), bigpos(300, 145, 1.0, 0.0, 220) + CardSelectorBase(observer), active(NULL), duel(duel), limitor(NULL), bigpos(300, 145, 1.0, 0.0, 220), timer(0.0f) { } diff --git a/projects/mtg/src/DeckEditorMenu.cpp b/projects/mtg/src/DeckEditorMenu.cpp index 5af4b183a..f88695d9a 100644 --- a/projects/mtg/src/DeckEditorMenu.cpp +++ b/projects/mtg/src/DeckEditorMenu.cpp @@ -7,7 +7,7 @@ #include #include "Translate.h" -DeckEditorMenu::DeckEditorMenu(int id, JGuiListener* listener, int fontId, const char * _title, DeckDataWrapper *_selectedDeck, StatsWrapper *stats) : +DeckEditorMenu::DeckEditorMenu(int id, JGuiListener* listener, int fontId, const string& _title, DeckDataWrapper *_selectedDeck, StatsWrapper *stats) : DeckMenu(id, listener, fontId, _title), selectedDeck(_selectedDeck), stw(stats) { backgroundName = "DeckEditorMenuBackdrop"; diff --git a/projects/mtg/src/DeckMenu.cpp b/projects/mtg/src/DeckMenu.cpp index 98122f87a..8524fc90e 100644 --- a/projects/mtg/src/DeckMenu.cpp +++ b/projects/mtg/src/DeckMenu.cpp @@ -370,7 +370,7 @@ void DeckMenu::Update(float dt) } -void DeckMenu::Add(int id, const char * text, string desc, bool forceFocus, DeckMetaData * deckMetaData) +void DeckMenu::Add(int id, const string& text, const string& desc, bool forceFocus, DeckMetaData * deckMetaData) { DeckMenuItem * menuItem = NEW DeckMenuItem(this, id, fontId, text, 0, mY + DeckMenuConst::kVerticalMargin + mCount * DeckMenuConst::kLineHeight, (mCount == 0), mAutoTranslate, deckMetaData); diff --git a/projects/mtg/src/DeckStats.cpp b/projects/mtg/src/DeckStats.cpp index 9f50b2a7c..677760bb6 100644 --- a/projects/mtg/src/DeckStats.cpp +++ b/projects/mtg/src/DeckStats.cpp @@ -587,7 +587,7 @@ void StatsWrapper::updateStats(DeckDataWrapper *myDeck) // This should probably be cached in DeckDataWrapper // or at least be calculated for all common types in one go -int StatsWrapper::countCardsByType(const char * _type, DeckDataWrapper * myDeck) +int StatsWrapper::countCardsByType(const string& _type, DeckDataWrapper * myDeck) { int result = 0; for (int i = 0; i < myDeck->Size(true); i++) diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index b7dcda29c..ed01c26d5 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -110,12 +110,12 @@ GamePhase GameObserver::getCurrentGamePhase() return mCurrentGamePhase; } -const char* GameObserver::getCurrentGamePhaseName() +const string& GameObserver::getCurrentGamePhaseName() { return phaseRing->phaseName(mCurrentGamePhase); } -const char* GameObserver::getNextGamePhaseName() +const string& GameObserver::getNextGamePhaseName() { return phaseRing->phaseName((mCurrentGamePhase + 1) % MTG_PHASE_CLEANUP); } @@ -1042,7 +1042,7 @@ void GameObserver::Affinity() } else { - reduce = card->controller()->game->battlefield->countByType(type.c_str()); + reduce = card->controller()->game->battlefield->countByType(type); } for(int i = 0; i < reduce;i++) { diff --git a/projects/mtg/src/GameOptions.cpp b/projects/mtg/src/GameOptions.cpp index b82265623..548029827 100644 --- a/projects/mtg/src/GameOptions.cpp +++ b/projects/mtg/src/GameOptions.cpp @@ -818,9 +818,9 @@ void GameSettings::createUsersFirstDeck(int setId) mCollection->addRandomCards(10, 0, 0, Constants::RARITY_L, "Island"); //Starter Deck - mCollection->addRandomCards(3, sets, 1, Constants::RARITY_R, NULL); - mCollection->addRandomCards(9, sets, 1, Constants::RARITY_U, NULL); - mCollection->addRandomCards(48, sets, 1, Constants::RARITY_C, NULL); + mCollection->addRandomCards(3, sets, 1, Constants::RARITY_R); + mCollection->addRandomCards(9, sets, 1, Constants::RARITY_U); + mCollection->addRandomCards(48, sets, 1, Constants::RARITY_C); //Boosters for (int i = 0; i < 2; i++) @@ -956,7 +956,7 @@ OptionMaxGrade::OptionMaxGrade() // MARK: OptionASkipPhase -OptionASkipPhase OptionASkipPhase::mDef; +OptionASkipPhase OptionASkipPhase::mDef = OptionASkipPhase(); OptionASkipPhase::OptionASkipPhase() { mDef.values.push_back(EnumDefinition::assoc(Constants::ASKIP_NONE, "Off")); diff --git a/projects/mtg/src/GameState.cpp b/projects/mtg/src/GameState.cpp index 227a7af42..30c4eabd1 100644 --- a/projects/mtg/src/GameState.cpp +++ b/projects/mtg/src/GameState.cpp @@ -134,7 +134,7 @@ void GameState::renderDeckMenu(DeckMenu * _menu, const vector& d // deck sorting routines bool sortByName(DeckMetaData * d1, DeckMetaData * d2) { - return strcmp(d1->getName().c_str(), d2->getName().c_str()) < 0; + return d1->getName() < d2->getName(); } diff --git a/projects/mtg/src/GameStateStory.cpp b/projects/mtg/src/GameStateStory.cpp index 621f66081..8ec25b7f5 100644 --- a/projects/mtg/src/GameStateStory.cpp +++ b/projects/mtg/src/GameStateStory.cpp @@ -65,7 +65,7 @@ void GameStateStory::Update(float dt) if (!menu && mEngine->GetButtonClick(JGE_BTN_MENU)) { menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), 100, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 25); - menu->Add(0, "Back to main menu"); + menu->Add(0, string("Back to main menu")); menu->Add(kCancelMenuID, "Cancel"); } if (menu) diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index cebf7e5ac..5a5fb68ca 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -1145,7 +1145,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG } - if(strncmp(s.c_str(), "chooseacolor ", strlen("chooseacolor ")) == 0 || strncmp(s.c_str(), "chooseatype ", strlen("chooseatype ")) == 0) + if(s.compare(0, strlen("chooseacolor "), "chooseacolor ") == 0 || s.compare(0, strlen("chooseatype "), "chooseatype ") == 0) { MTGAbility * choose = parseChooseActionAbility(s,card,spell,target,0,id); choose = NEW GenericActivatedAbility(observer, "","",id, card,choose,NULL); @@ -4368,6 +4368,7 @@ MTGAbility::MTGAbility(GameObserver* observer, int id, MTGCardInstance * card) : aType = MTGAbility::UNKNOWN; mCost = NULL; forceDestroy = 0; + forcedAlive = 0; oneShot = 0; canBeInterrupted = true; } @@ -4381,6 +4382,7 @@ MTGAbility::MTGAbility(GameObserver* observer, int id, MTGCardInstance * _source aType = MTGAbility::UNKNOWN; mCost = NULL; forceDestroy = 0; + forcedAlive = 0; oneShot = 0; canBeInterrupted = true; } @@ -4893,7 +4895,7 @@ int TargetAbility::resolve() return 0; } -const char * TargetAbility::getMenuText() +const string TargetAbility::getMenuText() { if (ability) return ability->getMenuText(); @@ -5423,7 +5425,7 @@ GenericTriggeredAbility::~GenericTriggeredAbility() SAFE_DELETE(destroyCondition); } -const char * GenericTriggeredAbility::getMenuText() +const string GenericTriggeredAbility::getMenuText() { return ability->getMenuText(); } @@ -5451,6 +5453,7 @@ AManaProducer::AManaProducer(GameObserver* observer, int id, MTGCardInstance * c aType = MTGAbility::MANA_PRODUCER; setCost(_cost); output = _output; + tap = 0; Producing = producing; menutext = ""; DoesntEmpty = doesntEmpty; @@ -5516,7 +5519,7 @@ int AManaProducer::reactToClick(MTGCardInstance * _card) return ActivatedAbility::activateAbility(); } -const char * AManaProducer::getMenuText() +const string AManaProducer::getMenuText() { if (menutext.size()) return menutext.c_str(); diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index a44f1aae2..e70320ae4 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -125,6 +125,7 @@ int MTGCardInstance::init() void MTGCardInstance::initMTGCI() { + X = 0; sample = ""; model = NULL; isToken = false; @@ -195,6 +196,8 @@ void MTGCardInstance::initMTGCI() lastController = NULL; regenerateTokens = 0; blocked = false; + graveEffects = false; + exileEffects = false; currentZone = NULL; cardsAbilities = vector(); data = this; //an MTGCardInstance point to itself for data, allows to update it without killing the underlying database item @@ -254,22 +257,22 @@ void MTGCardInstance::addType(int type) SAFE_DELETE(e); } -void MTGCardInstance::addType(char * type_text) +void MTGCardInstance::addType(const string& type_text) { setSubtype(type_text); } -void MTGCardInstance::setType(const char * type_text) +void MTGCardInstance::setType(const string& type_text) { setSubtype(type_text); } -void MTGCardInstance::setSubtype(string value) +void MTGCardInstance::setSubtype(const string& value) { int id = MTGAllCards::findType(value); addType(id); } -int MTGCardInstance::removeType(string value, int removeAll) +int MTGCardInstance::removeType(const string& value, int removeAll) { int id = MTGAllCards::findType(value); return removeType(id, removeAll); diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index 20580dc14..058c1d4c3 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -47,33 +47,33 @@ static inline int getGrade(int v) int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primitive) { if ('#' == s[0]) return 1; // a comment shouldn't be treated as an error condition - size_t i = s.find_first_of('='); - if (i == string::npos || 0 == i) + size_t del_pos = s.find_first_of('='); + if (del_pos == string::npos || 0 == del_pos) return 0; - char* key = const_cast (s.c_str()); // I know what I'm doing, let me do it - key[i] = 0; - char* val = key + i + 1; - + s[del_pos] = '\0'; + const string key = s.substr(0, del_pos); + const string val = s.substr(del_pos + 1); + switch (key[0]) { case 'a': - if (0 == strcmp("auto", key)) + if (key == "auto") { if (!primitive) primitive = NEW CardPrimitive(); primitive->addMagicText(val); } - else if (0 == strncmp("auto", key, 4)) + else if (StartsWith(key, "auto")) { if (!primitive) primitive = NEW CardPrimitive(); - primitive->addMagicText(val, key + 4); + primitive->addMagicText(val, key.substr(4)); } - else if (0 == strcmp("alias", key)) + else if (key == "alias") { if (!primitive) primitive = NEW CardPrimitive(); - primitive->alias = atoi(val); + primitive->alias = atoi(val.c_str()); } - else if (0 == strcmp("abilities", key)) + else if (key == "abilities") { if (!primitive) primitive = NEW CardPrimitive(); string value = val; @@ -152,12 +152,12 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi } case 'g': //grade - if (s.size() - i - 1 > 2) currentGrade = getGrade(val[2]); + if (s.size() - del_pos - 1 > 2) currentGrade = getGrade(val[2]); break; case 'i': //id if (!card) card = NEW MTGCard(); - card->setMTGId(atoi(val)); + card->setMTGId(atoi(val.c_str())); break; case 'k': //kicker @@ -222,7 +222,7 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi break; case 'p': - if ('r' == key[1]) + if (key[1] == 'r') { // primitive if (!card) card = NEW MTGCard(); map::iterator it = primitives.find(val); @@ -231,18 +231,18 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi else { //power if (!primitive) primitive = NEW CardPrimitive(); - primitive->setPower(atoi(val)); + primitive->setPower(atoi(val.c_str())); } break; case 'r': //retrace/rarity//restrictions - if('s' == key[2] && 't' == key[3])//restrictions + if(key[2] == 's' && key[3] == 't')//restrictions { if (!primitive) primitive = NEW CardPrimitive(); string value = val; primitive->setRestrictions(value); } - else if ('e' == key[1] && 't' == key[2]) + else if (key[1] == 'e' && key[2] == 't') { //retrace if (!primitive) primitive = NEW CardPrimitive(); if (ManaCost * cost = primitive->getManaCost()) @@ -279,7 +279,7 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi else { if (!primitive) primitive = NEW CardPrimitive(); - vector values = split(val, ' '); + vector values = split(val.c_str(), ' '); for (size_t values_i = 0; values_i < values.size(); ++values_i) primitive->setSubtype(values[values_i]); } @@ -288,21 +288,21 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi case 't': if (!primitive) primitive = NEW CardPrimitive(); - if (0 == strcmp("target", key)) + if (key == "target") { string value = val; std::transform(value.begin(), value.end(), value.begin(), ::tolower); primitive->spellTargetType = value; } - else if (0 == strcmp("text", key)) + else if (key == "text") primitive->setText(val); - else if (0 == strcmp("type", key)) + else if (key == "type") { vector values = split(val, ' '); for (size_t values_i = 0; values_i < values.size(); ++values_i) primitive->setType(values[values_i]); } - else if (0 == strcmp("toughness", key)) primitive->setToughness(atoi(val)); + else if (key == "toughness") primitive->setToughness(atoi(val.c_str())); break; default: @@ -317,7 +317,7 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi tempPrimitive = primitive; tempCard = card; - return i; + return del_pos; } @@ -381,10 +381,20 @@ void MTGAllCards::loadFolder(const string& infolder, const string& filename ) } } -int MTGAllCards::load(const char * config_file, const char * set_name, int) +int MTGAllCards::load(const string &config_file) +{ + return load(config_file, MTGSets::INTERNAL_SET); +} + +int MTGAllCards::load(const string& config_file, const string &set_name) +{ + const int set_id = setlist.Add(set_name); + return load(config_file, set_id); +} + +int MTGAllCards::load(const string &config_file, int set_id) { conf_read_mode = 0; - const int set_id = set_name ? setlist.Add(set_name) : MTGSets::INTERNAL_SET; MTGSetInfo *si = setlist.getInfo(set_id); int lineNumber = 0; @@ -532,14 +542,16 @@ int MTGAllCards::countBySet(int setId) } //TODO more efficient way ? -int MTGAllCards::countByType(const char * _type) +int MTGAllCards::countByType(const string &_type) { + int type_id = findType(_type); + int result = 0; map::iterator it; for (it = collection.begin(); it != collection.end(); it++) { MTGCard * c = it->second; - if (c->data->hasType(_type)) + if (c->data->hasType(type_id)) { result++; } @@ -772,7 +784,7 @@ int MTGDeck::totalPrice() return total; } -MTGDeck::MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only,int difficultyRating) +MTGDeck::MTGDeck(const string& config_file, MTGAllCards * _allcards, int meta_only, int difficultyRating) { total_cards = 0; database = _allcards; @@ -879,7 +891,7 @@ MTGCard * MTGDeck::getCardById(int mtgId) return database->getCardById(mtgId); } -int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, const char * _subtype, int * colors, int nbcolors) +int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, const string &_subtype, int * colors, int nbcolors) { if (howmany <= 0) return 1; @@ -900,8 +912,8 @@ int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, c int collectionTotal = database->totalCards(); if (!collectionTotal) return 0; - char subtype[4096]; - if (_subtype) sprintf(subtype, "%s", _subtype); + string subtype; + if (_subtype.size()) subtype = _subtype; vector subcollection; int subtotal = 0; @@ -911,7 +923,7 @@ int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, c int r = card->getRarity(); if (r != Constants::RARITY_T && (rarity == -1 || r == rarity) && // remove tokens card->setId != MTGSets::INTERNAL_SET && //remove cards that are defined in primitives. Those are workarounds (usually tokens) and should only be used internally - (!_subtype || card->data->hasSubtype(subtype))) + (!_subtype.size() || card->data->hasSubtype(subtype))) { int ok = 0; @@ -1265,7 +1277,7 @@ MTGSetInfo* MTGSets::randomSet(int blockId, int atleast) int blockSize(int blockId); -int MTGSets::Add(const char * name) +int MTGSets::Add(const string& name) { int setid = findSet(name); if (setid != -1) return setid; @@ -1344,7 +1356,7 @@ MTGSetInfo::~MTGSetInfo() SAFE_DELETE(mPack); } -MTGSetInfo::MTGSetInfo(string _id) +MTGSetInfo::MTGSetInfo(const string& _id) { string whitespaces(" \t\f\v\n\r"); id = _id; diff --git a/projects/mtg/src/MTGDefinitions.cpp b/projects/mtg/src/MTGDefinitions.cpp index 1ebf044f8..eaecce696 100644 --- a/projects/mtg/src/MTGDefinitions.cpp +++ b/projects/mtg/src/MTGDefinitions.cpp @@ -162,7 +162,7 @@ int Constants::GetColorStringIndex(string mtgColor) return -1; } -const char* Constants::MTGPhaseNames[] = +const string Constants::MTGPhaseNames[] = { "---", "Untap", diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index 56f7efe12..4a425ed1c 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -529,7 +529,7 @@ size_t MTGGameZone::getIndex(MTGCardInstance * card) } -unsigned int MTGGameZone::countByType(const char * value) +unsigned int MTGGameZone::countByType(const string &value) { int result = 0; int subTypeId = MTGAllCards::findType(value); @@ -539,7 +539,7 @@ unsigned int MTGGameZone::countByType(const char * value) { result++; } - else if(strcmp(value, "token") == 0 && cards[i]->isToken) + else if(value == "token" && cards[i]->isToken) result++; } return result; diff --git a/projects/mtg/src/MTGPack.cpp b/projects/mtg/src/MTGPack.cpp index 2aa3ea031..5e8b53d34 100644 --- a/projects/mtg/src/MTGPack.cpp +++ b/projects/mtg/src/MTGPack.cpp @@ -293,7 +293,7 @@ void MTGPacks::loadAll() sprintf(myFilename, "packs/%s",relative.c_str()); if (relative[0] == '.') continue; - if (!strcmp(relative.c_str(), "default_booster.txt")) + if (relative == "default_booster.txt") continue; MTGPack * p = NEW MTGPack(myFilename); if (!p->isValid()) diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 03101b281..b3ba2cd86 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -997,9 +997,9 @@ int MTGSuspendRule::reactToClick(MTGCardInstance * card) return 1; } -const char * MTGSuspendRule::getMenuText() +const string MTGSuspendRule::getMenuText() { - return suspendmenu.c_str(); + return suspendmenu; } ostream& MTGSuspendRule::toString(ostream& out) const @@ -1333,9 +1333,9 @@ int AAPlaneswalkerAttacked::resolve() return 1; } -const char* AAPlaneswalkerAttacked::getMenuText() +const string AAPlaneswalkerAttacked::getMenuText() { - return menuText.c_str(); + return menuText; } AAPlaneswalkerAttacked * AAPlaneswalkerAttacked::clone() const @@ -1597,9 +1597,9 @@ int MTGBlockRule::reactToClick(MTGCardInstance * card) return 1; } -const char * MTGBlockRule::getMenuText() +const string MTGBlockRule::getMenuText() { - return blockmenu.c_str(); + return blockmenu; } ostream& MTGBlockRule::toString(ostream& out) const diff --git a/projects/mtg/src/ModRules.cpp b/projects/mtg/src/ModRules.cpp index 029f5a9e8..a39c99bc9 100644 --- a/projects/mtg/src/ModRules.cpp +++ b/projects/mtg/src/ModRules.cpp @@ -25,23 +25,23 @@ bool ModRules::load(string filename) TiXmlElement* element = node->ToElement(); if (element != NULL) { - if (strcmp(element->Value(), "menu") == 0) + if (element->ValueStr() == "menu") { menu.parse(element); } - else if (strcmp(element->Value(), "general") == 0) + else if (element->ValueStr() == "general") { general.parse(element); } - else if (strcmp(element->Value(), "cards") == 0) + else if (element->ValueStr() == "cards") { cards.parse(element); } - else if (strcmp(element->Value(), "game") == 0) + else if (element->ValueStr() == "game") { game.parse(element); } - else if (strcmp(element->Value(), "cardgui") == 0) + else if (element->ValueStr() == "cardgui") { cardgui.parse(element); } diff --git a/projects/mtg/src/PhaseRing.cpp b/projects/mtg/src/PhaseRing.cpp index 330790099..bb9fb82e3 100644 --- a/projects/mtg/src/PhaseRing.cpp +++ b/projects/mtg/src/PhaseRing.cpp @@ -142,9 +142,10 @@ bool PhaseRing::extraDamagePhase(int id) return false; } -const char * PhaseRing::phaseName(int id) +const string& PhaseRing::phaseName(int id) { - if (extraDamagePhase(id)) return "Combat Damage (2)"; + static const string combatPhase2("Combat Damage (2)"); + if (extraDamagePhase(id)) return combatPhase2; return Constants::MTGPhaseNames[id]; } diff --git a/projects/mtg/src/SimpleMenu.cpp b/projects/mtg/src/SimpleMenu.cpp index 3aaa15ad0..8fb514185 100644 --- a/projects/mtg/src/SimpleMenu.cpp +++ b/projects/mtg/src/SimpleMenu.cpp @@ -328,7 +328,7 @@ void SimpleMenu::Update(float dt) } } -void SimpleMenu::Add(int id, const char * text, string desc, bool forceFocus) +void SimpleMenu::Add(int id, const string& text, string desc, bool forceFocus) { SimpleMenuItem * smi = NEW SimpleMenuItem(this, id, fontId, text, 0, mY + SimpleMenuConst::kVerticalMargin + mCount * SimpleMenuConst::kLineHeight, (mCount == 0), autoTranslate); diff --git a/projects/mtg/src/StoryFlow.cpp b/projects/mtg/src/StoryFlow.cpp index b77c40efd..98eacc5d7 100644 --- a/projects/mtg/src/StoryFlow.cpp +++ b/projects/mtg/src/StoryFlow.cpp @@ -333,15 +333,15 @@ StoryDuel::StoryDuel(TiXmlElement* root, StoryFlow * mParent) : if (element) { const char* textC = element->GetText(); - if (strcmp(element->Value(), "onwin") == 0) + if (element->ValueStr() == "onwin") { onWin = textC; } - else if (strcmp(element->Value(), "onlose") == 0) + else if (element->ValueStr() == "onlose") { onLose = textC; } - else if (strcmp(element->Value(), "bg") == 0) + else if (element->ValueStr() == "bg") { string text = textC; bg = string("campaigns/").append(mParent->folder).append("/").append(text); @@ -396,10 +396,10 @@ int StoryPage::loadElement(TiXmlElement* element) if (!element) return 0; const char* textC = element->GetText(); string text = textC; - if (strcmp(element->Value(), "music") == 0) + if (element->ValueStr() == "music") { musicFile = string("campaigns/").append(mParent->folder).append("/").append(text); - if (!fileExists(musicFile.c_str())) musicFile = text; + if (!FileExists(musicFile)) musicFile = text; return 1; } return 0; @@ -434,15 +434,15 @@ StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent) : string sFont = safeAttribute(element, "font"); int font = atoi(sFont.c_str()); - if (strcmp(element->Value(), "text") == 0) + if (element->ValueStr() == "text") { graphics.push_back(NEW StoryText(text, x, y, align, font)); } - else if (strcmp(element->Value(), "title") == 0) + else if (element->ValueStr() == "title") { graphics.push_back(NEW StoryText(text, x, y, "center", Fonts::MENU_FONT)); } - else if (strcmp(element->Value(), "img") == 0) + else if (element->ValueStr() == "img") { //special case to force center if (sX.compare("") == 0) @@ -452,7 +452,7 @@ StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent) : string img = string("campaigns/").append(mParent->folder).append("/").append(text); graphics.push_back(NEW StoryImage(img, x, y)); } - else if (strcmp(element->Value(), "answer") == 0) + else if (element->ValueStr() == "answer") { string id = element->Attribute("goto"); if (!align.size()) align = "center"; @@ -461,7 +461,7 @@ StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent) : graphics.push_back(sc); Add(sc); } - else if (strcmp(element->Value(), "reward") == 0) + else if (element->ValueStr() == "reward") { string type = safeAttribute(element, "type"); string value = safeAttribute(element, "value"); @@ -553,7 +553,7 @@ StoryPage * StoryFlow::loadPage(TiXmlElement* element) if (!typeNode) return NULL; StoryPage * result = NULL; const char* type = typeNode->ToElement()->GetText(); - if (strcmp(type, "duel") == 0) + if (string("duel") == type) { result = NEW StoryDuel(element, this); } @@ -615,7 +615,7 @@ bool StoryFlow::parse(string path) TiXmlElement* element = node->ToElement(); if (element != NULL) { - if (strcmp(element->Value(), "page") == 0) + if (element->ValueStr() == "page") { string id = element->Attribute("id"); diff --git a/projects/mtg/src/StyleManager.cpp b/projects/mtg/src/StyleManager.cpp index e2005a7c5..e904808aa 100644 --- a/projects/mtg/src/StyleManager.cpp +++ b/projects/mtg/src/StyleManager.cpp @@ -25,7 +25,7 @@ void StyleManager::killRules() styles.clear(); } -StyleManager::StyleManager() +StyleManager::StyleManager(): topRule(0), topSize(0), playerSrc(0) { loadRules(); } diff --git a/projects/mtg/src/TestSuiteAI.cpp b/projects/mtg/src/TestSuiteAI.cpp index eeb279fd2..bb7e236ce 100644 --- a/projects/mtg/src/TestSuiteAI.cpp +++ b/projects/mtg/src/TestSuiteAI.cpp @@ -350,8 +350,8 @@ void TestSuiteGame::assertGame() if (observer->getCurrentGamePhase() != endState.phase) { sprintf(result, "==phase problem. Expected [ %s ](%i), got [ %s ](%i)==
", - Constants::MTGPhaseNames[endState.phase],endState.phase, - Constants::MTGPhaseNames[observer->getCurrentGamePhase()], observer->getCurrentGamePhase()); + Constants::MTGPhaseNames[endState.phase].c_str(),endState.phase, + Constants::MTGPhaseNames[observer->getCurrentGamePhase()].c_str(), observer->getCurrentGamePhase()); Log(result); error++; } diff --git a/projects/mtg/src/utils.cpp b/projects/mtg/src/utils.cpp index 7a31822bd..2217b6143 100644 --- a/projects/mtg/src/utils.cpp +++ b/projects/mtg/src/utils.cpp @@ -399,3 +399,13 @@ void ReplaceString(std::string& subject, const std::string& search, const std::s } } +bool StartsWith(const std::string& base, const char *start) +{ + return base.compare(0, strlen(start), start) == 0; +} + +bool StartsWith(const std::string& base, const std::string& start) +{ + return base.compare(0, start.length(), start) == 0; +} + diff --git a/projects/mtg/template.vcxproj b/projects/mtg/template.vcxproj index 96f355a51..9fe22b571 100644 --- a/projects/mtg/template.vcxproj +++ b/projects/mtg/template.vcxproj @@ -108,7 +108,7 @@ MaxSpeed OnlyExplicitInline ./include;$(MTGEXTRAS);../../JGE/include;../../JGE/Dependencies/include;../../Boost;../../JGE/Dependencies/SDL/include;../../JGE/src/zipFS;%(AdditionalIncludeDirectories) - SDL_CONFIG;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + TIXML_USE_STL; SDL_CONFIG;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true MultiThreadedDLL true @@ -157,7 +157,7 @@ Disabled ./include;$(MTGEXTRAS);../../JGE/include;../../JGE/Dependencies/include;../../Boost;../../JGE/Dependencies/SDL/include;../../JGE/src/zipFS;%(AdditionalIncludeDirectories) - SDL_CONFIG;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + TIXML_USE_STL; SDL_CONFIG;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL .\Debug/template.pch @@ -209,7 +209,7 @@ Full OnlyExplicitInline ./include;$(MTGEXTRAS);../../JGE/include;../../JGE/Dependencies/include;../../Boost;../../JGE/Dependencies/SDL/include;../../JGE/src/zipFS;%(AdditionalIncludeDirectories) - SDL_CONFIG;WIN32;NDEBUG;_WINDOWS;_SECURE_SCL=0;_HAS_ITERATOR_DEBBUGING=0;%(PreprocessorDefinitions) + TIXML_USE_STL; SDL_CONFIG;WIN32;NDEBUG;_WINDOWS;_SECURE_SCL=0;_HAS_ITERATOR_DEBBUGING=0;%(PreprocessorDefinitions) true MultiThreadedDLL true @@ -261,7 +261,7 @@ Disabled ./include;$(MTGEXTRAS);../../JGE/include;../../JGE/Dependencies/include;../../Boost;../../JGE/Dependencies/SDL/include;../../JGE/src/zipFS;%(AdditionalIncludeDirectories) - SDL_CONFIG;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + TIXML_USE_STL; SDL_CONFIG;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL diff --git a/projects/mtg/wagic-SDL.pro b/projects/mtg/wagic-SDL.pro index 7617aae78..a1580106d 100644 --- a/projects/mtg/wagic-SDL.pro +++ b/projects/mtg/wagic-SDL.pro @@ -18,6 +18,7 @@ CONFIG(debug, debug|release):DEFINES += _DEBUG #DEFINES += QT_CONFIG #DEFINES += NETWORK_SUPPORT DEFINES += SDL_CONFIG +DEFINES += TIXML_USE_STL macx:DEFINES += USE_PHONON maemo5: { DEFINES += USE_PHONON diff --git a/projects/mtg/wagic-qt.pro b/projects/mtg/wagic-qt.pro index 43fd7710d..725ea37d6 100644 --- a/projects/mtg/wagic-qt.pro +++ b/projects/mtg/wagic-qt.pro @@ -49,6 +49,8 @@ android:INCLUDEPATH += $$ANDROID_NDK_ROOT/platforms/android-9/arch-arm/usr/inclu #DEFINES += QT_NO_DEBUG_OUTPUT DEFINES += NETWORK_SUPPORT +DEFINES += TIXML_USE_STL + windows:INCLUDEPATH += ../../JGE/Dependencies/include windows{ *-g++* {