Added more exits after errors.

This commit is contained in:
Steffen Fündgens 2015-01-23 16:02:10 +01:00
parent e9390d860b
commit f3580555cd

View File

@ -43,6 +43,7 @@ void Level::errorCheck(XMLError error){
else { else {
printf("Unknown error.\n"); printf("Unknown error.\n");
} }
exit(-1);
} }
} }
@ -109,6 +110,7 @@ void Level::load() {
const char* charSkydomeTexture = skydomeElement->FirstChildElement("texture")->GetText(); const char* charSkydomeTexture = skydomeElement->FirstChildElement("texture")->GetText();
if(charSkydomeTexture == NULL){ if(charSkydomeTexture == NULL){
printf("XMLError: No skydomeTexture found.\n"); printf("XMLError: No skydomeTexture found.\n");
exit(-1);
} }
std::string skydomeTexture = charSkydomeTexture; std::string skydomeTexture = charSkydomeTexture;
Model skydomeModel = Model("skydome.obj", skydomeSize); Model skydomeModel = Model("skydome.obj", skydomeSize);
@ -169,6 +171,7 @@ void Level::load() {
const char* charModelPath = xmlObject->FirstChildElement("modelPath")->GetText(); const char* charModelPath = xmlObject->FirstChildElement("modelPath")->GetText();
if(charModelPath == NULL){ if(charModelPath == NULL){
printf("XMLError: No modelPath found in object.\n"); printf("XMLError: No modelPath found in object.\n");
exit(-1);
} }
std::string modelPath = charModelPath; std::string modelPath = charModelPath;
float objectScale, compScale; float objectScale, compScale;
@ -181,6 +184,7 @@ void Level::load() {
const char* charDataModelPath = objectData->FirstChildElement("modelPath")->GetText(); const char* charDataModelPath = objectData->FirstChildElement("modelPath")->GetText();
if(charDataModelPath == NULL){ if(charDataModelPath == NULL){
printf("XMLError: No modelPath found in objectData.\n"); printf("XMLError: No modelPath found in objectData.\n");
exit(-1);
} }
std::string dataModelPath = charDataModelPath; std::string dataModelPath = charDataModelPath;
//objectData found //objectData found
@ -194,6 +198,7 @@ void Level::load() {
const char* charTexturePath = objectData->FirstChildElement("texturePath")->GetText(); const char* charTexturePath = objectData->FirstChildElement("texturePath")->GetText();
if(charTexturePath == NULL){ if(charTexturePath == NULL){
printf("XMLError: No texturePath found in objectData.\n"); printf("XMLError: No texturePath found in objectData.\n");
exit(-1);
} }
std::string texturePath = charTexturePath; std::string texturePath = charTexturePath;
Material material = Material(texturePath, ambientFactor, diffuseFactor, specularFactor, shininess); Material material = Material(texturePath, ambientFactor, diffuseFactor, specularFactor, shininess);
@ -242,6 +247,7 @@ void Level::load() {
const char* charPhysicType = objectData->FirstChildElement("physicType")->GetText(); const char* charPhysicType = objectData->FirstChildElement("physicType")->GetText();
if(charPhysicType == NULL){ if(charPhysicType == NULL){
printf("XMLError: No physicType found.\n"); printf("XMLError: No physicType found.\n");
exit(-1);
} }
std::string physicType = charPhysicType; std::string physicType = charPhysicType;
//add object to physics //add object to physics
@ -328,6 +334,7 @@ void Level::load() {
const char* charName = xmlTrigger->FirstChildElement("name")->GetText(); const char* charName = xmlTrigger->FirstChildElement("name")->GetText();
if(charName == NULL){ if(charName == NULL){
printf("XMLError: No name found for a trigger.\n"); printf("XMLError: No name found for a trigger.\n");
exit(-1);
} }
std::string name = charName; std::string name = charName;
if (name.compare("-") != 0){ if (name.compare("-") != 0){
@ -342,6 +349,7 @@ void Level::load() {
const char* charTarget = xmlTrigger->FirstChildElement("targetIdGreen")->GetText(); const char* charTarget = xmlTrigger->FirstChildElement("targetIdGreen")->GetText();
if(charTarget == NULL){ if(charTarget == NULL){
printf("XMLError: No targetIdGreen found for a trigger.\n"); printf("XMLError: No targetIdGreen found for a trigger.\n");
exit(-1);
} }
std::string stringTarget = charTarget; std::string stringTarget = charTarget;
if (stringTarget.compare("-") != 0){ if (stringTarget.compare("-") != 0){
@ -378,6 +386,7 @@ void Level::load() {
const char* charLuaScript = xmlTrigger->FirstChildElement("luaScript")->GetText(); const char* charLuaScript = xmlTrigger->FirstChildElement("luaScript")->GetText();
if(charLuaScript == NULL){ if(charLuaScript == NULL){
printf("XMLError: No Lua script found for a trigger.\n"); printf("XMLError: No Lua script found for a trigger.\n");
exit(-1);
} }
std::string luaScript = charLuaScript; std::string luaScript = charLuaScript;
@ -396,6 +405,7 @@ void Level::load() {
} }
else { else {
printf("Triggering object not found.\n"); printf("Triggering object not found.\n");
exit(-1);
} }
} }
} }