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.
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
#include "../include/config.h"
|
#include "../include/config.h"
|
||||||
#include "../include/MTGDeck.h"
|
#include "../include/MTGDeck.h"
|
||||||
#include "../include/utils.h"
|
#include "../include/utils.h"
|
||||||
@@ -8,10 +11,7 @@
|
|||||||
#include "../include/PriceList.h"
|
#include "../include/PriceList.h"
|
||||||
#include "../include/WDataSrc.h"
|
#include "../include/WDataSrc.h"
|
||||||
#include "../include/MTGPack.h"
|
#include "../include/MTGPack.h"
|
||||||
#include <algorithm>
|
#include "../include/utils.h"
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
#include <JGE.h>
|
#include <JGE.h>
|
||||||
|
|
||||||
@@ -496,8 +496,8 @@ MTGCard * MTGAllCards::getCardByName(string name){
|
|||||||
size_t found = name.find(" (");
|
size_t found = name.find(" (");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
size_t end = name.find(")");
|
size_t end = name.find(")");
|
||||||
string setName = name.substr(found+2,end-found-2);
|
string setName = trim(name.substr(found+2,end-found-2));
|
||||||
name = name.substr(0,found);
|
name = trim(name.substr(0,found));
|
||||||
setId = setlist[setName];
|
setId = setlist[setName];
|
||||||
}
|
}
|
||||||
map<int,MTGCard *>::iterator it;
|
map<int,MTGCard *>::iterator it;
|
||||||
|
|||||||
Reference in New Issue
Block a user