- updated error handling to be more flexible so we can display better error details (like bad tga file, etc)

This commit is contained in:
Mark Vejvoda 2012-11-10 23:19:42 +00:00
parent 56e4843d13
commit 8ba5524f35
12 changed files with 377 additions and 258 deletions

View File

@ -587,6 +587,35 @@ void Program::setState(ProgramState *programStateNew, bool cleanupOldState) {
this->programStateOldSystemError = NULL;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
}
catch(megaglest_runtime_error& e) {
//printf("3333333 ex.wantStackTrace() = %d\n",e.wantStackTrace());
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s Line: %d]\nError [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,szBuf);
//abort();
//printf("44444444a ex.wantStackTrace() = %d\n",e.wantStackTrace());
messageBoxIsSystemError = true;
string errorMsg = e.what();
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
if(dynamic_cast<Game *>(programStateNew) != NULL) {
try {
Game *game = dynamic_cast<Game *>(programStateNew);
Renderer &renderer= Renderer::getInstance();
renderer.initGame(game,game->getGameCameraPtr());
}
catch(megaglest_runtime_error& ex2) {
errorMsg += "\n" + string(ex2.what());
}
}
}
//printf("44444444b ex.wantStackTrace() = %d\n",e.wantStackTrace());
this->showMessage(errorMsg.c_str());
//setState(new Intro(this));
}
catch(const exception &e){
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s Line: %d]\nError [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what());

View File

@ -2688,6 +2688,19 @@ void MenuStateCustomGame::update() {
return;
}
}
catch(megaglest_runtime_error& ex) {
//abort();
//printf("1111111bbbb ex.wantStackTrace() = %d\n",ex.wantStackTrace());
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
//printf("2222222bbbb ex.wantStackTrace() = %d\n",ex.wantStackTrace());
showGeneralError=true;
generalErrorToShow = szBuf;
}
catch(const std::exception &ex) {
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());

View File

@ -40,7 +40,7 @@ FactionType::FactionType() {
void FactionType::load(const string &factionName, const TechTree *techTree, Checksum* checksum,
Checksum *techtreeChecksum, std::map<string,vector<pair<string, string> > > &loadedFileList) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
string techTreePath = techTree->getPath();
string techTreeName=techTree->getName();
@ -168,8 +168,14 @@ void FactionType::load(const string &factionName, const TechTree *techTree, Chec
SDL_PumpEvents();
}
}
catch(megaglest_runtime_error& ex) {
//printf("1111111b ex.wantStackTrace() = %d\n",ex.wantStackTrace());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
//printf("222222b\n");
throw megaglest_runtime_error("Error loading units: "+ currentPath + "\n" + ex.what(),!ex.wantStackTrace());
}
catch(const exception &e) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what());
throw megaglest_runtime_error("Error loading units: "+ currentPath + "\n" + e.what());
}
@ -184,7 +190,7 @@ void FactionType::load(const string &factionName, const TechTree *techTree, Chec
}
}
catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what());
throw megaglest_runtime_error("Error loading upgrades: "+ currentPath + "\n" + e.what());
}
@ -313,7 +319,7 @@ void FactionType::load(const string &factionName, const TechTree *techTree, Chec
}
}
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
}
int FactionType::getAIBehaviorStaticOverideValue(AIBehaviorStaticValueCategory type) const {
@ -778,14 +784,14 @@ const UnitType *FactionType::getUnitType(const string &name) const{
}
}
printf("In [%s::%s Line: %d] scanning [%s] size = " MG_SIZE_T_SPECIFIER "\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
printf("In [%s::%s Line: %d] scanning [%s] size = " MG_SIZE_T_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
for(int i=0; i<unitTypes.size();i++){
printf("In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName().c_str());
printf("In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName().c_str());
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] size = %d\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] size = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
for(int i=0; i<unitTypes.size();i++){
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName().c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName().c_str());
}
throw megaglest_runtime_error("Unit type not found: [" + name + "] in faction type [" + this->name + "]");
@ -798,14 +804,14 @@ const UnitType *FactionType::getUnitTypeById(int id) const{
}
}
printf("In [%s::%s Line: %d] scanning [%d] size = " MG_SIZE_T_SPECIFIER "\n",__FILE__,__FUNCTION__,__LINE__,id,unitTypes.size());
printf("In [%s::%s Line: %d] scanning [%d] size = " MG_SIZE_T_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,id,unitTypes.size());
for(int i=0; i<unitTypes.size();i++){
printf("In [%s::%s Line: %d] scanning [%s] idx = %d [%s][%d]\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName().c_str(),unitTypes[i].getId());
printf("In [%s::%s Line: %d] scanning [%s] idx = %d [%s][%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName().c_str(),unitTypes[i].getId());
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] size = %d\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] size = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
for(int i=0; i<unitTypes.size();i++){
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName().c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName().c_str());
}
throw megaglest_runtime_error("Unit type not found: [" + intToStr(id) + "] in faction type [" + this->name + "]");
@ -818,14 +824,14 @@ const UpgradeType *FactionType::getUpgradeType(const string &name) const{
}
}
printf("In [%s::%s Line: %d] scanning [%s] size = " MG_SIZE_T_SPECIFIER "\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
printf("In [%s::%s Line: %d] scanning [%s] size = " MG_SIZE_T_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
for(int i=0; i<upgradeTypes.size();i++){
printf("In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),i,upgradeTypes[i].getName().c_str());
printf("In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,upgradeTypes[i].getName().c_str());
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] size = %d\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] size = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
for(int i=0; i<upgradeTypes.size();i++){
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),i,upgradeTypes[i].getName().c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,upgradeTypes[i].getName().c_str());
}
throw megaglest_runtime_error("Upgrade type not found: [" + name + "] in faction type [" + this->name + "]");

View File

@ -83,7 +83,7 @@ string TechTree::findPath(const string &techName, const vector<string> &pathTech
void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum,
Checksum *techtreeChecksum, std::map<string,vector<pair<string, string> > > &loadedFileList) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
string currentPath = dir;
endPathWithSlash(currentPath);
@ -116,7 +116,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
}
}
catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what());
throw megaglest_runtime_error("Error loading Resource Types in: [" + currentPath + "]\n" + e.what());
}
@ -185,7 +185,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
}
}
catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what());
throw megaglest_runtime_error("Error loading Tech Tree: "+ currentPath + "\n" + e.what());
}
@ -218,9 +218,15 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
Window::handleEvent();
SDL_PumpEvents();
}
}
catch(megaglest_runtime_error& ex) {
//printf("1111111b ex.wantStackTrace() = %d\n",ex.wantStackTrace());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
//printf("222222b\n");
throw megaglest_runtime_error("Error loading Faction Types: "+ currentPath + "\n" + ex.what(),!ex.wantStackTrace());
}
catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what());
throw megaglest_runtime_error("Error loading Faction Types: "+ currentPath + "\n" + e.what());
}
@ -231,11 +237,11 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
Lang &lang = Lang::getInstance();
lang.loadTechTreeStrings(name);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
}
TechTree::~TechTree() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
Logger::getInstance().add(Lang::getInstance().get("LogScreenGameUnLoadingTechtree","",true), true);
resourceTypes.clear();
factionTypes.clear();
@ -309,7 +315,7 @@ FactionType *TechTree::getTypeByName(const string &name) {
return &factionTypes[i];
}
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
throw megaglest_runtime_error("Faction not found: "+name);
}
@ -319,7 +325,7 @@ const FactionType *TechTree::getType(const string &name) const {
return &factionTypes[i];
}
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
throw megaglest_runtime_error("Faction not found: "+name);
}

View File

@ -155,7 +155,7 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, const
const FactionType *factionType, Checksum* checksum,
Checksum* techtreeChecksum, std::map<string,vector<pair<string, string> > > &loadedFileList) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
string currentPath = dir;
endPathWithSlash(currentPath);
@ -639,12 +639,18 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, const
}
//Exception handling (conversions and so on);
catch(megaglest_runtime_error& ex) {
//printf("1111111a ex.wantStackTrace() = %d\n",ex.wantStackTrace());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
//printf("222222a\n");
throw megaglest_runtime_error("Error loading UnitType: " + path + "\n" + ex.what(),!ex.wantStackTrace());
}
catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what());
throw megaglest_runtime_error("Error loading UnitType: " + path + "\n" + e.what());
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
}
// ==================== get ====================
@ -664,7 +670,7 @@ const Level *UnitType::getLevel(string name) const {
const CommandType *UnitType::getFirstCtOfClass(CommandClass commandClass) const{
if(firstCommandTypeOfClass[commandClass] == NULL) {
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] commandClass = %d\n",__FILE__,__FUNCTION__,__LINE__,commandClass);
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] commandClass = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,commandClass);
/*
for(int j=0; j<ccCount; ++j){
@ -676,7 +682,7 @@ const CommandType *UnitType::getFirstCtOfClass(CommandClass commandClass) const{
}
*/
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
}
return firstCommandTypeOfClass[commandClass];
}
@ -692,7 +698,7 @@ const SkillType *UnitType::getFirstStOfClass(SkillClass skillClass) const{
}
}
*/
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
}
return firstSkillTypeOfClass[skillClass];
}
@ -979,7 +985,7 @@ const CommandType* UnitType::findCommandTypeById(int id) const{
const CommandType *UnitType::getCommandType(int i) const {
if(i >= commandTypes.size()) {
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s Line: %d] i >= commandTypes.size(), i = %d, commandTypes.size() = " MG_SIZE_T_SPECIFIER "",__FILE__,__FUNCTION__,__LINE__,i,commandTypes.size());
snprintf(szBuf,8096,"In [%s::%s Line: %d] i >= commandTypes.size(), i = %d, commandTypes.size() = " MG_SIZE_T_SPECIFIER "",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,commandTypes.size());
throw megaglest_runtime_error(szBuf);
}
return commandTypes[i];

View File

@ -158,6 +158,9 @@ static inline T* readFromFileReaders(vector<FileReader<T> const *>* readers, con
FileReader<T> const * reader = *i;
ret = reader->read(file, filepath); //It is guaranteed that at least the filepath matches ...
}
catch (megaglest_runtime_error &ex) { //TODO: Specific exceptions
throw;
}
catch (...) { //TODO: Specific exceptions
continue;
}
@ -202,7 +205,11 @@ static inline T* readFromFileReaders(vector<FileReader<T> const *>* readers, con
try {
FileReader<T> const * reader = *i;
ret = reader->read(file, filepath, object); //It is guaranteed that at least the filepath matches ...
} catch (...) { //TODO: Specific exceptions
}
catch (megaglest_runtime_error &ex) { //TODO: Specific exceptions
throw;
}
catch (...) { //TODO: Specific exceptions
continue;
}
if (ret != NULL) {
@ -321,7 +328,11 @@ bool FileReader<T>::canRead(ifstream& file) const {
bool ret = (wouldRead != NULL);
delete wouldRead;
return ret;
} catch (...) {
}
catch (megaglest_runtime_error &ex) { //TODO: Specific exceptions
throw;
}
catch (...) {
return false;
}
}

View File

@ -34,7 +34,7 @@ protected:
public:
megaglest_runtime_error(const string& __arg,bool noStackTrace=false);
bool wantStackTrace() const { return noStackTrace; }
bool wantStackTrace() const { return !noStackTrace; }
};
#ifndef WIN32

View File

@ -66,133 +66,143 @@ static inline std::vector<string> getExtensionStrings() {
TGAReader3D::TGAReader3D(): FileReader<Pixmap3D>(getExtensionStrings()) {}
Pixmap3D* TGAReader3D::read(ifstream& in, const string& path, Pixmap3D* ret) const {
assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
//read header
TargaFileHeader fileHeader;
in.read((char*)&fileHeader, sizeof(TargaFileHeader));
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
fileHeader.bitsPerPixel = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.bitsPerPixel);
fileHeader.colourMapDepth = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.colourMapDepth);
fileHeader.colourMapLength = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.colourMapDepth);
fileHeader.colourMapOrigin = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.colourMapOrigin);
fileHeader.colourMapType = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.colourMapType);
fileHeader.dataTypeCode = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.dataTypeCode);
fileHeader.height = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.height);
fileHeader.idLength = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.idLength);
fileHeader.imageDescriptor = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.imageDescriptor);
fileHeader.width = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.width);
}
if (!in.good()) {
throw megaglest_runtime_error(path + " could not be read");
}
//check that we can load this tga file
if(fileHeader.idLength!=0){
throw megaglest_runtime_error(path + ": id field is not 0");
}
if(fileHeader.dataTypeCode!=tgaUncompressedRgb && fileHeader.dataTypeCode!=tgaUncompressedBw){
throw megaglest_runtime_error(path + ": only uncompressed BW and RGB targa images are supported");
}
//check bits per pixel
if(fileHeader.bitsPerPixel!=8 && fileHeader.bitsPerPixel!=24 && fileHeader.bitsPerPixel!=32){
throw megaglest_runtime_error(path + ": only 8, 24 and 32 bit targa images are supported");
}
const int h = fileHeader.height;
const int w = fileHeader.width;
const int d = ret->getD();
const int slice = ret->getSlice();
const int fileComponents= fileHeader.bitsPerPixel/8;
const int picComponents = (ret->getComponents()==-1)?fileComponents:ret->getComponents();
//std::cout << "TGA-Components: Pic: " << picComponents << " old: " << (ret->getComponents()) << " File: " << fileComponents << " slice:" << ret->getSlice() << std::endl;
if(ret->getPixels() == NULL){
ret->init(w,h,d, picComponents);
}
uint8* pixels = ret->getPixels();
if(slice > 0) {
pixels = &pixels[slice*w*h*picComponents];
}
//read file
for(int i=0; i<h*w*picComponents; i+=picComponents){
uint8 r=0, g=0, b=0, a=0, l=0;
if(fileComponents==1){
in.read((char*)&l,1);
if(bigEndianSystem == true) {
l = Shared::PlatformByteOrder::fromCommonEndian(l);
}
r= l;
g= l;
b= l;
a= 255;
//printf("In [%s] line: %d\n",__FILE__,__LINE__);
// try {
assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
//read header
TargaFileHeader fileHeader;
in.read((char*)&fileHeader, sizeof(TargaFileHeader));
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
fileHeader.bitsPerPixel = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.bitsPerPixel);
fileHeader.colourMapDepth = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.colourMapDepth);
fileHeader.colourMapLength = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.colourMapDepth);
fileHeader.colourMapOrigin = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.colourMapOrigin);
fileHeader.colourMapType = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.colourMapType);
fileHeader.dataTypeCode = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.dataTypeCode);
fileHeader.height = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.height);
fileHeader.idLength = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.idLength);
fileHeader.imageDescriptor = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.imageDescriptor);
fileHeader.width = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.width);
}
else{
in.read((char*)&b, 1);
if(bigEndianSystem == true) {
b = Shared::PlatformByteOrder::fromCommonEndian(b);
}
in.read((char*)&g, 1);
if(bigEndianSystem == true) {
g = Shared::PlatformByteOrder::fromCommonEndian(g);
}
if (!in.good()) {
throw megaglest_runtime_error(path + " could not be read",true);
}
in.read((char*)&r, 1);
if(bigEndianSystem == true) {
r = Shared::PlatformByteOrder::fromCommonEndian(r);
}
//check that we can load this tga file
if(fileHeader.idLength!=0){
throw megaglest_runtime_error(path + ": id field is not 0",true);
}
if(fileComponents==4){
in.read((char*)&a, 1);
if(fileHeader.dataTypeCode!=tgaUncompressedRgb && fileHeader.dataTypeCode!=tgaUncompressedBw){
throw megaglest_runtime_error(path + ": only uncompressed BW and RGB targa images are supported",true);
}
//check bits per pixel
if(fileHeader.bitsPerPixel!=8 && fileHeader.bitsPerPixel!=24 && fileHeader.bitsPerPixel!=32){
throw megaglest_runtime_error(path + ": only 8, 24 and 32 bit targa images are supported",true);
}
const int h = fileHeader.height;
const int w = fileHeader.width;
const int d = ret->getD();
const int slice = ret->getSlice();
const int fileComponents= fileHeader.bitsPerPixel/8;
const int picComponents = (ret->getComponents()==-1)?fileComponents:ret->getComponents();
//std::cout << "TGA-Components: Pic: " << picComponents << " old: " << (ret->getComponents()) << " File: " << fileComponents << " slice:" << ret->getSlice() << std::endl;
if(ret->getPixels() == NULL){
ret->init(w,h,d, picComponents);
}
uint8* pixels = ret->getPixels();
if(slice > 0) {
pixels = &pixels[slice*w*h*picComponents];
}
//read file
for(int i=0; i<h*w*picComponents; i+=picComponents){
uint8 r=0, g=0, b=0, a=0, l=0;
if(fileComponents==1){
in.read((char*)&l,1);
if(bigEndianSystem == true) {
a = Shared::PlatformByteOrder::fromCommonEndian(a);
l = Shared::PlatformByteOrder::fromCommonEndian(l);
}
} else {
r= l;
g= l;
b= l;
a= 255;
}
l= (r+g+b)/3;
}
//if (!in.good()) {
// return NULL;
//}
else{
in.read((char*)&b, 1);
if(bigEndianSystem == true) {
b = Shared::PlatformByteOrder::fromCommonEndian(b);
}
switch(picComponents){
case 1:
pixels[i]= l;
in.read((char*)&g, 1);
if(bigEndianSystem == true) {
g = Shared::PlatformByteOrder::fromCommonEndian(g);
}
in.read((char*)&r, 1);
if(bigEndianSystem == true) {
r = Shared::PlatformByteOrder::fromCommonEndian(r);
}
if(fileComponents==4){
in.read((char*)&a, 1);
if(bigEndianSystem == true) {
a = Shared::PlatformByteOrder::fromCommonEndian(a);
}
} else {
a= 255;
}
l= (r+g+b)/3;
}
//if (!in.good()) {
// return NULL;
//}
switch(picComponents){
case 1:
pixels[i]= l;
break;
case 3:
pixels[i]= r;
pixels[i+1]= g;
pixels[i+2]= b;
break;
case 4:
pixels[i]= r;
pixels[i+1]= g;
pixels[i+2]= b;
pixels[i+3]= a;
break;
case 3:
pixels[i]= r;
pixels[i+1]= g;
pixels[i+2]= b;
break;
case 4:
pixels[i]= r;
pixels[i+1]= g;
pixels[i+2]= b;
pixels[i+3]= a;
break;
}
}
}
/*for(int i = 0; i < w*h*picComponents; ++i) {
if (i%39 == 0) std::cout << std::endl;
int first = pixels[i]/16;
if (first < 10)
std:: cout << first;
else
std::cout << (char)('A'+(first-10));
first = pixels[i]%16;
if (first < 10)
std:: cout << first;
else
std::cout << (char)('A'+(first-10));
std::cout << " ";
}*/
/*for(int i = 0; i < w*h*picComponents; ++i) {
if (i%39 == 0) std::cout << std::endl;
int first = pixels[i]/16;
if (first < 10)
std:: cout << first;
else
std::cout << (char)('A'+(first-10));
first = pixels[i]%16;
if (first < 10)
std:: cout << first;
else
std::cout << (char)('A'+(first-10));
std::cout << " ";
}*/
// }
// catch(exception& ex) {
// char szBuf[8096]="";
// snprintf(szBuf,8096,"Error in [%s] on line: %d msg: %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__,ex.what());
// throw megaglest_runtime_error(szBuf);
// }
return ret;
}
@ -200,125 +210,137 @@ Pixmap3D* TGAReader3D::read(ifstream& in, const string& path, Pixmap3D* ret) con
TGAReader::TGAReader(): FileReader<Pixmap2D>(getExtensionStrings()) {}
Pixmap2D* TGAReader::read(ifstream& in, const string& path, Pixmap2D* ret) const {
//read header
TargaFileHeader fileHeader;
in.read((char*)&fileHeader, sizeof(TargaFileHeader));
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
fileHeader.bitsPerPixel = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.bitsPerPixel);
fileHeader.colourMapDepth = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.colourMapDepth);
fileHeader.colourMapLength = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.colourMapDepth);
fileHeader.colourMapOrigin = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.colourMapOrigin);
fileHeader.colourMapType = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.colourMapType);
fileHeader.dataTypeCode = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.dataTypeCode);
fileHeader.height = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.height);
fileHeader.idLength = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.idLength);
fileHeader.imageDescriptor = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.imageDescriptor);
fileHeader.width = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.width);
}
if (!in.good()) {
throw megaglest_runtime_error(path + " could not be read");
}
//check that we can load this tga file
if(fileHeader.idLength!=0){
throw megaglest_runtime_error(path + ": id field is not 0");
}
if(fileHeader.dataTypeCode!=tgaUncompressedRgb && fileHeader.dataTypeCode!=tgaUncompressedBw){
throw megaglest_runtime_error(path + ": only uncompressed BW and RGB targa images are supported");
}
//check bits per pixel
if(fileHeader.bitsPerPixel!=8 && fileHeader.bitsPerPixel!=24 && fileHeader.bitsPerPixel!=32){
throw megaglest_runtime_error(path + ": only 8, 24 and 32 bit targa images are supported");
}
const int h = fileHeader.height;
const int w = fileHeader.width;
const int fileComponents= fileHeader.bitsPerPixel/8;
const int picComponents = (ret->getComponents()==-1)?fileComponents:ret->getComponents();
//std::cout << "TGA-Components: Pic: " << picComponents << " old: " << (ret->getComponents()) << " File: " << fileComponents << std::endl;
ret->init(w,h,picComponents);
uint8* pixels = ret->getPixels();
//read file
for(int i=0; i<h*w*picComponents; i+=picComponents){
uint8 r=0, g=0, b=0, a=0, l=0;
if(fileComponents==1){
in.read((char*)&l,1);
if(bigEndianSystem == true) {
l = Shared::PlatformByteOrder::fromCommonEndian(l);
}
r= l;
g= l;
b= l;
a= 255;
//printf("In [%s] line: %d\n",__FILE__,__LINE__);
//try {
//read header
TargaFileHeader fileHeader;
in.read((char*)&fileHeader, sizeof(TargaFileHeader));
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
fileHeader.bitsPerPixel = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.bitsPerPixel);
fileHeader.colourMapDepth = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.colourMapDepth);
fileHeader.colourMapLength = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.colourMapDepth);
fileHeader.colourMapOrigin = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.colourMapOrigin);
fileHeader.colourMapType = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.colourMapType);
fileHeader.dataTypeCode = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.dataTypeCode);
fileHeader.height = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.height);
fileHeader.idLength = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.idLength);
fileHeader.imageDescriptor = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.imageDescriptor);
fileHeader.width = Shared::PlatformByteOrder::fromCommonEndian(fileHeader.width);
}
else{
in.read((char*)&b, 1);
if(bigEndianSystem == true) {
b = Shared::PlatformByteOrder::fromCommonEndian(b);
}
in.read((char*)&g, 1);
if(bigEndianSystem == true) {
g = Shared::PlatformByteOrder::fromCommonEndian(g);
}
if (!in.good()) {
throw megaglest_runtime_error(path + " could not be read",true);
}
in.read((char*)&r, 1);
if(bigEndianSystem == true) {
r = Shared::PlatformByteOrder::fromCommonEndian(r);
}
//check that we can load this tga file
if(fileHeader.idLength!=0){
throw megaglest_runtime_error(path + ": id field is not 0",true);
}
if(fileComponents==4){
in.read((char*)&a, 1);
if(fileHeader.dataTypeCode!=tgaUncompressedRgb && fileHeader.dataTypeCode!=tgaUncompressedBw){
throw megaglest_runtime_error(path + ": only uncompressed BW and RGB targa images are supported",true);
}
//check bits per pixel
if(fileHeader.bitsPerPixel!=8 && fileHeader.bitsPerPixel!=24 && fileHeader.bitsPerPixel!=32){
throw megaglest_runtime_error(path + ": only 8, 24 and 32 bit targa images are supported",true);
}
const int h = fileHeader.height;
const int w = fileHeader.width;
const int fileComponents= fileHeader.bitsPerPixel/8;
const int picComponents = (ret->getComponents()==-1)?fileComponents:ret->getComponents();
//std::cout << "TGA-Components: Pic: " << picComponents << " old: " << (ret->getComponents()) << " File: " << fileComponents << std::endl;
ret->init(w,h,picComponents);
uint8* pixels = ret->getPixels();
//read file
for(int i=0; i<h*w*picComponents; i+=picComponents){
uint8 r=0, g=0, b=0, a=0, l=0;
if(fileComponents==1){
in.read((char*)&l,1);
if(bigEndianSystem == true) {
a = Shared::PlatformByteOrder::fromCommonEndian(a);
l = Shared::PlatformByteOrder::fromCommonEndian(l);
}
} else {
r= l;
g= l;
b= l;
a= 255;
}
l= (r+g+b)/3;
}
if (!in.good()) {
return NULL;
}
else{
in.read((char*)&b, 1);
if(bigEndianSystem == true) {
b = Shared::PlatformByteOrder::fromCommonEndian(b);
}
switch(picComponents){
case 1:
pixels[i]= l;
in.read((char*)&g, 1);
if(bigEndianSystem == true) {
g = Shared::PlatformByteOrder::fromCommonEndian(g);
}
in.read((char*)&r, 1);
if(bigEndianSystem == true) {
r = Shared::PlatformByteOrder::fromCommonEndian(r);
}
if(fileComponents==4){
in.read((char*)&a, 1);
if(bigEndianSystem == true) {
a = Shared::PlatformByteOrder::fromCommonEndian(a);
}
} else {
a= 255;
}
l= (r+g+b)/3;
}
if (!in.good()) {
return NULL;
}
switch(picComponents){
case 1:
pixels[i]= l;
break;
case 3:
pixels[i]= r;
pixels[i+1]= g;
pixels[i+2]= b;
break;
case 4:
pixels[i]= r;
pixels[i+1]= g;
pixels[i+2]= b;
pixels[i+3]= a;
break;
case 3:
pixels[i]= r;
pixels[i+1]= g;
pixels[i+2]= b;
break;
case 4:
pixels[i]= r;
pixels[i+1]= g;
pixels[i+2]= b;
pixels[i+3]= a;
break;
}
}
}
/*for(int i = 0; i < w*h*picComponents; ++i) {
if (i%39 == 0) std::cout << std::endl;
int first = pixels[i]/16;
if (first < 10)
std:: cout << first;
else
std::cout << (char)('A'+(first-10));
first = pixels[i]%16;
if (first < 10)
std:: cout << first;
else
std::cout << (char)('A'+(first-10));
std::cout << " ";
}*/
/*for(int i = 0; i < w*h*picComponents; ++i) {
if (i%39 == 0) std::cout << std::endl;
int first = pixels[i]/16;
if (first < 10)
std:: cout << first;
else
std::cout << (char)('A'+(first-10));
first = pixels[i]%16;
if (first < 10)
std:: cout << first;
else
std::cout << (char)('A'+(first-10));
std::cout << " ";
}*/
// }
// catch(exception& ex) {
// //printf("In [%s] line: %d msf [%s]\n",__FILE__,__LINE__,ex.what());
// //abort();
// char szBuf[8096]="";
// snprintf(szBuf,8096,"Error in [%s] on line: %d msg: %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__,ex.what());
// throw megaglest_runtime_error(szBuf);
// }
//printf("In [%s] line: %d\n",__FILE__,__LINE__);
return ret;
}

View File

@ -1279,8 +1279,15 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad,
}
fclose(f);
}
catch(megaglest_runtime_error& ex) {
//printf("1111111 ex.wantStackTrace() = %d\n",ex.wantStackTrace());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
//printf("2222222\n");
throw megaglest_runtime_error("Exception caught loading 3d file: " + path +"\n"+ ex.what(),!ex.wantStackTrace());
}
catch(exception &e){
//abort();
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what());
throw megaglest_runtime_error("Exception caught loading 3d file: " + path +"\n"+ e.what());
}

View File

@ -108,6 +108,8 @@ PixmapIoTga::~PixmapIoTga() {
}
void PixmapIoTga::openRead(const string &path) {
try {
#ifdef WIN32
file= _wfopen(utf8_decode(path).c_str(), L"rb");
#else
@ -155,6 +157,14 @@ void PixmapIoTga::openRead(const string &path) {
h= fileHeader.height;
w= fileHeader.width;
components= fileHeader.bitsPerPixel / 8;
}
catch(exception& ex) {
char szBuf[8096]="";
snprintf(szBuf,8096,"Error in [%s] on line: %d msg: %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__,ex.what());
throw megaglest_runtime_error(szBuf);
}
}
void PixmapIoTga::read(uint8 *pixels) {
@ -162,6 +172,7 @@ void PixmapIoTga::read(uint8 *pixels) {
}
void PixmapIoTga::read(uint8 *pixels, int components) {
try {
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
for(int i=0; i<h*w*components; i+=components) {
@ -248,6 +259,14 @@ void PixmapIoTga::read(uint8 *pixels, int components) {
break;
}
}
}
catch(exception& ex) {
char szBuf[8096]="";
snprintf(szBuf,8096,"Error in [%s] on line: %d msg: %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__,ex.what());
throw megaglest_runtime_error(szBuf);
}
}
void PixmapIoTga::openWrite(const string &path, int w, int h, int components) {

View File

@ -253,7 +253,7 @@ string PlatformExceptionHandler::getStackTrace() {
}
megaglest_runtime_error::megaglest_runtime_error(const string& __arg,bool noStackTrace)
: std::runtime_error(noStackTrace ? __arg + PlatformExceptionHandler::getStackTrace() : __arg), noStackTrace(noStackTrace) {
: std::runtime_error(noStackTrace == false ? __arg + PlatformExceptionHandler::getStackTrace() : __arg), noStackTrace(noStackTrace) {
}
}}//end namespace

View File

@ -225,7 +225,7 @@ string PlatformExceptionHandler::getStackTrace() {
}
megaglest_runtime_error::megaglest_runtime_error(const string& __arg,bool noStackTrace)
: std::runtime_error(noStackTrace ? __arg + PlatformExceptionHandler::getStackTrace() : __arg), noStackTrace(noStackTrace) {
: std::runtime_error(noStackTrace == false ? __arg + PlatformExceptionHandler::getStackTrace() : __arg), noStackTrace(noStackTrace) {
}
// =====================================================