Fixed a bug i created in my previous commit. Made output in case of errors more informative.
This commit is contained in:
parent
ba0677adde
commit
d6ed98b992
@ -14,6 +14,7 @@ Converter::Converter(std::string level){
|
|||||||
compositions->LoadFile(charCompositions);
|
compositions->LoadFile(charCompositions);
|
||||||
if (compositions->ErrorID()!=0){
|
if (compositions->ErrorID()!=0){
|
||||||
printf("Could not open Compositions!\n");
|
printf("Could not open Compositions!\n");
|
||||||
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create a backup of the current Level png file, if no backup exists
|
//Create a backup of the current Level png file, if no backup exists
|
||||||
@ -43,7 +44,7 @@ Converter::Converter(std::string level){
|
|||||||
printf("Could not open xml, do you want to create a new xml? (y/n)\n");
|
printf("Could not open xml, do you want to create a new xml? (y/n)\n");
|
||||||
std::cin >> answer;
|
std::cin >> answer;
|
||||||
while(answer.compare("y") != 0 && answer.compare("n") != 0){
|
while(answer.compare("y") != 0 && answer.compare("n") != 0){
|
||||||
printf("Answer with y or n");
|
printf("Answer with y or n\n");
|
||||||
std::cin >> answer;
|
std::cin >> answer;
|
||||||
}
|
}
|
||||||
if(answer.compare("n") == 0){
|
if(answer.compare("n") == 0){
|
||||||
@ -159,14 +160,19 @@ Converter::~Converter(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> Converter::newComposition(int type, float posX, float posZ){
|
std::vector<int> Converter::newComposition(int type, float posX, float posZ){
|
||||||
|
bool full = false;
|
||||||
while(idUsed[nextID[0]][nextID[1]]){
|
while(idUsed[nextID[0]][nextID[1]]){
|
||||||
nextID[1] += 1;
|
nextID[1] += 1;
|
||||||
if (nextID[1] == 256){
|
if (nextID[1] == 256){
|
||||||
nextID[1] = 0;
|
nextID[1] = 0;
|
||||||
nextID[0] +=1;
|
nextID[0] +=1;
|
||||||
if (nextID[0] == 256){
|
if (nextID[0] == 256){
|
||||||
std::cout << "Can not have more than 65535 compositions." << std::endl;
|
if(full){
|
||||||
exit(-1);
|
printf("Can not have more than 65535 compositions.\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
nextID[0] = 0;
|
||||||
|
full = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,7 +272,7 @@ void Converter::updateComposition(int idG, int idB, float posX, float posZ){
|
|||||||
errorCheck(thisComposition->FirstChildElement("idBlue")->QueryIntText(&idBlue));
|
errorCheck(thisComposition->FirstChildElement("idBlue")->QueryIntText(&idBlue));
|
||||||
if(idGreen == idG && idBlue == idB){
|
if(idGreen == idG && idBlue == idB){
|
||||||
if (compositionExists){
|
if (compositionExists){
|
||||||
std::cout << "An ID is used for multiple compositions in the xml." << std::endl;
|
std::cout << "The ID " << idGreen << "," << idBlue << " is used for multiple compositions in the xml." << std::endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
bool manualPos;
|
bool manualPos;
|
||||||
@ -279,7 +285,7 @@ void Converter::updateComposition(int idG, int idB, float posX, float posZ){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!compositionExists){
|
if(!compositionExists){
|
||||||
std::cout << "A composition has an ID in the png, but does'nt exist in the xml." << std::endl;
|
std::cout << "A composition has the ID " << idG << "," << idB << " in the png, but does not exist in the xml." << std::endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user