Converting unsinged ints to regular ints, because tinyxml cannot query for unsigned ones and thus negates the purpose of using unsigned ones. This also causes compiler errors.

This commit is contained in:
Faerbit 2014-12-08 13:33:38 +01:00
parent 3bb584631c
commit 03e94f0bb0
3 changed files with 11 additions and 11 deletions

View File

@ -58,7 +58,7 @@ Converter::Converter(){
Converter::~Converter(){ Converter::~Converter(){
} }
std::vector<unsigned int> Converter::newComposition(unsigned int type, float posX, float posZ){ std::vector<int> Converter::newComposition(int type, float posX, float posZ){
XMLElement* newComposition = doc->NewElement("composition"); XMLElement* newComposition = doc->NewElement("composition");
doc->InsertFirstChild(newComposition); doc->InsertFirstChild(newComposition);
@ -95,7 +95,7 @@ std::vector<unsigned int> Converter::newComposition(unsigned int type, float pos
newComposition->InsertFirstChild(xRot); newComposition->InsertFirstChild(xRot);
newComposition->InsertFirstChild(scale); newComposition->InsertFirstChild(scale);
std::vector<unsigned int> ret = nextID; std::vector<int> ret = nextID;
nextID[1] += 1; nextID[1] += 1;
if (nextID[1] == 255){ if (nextID[1] == 255){
nextID[1] = 0; nextID[1] = 0;
@ -104,7 +104,7 @@ std::vector<unsigned int> Converter::newComposition(unsigned int type, float pos
return ret; return ret;
} }
void Converter::updateComposition(unsigned int idG, unsigned int idB, float posX, float posZ){ void Converter::updateComposition(int idG, int idB, float posX, float posZ){
XMLElement* thisComposition = doc->FirstChildElement("composition"); XMLElement* thisComposition = doc->FirstChildElement("composition");
int idGreen, idBlue; int idGreen, idBlue;
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){ for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
@ -117,7 +117,7 @@ void Converter::updateComposition(unsigned int idG, unsigned int idB, float posX
} }
} }
void Converter::deleteComposition(unsigned int idG, unsigned 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;
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){ for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
@ -134,7 +134,7 @@ void Converter::save(){
doc->SaveFile(charXmlFile); doc->SaveFile(charXmlFile);
} }
std::vector<unsigned int> Converter::getNextID(){ std::vector<int> Converter::getNextID(){
return nextID; return nextID;
} }

View File

@ -11,14 +11,14 @@ class Converter {
Converter(std::string level); Converter(std::string level);
Converter(); Converter();
~Converter(); ~Converter();
void updateComposition(unsigned int idG, unsigned 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<unsigned int> newComposition(unsigned 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(unsigned int idG, unsigned int idB); void deleteComposition(int idG, int idB);
void save(); //writes the xml to file void save(); //writes the xml to file
std::vector<unsigned int> getNextID(); //returns the next unused ID std::vector<int> getNextID(); //returns the next unused ID
private: private:
std::vector<unsigned int> nextID; 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();

View File

@ -34,7 +34,7 @@ int main( int argc, char *argv[] ){
//if there is a composition here, adjust the xml and image //if there is a composition here, adjust the xml and image
if(image[pixel]!=0 && image[pixel]!=255){ if(image[pixel]!=0 && image[pixel]!=255){
if((image[pixel+1]==0 && image[pixel+2]==0) || (image[pixel+1]==255 && image[pixel+2]==255)){ if((image[pixel+1]==0 && image[pixel+2]==0) || (image[pixel+1]==255 && image[pixel+2]==255)){
std::vector<unsigned int> temp; std::vector<int> temp;
temp = conv.newComposition(image[pixel], 0.5+rowNum-0.5*height, 0.5+columnNum-0.5*width); temp = conv.newComposition(image[pixel], 0.5+rowNum-0.5*height, 0.5+columnNum-0.5*width);
idFound[temp[0]][temp[1]] = true; idFound[temp[0]][temp[1]] = true;
image[pixel+1] = temp[0]; image[pixel+1] = temp[0];