From be11b96775836a7022fdd1344175b570a8055058 Mon Sep 17 00:00:00 2001 From: "techdragon.nguyen@gmail.com" Date: Thu, 7 Oct 2010 03:01:05 +0000 Subject: [PATCH] adding trim to card loading. if player deck has multiple spaces separating card name from set name, the parser fails. Trimming ensures that there are no problems with trailing and leading spaces concerning card and set names. previously: [card name] ([set name]) *d would fail because when the parser when looking for the card name, it would use [[card name] ] and not [[card name]] since the card lookup is case insensitive but not whitespace insensitive the lookup would fail. --- projects/mtg/src/MTGDeck.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index 75150b1b3..84b220efb 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -1,4 +1,7 @@ #include +#include +#include +#include #include "../include/config.h" #include "../include/MTGDeck.h" #include "../include/utils.h" @@ -8,10 +11,7 @@ #include "../include/PriceList.h" #include "../include/WDataSrc.h" #include "../include/MTGPack.h" -#include -#include -#include -using std::string; +#include "../include/utils.h" #include @@ -496,8 +496,8 @@ MTGCard * MTGAllCards::getCardByName(string name){ size_t found = name.find(" ("); if (found != string::npos){ size_t end = name.find(")"); - string setName = name.substr(found+2,end-found-2); - name = name.substr(0,found); + string setName = trim(name.substr(found+2,end-found-2)); + name = trim(name.substr(0,found)); setId = setlist[setName]; } map::iterator it;