Changed errorChecking in the converter.
This commit is contained in:
parent
f3255f1053
commit
8c7648a51e
@ -33,21 +33,19 @@ Converter::Converter(std::string level){
|
|||||||
dst << src.rdbuf();
|
dst << src.rdbuf();
|
||||||
|
|
||||||
//Load the Level xml file
|
//Load the Level xml file
|
||||||
|
nextID.push_back(1);
|
||||||
|
nextID.push_back(1);
|
||||||
const char* charXmlFile = xmlFile.c_str();
|
const char* charXmlFile = xmlFile.c_str();
|
||||||
doc->LoadFile(charXmlFile);
|
doc->LoadFile(charXmlFile);
|
||||||
nextID.push_back(1);
|
|
||||||
nextID.push_back(1);
|
|
||||||
if (doc->ErrorID()!=0){
|
if (doc->ErrorID()!=0){
|
||||||
printf("Could not open xml, creating new xml.\n");
|
printf("Could not open xml, creating new xml.\n");
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
XMLElement* thisComposition = doc->FirstChildElement("composition");
|
XMLElement* thisComposition = doc->FirstChildElement("composition");
|
||||||
int idGreen, idBlue;
|
int idGreen, idBlue;
|
||||||
XMLError error=XML_NO_ERROR;
|
|
||||||
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
|
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
|
||||||
error = thisComposition->FirstChildElement("idGreen")->QueryIntText(&idGreen);
|
errorCheck(thisComposition->FirstChildElement("idGreen")->QueryIntText(&idGreen));
|
||||||
errorCheck(error);
|
errorCheck(thisComposition->FirstChildElement("idBlue")->QueryIntText(&idBlue));
|
||||||
error = thisComposition->FirstChildElement("idBlue")->QueryIntText(&idBlue);
|
|
||||||
errorCheck(error);
|
|
||||||
if(idGreen > nextID[0] || (idGreen == nextID[0] && idBlue > nextID[1])){
|
if(idGreen > nextID[0] || (idGreen == nextID[0] && idBlue > nextID[1])){
|
||||||
nextID[0] = idGreen;
|
nextID[0] = idGreen;
|
||||||
nextID[1] = idBlue;
|
nextID[1] = idBlue;
|
||||||
@ -116,15 +114,11 @@ void Converter::updateComposition(int idG, int idB, float posX, float posZ){
|
|||||||
int idGreen = 0, idBlue = 0;
|
int idGreen = 0, idBlue = 0;
|
||||||
bool compositionExists = false;
|
bool compositionExists = false;
|
||||||
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
|
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
|
||||||
XMLError error=XML_NO_ERROR;
|
errorCheck(thisComposition->FirstChildElement("idGreen")->QueryIntText(&idGreen));
|
||||||
error = thisComposition->FirstChildElement("idGreen")->QueryIntText(&idGreen);
|
errorCheck(thisComposition->FirstChildElement("idBlue")->QueryIntText(&idBlue));
|
||||||
errorCheck(error);
|
|
||||||
error = thisComposition->FirstChildElement("idBlue")->QueryIntText(&idBlue);
|
|
||||||
errorCheck(error);
|
|
||||||
if(idGreen == idG && idBlue == idB){
|
if(idGreen == idG && idBlue == idB){
|
||||||
bool manualPos;
|
bool manualPos;
|
||||||
error=thisComposition->FirstChildElement("manualPos")->QueryBoolText(&manualPos);
|
errorCheck(thisComposition->FirstChildElement("manualPos")->QueryBoolText(&manualPos));
|
||||||
errorCheck(error);
|
|
||||||
if(!manualPos){
|
if(!manualPos){
|
||||||
thisComposition->FirstChildElement("xPos")->SetText(std::to_string(posX).c_str());
|
thisComposition->FirstChildElement("xPos")->SetText(std::to_string(posX).c_str());
|
||||||
thisComposition->FirstChildElement("zPos")->SetText(std::to_string(posZ).c_str());
|
thisComposition->FirstChildElement("zPos")->SetText(std::to_string(posZ).c_str());
|
||||||
@ -141,12 +135,9 @@ void Converter::updateComposition(int idG, int idB, float posX, float posZ){
|
|||||||
void Converter::deleteComposition(int idG, int idB){
|
void Converter::deleteComposition(int idG, int idB){
|
||||||
XMLElement* thisComposition = doc->FirstChildElement("composition");
|
XMLElement* thisComposition = doc->FirstChildElement("composition");
|
||||||
int idGreen, idBlue;
|
int idGreen, idBlue;
|
||||||
XMLError error=XML_NO_ERROR;
|
|
||||||
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
|
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
|
||||||
error = thisComposition->FirstChildElement("idGreen")->QueryIntText(&idGreen);
|
errorCheck(thisComposition->FirstChildElement("idGreen")->QueryIntText(&idGreen));
|
||||||
errorCheck(error);
|
errorCheck(thisComposition->FirstChildElement("idBlue")->QueryIntText(&idBlue));
|
||||||
error = thisComposition->FirstChildElement("idBlue")->QueryIntText(&idBlue);
|
|
||||||
errorCheck(error);
|
|
||||||
if(idGreen == idG && idBlue == idB){
|
if(idGreen == idG && idBlue == idB){
|
||||||
doc->DeleteChild(thisComposition);
|
doc->DeleteChild(thisComposition);
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,12 @@ class Converter {
|
|||||||
void updateComposition(int idG, int idB, float posX, float posZ); //updates the position of a composition
|
void updateComposition(int idG, int idB, float posX, float posZ); //updates the position of a composition
|
||||||
std::vector<int> newComposition(int type, float posX, float posZ);//creates a new composition and returns its ID
|
std::vector<int> newComposition(int type, float posX, float posZ);//creates a new composition and returns its ID
|
||||||
void deleteComposition(int idG, int idB);
|
void deleteComposition(int idG, int idB);
|
||||||
void save(); //writes the xml to file
|
void save(); //writes the xml to file
|
||||||
std::vector<int> getNextID(); //returns the next unused ID
|
std::vector<int> getNextID(); //returns the next unused ID
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::vector<int> nextID;
|
|
||||||
void errorCheck(XMLError error);
|
void errorCheck(XMLError error);
|
||||||
|
std::vector<int> nextID;
|
||||||
std::string xmlFile;
|
std::string xmlFile;
|
||||||
XMLDocument* doc = new XMLDocument();
|
XMLDocument* doc = new XMLDocument();
|
||||||
XMLDocument* compositions = new XMLDocument();
|
XMLDocument* compositions = new XMLDocument();
|
||||||
|
Loading…
Reference in New Issue
Block a user