From 635f580ba667c28cd49ba55e7b4c604547c606a5 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Wed, 21 Jun 2023 00:58:10 -0700 Subject: [PATCH] Proper handling of names with spaces in parsing. --- Crawler/Crawler.cpp | 2 +- Crawler/TMXParser.h | 40 ++++++++++++++++++++++++++-------------- Crawler/Version.h | 2 +- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index d2321dde..dac14a27 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -26,7 +26,7 @@ Crawler::Crawler() } bool Crawler::OnUserCreate(){ - TMXParser("assets/maps/Level1.tmx"); + TMXParser level1("assets/maps/Level1.tmx"); //Initialize Camera. camera=Camera2D{WINDOW_SIZE}; diff --git a/Crawler/TMXParser.h b/Crawler/TMXParser.h index 444d31ed..9f487f95 100644 --- a/Crawler/TMXParser.h +++ b/Crawler/TMXParser.h @@ -87,30 +87,42 @@ private: std::string data; while (s.good()) { int quotationMarkCount=0; + bool pastEquals=false; data=""; + bool valid=false; while(s.good()){ int character=s.get(); if(character=='"'){ quotationMarkCount++; } - data+=character; if(character==' '&"ationMarkCount%2==0){ + valid=true; break; } + data+=character; + if(pastEquals&"ationMarkCount%2==0){ + valid=true; + break; + } + if(character=='='&"ationMarkCount%2==0){ + pastEquals=true; + } } - if (newTag.tag.length()==0) { //Tag's empty, so first line is the tag. - newTag.tag=data; - std::cout<<"Tag: "<0){ + if (newTag.tag.length()==0) { //Tag's empty, so first line is the tag. + newTag.tag=data; + std::cout<<"Tag: "<