Proper handling of names with spaces in parsing.
This commit is contained in:
parent
b0cdab41f5
commit
635f580ba6
@ -26,7 +26,7 @@ Crawler::Crawler()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Crawler::OnUserCreate(){
|
bool Crawler::OnUserCreate(){
|
||||||
TMXParser("assets/maps/Level1.tmx");
|
TMXParser level1("assets/maps/Level1.tmx");
|
||||||
|
|
||||||
//Initialize Camera.
|
//Initialize Camera.
|
||||||
camera=Camera2D{WINDOW_SIZE};
|
camera=Camera2D{WINDOW_SIZE};
|
||||||
|
@ -87,17 +87,28 @@ private:
|
|||||||
std::string data;
|
std::string data;
|
||||||
while (s.good()) {
|
while (s.good()) {
|
||||||
int quotationMarkCount=0;
|
int quotationMarkCount=0;
|
||||||
|
bool pastEquals=false;
|
||||||
data="";
|
data="";
|
||||||
|
bool valid=false;
|
||||||
while(s.good()){
|
while(s.good()){
|
||||||
int character=s.get();
|
int character=s.get();
|
||||||
if(character=='"'){
|
if(character=='"'){
|
||||||
quotationMarkCount++;
|
quotationMarkCount++;
|
||||||
}
|
}
|
||||||
data+=character;
|
|
||||||
if(character==' '&"ationMarkCount%2==0){
|
if(character==' '&"ationMarkCount%2==0){
|
||||||
|
valid=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
data+=character;
|
||||||
|
if(pastEquals&"ationMarkCount%2==0){
|
||||||
|
valid=true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
if(character=='='&"ationMarkCount%2==0){
|
||||||
|
pastEquals=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(valid&&data.length()>0){
|
||||||
if (newTag.tag.length()==0) { //Tag's empty, so first line is the tag.
|
if (newTag.tag.length()==0) { //Tag's empty, so first line is the tag.
|
||||||
newTag.tag=data;
|
newTag.tag=data;
|
||||||
std::cout<<"Tag: "<<newTag.tag<<"\n";
|
std::cout<<"Tag: "<<newTag.tag<<"\n";
|
||||||
@ -107,12 +118,13 @@ private:
|
|||||||
|
|
||||||
//Strip Quotation marks.
|
//Strip Quotation marks.
|
||||||
value = value.substr(1,std::string::npos);
|
value = value.substr(1,std::string::npos);
|
||||||
value = value.substr(0,value.length()-2);
|
value = value.substr(0,value.length()-1);
|
||||||
|
|
||||||
newTag.data[key]=value;
|
newTag.data[key]=value;
|
||||||
std::cout<<" "<<key<<":"<<newTag.data[key]<<"\n";
|
std::cout<<" "<<key<<":"<<newTag.data[key]<<"\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (newTag.tag=="map") {
|
if (newTag.tag=="map") {
|
||||||
parsedMapInfo.MapData=newTag;
|
parsedMapInfo.MapData=newTag;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 86
|
#define VERSION_BUILD 98
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user