mirror of
https://github.com/glest/glest-source.git
synced 2025-10-03 19:01:53 +02:00
- updated error handling to be more flexible so we can display better error details (like bad tga file, etc)
This commit is contained in:
@@ -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());
|
||||
|
@@ -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());
|
||||
|
@@ -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 + "]");
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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];
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -66,6 +66,8 @@ static inline std::vector<string> getExtensionStrings() {
|
||||
TGAReader3D::TGAReader3D(): FileReader<Pixmap3D>(getExtensionStrings()) {}
|
||||
|
||||
Pixmap3D* TGAReader3D::read(ifstream& in, const string& path, Pixmap3D* ret) const {
|
||||
//printf("In [%s] line: %d\n",__FILE__,__LINE__);
|
||||
// try {
|
||||
assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
|
||||
//read header
|
||||
TargaFileHeader fileHeader;
|
||||
@@ -85,21 +87,21 @@ Pixmap3D* TGAReader3D::read(ifstream& in, const string& path, Pixmap3D* ret) con
|
||||
}
|
||||
|
||||
if (!in.good()) {
|
||||
throw megaglest_runtime_error(path + " could not be read");
|
||||
throw megaglest_runtime_error(path + " could not be read",true);
|
||||
}
|
||||
|
||||
//check that we can load this tga file
|
||||
if(fileHeader.idLength!=0){
|
||||
throw megaglest_runtime_error(path + ": id field is not 0");
|
||||
throw megaglest_runtime_error(path + ": id field is not 0",true);
|
||||
}
|
||||
|
||||
if(fileHeader.dataTypeCode!=tgaUncompressedRgb && fileHeader.dataTypeCode!=tgaUncompressedBw){
|
||||
throw megaglest_runtime_error(path + ": only uncompressed BW and RGB targa images are supported");
|
||||
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");
|
||||
throw megaglest_runtime_error(path + ": only 8, 24 and 32 bit targa images are supported",true);
|
||||
}
|
||||
|
||||
const int h = fileHeader.height;
|
||||
@@ -193,6 +195,14 @@ Pixmap3D* TGAReader3D::read(ifstream& in, const string& path, Pixmap3D* ret) con
|
||||
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,6 +210,8 @@ 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 {
|
||||
//printf("In [%s] line: %d\n",__FILE__,__LINE__);
|
||||
//try {
|
||||
//read header
|
||||
TargaFileHeader fileHeader;
|
||||
in.read((char*)&fileHeader, sizeof(TargaFileHeader));
|
||||
@@ -218,21 +230,21 @@ Pixmap2D* TGAReader::read(ifstream& in, const string& path, Pixmap2D* ret) const
|
||||
}
|
||||
|
||||
if (!in.good()) {
|
||||
throw megaglest_runtime_error(path + " could not be read");
|
||||
throw megaglest_runtime_error(path + " could not be read",true);
|
||||
}
|
||||
|
||||
//check that we can load this tga file
|
||||
if(fileHeader.idLength!=0){
|
||||
throw megaglest_runtime_error(path + ": id field is not 0");
|
||||
throw megaglest_runtime_error(path + ": id field is not 0",true);
|
||||
}
|
||||
|
||||
if(fileHeader.dataTypeCode!=tgaUncompressedRgb && fileHeader.dataTypeCode!=tgaUncompressedBw){
|
||||
throw megaglest_runtime_error(path + ": only uncompressed BW and RGB targa images are supported");
|
||||
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");
|
||||
throw megaglest_runtime_error(path + ": only 8, 24 and 32 bit targa images are supported",true);
|
||||
}
|
||||
|
||||
const int h = fileHeader.height;
|
||||
@@ -319,6 +331,16 @@ Pixmap2D* TGAReader::read(ifstream& in, const string& path, Pixmap2D* ret) const
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -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());
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
@@ -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
|
||||
|
@@ -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) {
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
|
Reference in New Issue
Block a user